use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project wikidata-query-rdf by wikimedia.
the class Summarizer method getEventStream.
private static Stream<BasicQueryEvent> getEventStream(String path) {
ObjectReader objectReader = MapperUtils.getObjectMapper().readerFor(BasicQueryEvent.class);
Stream<String> lines = path != null ? streamRotatedEvents(path) : getStdInLines();
return lines.map(src -> {
try {
return objectReader.readValue(src);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project winery by eclipse.
the class MultiRepositoryManagerTest method testInitializeRepositoryList.
/**
* Tests whenever a file is created for the repository list in the root folder.
*/
@Test
public void testInitializeRepositoryList() throws IOException {
ArrayList<RepositoryProperties> repositoryList = new ArrayList<>();
repositoryList.add(new RepositoryProperties("mainTestRepository", "https://github.com/winery/mulit-repo-test", "master"));
MultiRepositoryManager multiRepositoryManager = new MultiRepositoryManager();
multiRepositoryManager.initializeRepositoryListForMultiRepositoryAndReconfigureFactory(repositoryList);
assertTrue(Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot(), Filename.FILENAME_JSON_MUTLI_REPOSITORIES).toFile().exists());
ObjectMapper objectMapper = new ObjectMapper();
ObjectReader reader = objectMapper.readerFor(new TypeReference<List<RepositoryProperties>>() {
});
repositoryList = reader.readValue(Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot(), Filename.FILENAME_JSON_MUTLI_REPOSITORIES).toFile());
assertEquals(1, repositoryList.size());
assertEquals("https://github.com/winery/mulit-repo-test", repositoryList.get(0).getUrl());
assertEquals("master", repositoryList.get(0).getBranch());
assertEquals("mainTestRepository", repositoryList.get(0).getName());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project kylo by Teradata.
the class FeedModelTransform method generateDifference.
/**
* @param fromVer
* @param toVer
*/
public EntityVersionDifference generateDifference(com.thinkbiganalytics.feedmgr.rest.model.EntityVersion fromVer, com.thinkbiganalytics.feedmgr.rest.model.EntityVersion toVer) {
try {
ObjectMapper om = new ObjectMapper();
ObjectWriter ow = om.writer();
ObjectReader or = om.reader();
String fromEntStr = ow.writeValueAsString(fromVer.getEntity());
String toEntStr = ow.writeValueAsString(toVer.getEntity());
JsonNode fromNode = or.readTree(fromEntStr);
JsonNode toNode = or.readTree(toEntStr);
// Produce a patch showing the changes from the "to" node back into the "from" node.
// This is because we will be providing the "to" entity content so the patch should show the original "from" values.
JsonNode diff = JsonDiff.asJson(toNode, fromNode);
com.thinkbiganalytics.feedmgr.rest.model.EntityVersion fromNoContent = new com.thinkbiganalytics.feedmgr.rest.model.EntityVersion(fromVer.getId(), fromVer.getName(), fromVer.getCreatedDate(), fromVer.getCreatedBy(), fromVer.getComment(), fromVer.getEntityId());
return new EntityVersionDifference(fromVer, toVer, diff);
} catch (IOException e) {
throw new ModelTransformException("Failed to generate entity difference between entity versions " + fromVer.getId() + " and " + toVer.getId());
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project repseqio by repseqio.
the class VDJCGeneTest method jsonTestCurrentLibrary1.
@Test
public void jsonTestCurrentLibrary1() throws Exception {
VDJCLibrary library = VDJCLibraryRegistry.getDefaultLibrary("hs");
VDJCGene gene = library.getSafe("TRBV12-3*00");
ObjectWriter writer = GlobalObjectMappers.PRETTY.writerFor(VDJCGene.class).withAttribute(VDJCGene.JSON_CURRENT_LIBRARY_ATTRIBUTE_KEY, library);
ObjectReader reader = GlobalObjectMappers.PRETTY.readerFor(VDJCGene.class).withAttribute(VDJCGene.JSON_CURRENT_LIBRARY_ATTRIBUTE_KEY, library);
String str = writer.writeValueAsString(gene);
assertEquals("\"TRBV12-3*00\"", str);
Object geneDeserialized = reader.readValue(str);
assertTrue(geneDeserialized == gene);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project ma-core-public by infiniteautomation.
the class DataPointEventsByDataPointRQLQueryDefinition method createQuery.
/* (non-Javadoc)
* @see com.serotonin.m2m2.module.ModuleQueryDefinition#createQuery(com.fasterxml.jackson.databind.JsonNode)
*/
@Override
public ASTNode createQuery(User user, JsonNode parameters) throws IOException {
JsonNode rqlNode = parameters.get("rql");
ObjectReader reader = Common.objectMapper.getObjectReader(String.class);
String rql = reader.readValue(rqlNode);
ASTNode rqlAstNode;
if (rql == null || rql.isEmpty()) {
rqlAstNode = new ASTNode("limit", AbstractBasicDao.DEFAULT_LIMIT);
}
RQLParser parser = new RQLParser();
try {
rqlAstNode = parser.parse(rql);
} catch (RQLParserException | IllegalArgumentException e) {
throw new IOException(e.getMessage());
}
// Lookup data points by tag
List<Object> args = new ArrayList<>();
args.add("typeRef1");
DataPointDao.instance.rqlQuery(rqlAstNode, new MappedRowCallback<DataPointVO>() {
@Override
public void row(DataPointVO dp, int index) {
if (Permissions.hasDataPointReadPermission(user, dp)) {
args.add(Integer.toString(dp.getId()));
}
}
});
// Create Event Query for these Points
if (args.size() > 0) {
ASTNode query = new ASTNode("in", args);
query = addAndRestriction(query, new ASTNode("eq", "userId", user.getId()));
query = addAndRestriction(query, new ASTNode("eq", "typeName", "DATA_POINT"));
return query;
} else {
return new ASTNode("limit", 0, 0);
}
}
Aggregations