use of eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition in project hale by halestudio.
the class Join method getJoinContribution.
/**
* Calculates the instance index contribution for the given cell
*
* @param cell Cell
* @return The properties to index
*/
public static Collection<List<PropertyEntityDefinition>> getJoinContribution(Cell cell) {
List<List<PropertyEntityDefinition>> result = new ArrayList<>();
JoinParameter joinParameter = cell.getTransformationParameters().get(JoinFunction.PARAMETER_JOIN).get(0).as(JoinParameter.class);
for (JoinCondition cond : joinParameter.getConditions()) {
// Index all base and join properties individually
result.add(Collections.singletonList(cond.baseProperty));
result.add(Collections.singletonList(cond.joinProperty));
}
return result;
}
use of eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition in project hale by halestudio.
the class GroovyJoinContentProvider method getElements.
/**
* @see eu.esdihumboldt.hale.ui.common.definition.viewer.TypePropertyContentProvider#getElements(java.lang.Object)
*/
@Override
public Object[] getElements(Object inputElement) {
List<Object> elements = new ArrayList<Object>();
JoinParameter joinParameter = param.as(JoinParameter.class);
for (JoinCondition j : joinParameter.getConditions()) {
if (j.baseProperty.getType().equals(inputElement)) {
elements.add(j.joinProperty.getType());
}
}
elements.addAll(Arrays.asList(super.getElements(inputElement)));
return elements.toArray(new Object[elements.size()]);
}
use of eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition in project hale by halestudio.
the class GroovyJoinContentProvider method getChildren.
/**
* @see eu.esdihumboldt.hale.ui.common.definition.viewer.TypeIndexContentProvider#getChildren(java.lang.Object)
*/
@Override
public Object[] getChildren(Object parentElement) {
List<Object> elements = new ArrayList<Object>();
JoinParameter joinParameter = param.as(JoinParameter.class);
for (JoinCondition j : joinParameter.getConditions()) {
if (j.baseProperty.getType().equals(parentElement)) {
elements.add(j.joinProperty.getType());
}
}
elements.addAll(Arrays.asList(super.getChildren(parentElement)));
return elements.toArray(new Object[elements.size()]);
}
use of eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition 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.functions.join.JoinParameter.JoinCondition in project hale by halestudio.
the class FeatureChainingConfigurationPage method onShowPage.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
*/
@Override
protected void onShowPage(boolean firstShow) {
super.onShowPage(firstShow);
if (firstShow) {
for (ChainPage page : pages) page.dispose();
pages.clear();
AlignmentService alignmentService = HaleUI.getServiceProvider().getService(AlignmentService.class);
Alignment alignment = alignmentService.getAlignment();
int pageIdx = 0;
Collection<? extends Cell> typeCells = alignment.getActiveTypeCells();
for (Cell typeCell : typeCells) {
if (AppSchemaMappingUtils.isJoin(typeCell)) {
JoinParameter joinParameter = getJoinParameter(typeCell);
List<JoinCondition> conditions = getSortedJoinConditions(joinParameter);
TypeEntityDefinition joinTarget = getTargetType(typeCell).getDefinition();
for (int i = 0; i < joinParameter.getTypes().size() - 1; i++) {
ChainPage chainPage = new ChainPage(pageIdx, typeCell.getId(), i, joinParameter.getTypes(), conditions, joinTarget);
chainPage.setWizard(getWizard());
pages.add(chainPage);
pageIdx++;
}
}
}
}
setPageComplete(true);
if (!goingBack) {
getContainer().showPage(getNextPage());
} else {
getContainer().showPage(getPreviousPage());
}
}
Aggregations