use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.
the class FilterEditor method setValue.
/**
* @see Editor#setValue(Object)
*/
@Override
public void setValue(final Filter filter) {
filterEnabled.setSelection(false);
setControlsEnabled(false);
if (filter != null) {
filter.accept(new FilterVisitor() {
@Override
protected void visitFilter(FilterIdentifier id, String propertyName, String value) {
Boolean invalidProperty = false;
List<ChildContext> path = new ArrayList<ChildContext>();
// set the correct selected name for the property selector
List<QName> qNames = PropertyResolver.getQNamesFromPath(propertyName);
ChildDefinition<?> child = typeDefinition.getChild(qNames.get(0));
if (child != null) {
path.add(new ChildContext(child));
for (int i = 1; i < qNames.size(); i++) {
child = DefinitionUtil.getChild(child, qNames.get(i));
if (child != null) {
path.add(new ChildContext(child));
} else {
invalidProperty = true;
break;
}
}
} else {
invalidProperty = true;
}
if (!invalidProperty && !path.isEmpty()) {
PropertyEntityDefinition entity = new PropertyEntityDefinition(typeDefinition, path, null, null);
propertySelect.setSelection(new StructuredSelection(entity));
} else {
propertySelect.setSelection(new StructuredSelection());
}
// set filter
filterSelect.setSelection(new StructuredSelection(id));
// set value
literal.getDocument().set(value);
filterEnabled.setSelection(true);
setControlsEnabled(true);
}
}, null);
}
}
use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.
the class AppSchemaMappingTest method buildJoinCell.
@SuppressWarnings("null")
private DefaultCell buildJoinCell(FeatureChaining chainingConf) {
boolean withChaining = chainingConf != null;
DefaultCell joinCell = new DefaultCell();
joinCell.setTransformationIdentifier(JoinFunction.ID);
if (withChaining) {
// set cell ID from feature chaining configuration
// WARNING: this code assumes only one join is configured
joinCell.setId(chainingConf.getJoins().keySet().iterator().next());
}
TypeEntityDefinition datasetEntityDef = new TypeEntityDefinition(datasetType, SchemaSpaceID.SOURCE, null);
TypeEntityDefinition unitEntityDef = null;
TypeEntityDefinition observationEntityDef = null;
if (!withChaining) {
unitEntityDef = new TypeEntityDefinition(unitDenormType, SchemaSpaceID.SOURCE, null);
} else {
unitEntityDef = new TypeEntityDefinition(unitType, SchemaSpaceID.SOURCE, null);
observationEntityDef = new TypeEntityDefinition(observationType, SchemaSpaceID.SOURCE, null);
}
ListMultimap<String, Type> source = ArrayListMultimap.create();
source.put(JoinFunction.JOIN_TYPES, new DefaultType(datasetEntityDef));
source.put(JoinFunction.JOIN_TYPES, new DefaultType(unitEntityDef));
if (observationEntityDef != null) {
source.put(JoinFunction.JOIN_TYPES, new DefaultType(observationEntityDef));
assertEquals(3, source.get(JoinFunction.JOIN_TYPES).size());
} else {
assertEquals(2, source.get(JoinFunction.JOIN_TYPES).size());
}
ListMultimap<String, Type> target = ArrayListMultimap.create();
target.put(null, new DefaultType(new TypeEntityDefinition(landCoverDatasetType, SchemaSpaceID.TARGET, null)));
List<TypeEntityDefinition> types = new ArrayList<TypeEntityDefinition>(Arrays.asList(datasetEntityDef, unitEntityDef));
Set<JoinCondition> conditions = new HashSet<JoinCondition>();
// join dataset and unit
PropertyEntityDefinition baseProperty = getDatasetIdSourceProperty().values().iterator().next().getDefinition();
PropertyEntityDefinition joinProperty = getUnitDatasetIdSourceProperty(unitEntityDef.getType()).values().iterator().next().getDefinition();
conditions.add(new JoinCondition(baseProperty, joinProperty));
if (withChaining) {
// add observation type
types.add(observationEntityDef);
// join unit and observation
baseProperty = getUnitIdSourceProperty(unitEntityDef.getType()).values().iterator().next().getDefinition();
joinProperty = getObservationUnitIdSourceProperty().values().iterator().next().getDefinition();
conditions.add(new JoinCondition(baseProperty, joinProperty));
}
JoinParameter joinParam = new JoinParameter(types, conditions);
ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
parameters.put(JoinFunction.PARAMETER_JOIN, new ParameterValue(new ComplexValue(joinParam)));
joinCell.setSource(source);
joinCell.setTarget(target);
joinCell.setTransformationParameters(parameters);
return joinCell;
}
use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.
the class FeatureChainingComplexType method toDOM.
/**
* @see eu.esdihumboldt.hale.common.core.io.ComplexValueType#toDOM(java.lang.Object)
*/
@Override
public Element toDOM(FeatureChaining value) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
try {
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.newDocument();
Element featureChainingEl = doc.createElementNS(APP_SCHEMA_NAMESPACE, "FeatureChaining");
featureChainingEl.setPrefix(APP_SCHEMA_PREFIX);
if (value != null && value.joins != null) {
for (JoinConfiguration joinConf : value.joins.values()) {
Element joinEl = doc.createElementNS(APP_SCHEMA_NAMESPACE, "join");
joinEl.setAttribute("id", joinConf.getJoinCellId());
featureChainingEl.appendChild(joinEl);
if (joinConf.chains != null) {
for (ChainConfiguration chainConf : joinConf.chains.values()) {
Element chainEl = doc.createElementNS(APP_SCHEMA_NAMESPACE, "chain");
chainEl.setAttribute("index", Integer.toString(chainConf.getChainIndex()));
chainEl.setAttribute("prevChainIndex", Integer.toString(chainConf.getPrevChainIndex()));
joinEl.appendChild(chainEl);
PropertyEntityDefinition nestedTypeTarget = chainConf.getNestedTypeTarget();
Element nestedTargetEl = DOMEntityDefinitionHelper.propertyToDOM(nestedTypeTarget);
if (nestedTargetEl != null) {
Node nestedTargetAdopted = doc.adoptNode(nestedTargetEl);
if (nestedTargetAdopted == null) {
nestedTargetAdopted = doc.importNode(nestedTargetEl, true);
}
chainEl.appendChild(nestedTargetAdopted);
}
if (chainConf.mappingName != null && !chainConf.mappingName.trim().isEmpty()) {
Element mappingEl = doc.createElementNS(APP_SCHEMA_NAMESPACE, "mapping");
mappingEl.setAttribute("name", chainConf.mappingName);
chainEl.appendChild(mappingEl);
}
}
}
}
}
return featureChainingEl;
} catch (ParserConfigurationException e) {
throw new IllegalStateException(e);
}
}
use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.
the class AbstractPropertyTransformationHandler method findChainConfiguration.
/**
* @param context the mapping context
* @return the chain configuration that applies to the current property
* mapping
*/
private ChainConfiguration findChainConfiguration(AppSchemaMappingContext context) {
ChainConfiguration chainConf = null;
PropertyEntityDefinition targetPropertyEntityDef = targetProperty.getDefinition();
FeatureChaining featureChaining = context.getFeatureChaining();
if (featureChaining != null) {
List<ChildContext> targetPropertyPath = targetPropertyEntityDef.getPropertyPath();
List<ChainConfiguration> chains = featureChaining.getChains(typeCell.getId());
chainConf = findLongestNestedPath(targetPropertyPath, chains);
}
return chainConf;
}
use of eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition in project hale by halestudio.
the class AbstractPropertyTransformationHandler method createGeometryAttributeMapping.
private void createGeometryAttributeMapping(TypeDefinition featureType, String mappingName, PropertyEntityDefinition geometry, AppSchemaMappingContext context) {
EntityDefinition geometryProperty = getGeometryPropertyEntity(geometry);
// use geometry property path to create / retrieve attribute mapping
attributeMapping = context.getOrCreateAttributeMapping(featureType, mappingName, geometryProperty.getPropertyPath());
}
Aggregations