Search in sources :

Example 31 with ObjectNode

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;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) ArrayNode(org.codehaus.jackson.node.ArrayNode) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 32 with 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));
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) Test(org.junit.Test)

Example 33 with ObjectNode

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"));
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) Test(org.junit.Test)

Example 34 with ObjectNode

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);
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 35 with ObjectNode

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;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) DatasetProxy(org.eol.globi.service.DatasetProxy)

Aggregations

ObjectNode (org.codehaus.jackson.node.ObjectNode)97 ArrayNode (org.codehaus.jackson.node.ArrayNode)29 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)28 JsonNode (org.codehaus.jackson.JsonNode)22 GET (javax.ws.rs.GET)21 Path (javax.ws.rs.Path)18 Test (org.junit.Test)17 Produces (javax.ws.rs.Produces)12 Map (java.util.Map)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)9 IOException (java.io.IOException)7 StringWriter (java.io.StringWriter)5 JsonFactory (org.codehaus.jackson.JsonFactory)5 HelixDataAccessor (org.apache.helix.HelixDataAccessor)4 Span (org.apache.stanbol.enhancer.nlp.model.Span)4 DatasetImpl (org.eol.globi.service.DatasetImpl)4 Date (java.util.Date)3 TaskDriver (org.apache.helix.task.TaskDriver)3 WorkflowConfig (org.apache.helix.task.WorkflowConfig)3