use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty 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;
}
use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty in project hale by halestudio.
the class OmlRdfGenerator method getPropertyCollection.
/**
* Translate the list of the OML Properties To the Jaxb-based
* PropertyCollectionType
*
* @param collection
* @return
*/
private PropertyCollectionType getPropertyCollection(List<Property> collection) {
PropertyCollectionType propCollectionType = new PropertyCollectionType();
if (collection != null) {
Iterator<?> iterator = collection.iterator();
while (iterator.hasNext()) {
// get property from a list
Property property = (Property) iterator.next();
// convert property to the property type
// TODO could be the circular dependencies in case of
// ComposedProperty
PropertyType pType = getPropertyType(property);
// add to the collection
Item item = new Item();
item.setProperty(pType);
propCollectionType.getItem().add(item);
}
}
return propCollectionType;
}
use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty 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;
}
use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty in project hale by halestudio.
the class EntityHelper method getShortName.
/**
* Get a short name for the given entity
*
* @param entity the entity
* @return the short name
*/
public static String getShortName(IEntity entity) {
if (entity.equals(Entity.NULL_ENTITY)) {
// $NON-NLS-1$
return "None";
}
if (entity instanceof ComposedProperty) {
ComposedProperty cp = (ComposedProperty) entity;
Iterator<Property> it = cp.getCollection().iterator();
StringBuffer result = new StringBuffer();
while (it.hasNext()) {
result.append(getShortName(it.next()));
if (it.hasNext()) {
// $NON-NLS-1$
result.append(" & ");
}
}
return result.toString();
}
if (entity.getAbout() != null && entity.getAbout().getAbout() != null) {
String label = entity.getAbout().getAbout();
// $NON-NLS-1$
String[] nameparts = label.split("\\/");
if (entity instanceof Property && nameparts.length >= 2) {
// $NON-NLS-1$
return nameparts[nameparts.length - 2] + "." + nameparts[nameparts.length - 1];
} else {
return nameparts[nameparts.length - 1];
}
}
// $NON-NLS-1$
return "unnamed";
}
use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty in project hale by halestudio.
the class OmlReader method setBeanLists.
private void setBeanLists(IEntity entity, List<NamedEntityBean> list, TypeIndex schema) {
if (entity.getAbout().getAbout().equals(Entity.NULL_ENTITY.getAbout().getAbout())) {
return;
}
if (entity instanceof ComposedFeatureClass) {
ComposedFeatureClass cfc = (ComposedFeatureClass) entity;
List<FeatureClass> coll = cfc.getCollection();
for (FeatureClass fc : coll) {
setBeanLists(fc, list, schema);
}
} else if (entity instanceof ComposedProperty) {
ComposedProperty cp = (ComposedProperty) entity;
List<Property> coll = cp.getCollection();
for (Property prop : coll) {
setBeanLists(prop, list, schema);
}
} else if (entity instanceof FeatureClass) {
// get the detailed about-information
IDetailedAbout about = DetailedAbout.getDetailedAbout(entity.getAbout(), false);
TypeBean typeBean = new TypeBean();
setTypeNameBean(typeBean, about, schema);
NamedEntityBean namedEntityBean = new NamedEntityBean();
namedEntityBean.setEntity(typeBean);
namedEntityBean.setName(null);
list.add(namedEntityBean);
} else if (entity instanceof Property) {
// get the detailed about-information
IDetailedAbout about = DetailedAbout.getDetailedAbout(entity.getAbout(), true);
PropertyBean prop = new PropertyBean();
List<ChildContextBean> childList = new ArrayList<ChildContextBean>();
List<String> props = about.getProperties();
for (String property : props) {
ChildContextBean ccb = new ChildContextBean();
ccb.setChildName(new QName(property));
childList.add(ccb);
}
setTypeNameBean(prop, about, schema);
prop.setProperties(childList);
NamedEntityBean namedEntityBean = new NamedEntityBean();
namedEntityBean.setEntity(prop);
namedEntityBean.setName(null);
list.add(namedEntityBean);
}
}
Aggregations