use of org.javarosa.core.model.instance.TreeReference in project javarosa by opendatakit.
the class Triggerable method readExternal.
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
expr = (IConditionExpr) ExtUtil.read(in, new ExtWrapTagged(), pf);
contextRef = (TreeReference) ExtUtil.read(in, TreeReference.class, pf);
originalContextRef = (TreeReference) ExtUtil.read(in, TreeReference.class, pf);
List<TreeReference> tlist = (List<TreeReference>) ExtUtil.read(in, new ExtWrapList(TreeReference.class), pf);
targets = new ArrayList<TreeReference>(tlist);
}
use of org.javarosa.core.model.instance.TreeReference in project javarosa by opendatakit.
the class Triggerable method writeExternal.
public void writeExternal(DataOutputStream out) throws IOException {
ExtUtil.write(out, new ExtWrapTagged(expr));
ExtUtil.write(out, contextRef);
ExtUtil.write(out, originalContextRef);
List<TreeReference> tlist = new ArrayList<TreeReference>(targets);
ExtUtil.write(out, new ExtWrapList(tlist));
}
use of org.javarosa.core.model.instance.TreeReference in project javarosa by opendatakit.
the class Triggerable method equals.
public boolean equals(Object o) {
if (o instanceof Triggerable) {
Triggerable t = (Triggerable) o;
if (this == t)
return true;
if (this.expr.equals(t.expr)) {
// the
try {
// resolved triggers should match...
Set<TreeReference> Atriggers = this.getTriggers();
Set<TreeReference> Btriggers = t.getTriggers();
return (Atriggers.size() == Btriggers.size()) && Atriggers.containsAll(Btriggers);
} catch (XPathException e) {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
use of org.javarosa.core.model.instance.TreeReference in project javarosa by opendatakit.
the class XFormParserTest method parsesExternalSecondaryInstanceForm.
@Test
public void parsesExternalSecondaryInstanceForm() throws IOException, XPathSyntaxException {
FormDef formDef = parse(EXTERNAL_SECONDARY_INSTANCE_XML).formDef;
assertEquals("Form with external secondary instance", formDef.getTitle());
TreeReference treeReference = ((XPathPathExpr) parseXPath("instance('towns')/data_set")).getReference();
EvaluationContext evaluationContext = formDef.getEvaluationContext();
List<TreeReference> treeReferences = evaluationContext.expandReference(treeReference);
assertEquals(1, treeReferences.size());
DataInstance townInstance = formDef.getNonMainInstance("towns");
AbstractTreeElement tiRoot = townInstance.getRoot();
assertEquals("towndata", tiRoot.getName());
assertEquals(1, tiRoot.getNumChildren());
AbstractTreeElement dataSetChild = tiRoot.getChild("data_set", 0);
assertEquals("us_east", dataSetChild.getValue().getDisplayText());
}
use of org.javarosa.core.model.instance.TreeReference in project javarosa by opendatakit.
the class XFormParserTest method parseGroupWithNodesetAttrForm.
@Test
public void parseGroupWithNodesetAttrForm() throws IOException {
// Given & When
ParseResult parseResult = parse(r("group-with-nodeset-attr.xml"));
// Then
assertEquals(parseResult.formDef.getTitle(), "group with nodeset attribute");
assertEquals("Number of error messages", 0, parseResult.errorMessages.size());
final TreeReference expectedTreeReference = new TreeReference();
// absolute reference
expectedTreeReference.setRefLevel(-1);
// the instance root
expectedTreeReference.add("data", -1);
// the outer repeat
expectedTreeReference.add("R1", -1);
// the inner group
expectedTreeReference.add("G2", -1);
final IDataReference expectedXPathReference = new XPathReference(expectedTreeReference);
IFormElement groupElement = parseResult.formDef.getChild(0).getChild(0);
assertThat(groupElement, instanceOf(GroupDef.class));
assertThat(((GroupDef) groupElement).getRepeat(), is(false));
assertThat(groupElement.getBind(), is(expectedXPathReference));
}
Aggregations