Search in sources :

Example 1 with FeatureChaining

use of eu.esdihumboldt.hale.io.appschema.model.FeatureChaining in project hale by halestudio.

the class AppSchemaIsolatedWorkspacesMappingTest method loadFeatureChainingConf.

private FeatureChaining loadFeatureChainingConf(String confResource) throws Exception {
    Element root = loadXmlResource(confResource);
    // read value object from XML
    FeatureChaining chainingConf = HaleIO.getComplexValue(root, FeatureChaining.class, null);
    assertNotNull(chainingConf);
    AppSchemaMappingUtils.resolvePropertyTypes(chainingConf, targetSchemaSpace, SchemaSpaceID.TARGET);
    return chainingConf;
}
Also used : FeatureChaining(eu.esdihumboldt.hale.io.appschema.model.FeatureChaining) Element(org.w3c.dom.Element)

Example 2 with FeatureChaining

use of eu.esdihumboldt.hale.io.appschema.model.FeatureChaining in project hale by halestudio.

the class AppSchemaMappingTest method readFeatureChainingConfiguration.

private FeatureChaining readFeatureChainingConfiguration(String confResource) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Element root = builder.parse(getClass().getResourceAsStream(confResource)).getDocumentElement();
    // read from XML
    FeatureChaining chainingConf = HaleIO.getComplexValue(root, FeatureChaining.class, null);
    assertNotNull(chainingConf);
    AppSchemaMappingUtils.resolvePropertyTypes(chainingConf, target, SchemaSpaceID.TARGET);
    return chainingConf;
}
Also used : FeatureChaining(eu.esdihumboldt.hale.io.appschema.model.FeatureChaining) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element)

Example 3 with FeatureChaining

use of eu.esdihumboldt.hale.io.appschema.model.FeatureChaining in project hale by halestudio.

the class FeatureChainingConfigurationPage method loadPreSelection.

/**
 * @see eu.esdihumboldt.hale.ui.io.IOWizardPage#loadPreSelection(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)
 */
@Override
public void loadPreSelection(IOConfiguration conf) {
    // TODO: I fear this method is never called...
    super.loadPreSelection(conf);
    FeatureChaining previousConf = conf.getProviderConfiguration().get(AppSchemaIO.PARAM_CHAINING).as(FeatureChaining.class);
    if (previousConf != null && previousConf.getJoins().size() > 0) {
        featureChaining.replaceJoins(previousConf.getJoins());
    }
}
Also used : FeatureChaining(eu.esdihumboldt.hale.io.appschema.model.FeatureChaining)

Example 4 with FeatureChaining

use of eu.esdihumboldt.hale.io.appschema.model.FeatureChaining in project hale by halestudio.

the class AbstractAppSchemaConfigurator method generateMapping.

/**
 * Uses a fresh {@link AppSchemaMappingGenerator} instance to generates the
 * mapping configuration based on the current provider's configuration
 * parameters.
 *
 * @param reporter the status reporter
 * @throws IOProviderConfigurationException if something is wrong with the
 *             provider configuration
 * @throws IOException if an error occurs loading the mapping template file
 */
public void generateMapping(IOReporter reporter) throws IOProviderConfigurationException, IOException {
    if (getAlignment() == null) {
        throw new IOProviderConfigurationException("No alignment was provided.");
    }
    if (getTargetSchema() == null) {
        throw new IOProviderConfigurationException("No target schema was provided.");
    }
    if (getTarget() == null) {
        throw new IOProviderConfigurationException("No target was provided.");
    }
    DataStore dataStoreParam = getDataStoreParameter();
    FeatureChaining featureChainingParam = getFeatureChainingParameter();
    // resolve property entity definitions here, could't do it on project
    // loading
    resolvePropertyTypes(featureChainingParam, getTargetSchema(), SchemaSpaceID.TARGET);
    WorkspaceConfiguration workspaceConfParam = getWorkspaceConfigurationParameter();
    generator = new AppSchemaMappingGenerator(getAlignment(), getTargetSchema(), dataStoreParam, featureChainingParam, workspaceConfParam);
    generator.generateMapping(reporter);
}
Also used : IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) FeatureChaining(eu.esdihumboldt.hale.io.appschema.model.FeatureChaining) DataStore(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore) WorkspaceConfiguration(eu.esdihumboldt.hale.io.appschema.model.WorkspaceConfiguration)

Example 5 with FeatureChaining

use of eu.esdihumboldt.hale.io.appschema.model.FeatureChaining in project hale by halestudio.

the class AppSchemaMappingTest method testFeatureChainingJoin.

@Test
public void testFeatureChainingJoin() throws Exception {
    FeatureChaining chainingConf = readFeatureChainingConfiguration(FEATURE_CHAINING_CONF_PATH);
    assertNotNull(chainingConf);
    DefaultCell joinCell = buildJoinCell(chainingConf);
    // create minimal alignment and pass it to JoinHandler
    DefaultAlignment alignment = new DefaultAlignment();
    alignment.addCell(joinCell);
    DefaultCell renameCell = new DefaultCell();
    renameCell.setTransformationIdentifier(RenameFunction.ID);
    renameCell.setSource(getUuidSourceProperty(unitType));
    renameCell.setTarget(getNestedUnitLocalIdTargetProperty());
    alignment.addCell(renameCell);
    DefaultCell renameClassCell = new DefaultCell();
    renameClassCell.setTransformationIdentifier(RenameFunction.ID);
    renameClassCell.setSource(getObservationClassSourceProperty());
    renameClassCell.setTarget(getNestedObservationClassTargetProperty());
    alignment.addCell(renameClassCell);
    processJoinAlignment(alignment, chainingConf);
    // logMapping(mappingWrapper.getMainMapping());
    // logMapping(mappingWrapper.getIncludedTypesMapping());
    List<FeatureTypeMapping> mainMappings = mappingWrapper.getMainMapping().getTypeMappings().getFeatureTypeMapping();
    assertEquals(2, mainMappings.size());
    List<FeatureTypeMapping> includedMappings = mappingWrapper.getIncludedTypesMapping().getTypeMappings().getFeatureTypeMapping();
    assertEquals(1, includedMappings.size());
    FeatureTypeMapping obsMapping = includedMappings.get(0);
    assertTrue(SOURCE_OBSERVATION.equals(obsMapping.getSourceType()) && "lcv:LandCoverObservation".equals(obsMapping.getTargetElement()));
    FeatureTypeMapping lcdMapping = null, lcuMapping = null;
    for (FeatureTypeMapping ftMapping : mainMappings) {
        if (SOURCE_DATASET.equals(ftMapping.getSourceType()) && "lcv:LandCoverDataset".equals(ftMapping.getTargetElement())) {
            lcdMapping = ftMapping;
        }
        if (SOURCE_UNIT.equals(ftMapping.getSourceType()) && "lcv:LandCoverUnit".equals(ftMapping.getTargetElement())) {
            lcuMapping = ftMapping;
        }
    }
    assertNotNull(lcdMapping);
    assertNotNull(lcuMapping);
    // check feature chaining configuration
    List<AttributeMappingType> lcdAttrMappings = lcdMapping.getAttributeMappings().getAttributeMapping();
    List<AttributeMappingType> lcuAttrMappings = lcuMapping.getAttributeMappings().getAttributeMapping();
    List<AttributeMappingType> obsAttrMappings = obsMapping.getAttributeMappings().getAttributeMapping();
    assertNotNull(lcdAttrMappings);
    assertNotNull(lcuAttrMappings);
    assertNotNull(obsAttrMappings);
    assertEquals(1, lcdAttrMappings.size());
    assertEquals(3, lcuAttrMappings.size());
    assertEquals(2, obsAttrMappings.size());
    // NOTE: the order of attribute mappings is predictable, as it follows
    // the order of join conditions
    AttributeMappingType datasetContainerMapping = lcdAttrMappings.get(0);
    assertEquals("lcv:member", datasetContainerMapping.getTargetAttribute());
    assertEquals("lcv:LandCoverUnit", datasetContainerMapping.getSourceExpression().getLinkElement());
    assertEquals("FEATURE_LINK[1]", datasetContainerMapping.getSourceExpression().getLinkField());
    assertEquals(SOURCE_DATASET_ID, datasetContainerMapping.getSourceExpression().getOCQL());
    assertTrue(datasetContainerMapping.isIsMultiple());
    AttributeMappingType unitNestedMapping = lcuAttrMappings.get(0);
    assertEquals("FEATURE_LINK[1]", unitNestedMapping.getTargetAttribute());
    assertEquals(SOURCE_DATASET_ID, unitNestedMapping.getSourceExpression().getOCQL());
    assertNull(unitNestedMapping.getSourceExpression().getLinkElement());
    assertNull(unitNestedMapping.getSourceExpression().getLinkField());
    assertNull(unitNestedMapping.isIsMultiple());
    AttributeMappingType unitContainerMapping = lcuAttrMappings.get(1);
    assertEquals("lcv:landCoverObservation", unitContainerMapping.getTargetAttribute());
    assertEquals(SOURCE_UNIT_ID, unitContainerMapping.getSourceExpression().getOCQL());
    assertEquals("lcv:LandCoverObservation", unitContainerMapping.getSourceExpression().getLinkElement());
    assertEquals("FEATURE_LINK[1]", unitContainerMapping.getSourceExpression().getLinkField());
    assertTrue(unitContainerMapping.isIsMultiple());
    AttributeMappingType unitLocalIdMapping = lcuAttrMappings.get(2);
    assertEquals(TARGET_LOCAL_ID, unitLocalIdMapping.getTargetAttribute());
    assertEquals(SOURCE_UUID_V1, unitLocalIdMapping.getSourceExpression().getOCQL());
    assertNull(unitLocalIdMapping.getSourceExpression().getLinkElement());
    assertNull(unitLocalIdMapping.getSourceExpression().getLinkField());
    assertNull(unitLocalIdMapping.isIsMultiple());
    AttributeMappingType observationNestedMapping = obsAttrMappings.get(0);
    assertEquals("FEATURE_LINK[1]", observationNestedMapping.getTargetAttribute());
    assertEquals(SOURCE_OBS_UNIT_ID, observationNestedMapping.getSourceExpression().getOCQL());
    assertNull(observationNestedMapping.getSourceExpression().getLinkElement());
    assertNull(observationNestedMapping.getSourceExpression().getLinkField());
    assertNull(observationNestedMapping.isIsMultiple());
    AttributeMappingType observationClassMapping = obsAttrMappings.get(1);
    assertEquals("lcv:class", observationClassMapping.getTargetAttribute());
    assertEquals(SOURCE_OBS_CLASS, observationClassMapping.getSourceExpression().getOCQL());
    assertNull(observationClassMapping.getSourceExpression().getLinkElement());
    assertNull(observationClassMapping.getSourceExpression().getLinkField());
    assertNull(observationClassMapping.isIsMultiple());
}
Also used : FeatureChaining(eu.esdihumboldt.hale.io.appschema.model.FeatureChaining) AttributeMappingType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) DefaultAlignment(eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) Test(org.junit.Test)

Aggregations

FeatureChaining (eu.esdihumboldt.hale.io.appschema.model.FeatureChaining)7 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)2 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)2 AttributeMappingType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType)2 FeatureTypeMapping (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping)2 ChainConfiguration (eu.esdihumboldt.hale.io.appschema.model.ChainConfiguration)2 Element (org.w3c.dom.Element)2 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1 Cell (eu.esdihumboldt.hale.common.align.model.Cell)1 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)1 Property (eu.esdihumboldt.hale.common.align.model.Property)1 JoinParameter (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter)1 JoinCondition (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter.JoinCondition)1 DefaultAlignment (eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)1 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)1 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)1 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 AttributeExpressionMappingType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeExpressionMappingType)1