当前位置: 首页>>代码示例>>Java>>正文


Java ComputedDatum类代码示例

本文整理汇总了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)));
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:CommCareSession.java

示例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)));
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:17,代码来源:CommCareSession.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:36,代码来源:CommCareSession.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:36,代码来源:CommCareSession.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:54,代码来源:AndroidSessionWrapper.java

示例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()));
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:7,代码来源:FormDataUtil.java


注:本文中的org.commcare.suite.model.ComputedDatum类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。