use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass in project hale by halestudio.
the class OmlRdfGenerator method getEntityType.
/**
* converts from IEntity to the Jaxb generated EntityType
*
* @param entity
* @return
*/
private JAXBElement<? extends EntityType> getEntityType(IEntity entity) {
JAXBElement<? extends EntityType> eType = null;
if (entity != null) {
if (entity instanceof Property) {
// instantiate as PropertyType
Property property = (Property) entity;
PropertyType pType = getPropertyType(property);
eType = new JAXBElement<PropertyType>(new QName("http://www.omwg.org/TR/d7/ontology/alignment", "Property"), PropertyType.class, pType);
} else if (entity instanceof FeatureClass) {
// instantiate as ClassType
FeatureClass feature = (FeatureClass) entity;
ClassType cType = getClassType(feature);
eType = new JAXBElement<ClassType>(new QName("http://www.omwg.org/TR/d7/ontology/alignment", "Class"), ClassType.class, cType);
} else if (entity instanceof Relation) {
// instantiate as RelationType
// TODO add implementation, for the next release
} else if (entity instanceof PropertyQualifier) {
// instantiate as PropertyQualifierType
// TODO add implementation, will get the examples from MDV
}
}
return eType;
}
use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass in project hale by halestudio.
the class OmlRdfReader method getOMLRelation.
/**
* Converts from the JAXB-Based RelationType to the OML Relation
*
* @param relation
* @return
*/
private Relation getOMLRelation(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.RelationType relationType) {
Relation relation = null;
IAbout about = null;
List<FeatureClass> features = null;
if (relationType != null) {
if (relationType.getAbout() != null) {
about = new About(relationType.getAbout());
}
relation = new Relation(about);
// set label list
if (relation.getLabel() != null) {
relation.setLabel(relationType.getLabel());
}
// set transformation
if (relationType.getTransf() != null) {
relation.setTransformation(getTransformation(relationType.getTransf()));
}
// set Range Restriction
if (relationType.getRangeRestriction() != null) {
features = new ArrayList<FeatureClass>();
features.add(getRangeRestriction(relationType.getRangeRestriction()));
relation.setRangeRestriction(features);
}
// set Domain Restriction
if (relationType.getDomainRestriction() != null) {
features = new ArrayList<FeatureClass>();
features.add(getDomainRestriction(relationType.getDomainRestriction()));
relation.setDomainRestriction(features);
}
}
return relation;
}
use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass 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;
}
use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass in project hale by halestudio.
the class OmlRdfReader method getRelation.
/**
* Implements casting from the JAXB-Type to the OML Type for the Relation
* element.
*
* @param relation jaxb-generated object
* @return omlRelation
*/
private Relation getRelation(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.RelationType relation) {
Relation omlRelation = new Relation(new About(""));
if (relation != null) {
// set about
if (relation.getAbout() != null && !relation.getAbout().equals("")) {
omlRelation.setAbout(new About(relation.getAbout()));
}
// set domain restriction
if (relation.getDomainRestriction() != null) {
FeatureClass domainRestriction = getDomainRestriction(relation.getDomainRestriction());
ArrayList<FeatureClass> domainRestrictions = new ArrayList<FeatureClass>();
domainRestrictions.add(domainRestriction);
omlRelation.setDomainRestriction(domainRestrictions);
}
// set label
if (relation.getLabel() != null && relation.getLabel().size() > 0) {
omlRelation.setLabel(relation.getLabel());
}
// set transformation
if (relation.getTransf() != null) {
omlRelation.setTransformation(getTransformation(relation.getTransf()));
}
// set Range Restriction
if (relation.getRangeRestriction() != null) {
FeatureClass omlRangeRestriction = getRangeRestriction(relation.getRangeRestriction());
List<FeatureClass> omlRangeRestrictions = new ArrayList<FeatureClass>();
omlRangeRestrictions.add(omlRangeRestriction);
omlRelation.setRangeRestriction(omlRangeRestrictions);
}
}
return omlRelation;
}
Aggregations