Search in sources :

Example 21 with DefaultCell

use of eu.esdihumboldt.hale.common.align.model.impl.DefaultCell 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());
}
Also used : 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) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) AppSchemaMappingContext(eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) RetypeHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.RetypeHandler) Test(org.junit.Test)

Example 22 with DefaultCell

use of eu.esdihumboldt.hale.common.align.model.impl.DefaultCell in project hale by halestudio.

the class AppSchemaMappingTest method testDateExtractionHandler.

@Test
public void testDateExtractionHandler() {
    final String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";
    final String OCQL = "dateParse(" + SOURCE_UUID_V1 + ", '" + DATE_FORMAT + "')";
    DefaultCell cell = new DefaultCell();
    cell.setTransformationIdentifier(DateExtractionFunction.ID);
    ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
    parameters.put(DateExtractionFunction.PARAMETER_DATE_FORMAT, new ParameterValue(DATE_FORMAT));
    cell.setSource(getUuidSourceProperty(unitDenormType));
    cell.setTarget(getFirstObservationDateTargetProperty());
    cell.setTransformationParameters(parameters);
    DateExtractionHandler handler = new DateExtractionHandler();
    AttributeMappingType attrMapping = handler.handlePropertyTransformation(getDefaultTypeCell(unitDenormType, landCoverUnitType), cell, new AppSchemaMappingContext(mappingWrapper));
    assertEquals(OCQL, attrMapping.getSourceExpression().getOCQL());
    assertEquals(TARGET_FIRST_OBSERVATION_DATE, attrMapping.getTargetAttribute());
}
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) AppSchemaMappingContext(eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext) DateExtractionHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.DateExtractionHandler) Test(org.junit.Test)

Example 23 with DefaultCell

use of eu.esdihumboldt.hale.common.align.model.impl.DefaultCell in project hale by halestudio.

the class AppSchemaMappingTest method testMathematicalExpressionHandler.

@Test
public void testMathematicalExpressionHandler() {
    final String EXPRESSION = "100 * unit_id / 2";
    final String OCQL = EXPRESSION;
    DefaultCell cell = new DefaultCell();
    cell.setTransformationIdentifier(MathematicalExpressionFunction.ID);
    ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
    parameters.put(MathematicalExpressionFunction.PARAMETER_EXPRESSION, new ParameterValue(EXPRESSION));
    ListMultimap<String, Property> source = ArrayListMultimap.create();
    source.putAll(MathematicalExpressionFunction.ENTITY_VARIABLE, getUnitIdSourceProperty(unitDenormType).values());
    cell.setSource(source);
    cell.setTarget(getLocalIdTargetProperty());
    cell.setTransformationParameters(parameters);
    MathematicalExpressionHandler handler = new MathematicalExpressionHandler();
    AttributeMappingType attrMapping = handler.handlePropertyTransformation(getDefaultTypeCell(unitDenormType, landCoverUnitType), cell, new AppSchemaMappingContext(mappingWrapper));
    assertEquals(OCQL, attrMapping.getSourceExpression().getOCQL());
    assertEquals(TARGET_LOCAL_ID, attrMapping.getTargetAttribute());
}
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) AppSchemaMappingContext(eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext) MathematicalExpressionHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.MathematicalExpressionHandler) 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 24 with DefaultCell

use of eu.esdihumboldt.hale.common.align.model.impl.DefaultCell in project hale by halestudio.

the class AppSchemaMappingTest method testFeatureGmlIdEncoding.

@Test
public void testFeatureGmlIdEncoding() {
    DefaultCell cell = new DefaultCell();
    cell.setTransformationIdentifier(RenameFunction.ID);
    cell.setSource(getUnitIdSourceProperty(unitDenormType));
    cell.setTarget(getGmlIdTargetProperty());
    RenameHandler renameHandler = new RenameHandler();
    AttributeMappingType attrMapping = renameHandler.handlePropertyTransformation(getDefaultTypeCell(unitDenormType, landCoverUnitType), cell, new AppSchemaMappingContext(mappingWrapper));
    assertNull(attrMapping.getSourceExpression());
    assertEquals(SOURCE_UNIT_ID, attrMapping.getIdExpression().getOCQL());
    assertEquals("lcv:LandCoverUnit", attrMapping.getTargetAttribute());
}
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)

Example 25 with DefaultCell

use of eu.esdihumboldt.hale.common.align.model.impl.DefaultCell in project hale by halestudio.

the class AppSchemaMappingTest method testRenameHandler.

@Test
public void testRenameHandler() {
    DefaultCell cell = new DefaultCell();
    cell.setTransformationIdentifier(RenameFunction.ID);
    cell.setSource(getUuidSourceProperty(unitDenormType));
    cell.setTarget(getLocalIdTargetProperty());
    RenameHandler renameHandler = new RenameHandler();
    AttributeMappingType attrMapping = renameHandler.handlePropertyTransformation(getDefaultTypeCell(unitDenormType, landCoverUnitType), cell, new AppSchemaMappingContext(mappingWrapper));
    assertEquals("uuid_v1", attrMapping.getSourceExpression().getOCQL());
    assertEquals(TARGET_LOCAL_ID, attrMapping.getTargetAttribute());
}
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)47 Test (org.junit.Test)24 AttributeMappingType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType)22 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)21 Cell (eu.esdihumboldt.hale.common.align.model.Cell)17 AppSchemaMappingContext (eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext)17 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)16 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)15 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)13 DefaultType (eu.esdihumboldt.hale.common.align.model.impl.DefaultType)12 Type (eu.esdihumboldt.hale.common.align.model.Type)11 ArrayList (java.util.ArrayList)10 Property (eu.esdihumboldt.hale.common.align.model.Property)9 DefaultAlignment (eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)9 ClientProperty (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType.ClientProperty)9 Entity (eu.esdihumboldt.hale.common.align.model.Entity)8 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)8 MutableAlignment (eu.esdihumboldt.hale.common.align.model.MutableAlignment)7 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)7 AssignHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.AssignHandler)6