/** * config generation for 'element -- operator -- element' mapping scenario stright forwerd and * this method provide assignment for this operator * * @param operator this operator * @param inputElement element map from input schema tree * @return assignment statement for map */ private AssignmentStatement getSimpleOperatorMapping(Operator operator, Element inputElement) { Element outputElement = getOutputElement(operator); TreeNode outputParent = getOutputElementParent(operator); String index = ""; if (inputElement.getFieldParent().getSchemaDataType().equals(SchemaDataType.ARRAY)) index = getIndex(); StringBuilder builder = new StringBuilder(); builder .append(getTreeHierarchy(outputElement.getFieldParent(), outputParent)) .append(".") .append(outputElement.getName()) .append(" = ") .append(inputElement.getFieldParent().getName()) .append(index) .append(".") .append(inputElement.getName()) .append(getOperatorFunction()) .append(";"); AssignmentStatement statement = new AssignmentStatement(); statement.setStatement(builder.toString()); return statement; }
@Override public AssignmentStatement transform(Operator operator) { EObject operatorInput = getInputObject(operator); EObject operatorOutput = getOutputObject(operator); if (operatorInput instanceof Element && operatorOutput instanceof Element) { Element inputElement = (Element) operatorInput; return getSimpleOperatorMapping(operator, inputElement); } else if (operatorInput instanceof Element && operatorOutput instanceof OperatorLeftConnector) { Operator nextOperator = (Operator) getOperator(operatorOutput); // create ___ = me ____ and pass String subAssign = createSubAssignment((Element) operatorInput); OperatorsTransformer transformer = DataMapperTransformerRegistry.getInstance().getTransformer(nextOperator); String assign = transformer.trasnform(subAssign, operator, nextOperator); AssignmentStatement statement = new AssignmentStatement(); statement.setStatement(assign); return statement; } return null; }