use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping in project hale by halestudio.
the class AppSchemaIsolatedWorkspacesMappingTest method testStationsIsolated.
/**
* Isolated attribute must be true for the stations ws and false for the
* measurements ws, names must match those specified in the workspace
* configuration, unique mapping names must be generated only for the
* stations ws.
*
* @throws IOException
*/
@Test
public void testStationsIsolated() throws IOException {
workspaceConf.getWorkspace(STATIONS_NS_URI).setIsolated(true);
AppSchemaMappingGenerator generator = new AppSchemaMappingGenerator(alignment, targetSchemaSpace, null, featureChainingConf, workspaceConf);
IOReporter reporter = new DefaultIOReporter(targetSchemaSpace.getSchemas().iterator().next(), "Generate App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, false);
generator.generateMapping(reporter);
assertEquals(STATIONS_WS_RENAMED, generator.getMainNamespace().name());
assertTrue((boolean) generator.getMainNamespace().getAttribute(Namespace.ISOLATED));
assertEquals(STATIONS_WS_RENAMED, generator.getMainWorkspace().name());
assertTrue((boolean) generator.getMainWorkspace().getAttribute(Namespace.ISOLATED));
boolean measurementsNsFound = false;
for (Namespace ns : generator.getSecondaryNamespaces()) {
if (MEASUREMENTS_NS_URI.equals(ns.getAttribute(Namespace.URI))) {
measurementsNsFound = true;
assertEquals(MEASUREMENTS_WS_RENAMED, ns.name());
assertFalse((boolean) ns.getAttribute(Namespace.ISOLATED));
assertEquals(MEASUREMENTS_WS_RENAMED, generator.getWorkspace(ns).name());
assertFalse((boolean) generator.getWorkspace(ns).getAttribute(Namespace.ISOLATED));
}
}
assertTrue(measurementsNsFound);
List<FeatureTypeMapping> typeMappings = generator.getGeneratedMapping().getAppSchemaMapping().getTypeMappings().getFeatureTypeMapping();
assertEquals(2, typeMappings.size());
boolean stationsFtFound = false, measurementsFtFound = false;
Set<String> mappingNames = new HashSet<String>();
for (FeatureTypeMapping typeMapping : typeMappings) {
if ((STATIONS_WS_RENAMED + ":Station_gml32").equals(typeMapping.getTargetElement())) {
stationsFtFound = true;
assertFalse(Strings.isNullOrEmpty(typeMapping.getMappingName()));
}
if ((MEASUREMENTS_WS_RENAMED + ":Measurement_gml32").equals(typeMapping.getTargetElement())) {
measurementsFtFound = true;
assertTrue(Strings.isNullOrEmpty(typeMapping.getMappingName()));
}
if (!Strings.isNullOrEmpty(typeMapping.getMappingName())) {
mappingNames.add(typeMapping.getMappingName());
}
}
assertEquals(1, mappingNames.size());
assertTrue(stationsFtFound);
assertTrue(measurementsFtFound);
}
use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping in project hale by halestudio.
the class AppSchemaMappingTest method testXrefJoinHandler.
@Test
public void testXrefJoinHandler() {
DefaultCell joinCell = buildJoinCell(null);
// create minimal alignment and pass it to JoinHandler
DefaultCell renameCell = new DefaultCell();
renameCell.setTransformationIdentifier(RenameFunction.ID);
renameCell.setSource(getUnitIdSourceProperty(unitDenormType));
renameCell.setTarget(getNestedUnitHrefTargetProperty());
DefaultAlignment alignment = new DefaultAlignment();
alignment.addCell(joinCell);
alignment.addCell(renameCell);
processJoinAlignment(alignment, null);
// logMapping(mappingWrapper.getMainMapping());
List<FeatureTypeMapping> ftMappings = mappingWrapper.getMainMapping().getTypeMappings().getFeatureTypeMapping();
assertEquals(2, ftMappings.size());
FeatureTypeMapping lcdMapping = null, lcuMapping = null;
for (FeatureTypeMapping ftMapping : ftMappings) {
if (SOURCE_DATASET.equals(ftMapping.getSourceType()) && "lcv:LandCoverDataset".equals(ftMapping.getTargetElement())) {
lcdMapping = ftMapping;
}
if (SOURCE_UNIT_DENORM.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();
assertNotNull(lcdAttrMappings);
assertNotNull(lcuAttrMappings);
assertEquals(1, lcdAttrMappings.size());
assertEquals(1, lcuAttrMappings.size());
AttributeMappingType containerMapping = lcdAttrMappings.get(0);
assertEquals("lcv:member", containerMapping.getTargetAttribute());
assertEquals("lcv:LandCoverUnit", containerMapping.getSourceExpression().getLinkElement());
assertEquals("FEATURE_LINK[1]", containerMapping.getSourceExpression().getLinkField());
assertEquals(SOURCE_DATASET_ID, containerMapping.getSourceExpression().getOCQL());
assertTrue(containerMapping.isIsMultiple());
assertNotNull(containerMapping.getClientProperty());
assertEquals(1, containerMapping.getClientProperty().size());
assertEquals("xlink:href", containerMapping.getClientProperty().get(0).getName());
assertEquals(SOURCE_UNIT_ID, containerMapping.getClientProperty().get(0).getValue());
AttributeMappingType nestedMapping = lcuAttrMappings.get(0);
assertEquals("FEATURE_LINK[1]", nestedMapping.getTargetAttribute());
assertEquals(SOURCE_DATASET_ID, nestedMapping.getSourceExpression().getOCQL());
assertNull(nestedMapping.getSourceExpression().getLinkElement());
assertNull(nestedMapping.getSourceExpression().getLinkField());
}
use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping in project hale by halestudio.
the class AppSchemaMappingTest method testRetypeHandler.
@Test
public void testRetypeHandler() {
DefaultCell cell = new DefaultCell();
cell.setTransformationIdentifier(RetypeFunction.ID);
ListMultimap<String, Type> source = ArrayListMultimap.create();
source.put(null, new DefaultType(new TypeEntityDefinition(unitDenormType, SchemaSpaceID.SOURCE, null)));
ListMultimap<String, Type> target = ArrayListMultimap.create();
target.put(null, new DefaultType(new TypeEntityDefinition(landCoverUnitType, SchemaSpaceID.TARGET, null)));
cell.setSource(source);
cell.setTarget(target);
RetypeHandler handler = new RetypeHandler();
FeatureTypeMapping ftMapping = handler.handleTypeTransformation(cell, new AppSchemaMappingContext(mappingWrapper));
assertEquals(SOURCE_UNIT_DENORM, ftMapping.getSourceType());
assertEquals("lcv:LandCoverUnit", ftMapping.getTargetElement());
}
use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping 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());
}
use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping in project hale by halestudio.
the class AppSchemaMappingGenerator method getFeatureTypes.
/**
* Returns the generated feature type configuration for all mapped feature
* types.
*
* @return the generated feature type configuration
*/
public List<FeatureType> getFeatureTypes() {
checkMappingGenerated();
eu.esdihumboldt.hale.io.geoserver.DataStore dataStore = getAppSchemaDataStore();
List<FeatureType> featureTypes = new ArrayList<FeatureType>();
// .getFeatureTypeMapping()) {
for (FeatureTypeMapping ftMapping : mainMapping.getTypeMappings().getFeatureTypeMapping()) {
featureTypes.add(getFeatureType(dataStore, ftMapping));
}
return featureTypes;
}
Aggregations