use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project snow-owl by b2ihealthcare.
the class SnomedRf2ImportRequest method read.
private void read(File rf2Archive, Rf2EffectiveTimeSlices slices, Rf2ValidationIssueReporter reporter) {
final CsvMapper csvMapper = new CsvMapper();
csvMapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
final CsvSchema schema = CsvSchema.emptySchema().withoutQuoteChar().withColumnSeparator('\t').withLineSeparator("\r\n");
final ObjectReader oReader = csvMapper.readerFor(String[].class).with(schema);
final Stopwatch w = Stopwatch.createStarted();
try (final ZipFile zip = new ZipFile(rf2Archive)) {
for (ZipEntry entry : Collections.list(zip.entries())) {
final String fileName = Paths.get(entry.getName()).getFileName().toString().toLowerCase();
if (fileName.endsWith(TXT_EXT)) {
if (fileName.contains(releaseType.toString().toLowerCase())) {
w.reset().start();
try (final InputStream in = zip.getInputStream(entry)) {
readFile(entry, in, oReader, slices, reporter);
}
log.info("{} - {}", entry.getName(), w);
}
}
}
} catch (IOException e) {
throw new SnowowlRuntimeException(e);
}
slices.flushAll();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project winery by eclipse.
the class MultiRepository method loadConfiguration.
/**
* Reads the dependencies file into the repositoriesList.
*
* @param dependency The path to the dependencies file
*/
private List<RepositoryProperties> loadConfiguration(File dependency) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
ObjectReader reader = objectMapper.readerFor(new TypeReference<List<RepositoryProperties>>() {
});
return reader.readValue(dependency);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project Slide by ccrama.
the class LiveThread method doLiveThreadUpdates.
public void doLiveThreadUpdates() {
final PaginatorAdapter adapter = new PaginatorAdapter(this);
baseRecycler.setAdapter(adapter);
doLiveSidebar();
if (thread.getWebsocketUrl() != null && !thread.getWebsocketUrl().isEmpty()) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
final ObjectReader o = new ObjectMapper().reader();
try {
WebSocket ws = new WebSocketFactory().createSocket(thread.getWebsocketUrl());
ws.addListener(new WebSocketAdapter() {
@Override
public void onTextMessage(WebSocket websocket, String s) {
LogUtil.v("Recieved" + s);
if (s.contains("\"type\": \"update\"")) {
try {
LiveUpdate u = new LiveUpdate(o.readTree(s).get("payload").get("data"));
updates.add(0, u);
runOnUiThread(new Runnable() {
@Override
public void run() {
adapter.notifyItemInserted(0);
baseRecycler.smoothScrollToPosition(0);
}
});
} catch (IOException e) {
e.printStackTrace();
}
} else if (s.contains("embeds_ready")) {
String node = updates.get(0).getDataNode().toString();
LogUtil.v("Getting");
try {
node = node.replace("\"embeds\":[]", "\"embeds\":" + o.readTree(s).get("payload").get("media_embeds").toString());
LiveUpdate u = new LiveUpdate(o.readTree(node));
updates.set(0, u);
runOnUiThread(new Runnable() {
@Override
public void run() {
adapter.notifyItemChanged(0);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
/* todoelse if(s.contains("delete")){
updates.remove(0);
adapter.notifyItemRemoved(0);
}*/
}
});
ws.connect();
} catch (IOException | WebSocketException e) {
e.printStackTrace();
}
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project Slide by ccrama.
the class OfflineSubreddit method getSubreddit.
public static OfflineSubreddit getSubreddit(String subreddit, Long time, boolean offline, Context c) {
if (cache == null)
cache = new HashMap<>();
String title;
if (subreddit != null) {
title = subreddit.toLowerCase(Locale.ENGLISH) + "," + time;
} else {
title = "";
subreddit = "";
}
if (cache.containsKey(title)) {
return cache.get(title);
} else {
subreddit = subreddit.toLowerCase(Locale.ENGLISH);
OfflineSubreddit o = new OfflineSubreddit();
o.subreddit = subreddit.toLowerCase(Locale.ENGLISH);
if (time == 0) {
o.base = true;
}
o.time = time;
String[] split = Reddit.cachedData.getString(subreddit.toLowerCase(Locale.ENGLISH) + "," + time, "").split(",");
if (split.length > 0) {
o.time = time;
o.submissions = new ArrayList<>();
ObjectMapper mapperBase = new ObjectMapper();
ObjectReader reader = mapperBase.reader();
for (String s : split) {
if (!s.contains("_"))
s = "t3_" + s;
if (!s.isEmpty()) {
try {
Submission sub = getSubmissionFromStorage(s, c, offline, reader);
if (sub != null) {
o.submissions.add(sub);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
} else {
o.submissions = new ArrayList<>();
}
cache.put(title, o);
return o;
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project eap-additional-testsuite by jboss-set.
the class Jsr310DeserializationTestCase method testDurationDeserialization.
@Test
public void testDurationDeserialization() throws Exception {
ObjectReader reader = new ObjectMapper().registerModule(new JavaTimeModule()).readerFor(Duration.class);
final String INPUT = "1e10000000";
// this should return almost instantly
Duration value = reader.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS).readValue(INPUT);
Assert.assertEquals("Didn't get the expected value.", 0, value.getSeconds());
}
Aggregations