Search in sources :

Example 16 with If

use of org.w3._2007.rif.If in project hale by halestudio.

the class ModelRifToRifTranslator method translate.

/**
 * @see com.onespatial.jrc.tns.oml_to_rif.api.Translator#translate(Object)
 *      which this method implements.
 * @param source
 *            {@link ModelRifDocument}
 * @return {@link Document}
 * @throws TranslationException
 *             if any exceptions are thrown during translation.
 */
@Override
public Document translate(ModelRifDocument source) throws TranslationException {
    final Document document = factory.createDocument();
    Payload payload = factory.createPayload();
    document.setPayload(payload);
    GroupContents group = factory.createGroupContents();
    payload.setGroup(group);
    for (ModelSentence s : source.getSentences()) {
        group.getSentence().add(buildSentence(s));
    }
    return document;
}
Also used : ModelSentence(com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelSentence) Payload(org.w3._2007.rif.Payload) Document(org.w3._2007.rif.Document) ModelRifDocument(com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelRifDocument) GroupContents(org.w3._2007.rif.GroupContents)

Example 17 with If

use of org.w3._2007.rif.If in project hale by halestudio.

the class ModelRifToRifTranslator method createTargetVariableDeclare.

private ActionVar createTargetVariableDeclare(RifVariable variable) {
    ActionVar targetInstanceActionVar = factory.createDoActionVar();
    Var var = factory.createVar();
    var.getContent().add(variable.getName());
    targetInstanceActionVar.setVar(var);
    if (variable.getType() == Type.INSTANCE) {
        // $NON-NLS-1$
        targetInstanceActionVar.setNew(createElement("New"));
    } else {
        Frame frame = initialiseFrame(variable.getContextVariable());
        createBindingSlot(variable, frame);
        targetInstanceActionVar.setFrame(frame);
    }
    return targetInstanceActionVar;
}
Also used : ActionVar(org.w3._2007.rif.Do.ActionVar) Frame(org.w3._2007.rif.Frame) ActionVar(org.w3._2007.rif.Do.ActionVar) Var(org.w3._2007.rif.Var)

Example 18 with If

use of org.w3._2007.rif.If in project hale by halestudio.

the class ModelRifToRifTranslator method buildSentence.

private Sentence buildSentence(ModelSentence s) {
    // sort variables within sentence
    final Sentence sentence = factory.createSentence();
    final Implies implies = factory.createImplies();
    sentence.setImplies(implies);
    final If if1 = factory.createIf();
    implies.setIf(if1);
    final Exists exists = factory.createExists();
    if1.setExists(exists);
    ThenPart then = factory.createThenPart();
    implies.setThen(then);
    Do do1 = factory.createDo();
    then.setDo(do1);
    processChildren(s, exists, do1);
    return sentence;
}
Also used : Implies(org.w3._2007.rif.Implies) Exists(org.w3._2007.rif.Exists) ThenPart(org.w3._2007.rif.ThenPart) Do(org.w3._2007.rif.Do) ModelSentence(com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelSentence) Sentence(org.w3._2007.rif.Sentence) If(org.w3._2007.rif.If)

Example 19 with If

use of org.w3._2007.rif.If 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 20 with If

use of org.w3._2007.rif.If 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)

Aggregations

Actuate (org.n52.shetland.w3c.xlink.Actuate)15 Show (org.n52.shetland.w3c.xlink.Show)15 ActuateType (org.w3.x1999.xlink.ActuateType)15 ShowType (org.w3.x1999.xlink.ShowType)15 Reference (org.n52.shetland.w3c.xlink.Reference)14 Type (org.n52.shetland.w3c.xlink.Type)14 TypeType (org.w3.x1999.xlink.TypeType)14 IOException (java.io.IOException)13 XmlObject (org.apache.xmlbeans.XmlObject)11 AbstractCRSType (net.opengis.gml.x32.AbstractCRSType)10 CodeType (net.opengis.gml.x32.CodeType)10 EXExtentType (org.isotc211.x2005.gmd.EXExtentType)10 ProvideAndRegisterDocumentSetRequestType (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)9 ArrayList (java.util.ArrayList)8 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)8 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 BaseUnitType (net.opengis.gml.x32.BaseUnitType)6 VerticalDatumPropertyType (net.opengis.gml.x32.VerticalDatumPropertyType)5 VerticalDatumType (net.opengis.gml.x32.VerticalDatumType)5