use of org.w3._2007.rif.Frame in project hale by halestudio.
the class ModelRifToRifTranslator method createAssignmentSlot.
private void createAssignmentSlot(PropertyMapping mapping, Frame frame) {
SlotFrameType slot = factory.createSlotFrameType();
// $NON-NLS-1$
slot.setOrdered("yes");
Const const1 = factory.createConst();
const1.getContent().add(mapping.getTarget().getPropertyName());
// $NON-NLS-1$
const1.setType("rif:iri");
slot.getContent().add(const1);
Var var1 = factory.createVar();
var1.getContent().add(mapping.getSource().getName());
slot.getContent().add(var1);
frame.getSlot().add(slot);
}
use of org.w3._2007.rif.Frame in project hale by halestudio.
the class ModelRifToRifTranslator method initialiseFrame.
private Frame initialiseFrame(RifVariable contextVariable) {
Frame frame = factory.createFrame();
frame = factory.createFrame();
org.w3._2007.rif.Object frameObject = factory.createObject();
frame.setObject(frameObject);
Var var = factory.createVar();
var.getContent().add(contextVariable.getName());
frameObject.setVar(var);
return frame;
}
use of org.w3._2007.rif.Frame 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;
}
use of org.w3._2007.rif.Frame 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);
}
}
}
}
use of org.w3._2007.rif.Frame 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);
}
}
Aggregations