use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property 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.Property 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.Property 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.Property 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);
}
}
use of eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property in project hale by halestudio.
the class GeographicalNameTranslator method getNewParameters.
/**
* @see eu.esdihumboldt.hale.io.oml.helper.FunctionTranslator#getNewParameters(java.util.List,
* eu.esdihumboldt.hale.common.align.io.impl.internal.CellBean,
* eu.esdihumboldt.hale.common.core.io.report.IOReporter,
* eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)
*/
@Override
public List<ParameterValueBean> getNewParameters(List<ParameterValueBean> params, CellBean cellBean, IOReporter reporter, ICell cell) {
// create the new parameter list
List<ParameterValueBean> newParams = new ArrayList<ParameterValueBean>();
IEntity source = cell.getEntity1();
if (source instanceof ComposedProperty) {
ComposedProperty cp = (ComposedProperty) source;
// usually the composed property should only have one element in the
// collection
Property coll = cp.getCollection().get(0);
// that should be a composed property too
if (coll instanceof ComposedProperty) {
ComposedProperty comProp = (ComposedProperty) coll;
// parameters defined by the parameter page
List<IParameter> pageParams = comProp.getTransformation().getParameters();
// add each parameter defined by the parameter page
for (IParameter p : pageParams) {
newParams.add(new ParameterValueBean(p.getName(), p.getValue()));
}
// the collection of the collection contains the parameters
// defined for the spellings
List<Property> props = comProp.getCollection();
for (Property prop : props) {
// each property has a list of 3 parameters (text, script,
// transliterationScheme)
List<IParameter> spellingParams = prop.getTransformation().getParameters();
for (IParameter p : spellingParams) {
newParams.add(new ParameterValueBean(p.getName(), p.getValue()));
}
}
}
}
return newParams;
}
Aggregations