use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveScrollDescendants method writeJSONBlob.
protected Blob writeJSONBlob(ScrollFileSystemItemList scrollFSIList) throws IOException {
StringWriter writer = new StringWriter();
JsonFactory factory = new JsonFactory();
try (JsonGenerator jg = factory.createGenerator(writer)) {
jg.setCodec(new ObjectMapper());
jg.writeStartObject();
jg.writeStringField("scrollId", scrollFSIList.getScrollId());
jg.writeObjectField("fileSystemItems", scrollFSIList);
jg.writeEndObject();
}
return Blobs.createJSONBlob(writer.toString());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project whole by wholeplatform.
the class JSONLDPersistenceKit method doReadModel.
protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
JsonFactory factory = new JsonFactory();
JsonParser parser = factory.createParser(pp.getInputStream());
parser.disable(Feature.AUTO_CLOSE_SOURCE);
try {
return new JSONLDEntityDecoder().clone(new JSONParserTemplateFactory(parser).create());
} finally {
parser.close();
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project syndesis by syndesisio.
the class JsonRecordSupport method jsonStreamToRecords.
public static void jsonStreamToRecords(Set<String> indexes, String dbPath, InputStream is, Consumer<JsonRecord> consumer) throws IOException {
try (JsonParser jp = new JsonFactory().createParser(is)) {
jsonStreamToRecords(indexes, jp, dbPath, consumer);
JsonToken jsonToken = jp.nextToken();
if (jsonToken != null) {
throw new JsonParseException(jp, "Document did not terminate as expected.");
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafRequestContext method createLightWeightCloneFromJson.
/**
* Resurrect the BroadleafRequestContext state based on a JSON representation.
*
* @param Json
* @param em
* @return
*/
public static BroadleafRequestContext createLightWeightCloneFromJson(String Json, EntityManager em) {
BroadleafRequestContext context = new BroadleafRequestContext();
JsonFactory factory = new JsonFactory();
ObjectMapper mapper = new ObjectMapper(factory);
TypeReference<HashMap<String, String>> typeRef = new TypeReference<HashMap<String, String>>() {
};
HashMap<String, String> json;
try {
json = mapper.readValue(Json, typeRef);
} catch (IOException e) {
throw ExceptionHelper.refineException(e);
}
if (!json.get("ignoreSite").equals("null")) {
context.setIgnoreSite(Boolean.valueOf(json.get("ignoreSite")));
}
if (!json.get("sandBox").equals("null")) {
context.setSandBox(em.find(SandBoxImpl.class, Long.parseLong(json.get("sandBox"))));
}
if (!json.get("nonPersistentSite").equals("null")) {
context.setNonPersistentSite(em.find(SiteImpl.class, Long.parseLong(json.get("nonPersistentSite"))));
}
if (!json.get("enforceEnterpriseCollectionBehaviorState").equals("null")) {
context.setEnforceEnterpriseCollectionBehaviorState(EnforceEnterpriseCollectionBehaviorState.valueOf(json.get("enforceEnterpriseCollectionBehaviorState")));
}
if (!json.get("admin").equals("null")) {
context.setAdmin(Boolean.valueOf(json.get("admin")));
}
if (!json.get("adminUserId").equals("null")) {
context.setAdminUserId(Long.parseLong(json.get("adminUserId")));
}
if (!json.get("broadleafCurrency").equals("null")) {
context.setBroadleafCurrency(em.find(BroadleafCurrencyImpl.class, json.get("broadleafCurrency")));
}
if (!json.get("currentCatalog").equals("null")) {
context.setCurrentCatalog(em.find(CatalogImpl.class, Long.parseLong(json.get("currentCatalog"))));
}
if (!json.get("currentProfile").equals("null")) {
context.setCurrentProfile(em.find(SiteImpl.class, Long.parseLong(json.get("currentProfile"))));
}
if (!json.get("deployBehavior").equals("null")) {
context.setDeployBehavior(DeployBehavior.valueOf(json.get("deployBehavior")));
}
if (!json.get("deployState").equals("null")) {
context.setDeployState(DeployState.valueOf(json.get("deployState")));
}
if (!json.get("internalIgnoreFilters").equals("null")) {
context.setInternalIgnoreFilters(Boolean.valueOf(json.get("internalIgnoreFilters")));
}
if (!json.get("locale").equals("null")) {
context.setLocale(em.find(LocaleImpl.class, json.get("locale")));
}
if (!json.get("validateProductionChangesState").equals("null")) {
context.setValidateProductionChangesState(ValidateProductionChangesState.valueOf(json.get("validateProductionChangesState")));
}
if (!json.get("timeZone").equals("null")) {
context.setTimeZone(TimeZone.getTimeZone(json.get("timeZone")));
}
return context;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project calcite by apache.
the class DruidQueryFilterTest method testInFilter.
@Test
public void testInFilter() throws IOException {
final Fixture f = new Fixture();
final List<? extends RexNode> listRexNodes = ImmutableList.of(f.rexBuilder.makeInputRef(f.varcharRowType, 0), f.rexBuilder.makeExactLiteral(BigDecimal.valueOf(1)), f.rexBuilder.makeExactLiteral(BigDecimal.valueOf(5)), f.rexBuilder.makeLiteral("value1"));
RexNode inRexNode = f.rexBuilder.makeCall(SqlStdOperatorTable.IN, listRexNodes);
DruidJsonFilter returnValue = DruidJsonFilter.toDruidFilters(inRexNode, f.varcharRowType, druidQuery);
Assert.assertNotNull("Filter is null", returnValue);
JsonFactory jsonFactory = new JsonFactory();
final StringWriter sw = new StringWriter();
JsonGenerator jsonGenerator = jsonFactory.createGenerator(sw);
returnValue.write(jsonGenerator);
jsonGenerator.close();
Assert.assertThat(sw.toString(), is("{\"type\":\"in\",\"dimension\":\"dimensionName\"," + "\"values\":[\"1\",\"5\",\"value1\"]}"));
}
Aggregations