Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register stub setgeopoint implementation that does nothing #79

Merged
merged 2 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sourceCompatibility = '1.8'

dependencies {
compile group: 'net.sf.kxml', name: 'kxml2', version: '2.3.0'
compile group: 'org.opendatakit', name: 'opendatakit-javarosa', version: '2.15.0'
compile group: 'org.opendatakit', name: 'opendatakit-javarosa', version: '2.15.1'
compile group: 'org.slf4j', name: 'slf4j-nop', version: '1.7.25'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-all:1.3'
Expand Down
4 changes: 4 additions & 0 deletions src/org/opendatakit/validate/FormValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.javarosa.form.api.FormEntryPrompt;
import org.javarosa.model.xform.XFormsModule;
import org.javarosa.xform.parse.XFormParseException;
import org.javarosa.xform.parse.XFormParser;
import org.javarosa.xform.util.XFormUtils;

import org.opendatakit.validate.buildconfig.BuildConfig;
Expand Down Expand Up @@ -453,6 +454,9 @@ public void validate(byte[] xformData) {
final ReferenceManager referenceManager = ReferenceManager.instance();
referenceManager.addReferenceFactory(new StubReferenceFactory());

PrototypeManager.registerPrototype("org.opendatakit.validate.StubSetGeopointAction");
XFormParser.registerActionHandler(StubSetGeopointActionHandler.ELEMENT_NAME, new StubSetGeopointActionHandler());

// validate if the xform can be parsed.
try {
FormDef fd = XFormUtils.getFormFromInputStream(new ByteArrayInputStream(xformData));
Expand Down
22 changes: 22 additions & 0 deletions src/org/opendatakit/validate/StubSetGeopointAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.opendatakit.validate;

import org.javarosa.core.model.actions.setgeopoint.SetGeopointAction;
import org.javarosa.core.model.instance.TreeReference;

/**
* An odk:setgeopoint implementation that does nothing when triggered.
*/
public final class StubSetGeopointAction extends SetGeopointAction {
public StubSetGeopointAction() {
// empty body for serialization
}

StubSetGeopointAction(TreeReference targetReference) {
super(targetReference);
}

@Override
public void requestLocationUpdates() {

}
}
19 changes: 19 additions & 0 deletions src/org/opendatakit/validate/StubSetGeopointActionHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.opendatakit.validate;

import org.javarosa.core.model.actions.setgeopoint.SetGeopointAction;
import org.javarosa.core.model.actions.setgeopoint.SetGeopointActionHandler;

/**
* Set an implementation that does nothing.
*/
public final class StubSetGeopointActionHandler extends SetGeopointActionHandler {
@Override
public SetGeopointAction getSetGeopointAction() {
// We'd like to use the default constructor but then the name field defined in Action wouldn't be set.
// This is because the default constructor has to have an empty body for serialization. Instead, we've
// defined a constructor in StubSetGeopointAction that takes in a TreeReference (and sets the name field).
// We can pass in null since we don't know the target node at this point and SetGeopointActionHandler's
// handle() method will set the target.
return new StubSetGeopointAction(null);
}
}