org.icij.ftm.Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ftm.java Show documentation
Show all versions of ftm.java Show documentation
ICIJ implementation of the Aleph Follow the Money ontology.
The newest version!
package org.icij.ftm;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.snakeyaml.engine.v2.api.Load;
import org.snakeyaml.engine.v2.api.LoadSettings;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
/**
* Utils methods, that would need at some point to be in
* other classes.
*/
public class Utils {
private static final Load yaml = new Load(LoadSettings.builder().build());
public static Properties propertiesFromMap(Map map) {
Properties props = new Properties();
props.putAll(map);
return props;
}
static Path downloadYamlModels(URI downloadUri) throws IOException, InterruptedException {
Path tempDirectory = Files.createTempDirectory("ftm.java");
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder().uri(downloadUri).build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
List