sosol/sosol — pull request #46 by balmas (2014-09-13 18:08:44+00:00)
Title: First round of changes for EAGLE/Mediawiki integration

This is the first round of changes for the EAGLE/MediaWiki integration. (See https://github.com/EAGLE-BPN/eagle-wiki/pull/1 and https://github.com/PerseusDL/perseids_docs/wiki/EAGLE-Integration-Requirements). Major changes only described below:

* cts_publications_controller has a new action, create_from_agent. It takes a required agent parameter, which must be set to the uri identifier for the agent (i.e. the agent being the mediawiki site to get/post to) and a required id parameter, which must be set to the id the item being retrieved from on the mediawiki site. an optional 3rd parameter of filter specifies to retrieve a specific claim from the mediawiki site, and if not specified, a lang parameter specifies the language for a new translations (not quite happy with this API yet..). The agent specified in the uri parameter must be configured in the agents.yml with auth info and transforms for the content. The mediawiki integration details will be documented more fully in a README in the code when they are finalized, but here's a brief summary:

* the agents.yml is expected to define transformations specific to the identifier type. This still needs work to make the config settings cleaner, but for now it defines an inbound transformation for the CTSIdentifier type, and an outbound transformation for the EpiCtsIdentifier type. The Inbound transformation takes XML from the MediaWiki wbgetentities api call, and transforms it to EpiDoc. It includes information about the original mediawiki item needed for the post back to mediawiki in the teiHeader:
* the agent uri is included as the content of "/tei:TEI/tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:distributor
* the mediawiki entity id is included as the value of tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:idno[@type='agentitemid']
* the mediawiki baserevid is included as the value of tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:idno[@type='lastrevid']
* Additional properties from the mediawiki item are mapped as well. See the eagle-xml-perseids.xsl transform for details.

* the outbound transform transforms the EpiDoc XML back into a mediawiki claim in JSON format. It used the above-listed information to populate the necessary information for the POST back to the mediawiki. This is done upon finalization of the identifier in SoSOL (i.e. after the board approval). This step also inserts the details of the review board into the claim to be submitted to the mediawiki as additional source items.

* The mediawiki integration uses the mediawiki_api gem. It is a backport of version 0.2.1 of this gem included in the vendor directory in order to support rails 2.

* the post back to mediawiki executes 2 calls: wbcreateclaim and wbsetclaim. If wbcreateclaim succeeds and wbsetclaim fails, the newly created claim is destroyed.

* cts_identifier now has a new contructor method, new_from_supplied, which can be used to create a new identifier from supplied content.

* epi_cts_identifier implements preprocess_for_finalization, a pre-existing method call which is executed on the identifier just before it is finalized as described above (this was was previously added for citation_cts_identifiers and used for merging a passage back into its parent xml document).