All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.stapi.graphoperations.ogmProviders.specific.objectGraphMappingMappingProviders.ObjectOgmProvider Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
package ai.stapi.graphoperations.ogmProviders.specific.objectGraphMappingMappingProviders;

import ai.stapi.graphoperations.graphLanguage.graphDescription.GraphDescription;
import ai.stapi.graphoperations.graphLanguage.graphDescription.graphDescriptionBuilder.GraphDescriptionBuilder;
import ai.stapi.graphoperations.objectGraphLanguage.ObjectFieldDefinition;
import ai.stapi.graphoperations.objectGraphLanguage.ObjectGraphMapping;
import ai.stapi.graphoperations.objectGraphLanguage.ObjectObjectGraphMapping;
import ai.stapi.graphoperations.objectGraphLanguage.objectGraphMappingBuilder.specific.ogm.ObjectGraphMappingBuilder;
import ai.stapi.graphoperations.ogmProviders.specific.SpecificGraphMappingProvider;

public class ObjectOgmProvider implements SpecificGraphMappingProvider {

  @Override
  public ObjectGraphMapping provideGraphMapping(String serializationType, String fieldName) {
    var objectOgmBuilder = new ObjectGraphMappingBuilder();
    objectOgmBuilder
        .setGraphDescription(
            new GraphDescriptionBuilder().addNodeDescription(OgmGraphElementTypes.OGM_OBJECT_NODE));
    objectOgmBuilder
        .addField("graphDescription")
        .setRelation(new GraphDescriptionBuilder().addOutgoingEdge(
            OgmGraphElementTypes.EDGE_FROM_OGM_TO_GRAPH_DESCRIPTION))
        .addInterfaceAsObjectFieldMapping()
        .setUuid(GraphDescription.INTERFACE_UUID);
    var mapOgmBuilder = objectOgmBuilder
        .addField("fields")
        .setRelation(new GraphDescriptionBuilder().addOutgoingEdge(
            OgmGraphElementTypes.EDGE_FROM_OBJECT_OGM_TO_FIELD_OGM))
        .addMapAsObjectFieldMapping();
    mapOgmBuilder
        .addLeafKeyMapping()
        .setGraphDescription(
            new GraphDescriptionBuilder()
                .addLeafAttribute(OgmGraphElementTypes.FIELD_NAME_ATTRIBUTE)
                .addStringAttributeValue()
        );
    mapOgmBuilder
        .addInterfaceObjectValueMapping()
        .setUuid(ObjectFieldDefinition.SERIALIZATION_TYPE);
    return objectOgmBuilder.build();
  }

  @Override
  public boolean supports(String serializationType) {
    return serializationType.equals(ObjectObjectGraphMapping.SERIALIZATION_TYPE);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy