Search in sources :

Example 1 with RifVariable

use of com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable in project hale by halestudio.

the class ModelAlignmentToModelRifTranslator method buildPropertyMapping.

private void buildPropertyMapping(ModelSentence sentence, ModelAttributeMappingCell attributeMapping) {
    RifVariable sourceVariable = descendGmlAttributePath(sentence, attributeMapping.getSourceAttribute(), true);
    RifVariable targetVariable = descendGmlAttributePath(sentence, attributeMapping.getTargetAttribute(), false);
    sentence.addPropertyMapping(new PropertyMapping(sourceVariable, targetVariable));
}
Also used : PropertyMapping(com.onespatial.jrc.tns.oml_to_rif.model.rif.PropertyMapping) RifVariable(com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable)

Example 2 with RifVariable

use of com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable in project hale by halestudio.

the class ModelAlignmentToModelRifTranslator method getContents.

private RifVariable getContents(ModelSentence sentence, LeafNode leaf) {
    // it's either a property or a literal
    if (leaf.getPropertyName() == null) {
        // we don't need a variable
        return null;
    }
    RifVariable contextVariable = sentence.getSourceClass();
    String className = contextVariable.getClassName();
    String variableName = className.substring(className.lastIndexOf(':') + 1, className.length()) + "-" + leaf.getPropertyName().toLowerCase() + // $NON-NLS-1$ //$NON-NLS-2$
    "-filter";
    RifVariable variable = sentence.createVariable(variableName);
    variable.setContextVariable(sentence.getSourceClass());
    variable.setName(variableName.toLowerCase());
    variable.setPropertyName(className.substring(0, className.lastIndexOf(':') + 1) + leaf.getPropertyName());
    variable.setType(Type.ATTRIBUTE);
    return variable;
}
Also used : RifVariable(com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable)

Example 3 with RifVariable

use of com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable in project hale by halestudio.

the class ModelRifToRifTranslator method recurseChildren.

private void recurseChildren(final Exists exists, Do do1, RifVariable variable, ModelSentence sentence, boolean isSource) {
    List<RifVariable> children = sentence.findChildren(variable);
    if (isSource) {
        exists.getDeclare().add(createSourceDeclare(variable));
        if (variable.getType().equals(Type.INSTANCE)) {
            exists.getFormula().getAnd().getFormula().add(createSourceInstanceMembershipFormula(sentence, variable));
        }
    } else {
        // if (!children.isEmpty()) // problem?
        do1.getActionVar().add(createTargetVariableDeclare(variable));
        if (variable.getType() == Type.INSTANCE) {
            do1.getActions().getACTION().add(createTargetInstanceMembershipFormula(do1.getActions(), sentence, variable));
        }
    }
    if (!children.isEmpty()) {
        if (isSource) {
            Frame frame = initialiseFrame(variable);
            for (RifVariable child : children) {
                recurseChildren(exists, do1, child, sentence, isSource);
                createBindingSlot(child, frame);
            }
            Formula frameFormula = factory.createFormula();
            frameFormula.setFrame(frame);
            exists.getFormula().getAnd().getFormula().add(frameFormula);
        } else {
            for (RifVariable child : children) {
                recurseChildren(exists, do1, child, sentence, isSource);
            }
        }
    }
}
Also used : Formula(org.w3._2007.rif.Formula) Frame(org.w3._2007.rif.Frame) RifVariable(com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable)

Example 4 with RifVariable

use of com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable in project hale by halestudio.

the class ModelRifToRifTranslator method processChildren.

private void processChildren(ModelSentence s, final Exists exists, Do do1) {
    Formula existsFormula = factory.createFormula();
    And and = factory.createAnd();
    existsFormula.setAnd(and);
    exists.setFormula(existsFormula);
    Actions actions = factory.createDoActions();
    do1.setActions(actions);
    for (RifVariable instanceVariable : s.getVariables(Type.INSTANCE)) {
        // source instance variables
        if (!instanceVariable.isActionVar()) {
            recurseChildren(exists, do1, instanceVariable, s, true);
        } else // target instance variables
        {
            recurseChildren(exists, do1, instanceVariable, s, false);
        }
    }
    Map<RifVariable, Frame> map = new LinkedHashMap<RifVariable, Frame>();
    for (PropertyMapping mapping : s.getPropertyMappings()) {
        RifVariable contextVariable = mapping.getTarget().getContextVariable();
        Frame match = map.get(contextVariable);
        if (match == null) {
            map.put(contextVariable, initialiseFrame(contextVariable));
        }
    }
    for (StaticAssignment staticAssignment : s.getStaticAssignments()) {
        RifVariable contextVariable = staticAssignment.getTarget().getContextVariable();
        Frame match = map.get(contextVariable);
        if (match == null) {
            map.put(contextVariable, initialiseFrame(contextVariable));
        }
    }
    for (PropertyMapping mapping : s.getPropertyMappings()) {
        Frame frame = map.get(mapping.getTarget().getContextVariable());
        createAssignmentSlot(mapping, frame);
    }
    for (StaticAssignment staticAssignment : s.getStaticAssignments()) {
        Frame frame = map.get(staticAssignment.getTarget().getContextVariable());
        createStaticAssignmentSlot(staticAssignment, frame);
    }
    for (ModelRifMappingCondition mappingCondition : s.getMappingConditions()) {
        createFilter(exists.getFormula().getAnd().getFormula(), mappingCondition);
    }
    for (Frame frame : map.values()) {
        Assert assert1 = factory.createAssert();
        Target target = factory.createAssertTarget();
        target.setFrame(frame);
        assert1.setTarget(target);
        actions.getACTION().add(assert1);
    }
}
Also used : Formula(org.w3._2007.rif.Formula) StaticAssignment(com.onespatial.jrc.tns.oml_to_rif.model.rif.StaticAssignment) Frame(org.w3._2007.rif.Frame) Target(org.w3._2007.rif.Assert.Target) Assert(org.w3._2007.rif.Assert) Actions(org.w3._2007.rif.Do.Actions) And(org.w3._2007.rif.And) ModelRifMappingCondition(com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelRifMappingCondition) PropertyMapping(com.onespatial.jrc.tns.oml_to_rif.model.rif.PropertyMapping) RifVariable(com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with RifVariable

use of com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable in project hale by halestudio.

the class ModelAlignmentToModelRifTranslator method buildStaticAssignment.

private void buildStaticAssignment(ModelSentence sentence, ModelStaticAssignmentCell staticAssigment) {
    RifVariable targetVariable = descendGmlAttributePath(sentence, staticAssigment.getTarget(), false);
    sentence.addStaticAssigment(new StaticAssignment(targetVariable, staticAssigment.getContent()));
}
Also used : StaticAssignment(com.onespatial.jrc.tns.oml_to_rif.model.rif.StaticAssignment) RifVariable(com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable)

Aggregations

RifVariable (com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable)6 PropertyMapping (com.onespatial.jrc.tns.oml_to_rif.model.rif.PropertyMapping)2 StaticAssignment (com.onespatial.jrc.tns.oml_to_rif.model.rif.StaticAssignment)2 Formula (org.w3._2007.rif.Formula)2 Frame (org.w3._2007.rif.Frame)2 ModelRifMappingCondition (com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelRifMappingCondition)1 LinkedHashMap (java.util.LinkedHashMap)1 And (org.w3._2007.rif.And)1 Assert (org.w3._2007.rif.Assert)1 Target (org.w3._2007.rif.Assert.Target)1 Actions (org.w3._2007.rif.Do.Actions)1