本文整理汇总了Java中org.javarosa.core.model.SubmissionProfile类的典型用法代码示例。如果您正苦于以下问题:Java SubmissionProfile类的具体用法?Java SubmissionProfile怎么用?Java SubmissionProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubmissionProfile类属于org.javarosa.core.model包,在下文中一共展示了SubmissionProfile类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendDataFormInstance
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
public void sendDataFormInstance(final FormInstance data) {
JRDemoFormTransportState send;
try {
//Link to the FormDef so we can find the appropriate submission profile
FormDefFetcher fd = new FormDefFetcher(new ModelRmsRetrievalMethod(data), JRDemoContext._().getPreloaders(), JRDemoContext._().getFuncHandlers(), new InstanceInitializationFactory());
SubmissionProfile profile = fd.getFormDef().getSubmissionProfile();
send = new JRDemoFormTransportState(data, profile, data.getID()) {
public void done() {
new JRDemoSavedFormListState().start();
}
public void sendToBackground() {
new JRDemoSavedFormListState().start();
}
};
} catch (IOException e) {
throw new RuntimeException("Unable to serialize XML Payload!");
}
send.start();
}
示例2: buildMessage
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
public TransportMessage buildMessage(FormInstance data, SubmissionProfile profile) {
//Right now we have to just give the message the stream, rather than the payload,
//since the transport layer won't take payloads. This should be fixed _as soon
//as possible_ so that we don't either (A) blow up the memory or (B) lose the ability
//to send payloads > than the phones' heap.
if(profile == null) {
profile = SubmissionTransportHelper.defaultPostSubmission(PropertyManager._().getSingularProperty(DemoAppProperties.POST_URL_PROPERTY));
}
try {
return SubmissionTransportHelper.createMessage(data, profile, false);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("Error Serializing Data to be transported");
}
}
示例3: processAction
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
@Override
public TreeReference processAction(FormDef model, TreeReference contextRef) {
SubmissionProfile profile = model.getSubmissionProfile(this.submissionId);
String url = profile.getResource();
TreeReference ref = profile.getRef();
Map<String, String> map = null;
if(ref != null) {
map = getKeyValueMapping(model, ref);
}
String result = null;
try {
result = model.dispatchSendCallout(url, map);
} catch (Exception e ) {
Logger.exception("send-action", e);
}
if(result == null) {
return null;
} else {
TreeReference target = profile.getTargetRef();
model.setValue(new UncastData(result), target);
return target;
}
}
示例4: getSubmissionDataReference
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
/**
* Find the portion of the form that is to be submitted
*
* @return
*/
private IDataReference getSubmissionDataReference() {
FormDef formDef = mFormEntryController.getModel().getForm();
// Determine the information about the submission...
SubmissionProfile p = formDef.getSubmissionProfile();
if (p == null || p.getRef() == null) {
return new XPathReference("/");
} else {
return p.getRef();
}
}
示例5: parseSubmission
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
public SubmissionProfile parseSubmission(String method, String action, IDataReference ref, Element element) {
String mediatype = element.getAttributeValue(null,"mediatype");
HashMap<String,String> attributeMap = new HashMap<String,String>();
int nAttr = element.getAttributeCount();
for ( int i = 0 ; i < nAttr ; ++i ) {
String name = element.getAttributeName(i);
if ( name.equals("ref")) continue;
if ( name.equals("bind")) continue;
if ( name.equals("method")) continue;
if ( name.equals("action")) continue;
String value = element.getAttributeValue(i);
attributeMap.put(name, value);
}
return new SubmissionProfile(ref, method, action, mediatype, attributeMap);
}
示例6: formEntrySaved
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
public void formEntrySaved(FormDef form, FormInstance instanceData, boolean formWasCompleted) {
if(formWasCompleted) {
form.seal();
logCompleted(instanceData);
// This process will take place in three parts, in order to ensure that the server and client don't get
// out of sync.
// 1) First we'll ensure that a transport message or other off-line element can be created and
// saved. This should establish that it will be sent from the device no matter what.
//First, figure out what the submission action is
SubmissionProfile profile = CommCareFormEntryState.getSubmissionProfile(form, instanceData);
// Get the workflow that will be responsible for managing the flow of form sending
FormTransportWorkflow workflow = getWorkflowFactory(profile);
//Let the workflow perform its first action
workflow.preProcessing(instanceData);
// 2) Next we'll post process the data and manage any local information that should be handled on
// the local device
boolean save = postProcess(instanceData);
if (save) {
IStorageUtility instances = StorageManager.getStorage(FormInstance.STORAGE_KEY);
instanceData.setDateSaved(new Date());
instances.write(instanceData);
postSaveProcess(instanceData);
}
// 3) Actually manage what to do after the data is processed locally
workflow.postProcessing();
} else {
abort();
}
}
示例7: parseSubmission
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
public SubmissionProfile parseSubmission(String method, String action, XPathReference ref, Element element) {
String mediatype = element.getAttributeValue(null, "mediatype");
Hashtable<String, String> attributeMap = new Hashtable<String, String>();
int nAttr = element.getAttributeCount();
for (int i = 0; i < nAttr; ++i) {
String name = element.getAttributeName(i);
if (name.equals("ref")) continue;
if (name.equals("bind")) continue;
if (name.equals("method")) continue;
if (name.equals("action")) continue;
String value = element.getAttributeValue(i);
attributeMap.put(name, value);
}
return new SubmissionProfile(ref, method, action, mediatype, attributeMap);
}
示例8: successfulParses
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
@Test
public void successfulParses() {
SubmissionProfile profile = new FormParseInit("/submission_profiles/submission_full.xml").getFormDef().getSubmissionProfile("submitid");
Assert.assertNotNull(profile);
"http://test.test".equals(profile.getResource());
XPathReference.getPathExpr("/data/item").equals(profile.getRef());
XPathReference.getPathExpr("/data/params").equals(profile.getTargetRef());
}
示例9: getSubmissionDataReference
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
/**
* Find the portion of the form that is to be submitted
*
* @return
*/
private IDataReference getSubmissionDataReference() {
FormDef formDef = mFormEntryController.getModel().getForm();
// Determine the information about the submission...
SubmissionProfile p = formDef.getSubmissionProfile();
if (p == null || p.getRef() == null) {
return new XPathReference("/");
} else {
return p.getRef();
}
}
示例10: getSubmissionMetadata
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
/**
* Get the OpenRosa required metadata of the portion of the form beng submitted
* @return
*/
public InstanceMetadata getSubmissionMetadata() {
FormDef formDef = mFormEntryController.getModel().getForm();
TreeElement rootElement = formDef.getInstance().getRoot();
TreeElement trueSubmissionElement;
// Determine the information about the submission...
SubmissionProfile p = formDef.getSubmissionProfile();
if ( p == null || p.getRef() == null ) {
trueSubmissionElement = rootElement;
} else {
IDataReference ref = p.getRef();
trueSubmissionElement = formDef.getInstance().resolveReference(ref);
// resolveReference returns null if the reference is to the root element...
if ( trueSubmissionElement == null ) {
trueSubmissionElement = rootElement;
}
}
// and find the depth-first meta block in this...
TreeElement e = findDepthFirst(trueSubmissionElement, "meta");
String instanceId = null;
if ( e != null ) {
Vector<TreeElement> v;
// instance id...
v = e.getChildrenWithName(INSTANCE_ID);
if ( v.size() == 1 ) {
StringData sa = (StringData) v.get(0).getValue();
instanceId = (String) sa.getValue();
}
}
return new InstanceMetadata(instanceId);
}
示例11: defaultPostSubmission
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
public static SubmissionProfile defaultPostSubmission(String url) {
return new SubmissionProfile(new XPathReference("/"), "post", url, null, new Hashtable<String,String>());
}
示例12: JRDemoFormTransportState
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
public JRDemoFormTransportState(FormInstance tree, SubmissionProfile profile, int formId) throws IOException {
this(JRDemoContext._().buildMessage(tree, profile), formId);
}
示例13: parseSubmission
import org.javarosa.core.model.SubmissionProfile; //导入依赖的package包/类
private void parseSubmission(Element submission) {
String id = submission.getAttributeValue(null, ID_ATTR);
String resource = getRequiredAttribute(submission, "resource");
String targetref = getRequiredAttribute(submission, "targetref");
String ref = submission.getAttributeValue(null, "ref");
//For Validation Only
String method = submission.getAttributeValue(null, "method");
if(!("get".equals(method))) {
throw new XFormParseException("Unsupported submission @method: " + method);
}
String replace = submission.getAttributeValue(null, "replace");
if(!("text".equals(replace))) {
throw new XFormParseException("Unsupported submission @replace: " + replace);
}
String mode = submission.getAttributeValue(null, "mode");
if(!("synchronous".equals(mode))) {
throw new XFormParseException("Unsupported submission @mode: " + mode);
}
TreeReference targetReference = XPathReference.getPathExpr(targetref).getReference();
if(targetReference.getInstanceName() != null) {
throw new XFormParseException("<submission> events can only target the main instance", submission);
}
registerActionTarget(targetReference);
TreeReference refReference = null;
if(ref != null) {
refReference = XPathReference.getPathExpr(ref).getReference();
registerActionTarget(refReference);
}
SubmissionProfile profile = new SubmissionProfile(resource, targetReference, refReference);
//add the profile
_f.addSubmissionProfile(id, profile);
}