use of org.codehaus.jackson.node.ObjectNode in project openmrs-module-mirebalais by PIH.
the class CustomAppLoaderUtil method objectNode.
public static ObjectNode objectNode(Object... obj) {
ObjectNode objectNode = new ObjectMapper().createObjectNode();
for (int i = 0; i < obj.length; i = i + 2) {
String key = (String) obj[i];
Object value = obj[i + 1];
if (value instanceof Boolean) {
objectNode.put(key, (Boolean) value);
} else if (value instanceof String) {
objectNode.put(key, (String) value);
} else if (value instanceof Integer) {
objectNode.put(key, (Integer) value);
} else if (value instanceof ArrayNode) {
objectNode.put(key, (ArrayNode) value);
} else if (value instanceof ObjectNode) {
objectNode.put(key, (ObjectNode) value);
}
}
return objectNode;
}
use of org.codehaus.jackson.node.ObjectNode in project openmrs-module-mirebalais by PIH.
the class CustomAppLoaderTest method shouldConvertToObjectNode.
@Test
public void shouldConvertToObjectNode() {
ObjectNode objectNode = CustomAppLoaderUtil.objectNode("int", 1, "string", "string", "boolean", true);
assertThat(objectNode.get("int").getIntValue(), is(1));
assertThat(objectNode.get("string").getTextValue(), is("string"));
assertThat(objectNode.get("boolean").getBooleanValue(), is(true));
}
use of org.codehaus.jackson.node.ObjectNode in project openmrs-module-mirebalais by PIH.
the class CustomAppLoaderTest method shouldCreatePatientRegistrationConfig.
@Test
public void shouldCreatePatientRegistrationConfig() {
ObjectNode config = CustomAppLoaderUtil.patientRegistrationConfig("afterCreatedUrl", "", "123abc", "456def", CustomAppLoaderUtil.section("someSectionId", "someSectionLabel", CustomAppLoaderUtil.question("someQuestionId", "someQuestionLegend", CustomAppLoaderUtil.field("someField", "someLabel", "someType", "", "", ""))));
assertThat(config.get("afterCreatedUrl").getTextValue(), is("afterCreatedUrl"));
assertThat(config.get("registrationEncounter").get("encounterType").getTextValue(), is("123abc"));
assertThat(config.get("registrationEncounter").get("encounterRole").getTextValue(), is("456def"));
assertThat(config.get("allowRetrospectiveEntry").getBooleanValue(), is(true));
assertThat(config.get("allowManualIdentifier").getBooleanValue(), is(true));
assertThat(config.get("allowUnknownPatients").getBooleanValue(), is(true));
ObjectNode section = (ObjectNode) config.get("sections").get(0);
assertThat(section.get("id").getTextValue(), is("someSectionId"));
assertThat(section.get("label").getTextValue(), is("someSectionLabel"));
ObjectNode question1 = (ObjectNode) section.get("questions").get(0);
assertThat(question1.get("id").getTextValue(), is("someQuestionId"));
assertThat(question1.get("legend").getTextValue(), is("someQuestionLegend"));
}
use of org.codehaus.jackson.node.ObjectNode in project eol-globi-data by jhpoelen.
the class GitHubUtil method configureStudyWithNamespace.
public static void configureStudyWithNamespace(StudyImpl study, boolean shouldResolveReferences, String namespace) {
study.setSourceId("globi:" + namespace);
DatasetImpl originatingDataset = new DatasetImpl(namespace, URI.create(getBaseUrlMaster(namespace)));
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, shouldResolveReferences);
originatingDataset.setConfig(objectNode);
study.setOriginatingDataset(originatingDataset);
}
use of org.codehaus.jackson.node.ObjectNode in project eol-globi-data by jhpoelen.
the class StudyImporterForArthopodEasyCapture method embeddedDatasetFor.
static Dataset embeddedDatasetFor(Dataset datasetOrig, String embeddedCitation, URI embeddedArchiveURI) {
ObjectNode config = new ObjectMapper().createObjectNode();
config.put("citation", embeddedCitation);
ObjectNode referencesNode = new ObjectMapper().createObjectNode();
referencesNode.put("archive", embeddedArchiveURI.toString());
config.put("resources", referencesNode);
DatasetProxy dataset = new DatasetProxy(datasetOrig);
dataset.setConfig(config);
return dataset;
}
Aggregations