2020-04-29 13:24:29 +02:00
|
|
|
|
2020-04-20 10:02:42 +02:00
|
|
|
package eu.dnetlib.doiboost.orcid;
|
2020-04-17 18:52:39 +02:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.URI;
|
2020-04-29 13:24:29 +02:00
|
|
|
|
2020-04-20 12:00:04 +02:00
|
|
|
import org.apache.commons.io.IOUtils;
|
2020-04-17 18:52:39 +02:00
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
|
|
import org.apache.hadoop.fs.Path;
|
2020-04-22 14:41:19 +02:00
|
|
|
import org.mortbay.log.Log;
|
2020-04-20 12:00:04 +02:00
|
|
|
|
2020-04-29 13:24:29 +02:00
|
|
|
import eu.dnetlib.dhp.application.ArgumentApplicationParser;
|
|
|
|
|
2020-04-17 18:52:39 +02:00
|
|
|
public class OrcidDSManager {
|
|
|
|
|
2020-04-29 13:24:29 +02:00
|
|
|
protected String hdfsServerUri;
|
2020-07-03 23:30:31 +02:00
|
|
|
protected String workingPath;
|
2020-04-29 13:24:29 +02:00
|
|
|
private String summariesFileNameTarGz;
|
|
|
|
private String outputAuthorsPath;
|
2020-04-22 14:41:19 +02:00
|
|
|
|
2021-05-14 10:58:12 +02:00
|
|
|
public static void main(String[] args) throws Exception {
|
2020-04-29 13:24:29 +02:00
|
|
|
OrcidDSManager orcidDSManager = new OrcidDSManager();
|
|
|
|
orcidDSManager.loadArgs(args);
|
|
|
|
orcidDSManager.generateAuthors();
|
|
|
|
}
|
2020-04-17 18:52:39 +02:00
|
|
|
|
2021-08-11 12:13:22 +02:00
|
|
|
public void generateAuthors() throws IOException {
|
2020-04-29 13:24:29 +02:00
|
|
|
Configuration conf = initConfigurationObject();
|
2020-07-03 23:30:31 +02:00
|
|
|
String tarGzUri = hdfsServerUri.concat(workingPath).concat(summariesFileNameTarGz);
|
2020-04-29 13:24:29 +02:00
|
|
|
Path outputPath = new Path(
|
|
|
|
hdfsServerUri
|
2020-07-03 23:30:31 +02:00
|
|
|
.concat(workingPath)
|
2020-04-29 13:24:29 +02:00
|
|
|
.concat(outputAuthorsPath)
|
|
|
|
.concat("authors.seq"));
|
|
|
|
SummariesDecompressor.parseGzSummaries(conf, tarGzUri, outputPath);
|
|
|
|
}
|
2020-04-22 14:41:19 +02:00
|
|
|
|
2020-04-29 13:24:29 +02:00
|
|
|
protected Configuration initConfigurationObject() {
|
|
|
|
// ====== Init HDFS File System Object
|
|
|
|
Configuration conf = new Configuration();
|
|
|
|
// Set FileSystem URI
|
2020-07-03 23:30:31 +02:00
|
|
|
conf.set("fs.defaultFS", hdfsServerUri.concat(workingPath));
|
2020-04-29 13:24:29 +02:00
|
|
|
// Because of Maven
|
|
|
|
conf.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
|
|
|
|
conf.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
|
|
|
|
return conf;
|
|
|
|
}
|
2020-04-22 14:41:19 +02:00
|
|
|
|
2020-09-22 10:46:34 +02:00
|
|
|
protected FileSystem initFileSystemObject(Configuration conf) throws IOException {
|
2020-04-29 13:24:29 +02:00
|
|
|
// Get the filesystem - HDFS
|
2020-10-22 14:07:26 +02:00
|
|
|
// if there is an exception, it will be propagate
|
2020-04-29 13:24:29 +02:00
|
|
|
FileSystem fs = null;
|
2020-09-22 10:46:34 +02:00
|
|
|
fs = FileSystem.get(URI.create(hdfsServerUri.concat(workingPath)), conf);
|
2020-04-29 13:24:29 +02:00
|
|
|
return fs;
|
|
|
|
}
|
2020-04-22 14:41:19 +02:00
|
|
|
|
2021-05-14 10:58:12 +02:00
|
|
|
private void loadArgs(String[] args) throws Exception {
|
2020-04-29 13:24:29 +02:00
|
|
|
final ArgumentApplicationParser parser = new ArgumentApplicationParser(
|
|
|
|
IOUtils
|
|
|
|
.toString(
|
|
|
|
OrcidDSManager.class
|
|
|
|
.getResourceAsStream(
|
2020-11-06 13:47:50 +01:00
|
|
|
"/eu/dnetlib/dhp/doiboost/gen_orcid_authors_from_summaries.json")));
|
2020-04-29 13:24:29 +02:00
|
|
|
parser.parseArgument(args);
|
2020-04-20 12:00:04 +02:00
|
|
|
|
2020-04-29 13:24:29 +02:00
|
|
|
hdfsServerUri = parser.get("hdfsServerUri");
|
|
|
|
Log.info("HDFS URI: " + hdfsServerUri);
|
2020-07-03 23:30:31 +02:00
|
|
|
workingPath = parser.get("workingPath");
|
|
|
|
Log.info("Working Path: " + workingPath);
|
2020-04-29 13:24:29 +02:00
|
|
|
summariesFileNameTarGz = parser.get("summariesFileNameTarGz");
|
|
|
|
Log.info("Summaries File Name: " + summariesFileNameTarGz);
|
|
|
|
outputAuthorsPath = parser.get("outputAuthorsPath");
|
|
|
|
Log.info("Output Authors Data: " + outputAuthorsPath);
|
|
|
|
}
|
2020-04-17 18:52:39 +02:00
|
|
|
}
|