Search in sources :

Example 1 with PropertyCompositionType

use of eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType in project hale by halestudio.

the class OmlRdfGenerator method getPropertyType.

/**
 * Converts from OML Property to the JAXB PropertyType
 *
 * @param property
 * @return
 */
private PropertyType getPropertyType(Property property) {
    PropertyType pType = new PropertyType();
    if (property != null) {
        IAbout about = property.getAbout();
        if (about != null)
            pType.setAbout(about.getAbout());
        if (property instanceof ComposedProperty) /* && this.propertyStack < propertyStackSize */
        {
            // this.propertyStack++;
            // in case it is a composed property add the property
            // composition
            // element
            PropertyCompositionType propCompType = new PropertyCompositionType();
            // set Relation
            propCompType.setRelation(getRelation(((ComposedProperty) property).getRelation()));
            // set property collection or single property
            if (((ComposedProperty) property).getCollection().size() > 1) {
                // set collection
                propCompType.setCollection(getPropertyCollection(((ComposedProperty) property).getCollection()));
            } else if (((ComposedProperty) property).getCollection().size() == 1) {
                // set single property
                propCompType.setProperty(getPropertyType(((ComposedProperty) property).getCollection().get(0)));
            }
            // set PropertyOperatorType
            propCompType.setOperator(getOperatorType(((ComposedProperty) property).getPropertyOperatorType()));
            pType.setPropertyComposition(propCompType);
        }
        if (property.getTransformation() != null) {
            pType.setTransf(getTransf(property.getTransformation()));
        }
        if (property.getDomainRestriction() != null) {
            pType.getDomainRestriction().addAll(getDomainRestrictionTypes(property.getDomainRestriction()));
        }
        if (property.getTypeCondition() != null) {
            pType.getTypeCondition().addAll(property.getTypeCondition());
        }
        if (property.getLabel() != null) {
            pType.getLabel().addAll(property.getLabel());
        }
        if (property.getValueCondition() != null) {
            pType.getValueCondition().addAll(getValueConditions(property.getValueCondition()));
        }
    }
    return pType;
}
Also used : PropertyCompositionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout) PropertyType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyType)

Example 2 with PropertyCompositionType

use of eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType in project hale by halestudio.

the class OmlRdfReader method getProperty.

/**
 * Implements casting from the JAXB-Type to the OML Type for the Property
 * element.
 *
 * @param property jaxb-generated object
 * @return omlProperty
 */
private Property getProperty(PropertyType property) {
    Property omlProperty;
    // make decision: simple property or composed property
    if (property.getPropertyComposition() != null) {
        PropertyCompositionType pcType = property.getPropertyComposition();
        // initialize as composed property
        omlProperty = new ComposedProperty(getOperator(pcType.getOperator()), new About(""));
        // set collection of properties and/or relation
        if (pcType.getCollection() != null && pcType.getCollection().getItem() != null) {
            // set collection
            ((ComposedProperty) omlProperty).setCollection(getPropertyCollection(pcType.getCollection()));
        } else if (pcType.getProperty() != null) {
            // set a single property
            ((ComposedProperty) omlProperty).getCollection().add(getProperty(pcType.getProperty()));
        }
        if (pcType.getRelation() != null) {
            // set relation
            ((ComposedProperty) omlProperty).setRelation(getRelation(pcType.getRelation()));
        }
    } else {
        // initialize as property
        omlProperty = new Property(new About(""));
    }
    // set About
    if (property.getAbout() != null && !property.getAbout().equals("")) {
        omlProperty.setAbout(new About(property.getAbout()));
    }
    // set domain restriction
    if (property.getDomainRestriction() != null) {
        omlProperty.setDomainRestriction(getDomainRestriction(property.getDomainRestriction()));
    }
    // set label
    if (property.getLabel() != null) {
        omlProperty.setLabel(property.getLabel());
    }
    // set transformation
    if (property.getTransf() != null) {
        omlProperty.setTransformation(getTransformation(property.getTransf()));
    }
    // set type condition
    if (property.getTypeCondition() != null) {
        omlProperty.setTypeCondition(property.getTypeCondition());
    }
    // set value condition
    if (property.getValueCondition() != null) {
        omlProperty.setValueCondition(getValueCondition(property.getValueCondition()));
    }
    return omlProperty;
}
Also used : PropertyCompositionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) Property(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property) About(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)

Example 3 with PropertyCompositionType

use of eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType in project hale by halestudio.

the class OmlRdfReader method getEntity.

/**
 * Converts from the JAXB generated EntityType to the {@link IEntity}
 *
 * @param entity
 * @return
 */
private IEntity getEntity(JAXBElement<? extends EntityType> jaxbEntity) {
    EntityType entityType = jaxbEntity.getValue();
    // TODO allow to instantiate entity as Property, FeatureClass, Relation,
    // ComposedFeatureClass, ComposedFeatureType, composedRelation
    // instantiate entity es property
    Entity entity = null;
    IAbout about = null;
    // TODO add convertion to the RelationType if needed
    if (entityType instanceof PropertyType) {
        // make decision whether it is ComposedProperty
        if (((PropertyType) entityType).getPropertyComposition() != null) {
            PropertyCompositionType propCompType = ((PropertyType) entityType).getPropertyComposition();
            // instantiate entity as ComposedProperty
            if (entityType.getAbout() != null) {
                about = new About(entityType.getAbout());
            }
            entity = new ComposedProperty(getOperator(propCompType.getOperator()), about);
            if (propCompType.getCollection() != null && propCompType.getCollection().getItem().size() > 0) {
                // set collection
                ((ComposedProperty) entity).setCollection(getPropertyCollection(propCompType.getCollection()));
            } else if (propCompType.getProperty() != null) {
                // set Property
                ((ComposedProperty) entity).getCollection().add(getProperty(propCompType.getProperty()));
            } else if (propCompType.getRelation() != null) {
                // set Relation
                ((ComposedProperty) entity).setRelation(getOMLRelation(propCompType.getRelation()));
            }
        // set ComposedProperty specific members
        } else {
            // instantiate entity as property
            if (entityType.getAbout() != null) {
                about = new About(entityType.getAbout());
            }
            entity = new Property(about);
        }
        // set property-specific members to the entity
        PropertyType propertyType = ((PropertyType) entityType);
        // set domainRestriction
        if (propertyType.getDomainRestriction() != null) {
            ((Property) entity).setDomainRestriction(getDomainRestriction(propertyType.getDomainRestriction()));
        }
        // set typeCondition
        if (propertyType.getTypeCondition() != null) {
            ((Property) entity).setTypeCondition(propertyType.getTypeCondition());
        }
        // set value conditions
        if (propertyType.getValueCondition() != null) {
            ((Property) entity).setValueCondition(getValueCondition(propertyType.getValueCondition()));
        }
    } else if (entityType instanceof ClassType) {
        // initiates entity as FeatureType
        ClassType cType = (ClassType) entityType;
        if (entityType.getAbout() != null) {
            about = new About(entityType.getAbout());
        }
        entity = new FeatureClass(about);
        // set attribute occurence conditions if exist
        if (cType.getAttributeOccurenceCondition() != null) {
            ((FeatureClass) entity).setAttributeOccurenceCondition(getRestrictions(cType.getAttributeOccurenceCondition()));
        }
        // set attribute type conditions if exist
        if (cType.getAttributeTypeCondition() != null) {
            ((FeatureClass) entity).setAttributeTypeCondition(getRestrictions(cType.getAttributeTypeCondition()));
        }
        // set attribute value conditions if exist
        if (cType.getAttributeValueCondition() != null) {
            ((FeatureClass) entity).setAttributeValueCondition(getRestrictions(cType.getAttributeValueCondition()));
        }
    } else {
        throw new IllegalArgumentException("Illegal entity type given");
    }
    if (entityType.getTransf() != null) {
        // set Transformation to Entity
        Transformation transformation = getTransformation(entityType.getTransf());
        entity.setTransformation(transformation);
    }
    // set About
    About eabout = new About(UUID.randomUUID());
    if (entityType.getAbout() != null) {
        eabout.setAbout(entityType.getAbout());
    }
    entity.setAbout(eabout);
    // set Labels
    if (entityType.getLabel() != null) {
        entity.setLabel(entityType.getLabel());
    }
    return entity;
}
Also used : EntityType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.EntityType) PropertyCompositionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType) Entity(eu.esdihumboldt.hale.io.oml.internal.goml.align.Entity) IEntity(eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity) Transformation(eu.esdihumboldt.hale.io.oml.internal.goml.oml.ext.Transformation) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout) PropertyType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyType) ClassType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ClassType) ValueClassType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueClassType) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) Property(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property) FeatureClass(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass) About(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)

Aggregations

ComposedProperty (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty)3 PropertyCompositionType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType)3 IAbout (eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)3 Property (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property)2 About (eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About)2 PropertyType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyType)2 Entity (eu.esdihumboldt.hale.io.oml.internal.goml.align.Entity)1 Transformation (eu.esdihumboldt.hale.io.oml.internal.goml.oml.ext.Transformation)1 FeatureClass (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass)1 IEntity (eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity)1 ClassType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ClassType)1 EntityType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.EntityType)1 ValueClassType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueClassType)1