Search in sources :

Example 6 with JoinCondition

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;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JoinParameter(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter) JoinCondition(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)

Example 7 with JoinCondition

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()]);
}
Also used : ArrayList(java.util.ArrayList) JoinParameter(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter) JoinCondition(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)

Example 8 with JoinCondition

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()]);
}
Also used : ArrayList(java.util.ArrayList) JoinParameter(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter) JoinCondition(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)

Example 9 with JoinCondition

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;
}
Also used : ComplexValue(eu.esdihumboldt.hale.common.core.io.impl.ComplexValue) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) ArrayList(java.util.ArrayList) JoinParameter(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter) JoinCondition(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) Type(eu.esdihumboldt.hale.common.align.model.Type) AttributeMappingType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType) AppSchemaDataAccessType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) HashSet(java.util.HashSet)

Example 10 with JoinCondition

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());
    }
}
Also used : Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) AppSchemaMappingUtils.getJoinParameter(eu.esdihumboldt.hale.io.appschema.writer.AppSchemaMappingUtils.getJoinParameter) JoinParameter(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter) Cell(eu.esdihumboldt.hale.common.align.model.Cell) JoinCondition(eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)

Aggregations

JoinCondition (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)15 JoinParameter (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter)11 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 Cell (eu.esdihumboldt.hale.common.align.model.Cell)5 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)5 List (java.util.List)5 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)4 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)2 ListMultimap (com.google.common.collect.ListMultimap)2 AlignmentMigration (eu.esdihumboldt.hale.common.align.migrate.AlignmentMigration)2 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)2 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)2 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)2 JoinFunction (eu.esdihumboldt.hale.common.align.model.functions.JoinFunction)2 FamilyInstanceImpl (eu.esdihumboldt.hale.common.align.transformation.function.impl.FamilyInstanceImpl)2 Value (eu.esdihumboldt.hale.common.core.io.Value)2