Search in sources :

Example 1 with AbstractFilterNode

use of com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.AbstractFilterNode in project hale by halestudio.

the class ModelAlignmentToModelRifTranslator method buildModelSentance.

private ModelSentence buildModelSentance(ModelClassMappingCell classMapping, List<ModelAttributeMappingCell> attributeMappings, List<ModelStaticAssignmentCell> staticAssignments) {
    ModelSentence sentence = new ModelSentence();
    sentence.setSourceClass(// $NON-NLS-1$
    classMapping.getSourceClass().getElementName().getLocalPart().toLowerCase() + "-instance", getName(classMapping.getSourceClass().getElementName()));
    sentence.setTargetClass(// $NON-NLS-1$
    classMapping.getTargetClass().getElementName().getLocalPart().toLowerCase() + "-instance", getName(classMapping.getTargetClass().getElementName()));
    for (ModelMappingCondition condition : classMapping.getMappingConditions()) {
        sentence.addMappingCondition(buildRifMappingCondition(sentence, (AbstractFilterNode) condition.getRoot()));
    }
    for (ModelAttributeMappingCell attributeMapping : attributeMappings) {
        buildPropertyMapping(sentence, attributeMapping);
    }
    for (ModelStaticAssignmentCell staticAssigment : staticAssignments) {
        buildStaticAssignment(sentence, staticAssigment);
    }
    return sentence;
}
Also used : ModelSentence(com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelSentence) AbstractFilterNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.AbstractFilterNode) ModelAttributeMappingCell(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelAttributeMappingCell) ModelStaticAssignmentCell(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelStaticAssignmentCell) ModelMappingCondition(com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelMappingCondition)

Example 2 with AbstractFilterNode

use of com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.AbstractFilterNode in project hale by halestudio.

the class ModelAlignmentToModelRifTranslator method buildRifMappingCondition.

private ModelRifMappingCondition buildRifMappingCondition(ModelSentence sentence, AbstractFilterNode node) {
    ModelRifMappingCondition rifCondition = new ModelRifMappingCondition();
    if (node != null) {
        // logical ones
        if (node.isLogical()) {
            for (FilterNode child : node.getChildren()) {
                AbstractFilterNode childNode = (AbstractFilterNode) child;
                rifCondition.addChild(buildRifMappingCondition(sentence, childNode));
            }
            if (node.getNodeType().equals(AND_NODE)) {
                rifCondition.setLogicalType(LogicalType.AND);
            } else if (node.getNodeType().equals(OR_NODE)) {
                rifCondition.setLogicalType(LogicalType.OR);
            } else if (node.getNodeType().equals(NOT_NODE)) {
                rifCondition.setLogicalType(LogicalType.NOT);
                rifCondition.setNegated(true);
            }
        } else // comparison ones
        if (node.isComparison()) {
            AbstractComparisonNode cnode = (AbstractComparisonNode) node;
            if (node.getNodeType().equals(EQUAL_TO_NODE)) {
                EqualToNode equalNode = (EqualToNode) node;
                // work out if it's a string or a numeric equality test
                rifCondition.setOperator(STRING_EQUALS);
                if (equalNode.getRight().isNumeric()) {
                    rifCondition.setOperator(NUMBER_EQUALS);
                }
            } else // less-than comparisons
            if (node.getNodeType().equals(GREATER_THAN_NODE)) {
                rifCondition.setOperator(NUMBER_GREATER_THAN);
            } else if (node.getNodeType().equals(LESS_THAN_NODE)) {
                rifCondition.setOperator(NUMBER_LESS_THAN);
            } else if (node.getNodeType().equals(LIKE_NODE)) {
                rifCondition.setOperator(STRING_CONTAINS);
            }
            rifCondition.setLeft(getContents(sentence, cnode.getLeft()));
            rifCondition.setLiteralClass(cnode.getRight().getLiteralValue().getValueClass());
            rifCondition.setLiteralValue(cnode.getRight().getLiteralValue().toString());
            rifCondition.setRight(getContents(sentence, cnode.getRight()));
        } else // geometric ones
        if (node.isGeometric()) {
        // TODO add this
        }
    }
    return rifCondition;
}
Also used : EqualToNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.comparison.EqualToNode) AbstractFilterNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.AbstractFilterNode) ModelRifMappingCondition(com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelRifMappingCondition) FilterNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.FilterNode) AbstractFilterNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.AbstractFilterNode) AbstractComparisonNode(com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.comparison.AbstractComparisonNode)

Aggregations

AbstractFilterNode (com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.AbstractFilterNode)2 ModelAttributeMappingCell (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelAttributeMappingCell)1 ModelMappingCondition (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelMappingCondition)1 ModelStaticAssignmentCell (com.onespatial.jrc.tns.oml_to_rif.model.alignment.ModelStaticAssignmentCell)1 ModelRifMappingCondition (com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelRifMappingCondition)1 ModelSentence (com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelSentence)1 FilterNode (com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.FilterNode)1 AbstractComparisonNode (com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.comparison.AbstractComparisonNode)1 EqualToNode (com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.comparison.EqualToNode)1