2020-06-15 11:12:14 +02:00
|
|
|
|
2020-07-20 17:54:28 +02:00
|
|
|
package eu.dnetlib.dhp.oa.graph.dump.community;
|
2020-06-09 15:37:46 +02:00
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.*;
|
2020-06-15 11:12:14 +02:00
|
|
|
|
2020-11-24 14:37:36 +01:00
|
|
|
import javax.swing.text.html.Option;
|
|
|
|
|
2020-06-09 15:37:46 +02:00
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2020-07-29 16:52:44 +02:00
|
|
|
|
2020-06-09 15:37:46 +02:00
|
|
|
import eu.dnetlib.dhp.application.ArgumentApplicationParser;
|
2020-07-29 16:52:44 +02:00
|
|
|
import eu.dnetlib.dhp.oa.graph.dump.DumpProducts;
|
2020-11-24 14:37:36 +01:00
|
|
|
import eu.dnetlib.dhp.oa.graph.dump.Utils;
|
2020-07-29 16:52:44 +02:00
|
|
|
import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityResult;
|
2020-06-09 15:37:46 +02:00
|
|
|
import eu.dnetlib.dhp.schema.oaf.Result;
|
|
|
|
|
2020-08-13 12:05:44 +02:00
|
|
|
/**
|
|
|
|
* Spark action to trigger the dump of results associated to research community - reseach initiative/infrasctructure The
|
|
|
|
* actual dump if performed via the class DumpProducts that is used also for the entire graph dump
|
|
|
|
*/
|
2020-06-09 15:39:03 +02:00
|
|
|
public class SparkDumpCommunityProducts implements Serializable {
|
2020-06-09 15:37:46 +02:00
|
|
|
|
2020-06-15 11:12:14 +02:00
|
|
|
private static final Logger log = LoggerFactory.getLogger(SparkDumpCommunityProducts.class);
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
String jsonConfiguration = IOUtils
|
|
|
|
.toString(
|
|
|
|
SparkDumpCommunityProducts.class
|
|
|
|
.getResourceAsStream(
|
|
|
|
"/eu/dnetlib/dhp/oa/graph/dump/input_parameters.json"));
|
|
|
|
|
|
|
|
final ArgumentApplicationParser parser = new ArgumentApplicationParser(jsonConfiguration);
|
|
|
|
parser.parseArgument(args);
|
|
|
|
|
|
|
|
Boolean isSparkSessionManaged = Optional
|
|
|
|
.ofNullable(parser.get("isSparkSessionManaged"))
|
|
|
|
.map(Boolean::valueOf)
|
|
|
|
.orElse(Boolean.TRUE);
|
|
|
|
log.info("isSparkSessionManaged: {}", isSparkSessionManaged);
|
|
|
|
|
|
|
|
final String inputPath = parser.get("sourcePath");
|
|
|
|
log.info("inputPath: {}", inputPath);
|
|
|
|
|
|
|
|
final String outputPath = parser.get("outputPath");
|
|
|
|
log.info("outputPath: {}", outputPath);
|
|
|
|
|
|
|
|
final String resultClassName = parser.get("resultTableName");
|
|
|
|
log.info("resultTableName: {}", resultClassName);
|
|
|
|
|
2020-08-03 17:56:31 +02:00
|
|
|
String communityMapPath = parser.get("communityMapPath");
|
|
|
|
|
2020-11-24 14:37:36 +01:00
|
|
|
final String dumpType = Optional
|
|
|
|
.ofNullable(parser.get("dumpType"))
|
|
|
|
.map(String::valueOf)
|
|
|
|
.orElse("community");
|
|
|
|
|
2020-06-15 11:12:14 +02:00
|
|
|
Class<? extends Result> inputClazz = (Class<? extends Result>) Class.forName(resultClassName);
|
|
|
|
|
2020-07-20 17:54:28 +02:00
|
|
|
DumpProducts dump = new DumpProducts();
|
2020-06-15 11:12:14 +02:00
|
|
|
|
2020-08-03 17:56:31 +02:00
|
|
|
dump
|
|
|
|
.run(
|
|
|
|
isSparkSessionManaged, inputPath, outputPath, communityMapPath, inputClazz, CommunityResult.class,
|
2020-11-24 14:37:36 +01:00
|
|
|
dumpType);
|
2020-08-03 17:56:31 +02:00
|
|
|
|
2020-06-15 11:12:14 +02:00
|
|
|
}
|
|
|
|
|
2020-06-09 15:37:46 +02:00
|
|
|
}
|