Exchange semantic data across system boundaries - ecologylab/BigSemantics GitHub Wiki

Exchanging semantic data is supported by serializing and deserializing metadata object through S.IM.PL.

Serializing metadata

Each extracted metadata object is serializable through S.IM.PL, like any other S.IM.PL-annotated classes. Use SimplTypesScope.serialize() methods to do so. The most common formats include XML and JSON.

Deserializing metadata

Deserializing metadata is trickier than serializing, since we want to make sure that we can still access the wrapper information after deserialization. Therefore:

  • We need a SemanticsSessionScope object since it contains the wrappers.
  • We need to use a special deserialization strategy to bind wrapper information with deserialized metadata during the process.
The SemanticsSessionScope is not different from the one you see in ExampleOne or MmTest, and if you are using BigSemantics you probably have created this object in the initialization phase of your program.

The special deserialization strategy is already provided by BigSemantics.

Also, for S.IM.PL to deserialize a sequence, it needs a SimplTypesScope object which contains descriptions of types you want to deserialize. This should have already been generated by the meta-metadata compiler; you can obtain it by calling semanticsSessionScope.getMetadataTypesScope().

Putting them together:

MetadataDeserializationHookStrategy deserializationStrategy =
    new MetadataDeserializationHookStrategy(mySemanticsSessionScope);
Document doc = (Document) metadataTypeScope.deserialize(sequenceToDeserialize, deserializationStrategy, StringFormat.XML);
⚠️ **GitHub.com Fallback** ⚠️