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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations