Search in sources :

Example 1 with MathematicalExpressionHandler

use of eu.esdihumboldt.hale.io.appschema.writer.internal.MathematicalExpressionHandler 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)

Aggregations

ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)1 Property (eu.esdihumboldt.hale.common.align.model.Property)1 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)1 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)1 AttributeMappingType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType)1 ClientProperty (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType.ClientProperty)1 MathematicalExpressionHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.MathematicalExpressionHandler)1 AppSchemaMappingContext (eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext)1 Test (org.junit.Test)1