本文整理汇总了Java中org.commcare.suite.model.Entry.getSessionDataReqs方法的典型用法代码示例。如果您正苦于以下问题:Java Entry.getSessionDataReqs方法的具体用法?Java Entry.getSessionDataReqs怎么用?Java Entry.getSessionDataReqs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.commcare.suite.model.Entry
的用法示例。
在下文中一共展示了Entry.getSessionDataReqs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: guessUnknownType
import org.commcare.suite.model.Entry; //导入方法依赖的package包/类
/**
* When StackFrameSteps are parsed, those that are "datum" operations will be marked as type
* "unknown". When we encounter a StackFrameStep of unknown type at runtime, we need to
* determine whether it should be interpreted as STATE_DATUM_COMPUTED, STATE_COMMAND_ID,
* or STATE_DATUM_VAL This primarily affects the behavior of stepBack().
*
* The logic being employed is: If there is a previous step on the stack whose entries would
* have added this command, interpret it as a command. If there is an EntityDatum that
* was have added this as an entity selection, interpret this as a datum_val. O
* Otherwise, interpret it as a computed datum.
*/
private String guessUnknownType(StackFrameStep popped) {
String poppedId = popped.getId();
for (StackFrameStep stackFrameStep : frame.getSteps()) {
String commandId = stackFrameStep.getId();
Vector<Entry> entries = getEntriesForCommand(commandId);
for (Entry entry : entries) {
String childCommand = entry.getCommandId();
if (childCommand.equals(poppedId)) {
return SessionFrame.STATE_COMMAND_ID;
}
Vector<SessionDatum> data = entry.getSessionDataReqs();
for (SessionDatum datum : data) {
if (datum instanceof EntityDatum &&
datum.getDataId().equals(poppedId)) {
return SessionFrame.STATE_DATUM_VAL;
}
}
}
}
return SessionFrame.STATE_DATUM_COMPUTED;
}
示例2: print
import org.commcare.suite.model.Entry; //导入方法依赖的package包/类
private void print(Suite s, Entry e, int level) {
String head = "";
String emptyhead = "";
for(int i = 0; i < level; ++i ){
head += "|- ";
emptyhead += " ";
}
if (e.isView()) {
print.println(head + "View: " + e.getText().evaluate());
} else {
print.println(head + "Entry: " + e.getText().evaluate());
}
for(SessionDatum datum : e.getSessionDataReqs()) {
if(datum instanceof FormIdDatum) {
print.println(emptyhead + "Form: " + datum.getValue());
} else if (datum instanceof EntityDatum) {
String shortDetailId = ((EntityDatum)datum).getShortDetail();
if(shortDetailId != null) {
Detail d = s.getDetail(shortDetailId);
try {
print.println(emptyhead + "|Select: " + d.getTitle().getText().evaluate(new EvaluationContext(null)));
} catch(XPathMissingInstanceException ex) {
print.println(emptyhead + "|Select: " + "(dynamic title)");
}
print.print(emptyhead + "| ");
for(DetailField f : d.getFields()) {
print.print(f.getHeader().evaluate() + " | ");
}
print.print("\n");
}
}
}
}
示例3: entryRequirementsSatsified
import org.commcare.suite.model.Entry; //导入方法依赖的package包/类
private static boolean entryRequirementsSatsified(Entry entry,
OrderedHashtable<String, String> currentSessionData) {
Vector<SessionDatum> requirements = entry.getSessionDataReqs();
if (requirements.size() >= currentSessionData.size()) {
for (int i = 0; i < currentSessionData.size(); ++i) {
if (!requirements.elementAt(i).getDataId().equals(currentSessionData.keyAt(i))) {
return false;
}
}
}
return true;
}
示例4: findDatumDefinition
import org.commcare.suite.model.Entry; //导入方法依赖的package包/类
/**
* Retrieves a valid datum definition in the current session's history
* which contains a selector for the datum Id provided.
*
* Can be used to resolve the context about an item that
* has been selected in this session.
*
* @param datumId The ID of a session datum in the session history
* @return An Entry object which contains a selector for that datum
* which is in this session history
*/
public EntityDatum findDatumDefinition(String datumId) {
//We're performing a walk down the entities in this session here,
//we should likely generalize this to make it easier to do it for other
//operations
Vector<StackFrameStep> steps = frame.getSteps();
int stepId = -1;
//walk to our datum
for (int i = 0; i < steps.size(); ++i) {
if (SessionFrame.STATE_DATUM_VAL.equals(steps.elementAt(i).getType()) &&
steps.elementAt(i).getId().equals(datumId)) {
stepId = i;
break;
}
}
if (stepId == -1) {
System.out.println("I don't think this should be possible...");
return null;
}
//ok, so now we have our step, we want to walk backwards until we find the entity
//associated with our ID
for (int i = stepId; i >= 0; i--) {
if (steps.elementAt(i).getType().equals(SessionFrame.STATE_COMMAND_ID)) {
Vector<Entry> entries = this.getEntriesForCommand(steps.elementAt(i).getId());
//TODO: Don't we know the right entry? What if our last command is an actual entry?
for (Entry entry : entries) {
for (SessionDatum datum : entry.getSessionDataReqs()) {
if (datum.getDataId().equals(datumId) && datum instanceof EntityDatum) {
return (EntityDatum)datum;
}
}
}
}
}
return null;
}
示例5: findDatumDefinition
import org.commcare.suite.model.Entry; //导入方法依赖的package包/类
/**
* Retrieves a valid datum definition in the current session's history
* which contains a selector for the datum Id provided.
*
* Can be used to resolve the context about an item that
* has been selected in this session.
*
* @param datumId The ID of a session datum in the session history
* @return An Entry object which contains a selector for that datum
* which is in this session history
*/
public EntityDatum findDatumDefinition(String datumId) {
//We're performing a walk down the entities in this session here,
//we should likely generalize this to make it easier to do it for other
//operations
Vector<StackFrameStep> steps = frame.getSteps();
int stepId = -1;
//walk to our datum
for (int i = 0; i < steps.size(); ++i) {
StackFrameStep step = steps.elementAt(i);
if (step.getId().equals(datumId) && stepIsOfType(step, SessionFrame.STATE_DATUM_VAL)) {
stepId = i;
break;
}
}
if (stepId == -1) {
System.out.println("I don't think this should be possible...");
return null;
}
//ok, so now we have our step, we want to walk backwards until we find the entity
//associated with our ID
for (int i = stepId; i >= 0; i--) {
if (steps.elementAt(i).getType().equals(SessionFrame.STATE_COMMAND_ID)) {
Vector<Entry> entries = this.getEntriesForCommand(steps.elementAt(i).getId());
//TODO: Don't we know the right entry? What if our last command is an actual entry?
for (Entry entry : entries) {
for (SessionDatum datum : entry.getSessionDataReqs()) {
if (datum.getDataId().equals(datumId) && datum instanceof EntityDatum) {
return (EntityDatum)datum;
}
}
}
}
}
return null;
}
示例6: print
import org.commcare.suite.model.Entry; //导入方法依赖的package包/类
private void print(Suite s, Entry e, int level) {
String head = "";
String emptyhead = "";
for (int i = 0; i < level; ++i) {
head += "|- ";
emptyhead += " ";
}
if (e.isView()) {
print.println(head + "View: " + e.getText().evaluate());
} else {
print.println(head + "Entry: " + e.getText().evaluate());
}
for (SessionDatum datum : e.getSessionDataReqs()) {
if (datum instanceof FormIdDatum) {
print.println(emptyhead + "Form: " + datum.getValue());
} else if (datum instanceof EntityDatum) {
String shortDetailId = ((EntityDatum)datum).getShortDetail();
if (shortDetailId != null) {
Detail d = s.getDetail(shortDetailId);
try {
print.println(emptyhead + "|Select: " + d.getTitle().getText().evaluate(new EvaluationContext(null)));
} catch (XPathMissingInstanceException ex) {
print.println(emptyhead + "|Select: " + "(dynamic title)");
}
print.print(emptyhead + "| ");
for (DetailField f : d.getFields()) {
print.print(f.getHeader().evaluate() + " | ");
}
print.print("\n");
}
}
}
}