Search in sources :

Example 11 with Jdk8Module

use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project syndesis-qe by syndesisio.

the class AbstractStep method withCustomDatashape.

/**
 * Sets the custom datashape to the action object.
 * @param action action
 * @param connectorDescriptor action's connector descriptor to fill other values
 * @param direction "in" for InputDataShape, "out" for OutputDataShape
 * @param kind {@link DataShapeKinds} value
 * @param datashape Datashape specification
 * @return action object with datashapes
 */
Action withCustomDatashape(Action action, ConnectorDescriptor connectorDescriptor, String direction, DataShapeKinds kind, String datashape) {
    // This will set datashapes and property definitions from the connectorDescriptor
    Action a = generateStepAction(action, connectorDescriptor);
    ObjectMapper mapper = new ObjectMapper().registerModules(new Jdk8Module());
    try {
        JSONObject json = new JSONObject(mapper.writeValueAsString(a));
        DataShape ds = new DataShape.Builder().name(kind.toString()).description(kind.toString()).kind(kind).specification(datashape).build();
        json.getJSONObject("descriptor").put("in".equals(direction) ? "inputDataShape" : "outputDataShape", new JSONObject(mapper.writeValueAsString(ds)));
        a = JsonUtils.reader().forType(Action.class).readValue(json.toString());
    } catch (IOException ex) {
        log.error("Error: " + ex);
    }
    return a;
}
Also used : ConnectorAction(io.syndesis.common.model.action.ConnectorAction) Action(io.syndesis.common.model.action.Action) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) JSONObject(org.json.JSONObject) IOException(java.io.IOException) DataShape(io.syndesis.common.model.DataShape) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 12 with Jdk8Module

use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project dcos-commons by mesosphere.

the class TaskStatusesTracker method getJson.

// CHECKSTYLE:ON NestedForDepth
public Response getJson(@QueryParam("plan") String filterPlan, @QueryParam("phase") String filterPhase, @QueryParam("step") String filterStep, @QueryParam("sync") boolean requireSync) {
    ObjectMapper jsonMapper = new ObjectMapper();
    jsonMapper.registerModule(new Jdk8Module());
    jsonMapper.registerModule(new JsonOrgModule());
    List<PlanResponse> serviceResponse = getTaskStatuses(filterPlan, filterPhase, filterStep);
    JSONArray response = jsonMapper.convertValue(serviceResponse, JSONArray.class);
    return ResponseUtils.jsonOkResponse(response);
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) JsonOrgModule(com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule) JSONArray(org.json.JSONArray) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 13 with Jdk8Module

use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project dcos-commons by mesosphere.

the class OfferOutcomeTrackerV2 method getJson.

public Response getJson(@QueryParam("plan") String plan, @QueryParam("phase") String phase, @QueryParam("step") String step, @QueryParam("sync") boolean sync) {
    ObjectMapper jsonMapper = new ObjectMapper();
    jsonMapper.registerModule(new Jdk8Module());
    jsonMapper.registerModule(new JsonOrgModule());
    JSONObject response = jsonMapper.convertValue(this.getSummary(), JSONObject.class);
    response.put("offers", this.getSummary().toJson());
    return ResponseUtils.jsonOkResponse(response);
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) JsonOrgModule(com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule) JSONObject(org.json.JSONObject) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 14 with Jdk8Module

use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project dcos-commons by mesosphere.

the class TaskReservationsTracker method getJson.

public Response getJson(@QueryParam("plan") String filterPlan, @QueryParam("phase") String filterPhase, @QueryParam("step") String filterStep, @QueryParam("sync") boolean requireSync) {
    Map<String, Set<String>> resourceIdsByAgentHost = SchedulerUtils.getResourceIdsByAgentHost(stateStore);
    ObjectMapper jsonMapper = new ObjectMapper();
    jsonMapper.registerModule(new Jdk8Module());
    jsonMapper.registerModule(new JsonOrgModule());
    JSONObject response = jsonMapper.convertValue(resourceIdsByAgentHost, JSONObject.class);
    return ResponseUtils.jsonOkResponse(response);
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) Set(java.util.Set) JsonOrgModule(com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule) JSONObject(org.json.JSONObject) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 15 with Jdk8Module

use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project atlasdb by palantir.

the class TimeLockServerLauncher method initialize.

@Override
public void initialize(Bootstrap<TimeLockServerConfiguration> bootstrap) {
    MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate("AtlasDbTest" + UUID.randomUUID().toString());
    TaggedMetricRegistry taggedMetricRegistry = new DefaultTaggedMetricRegistry();
    AtlasDbMetrics.setMetricRegistries(metricRegistry, taggedMetricRegistry);
    bootstrap.setMetricRegistry(metricRegistry);
    bootstrap.getObjectMapper().registerSubtypes(NonBlockingFileAppenderFactory.class);
    bootstrap.getObjectMapper().registerModule(new Jdk8Module());
    super.initialize(bootstrap);
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) MetricRegistry(com.codahale.metrics.MetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)

Aggregations

Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)199 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)160 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)84 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)37 IOException (java.io.IOException)34 ParameterNamesModule (com.fasterxml.jackson.module.paramnames.ParameterNamesModule)29 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)24 Bean (org.springframework.context.annotation.Bean)20 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)16 Test (org.junit.jupiter.api.Test)16 ArrayList (java.util.ArrayList)12 BeforeClass (org.junit.BeforeClass)11 List (java.util.List)10 Test (org.junit.Test)10 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)9 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)8 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)8 JSONObject (org.json.JSONObject)8 QuarkusTestResource (io.quarkus.test.common.QuarkusTestResource)7 QuarkusTest (io.quarkus.test.junit.QuarkusTest)7