本文整理匯總了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()));
}