Search in sources :

Example 6 with RenameHandler

use of eu.esdihumboldt.hale.io.appschema.writer.internal.RenameHandler in project hale by halestudio.

the class AppSchemaMappingTest method testGenericGeometryPropertyIdEncoding.

@Test
public void testGenericGeometryPropertyIdEncoding() {
    final String GML_ID_PATTERN = "geom.{dataset_id}";
    final String GML_ID_OCQL = "strConcat('geom.', dataset_id)";
    // create mapping context
    AppSchemaMappingContext context = new AppSchemaMappingContext(mappingWrapper);
    // create retype cell
    Cell retypeCell = getDefaultTypeCell(datasetType, landCoverDatasetType);
    // create rename cell to produce LCD's geometry
    DefaultCell geomRenameCell = new DefaultCell();
    geomRenameCell.setTransformationIdentifier(RenameFunction.ID);
    geomRenameCell.setSource(getDatasetGeomSourceProperty());
    geomRenameCell.setTarget(getLandCoverDatasetGeometryTargetProperty());
    // create formatted string cell to produce LCD geometry's gml:id
    DefaultCell geomGmlIdFormatCell = new DefaultCell();
    geomGmlIdFormatCell.setTransformationIdentifier(FormattedStringFunction.ID);
    ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
    parameters.put(FormattedStringFunction.PARAMETER_PATTERN, new ParameterValue(GML_ID_PATTERN));
    ListMultimap<String, Property> source = ArrayListMultimap.create();
    source.putAll(FormattedStringFunction.ENTITY_VARIABLE, getDatasetIdSourceProperty().values());
    geomGmlIdFormatCell.setSource(source);
    geomGmlIdFormatCell.setTarget(getLandCoverDatasetGeometryGmlIdTargetProperty());
    geomGmlIdFormatCell.setTransformationParameters(parameters);
    // process cells in whatever order
    FormattedStringHandler formatHandler = new FormattedStringHandler();
    formatHandler.handlePropertyTransformation(retypeCell, geomGmlIdFormatCell, context);
    RenameHandler renameHandler = new RenameHandler();
    AttributeMappingType attrMapping = renameHandler.handlePropertyTransformation(retypeCell, geomRenameCell, context);
    assertEquals(SOURCE_GEOM, attrMapping.getSourceExpression().getOCQL());
    assertEquals("gml:MultiSurfaceType", attrMapping.getTargetAttributeNode());
    assertEquals(TARGET_GEOMETRY_LCD, attrMapping.getTargetAttribute());
    assertNotNull(attrMapping.getIdExpression());
    assertEquals(GML_ID_OCQL, attrMapping.getIdExpression().getOCQL());
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) AttributeMappingType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) RenameHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.RenameHandler) AppSchemaMappingContext(eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext) FormattedStringHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.FormattedStringHandler) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Property(eu.esdihumboldt.hale.common.align.model.Property) ClientProperty(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType.ClientProperty) DefaultProperty(eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty) Test(org.junit.Test)

Example 7 with RenameHandler

use of eu.esdihumboldt.hale.io.appschema.writer.internal.RenameHandler in project hale by halestudio.

the class AppSchemaMappingTest method testGeometryEncoding.

@Test
public void testGeometryEncoding() {
    DefaultCell cell = new DefaultCell();
    cell.setTransformationIdentifier(RenameFunction.ID);
    cell.setSource(getUnitGeomSourceProperty(unitDenormType));
    cell.setTarget(getLandCoverDatasetGeometryTargetProperty());
    RenameHandler renameHandler = new RenameHandler();
    AttributeMappingType attrMapping = renameHandler.handlePropertyTransformation(getDefaultTypeCell(datasetType, landCoverDatasetType), cell, new AppSchemaMappingContext(mappingWrapper));
    assertEquals(SOURCE_GEOM, attrMapping.getSourceExpression().getOCQL());
    assertEquals(TARGET_GEOMETRY_LCD, attrMapping.getTargetAttribute());
    assertEquals("gml:MultiSurfaceType", attrMapping.getTargetAttributeNode());
}
Also used : AttributeMappingType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) RenameHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.RenameHandler) AppSchemaMappingContext(eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext) Test(org.junit.Test)

Aggregations

DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)7 AttributeMappingType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType)7 RenameHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.RenameHandler)7 AppSchemaMappingContext (eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext)7 Test (org.junit.Test)7 Cell (eu.esdihumboldt.hale.common.align.model.Cell)4 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)4 ClientProperty (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType.ClientProperty)3 Property (eu.esdihumboldt.hale.common.align.model.Property)2 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)2 AssignHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.AssignHandler)2 FormattedStringHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.FormattedStringHandler)2