本文整理汇总了Java中org.commcare.suite.model.ComputedDatum类的典型用法代码示例。如果您正苦于以下问题:Java ComputedDatum类的具体用法?Java ComputedDatum怎么用?Java ComputedDatum使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComputedDatum类属于org.commcare.suite.model包,在下文中一共展示了ComputedDatum类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setComputedDatum
import org.commcare.suite.model.ComputedDatum; //导入依赖的package包/类
public void setComputedDatum(EvaluationContext ec) throws XPathException {
SessionDatum datum = getNeededDatum();
XPathExpression form;
try {
form = XPathParseTool.parseXPath(datum.getValue());
} catch (XPathSyntaxException e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
if (datum instanceof FormIdDatum) {
setXmlns(XPathFuncExpr.toString(form.eval(ec)));
setDatum("", "awful");
} else if (datum instanceof ComputedDatum) {
setDatum(datum.getDataId(), XPathFuncExpr.toString(form.eval(ec)));
}
}
示例2: setComputedDatum
import org.commcare.suite.model.ComputedDatum; //导入依赖的package包/类
public void setComputedDatum(EvaluationContext ec) throws XPathException {
SessionDatum datum = getNeededDatum();
XPathExpression form;
try {
form = XPathParseTool.parseXPath(datum.getValue());
} catch (XPathSyntaxException e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
if (datum instanceof FormIdDatum) {
setXmlns(FunctionUtils.toString(form.eval(ec)));
setDatum("", "awful");
} else if (datum instanceof ComputedDatum) {
setDatum(datum.getDataId(), FunctionUtils.toString(form.eval(ec)));
}
}
示例3: getDataNeededByAllEntries
import org.commcare.suite.model.ComputedDatum; //导入依赖的package包/类
/**
* Checks that all entries have the same id for their first required data,
* and if so, returns the data's associated session state. Otherwise,
* returns null.
*/
private String getDataNeededByAllEntries(Vector<Entry> entries) {
String datumNeededByAllEntriesSoFar = null;
String neededDatumId = null;
for (Entry e : entries) {
SessionDatum datumNeededForThisEntry =
getFirstMissingDatum(collectedDatums, e.getSessionDataReqs());
if (datumNeededForThisEntry != null) {
if (neededDatumId == null) {
neededDatumId = datumNeededForThisEntry.getDataId();
if (datumNeededForThisEntry instanceof EntityDatum) {
datumNeededByAllEntriesSoFar = SessionFrame.STATE_DATUM_VAL;
} else if (datumNeededForThisEntry instanceof ComputedDatum) {
datumNeededByAllEntriesSoFar = SessionFrame.STATE_DATUM_COMPUTED;
} else if (datumNeededForThisEntry instanceof RemoteQueryDatum) {
datumNeededByAllEntriesSoFar = SessionFrame.STATE_QUERY_REQUEST;
}
} else if (!neededDatumId.equals(datumNeededForThisEntry.getDataId())) {
// data needed from the first entry isn't consistent with
// the current entry
return null;
}
} else {
// we don't need any data, or the first data needed isn't
// consistent across entries
return null;
}
}
return datumNeededByAllEntriesSoFar;
}
示例4: getDataNeededByAllEntries
import org.commcare.suite.model.ComputedDatum; //导入依赖的package包/类
/**
* Checks that all entries have the same id for their first required data,
* and if so, returns the data's associated session state. Otherwise,
* returns null.
*/
private String getDataNeededByAllEntries(Vector<Entry> entries) {
String datumNeededByAllEntriesSoFar = null;
String neededDatumId = null;
for (Entry e : entries) {
SessionDatum datumNeededForThisEntry =
getFirstMissingDatum(collectedDatums, e.getSessionDataReqs());
if (datumNeededForThisEntry != null) {
if (neededDatumId == null) {
neededDatumId = datumNeededForThisEntry.getDataId();
if (datumNeededForThisEntry instanceof EntityDatum) {
datumNeededByAllEntriesSoFar = SessionFrame.STATE_DATUM_VAL;
} else if (datumNeededForThisEntry instanceof ComputedDatum) {
datumNeededByAllEntriesSoFar = SessionFrame.STATE_DATUM_COMPUTED;
} else if (datumNeededForThisEntry instanceof RemoteQueryDatum) {
datumNeededByAllEntriesSoFar = SessionFrame.STATE_QUERY_REQUEST;
}
} else if (!neededDatumId.equals(datumNeededForThisEntry.getDataId())) {
// data needed from the first entry isn't consistent with
// the current entry
return null;
}
} else {
// we don't need any data, or the first data needed isn't
// consistent across entries
return null;
}
}
return datumNeededByAllEntriesSoFar;
}
示例5: mockEasiestRoute
import org.commcare.suite.model.ComputedDatum; //导入依赖的package包/类
public static AndroidSessionWrapper mockEasiestRoute(CommCarePlatform platform, String formNamespace, String selectedValue) {
AndroidSessionWrapper wrapper = null;
int curPredicates = -1;
Hashtable<String, Entry> menuMap = platform.getMenuMap();
for (String key : menuMap.keySet()) {
Entry e = menuMap.get(key);
if (!(e.isView() || e.isRemoteRequest()) && formNamespace.equals(((FormEntry)e).getXFormNamespace())) {
//We have an entry. Don't worry too much about how we're supposed to get there for now.
//The ideal is that we only need one piece of data
if (e.getSessionDataReqs().size() == 1) {
//This should fit the bill. Single selection.
SessionDatum datum = e.getSessionDataReqs().firstElement();
// we only know how to mock a single case selection
if (datum instanceof ComputedDatum) {
// Allow mocking of routes that need computed data, useful for case creation forms
wrapper = new AndroidSessionWrapper(platform);
wrapper.session.setCommand(platform.getModuleNameForEntry((FormEntry) e));
wrapper.session.setCommand(e.getCommandId());
wrapper.session.setComputedDatum(wrapper.getEvaluationContext());
} else if (datum instanceof EntityDatum) {
EntityDatum entityDatum = (EntityDatum)datum;
//The only thing we need to know now is whether we have a better option available
int countPredicates = CommCareUtil.countPreds(entityDatum.getNodeset());
if (wrapper == null) {
//No previous value! Yay.
//Record the degree of specificity of this selection for now (we'll
//actually create the wrapper later
curPredicates = countPredicates;
} else {
//There's already a path to this form. Only keep going
//if the current choice is less specific
if (countPredicates >= curPredicates) {
continue;
}
}
wrapper = new AndroidSessionWrapper(platform);
wrapper.session.setCommand(platform.getModuleNameForEntry((FormEntry) e));
wrapper.session.setCommand(e.getCommandId());
wrapper.session.setDatum(entityDatum.getDataId(), selectedValue);
}
}
//We don't really have a good thing to do with this yet. For now, just
//hope there's another easy path to this form
}
}
return wrapper;
}
示例6: isCaseIdComputedDatum
import org.commcare.suite.model.ComputedDatum; //导入依赖的package包/类
private static boolean isCaseIdComputedDatum(SessionDatum datum,
String currentDatumValue,
StackFrameStep poppedStep) {
return datum instanceof ComputedDatum &&
(currentDatumValue == null || poppedStep.getId().equals(datum.getDataId()));
}