Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Main Page

Table of Contents
outlinetrue
indent20px
stylenone
printablefalse

Serializer

MetadataSerializer is responsible for serializing and deserializing OpenmrsObjects. It is build upon XStream library and uses XML format. It is able to produce a list of metadata with all related items and a package header that contains information such as name, description, creation date, OpenMRS version. They are stored in two separate files called metadata.xml and header.xml and packaged in a zip file.

You can implement the writeReplace/readResolve methods in your shareable class if you want to provide a custom serialization. It needs to conform standard rules specified in the Java documentation. You can use it to provide extra dependencies for your object which you need to export together with your object. Typically it is not needed since all fields of your object will be examined and references to other objects resolved and serialized as well. However, you will need to define an extra field for dependencies and initialize it in the writeReplace method, if you reference objects in xmls or other text formats.

...

You can see a reference implementation of this mechanism in HTML Form Entry Module under HTML-184.

Handler

Handler is an interface that can be implemented to support different kinds of metadata. A custom handler can be registered in HandlerFactory. There is ConceptHandler that provides support for org.openmrs.Concept. Apart from that there are OpenmrsMetadataHandler and OpenmrsObjectHandler. They provide with just a basic support for classes implementing OpenmrsMetadata and OpenmrsObject. OpenmrsMetadataHandler in particular determines at runtime a list of classes on the classpath that can be exported.

...

Example of a publish URL: http:/localhost:8080/openmrs/ws/rest/metadatasharing/package/7f2d4731-0a98-4118-8fe0-d4b9731986c6/latest

Example of a curl to this URL

Code Block
xml
xml
<subscriptionHeader id="1">
    <packageHeader id="2" uuid="874f1efb-d73e-4093-9dd9-6e532be3a6fe">
        <dateCreated id="3">2011-08-18 00:30:45</dateCreated>
        <name>Roles</name>
        <description>All available roles</description>
        <openmrsVersion>1.8.2 Build 21762</openmrsVersion>
        <version>5</version>
        <group>7f2d4731-0a98-4118-8fe0-d4b9731986c6</group>
    </packageHeader>
    <contentUri id="4">../7f2d4731-0a98-4118-8fe0-d4b9731986c6/5/download</contentUri>
</subscriptionHeader>

...