Java 类org.apache.camel.component.salesforce.api.utils.JsonUtils 实例源码

项目:syndesis-verifier    文件:SalesforceMetadataAdapter.java   
static ObjectSchema convertSalesforceGlobalObjectJsonToSchema(final JsonNode payload) {
    final Set<Object> allSchemas = new HashSet<>();

    for (final JsonNode sobject : payload) {
        // generate SObject schema from description
        final ObjectSchema sobjectSchema = new ObjectSchema();
        sobjectSchema.setId(JsonUtils.DEFAULT_ID_PREFIX + ":" + sobject.get("name").asText());
        sobjectSchema.setTitle(sobject.get("label").asText());

        allSchemas.add(sobjectSchema);
    }

    final ObjectSchema schema = new ObjectSchema();
    schema.setOneOf(allSchemas);

    return schema;
}
项目:syndesis    文件:SalesforceMetadataAdapter.java   
static ObjectSchema convertSalesforceGlobalObjectJsonToSchema(final JsonNode payload) {
    final Set<Object> allSchemas = new HashSet<>();

    for (final JsonNode sobject : payload) {
        // generate SObject schema from description
        final ObjectSchema sobjectSchema = new ObjectSchema();
        sobjectSchema.setId(JsonUtils.DEFAULT_ID_PREFIX + ":" + sobject.get("name").asText());
        sobjectSchema.setTitle(sobject.get("label").asText());

        allSchemas.add(sobjectSchema);
    }

    final ObjectSchema schema = new ObjectSchema();
    schema.setOneOf(allSchemas);

    return schema;
}
项目:connectors    文件:SalesforceUpdateSObjectComponent.java   
public SalesforceUpdateSObjectComponent() {
    super("salesforce-update-sobject", SalesforceUpdateSObjectComponent.class.getName());

    // set sObjectId header
    setBeforeProducer(exchange -> {

        // parse input json and extract Id field
        final ObjectMapper mapper = JsonUtils.createObjectMapper();
        final JsonNode node = mapper.readTree(exchange.getIn().getBody(String.class));

        final JsonNode sObjectId = node.get("Id");
        if (sObjectId == null) {
            exchange.setException(new SalesforceException("Missing field Id", 404));
        } else {
            exchange.getIn().setHeader(SalesforceEndpointConfig.SOBJECT_ID, sObjectId.asText());
        }

        clearBaseFields((ObjectNode) node);

        // update input json
        exchange.getIn().setBody(mapper.writeValueAsString(node));
    });
}
项目:syndesis-verifier    文件:SalesforceMetadataAdapterTest.java   
@Test
public void shouldAdaptObjectMetadataForSchema() {
    final Map<String, Object> properties = new HashMap<>();
    properties.put("sObjectName", "SimpleObject");

    final SyndesisMetadata<ObjectSchema> metadata = adapter.adapt(properties,
        MetaDataBuilder.on(CONTEXT).withAttribute("scope", "object").withPayload(payload).build());

    assertThat(metadata.inputSchema).isSameAs(metadata.outputSchema);
    final Object oneOf = payload.getOneOf().iterator().next();
    assertThat(metadata.inputSchema).isSameAs(oneOf);
    assertThat(metadata.inputSchema.get$schema()).isEqualTo(JsonUtils.SCHEMA4);
}
项目:syndesis-verifier    文件:SalesforceMetadataAdapterTest.java   
ObjectSchema simpleObjectSchema(final String name, final String label) {
    final ObjectSchema objectSchema = new ObjectSchema();
    objectSchema.setId(JsonUtils.DEFAULT_ID_PREFIX + ":" + name);
    objectSchema.setTitle(label);

    return objectSchema;
}
项目:syndesis    文件:SalesforceMetadataAdapterTest.java   
@Test
public void shouldAdaptObjectMetadataForSchema() {
    final Map<String, Object> properties = new HashMap<>();
    properties.put("sObjectName", "SimpleObject");

    final SyndesisMetadata<ObjectSchema> metadata = adapter.adapt(null, properties,
        MetaDataBuilder.on(CONTEXT).withAttribute("scope", "object").withPayload(payload).build());

    assertThat(metadata.inputSchema).isSameAs(metadata.outputSchema);
    final Object oneOf = payload.getOneOf().iterator().next();
    assertThat(metadata.inputSchema).isSameAs(oneOf);
    assertThat(metadata.inputSchema.get$schema()).isEqualTo(JsonUtils.SCHEMA4);
}
项目:syndesis    文件:SalesforceMetadataAdapterTest.java   
ObjectSchema simpleObjectSchema(final String name, final String label) {
    final ObjectSchema objectSchema = new ObjectSchema();
    objectSchema.setId(JsonUtils.DEFAULT_ID_PREFIX + ":" + name);
    objectSchema.setTitle(label);

    return objectSchema;
}
项目:connectors    文件:SalesforceCreateSObjectComponent.java   
public SalesforceCreateSObjectComponent() {
    super("salesforce-create-sobject", SalesforceCreateSObjectComponent.class.getName());

    setAfterProducer( exchange -> {

        // map json response back to CreateSObjectResult POJO
        ObjectMapper mapper = JsonUtils.createObjectMapper();
        if (!exchange.isFailed()) {
            Message out = exchange.getOut();
            CreateSObjectResult result = mapper.readValue(out.getBody(String.class),
                    CreateSObjectResult.class);
            out.setBody(result);
        }
    });
}
项目:syndesis-verifier    文件:SalesforceMetadataAdapter.java   
static ObjectSchema adaptSchema(final ObjectSchema schema) {
    schema.set$schema(JsonUtils.SCHEMA4);

    return schema;
}
项目:syndesis    文件:SalesforceMetadataAdapter.java   
static ObjectSchema adaptSchema(final ObjectSchema schema) {
    schema.set$schema(JsonUtils.SCHEMA4);

    return schema;
}