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


Java FormEntryModel类代码示例

本文整理汇总了Java中org.javarosa.form.api.FormEntryModel的典型用法代码示例。如果您正苦于以下问题:Java FormEntryModel类的具体用法?Java FormEntryModel怎么用?Java FormEntryModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FormEntryModel类属于org.javarosa.form.api包,在下文中一共展示了FormEntryModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: FormInstanceValidator

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
public FormInstanceValidator(InputStream formInput, InputStream instanceInput) throws Exception {
		theForm = XFormUtils.getFormFromInputStream(formInput);
		
		savedModel = XFormParser.restoreDataModel(instanceInput, null);
        TreeElement templateRoot = theForm.getInstance().getRoot().deepCopy(true);

        //sanity check instance names before loading
        if (!savedModel.getRoot().getName().equals(templateRoot.getName()) || savedModel.getRoot().getMult() != 0) {
			System.out.println("Instance model name does not match xform instance name.");
			System.out.println("Instance: " + savedModel.getName() + " Xform: " + templateRoot.getName());
			System.exit(1);
        }
        
        model = new FormEntryModel(theForm);
        controller = new FormEntryController(model);

        
        //Populate XForm Model 
//        TreeReference tr = TreeReference.rootRef();
//        tr.add(templateRoot.getName(), TreeReference.INDEX_UNBOUND);
//        templateRoot.populate(savedRoot, f);
//
//        f.getInstance().setRoot(templateRoot);
	}
 
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:FormInstanceValidator.java

示例2: init

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
public void init(){
	String xf_name = FORM_NAME; 			
	FileInputStream is;
	try {
		is = new FileInputStream(xf_name);
	} catch (FileNotFoundException e) {
		System.err.println("Error: the file '" + xf_name
				+ "' could not be found!");
		throw new RuntimeException("Error: the file '" + xf_name
				+ "' could not be found!");
	}
	
	// Parse the form
	xform = XFormUtils.getFormFromInputStream(is);
	
	femodel = new FormEntryModel(xform);
	fec = new FormEntryController(femodel);
	
	if( xform == null ) {
		System.out.println("\n\n==================================\nERROR: XForm has failed validation!!");
	} else {
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:24,代码来源:FormParseInit.java

示例3: countUnansweredQuestions

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
/**
 * @param countRequiredOnly
 *            if true count only the questions that are unanswered and also
 *            required
 * @return number of unanswered questions
 */
public static int countUnansweredQuestions(FormEntryModel model, boolean countRequiredOnly) {
    //ctsims - Made this list only count relevant questions
    int counter = 0;

    for(FormIndex index = model.incrementIndex(FormIndex.createBeginningOfFormIndex());!index.isEndOfFormIndex();index = model.incrementIndex(index)) {
        if(!model.isIndexRelevant(index)) {
            continue;
        }

        if(model.getEvent(index) == FormEntryController.EVENT_QUESTION) {
            FormEntryPrompt prompt = model.getQuestionPrompt(index);
            if(prompt.getAnswerValue() == null) {
                if(!countRequiredOnly || prompt.isRequired()) {
                    counter++;
                }
            }
        }
    }

    return counter;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:28,代码来源:FormSummaryController.java

示例4: countQuestionsToIndex

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
/**
 * @param model Form entry model to test index against
 * @return number of unanswered questions
 */

public static int countQuestionsToIndex(FormEntryModel model, FormIndex last) {
    //ctsims - Made this list only count relevant questions
    int counter = 0;

    for(FormIndex index = model.incrementIndex(FormIndex.createBeginningOfFormIndex());!index.equals(last);index = model.incrementIndex(index)) {
        if(!model.isIndexRelevant(index)) {
            continue;
        }

        if(model.getEvent(index) == FormEntryController.EVENT_QUESTION) {
            counter++;
        }
    }

    return counter;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:22,代码来源:FormSummaryController.java

示例5: getWidget

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
/**
 * NOTE: Only applicable for Questions right now, not any other kind of IFormElement
 * @param questionIndex
 * @param form
 * @param initViewState
 * @return
 */
public ChatterboxWidget getWidget (FormIndex questionIndex, FormEntryModel model, int initViewState) {
    IWidgetStyle collapsedStyle = null;
    IWidgetStyleEditable expandedStyle = null;

    FormEntryPrompt prompt = model.getQuestionPrompt(questionIndex);

    int controlType = prompt.getControlType();
    int dataType = prompt.getDataType();

    String appearanceAttr = prompt.getAppearanceHint();

    collapsedStyle = new CollapsedWidget();
    ((CollapsedWidget)collapsedStyle).setSeekable(this.readOnly);

    expandedStyle = widgetFactory.getWidget(controlType,dataType,appearanceAttr);

    if (collapsedStyle == null || expandedStyle == null) {
        throw new IllegalStateException("No appropriate widget to render question");
    }

    expandedStyle.registerMultimediaController(mediaController);
    ChatterboxWidget widget = new ChatterboxWidget(cbox, prompt, initViewState, collapsedStyle, expandedStyle);
    prompt.register(widget);
    return widget;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:33,代码来源:ChatterboxWidgetFactory.java

示例6: getRepeatJunctureWidget

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
public ChatterboxWidget getRepeatJunctureWidget (FormIndex index, FormEntryModel model, Chatterbox cbox) {
    FormEntryCaption capt = model.getCaptionPrompt(index);
    Vector<String> choices = capt.getRepetitionsText();
    FormEntryCaption.RepeatOptions repopt = capt.getRepeatOptions();

    FakedFormEntryPrompt prompt = new FakedFormEntryPrompt(repopt.header, Constants.CONTROL_SELECT_ONE, Constants.DATATYPE_TEXT);
    for (int i = 0; i < choices.size(); i++) {
        prompt.addSelectChoice(new SelectChoice(null, choices.elementAt(i), "rep" + i, false));
    }

    if (repopt.add != null) {
        prompt.addSelectChoice(new SelectChoice(null, repopt.add, "new", false));
    }
    if (repopt.delete != null) {
        prompt.addSelectChoice(new SelectChoice(null, repopt.delete, "del", false));
    }
    prompt.addSelectChoice(new SelectChoice(null, repopt.done, "done", false));

    return new ChatterboxWidget(cbox, prompt, ChatterboxWidget.VIEW_EXPANDED, new CollapsedWidget(), new SelectOneEntryWidget(ChoiceGroup.EXCLUSIVE));
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:21,代码来源:ChatterboxWidgetFactory.java

示例7: setup

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
public FormEntryController setup(InstanceInitializationFactory factory) {
    form.setEvaluationContext(getEC());

    form.initialize(true, factory, preferredLocale);

    if(recording) {
        session = new Session();
        currentStep = new Step();
    } else {
        currentStep = session.getSteps().elementAt(0);
    }

    FormEntryModel fem = new FormEntryModel(form);
    FormEntryController fec = FormEntryController.buildRecordingController(fem);

    return fec;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:18,代码来源:XFormEnvironment.java

示例8: FormInstanceValidator

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
public FormInstanceValidator(InputStream formInput, InputStream instanceInput) throws Exception {
        theForm = XFormUtils.getFormFromInputStream(formInput);

        savedModel = XFormParser.restoreDataModel(instanceInput, null);
        TreeElement templateRoot = theForm.getInstance().getRoot().deepCopy(true);

        //sanity check instance names before loading
        if (!savedModel.getRoot().getName().equals(templateRoot.getName()) || savedModel.getRoot().getMult() != 0) {
            System.out.println("Instance model name does not match xform instance name.");
            System.out.println("Instance: " + savedModel.getName() + " Xform: " + templateRoot.getName());
            System.exit(1);
        }

        model = new FormEntryModel(theForm);
        controller = new FormEntryController(model);


        //Populate XForm Model
//        TreeReference tr = TreeReference.rootRef();
//        tr.add(templateRoot.getName(), TreeReference.INDEX_UNBOUND);
//        templateRoot.populate(savedRoot, f);
//
//        f.getInstance().setRoot(templateRoot);
    }
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:25,代码来源:FormInstanceValidator.java

示例9: isXFormValid

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
protected StringBuilder isXFormValid(File xformFile) throws ParserConfigurationException, SAXException, IOException
{
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	dBuilder.parse(xformFile);

	byte[] xformRawData = Files.readAllBytes(xformFile.toPath());
       ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xformRawData);
       FormDef formDef = XFormUtils.getFormFromInputStream(byteArrayInputStream);
       FormEntryModel formEntryModel = new FormEntryModel(formDef);
       StringBuilder fieldErrors = new StringBuilder();
       inspectFields(formEntryModel, formDef, fieldErrors);
	return fieldErrors;
}
 
开发者ID:benetech,项目名称:Secure-App-Generator,代码行数:15,代码来源:ObtainXFormController.java

示例10: validateUserAnswersOneAtATime

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
public int validateUserAnswersOneAtATime() throws Exception {
    FormDef formDef = XFormUtils.getFormFromInputStream(new ByteArrayInputStream(getFormModel().getBytes("UTF-8")));
    FormEntryModel formEntryModel = new FormEntryModel(formDef);
    FormEntryController formEntryController = new FormEntryController(formEntryModel);
    TreeElement modelRootElement = formEntryController.getModel().getForm().getInstance().getRoot().deepCopy(true);
    TreeElement instanceRootElement = XFormParser.restoreDataModel(getFormInstance().getBytes("UTF-8"), null).getRoot();

    populateDataModel(modelRootElement);
    modelRootElement.populate(instanceRootElement, formEntryController.getModel().getForm());
    populateFormEntryControllerModel(formEntryController, modelRootElement);
    fixLanguageIusses(formEntryController);

    return createFieldSpecsFromXForms(formEntryController);
}
 
开发者ID:benetech,项目名称:Secure-App-Generator,代码行数:15,代码来源:OdkFormInstanceValidator.java

示例11: listQuestions

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
private static void listQuestions (FormDef f, int indent, StringBuilder sb) {
		//using fec to walk through form (instead of old recursive algorithm)
		FormEntryModel femodel = new FormEntryModel(f);
		FormEntryController fec = new FormEntryController(femodel);
		fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
		IFormElement fe;
		do{
			fe = femodel.getCaptionPrompt().getFormElement();
			if(fe instanceof QuestionDef){
				listQuestion(f,(QuestionDef)fe,fec,indent,sb);
			}else if(fe instanceof GroupDef){
				if (listGroup(f, (GroupDef)fe, indent, sb)) {
					indent += 1;
				}
			}

		}while(fec.stepToNextEvent()!=fec.EVENT_END_OF_FORM);

		//Old Recursive Algorithm
//		if (fe instanceof QuestionDef) {
//			listQuestion(f, (QuestionDef)fe, indent, sb);
//		} else {
//			if (fe instanceof GroupDef) {
//				if (listGroup(f, (GroupDef)fe, indent, sb)) {
//					indent += 1;
//				}
//			}
//
//			for (int i = 0; i < fe.getChildren().size(); i++) {
//				listQuestions(f, fe.getChild(i), indent, sb);
//			}
//		}

	}
 
开发者ID:medic,项目名称:javarosa,代码行数:35,代码来源:FormOverview.java

示例12: listQuestion

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
private static void listQuestion (FormDef f, QuestionDef q,FormEntryController fec, int indent, StringBuilder sb) {
	FormEntryModel femodel = fec.getModel();
	TreeElement instanceNode = getInstanceNode(f.getInstance(), q.getBind());
	String caption = "";
	FormEntryPrompt fep = femodel.getQuestionPrompt();
	caption = fep.getLongText();

	int type = instanceNode.getDataType();

	if (q.getControlType() != Constants.CONTROL_TRIGGER) {
		println(sb, indent, "Question: \"" + caption + "\"");
		println(sb, indent + 1, "Type: " + printType(type));
	} else {
		println(sb, indent, "Info: \"" + caption + "\"");
	}

	if (q.getControlType() == Constants.CONTROL_SELECT_ONE || q.getControlType() == Constants.CONTROL_SELECT_MULTI) {
		printChoices(f,q,fec, indent + 1, sb);
	}

	printProperty("relevant", f, instanceNode, indent + 1, sb);

	printProperty("required", f, instanceNode, indent + 1, sb);

	printProperty("readonly", f, instanceNode, indent + 1, sb);

	String defaultValue = printDefault(instanceNode);
	if (defaultValue != null) {
		println(sb, indent + 1, "Default: " + defaultValue);
	}

	if (instanceNode.getConstraint() != null) {
		println(sb, indent + 1, "Constraint: " + printCondition(instanceNode.getConstraint().constraint));
	}

	println(sb);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:38,代码来源:FormOverview.java

示例13: printChoices

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
private static void printChoices (FormDef f,QuestionDef q,FormEntryController fec,int indent, StringBuilder sb) {
		FormEntryModel femodel = fec.getModel();

		println(sb, indent, "Choices: " + q.getNumChoices());
//		for (int i = 0; i < q.getNumChoices(); i++) {
		for (SelectChoice choice : q.getChoices()){
			println(sb, indent + 1, "\"" + femodel.getQuestionPrompt().getSelectChoiceText(choice) + "\"");
		}
	}
 
开发者ID:medic,项目名称:javarosa,代码行数:10,代码来源:FormOverview.java

示例14: listGroup

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
private static boolean listGroup (FormDef f, GroupDef g, int indent, StringBuilder sb) {
	FormEntryModel femodel = new FormEntryModel(f);
	boolean repeat = g.getRepeat();
	String caption = ExtUtil.nullIfEmpty(femodel.getCaptionPrompt().getLongText());
	TreeElement instanceNode = getInstanceNode(f.getInstance(), g.getBind());

	String relevant = printConditionalProperty("relevant", f, instanceNode);
	String readonly = printConditionalProperty("readonly", f, instanceNode);

	if (repeat || caption != null || (relevant != null || readonly != null)) {
		println(sb, indent, (repeat ? "Repeat" : "Group") + ":" + (caption != null ? " \"" + caption + "\"" : ""));

		if (relevant != null) {
			println(sb, indent + 1, relevant);
		}

		if (readonly != null) {
			println(sb, indent + 1, readonly);
		}

		println(sb);

		return true;
	} else {
		return false;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:28,代码来源:FormOverview.java

示例15: FormSummaryView

import org.javarosa.form.api.FormEntryModel; //导入依赖的package包/类
public FormSummaryView(FormEntryModel model) {
    //#style View_All_Form
    super("Form Overview", List.IMPLICIT);
    this.model = model;
    createView();

    addCommand(CMD_EXIT);

    // TODO: handle readonly
    if (true) {
        addCommand(CMD_SAVE_EXIT);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:14,代码来源:FormSummaryView.java


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