diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/common/MakeTarArchive.java b/dhp-common/src/main/java/eu/dnetlib/dhp/common/MakeTarArchive.java new file mode 100644 index 0000000000..4047fdca4f --- /dev/null +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/common/MakeTarArchive.java @@ -0,0 +1,117 @@ + +package eu.dnetlib.dhp.common; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; + +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; +import org.apache.hadoop.fs.*; + +public class MakeTarArchive implements Serializable { + + private static TarArchiveOutputStream getTar(FileSystem fileSystem, String outputPath) throws IOException { + Path hdfsWritePath = new Path(outputPath); + FSDataOutputStream fsDataOutputStream = null; + if (fileSystem.exists(hdfsWritePath)) { + fileSystem.delete(hdfsWritePath, true); + + } + fsDataOutputStream = fileSystem.create(hdfsWritePath); + + return new TarArchiveOutputStream(fsDataOutputStream.getWrappedStream()); + } + + private static void write(FileSystem fileSystem, String inputPath, String outputPath, String dir_name) + throws IOException { + + Path hdfsWritePath = new Path(outputPath); + FSDataOutputStream fsDataOutputStream = null; + if (fileSystem.exists(hdfsWritePath)) { + fileSystem.delete(hdfsWritePath, true); + + } + fsDataOutputStream = fileSystem.create(hdfsWritePath); + + TarArchiveOutputStream ar = new TarArchiveOutputStream(fsDataOutputStream.getWrappedStream()); + + RemoteIterator fileStatusListIterator = fileSystem + .listFiles( + new Path(inputPath), true); + + while (fileStatusListIterator.hasNext()) { + writeCurrentFile(fileSystem, dir_name, fileStatusListIterator, ar, 0); + } + + ar.close(); + } + + public static void tarMaxSize(FileSystem fileSystem, String inputPath, String outputPath, String dir_name, + int gBperSplit) throws IOException { + final long bytesPerSplit = 1024L * 1024L * 1024L * gBperSplit; + + long sourceSize = fileSystem.getContentSummary(new Path(inputPath)).getSpaceConsumed(); + + if (sourceSize < bytesPerSplit) { + write(fileSystem, inputPath, outputPath + ".tar", dir_name); + } else { + int partNum = 0; + + RemoteIterator fileStatusListIterator = fileSystem + .listFiles( + new Path(inputPath), true); + boolean next = fileStatusListIterator.hasNext(); + while (next) { + TarArchiveOutputStream ar = getTar(fileSystem, outputPath + "_" + (partNum + 1) + ".tar"); + + long current_size = 0; + while (next && current_size < bytesPerSplit) { + current_size = writeCurrentFile(fileSystem, dir_name, fileStatusListIterator, ar, current_size); + next = fileStatusListIterator.hasNext(); + + } + + partNum += 1; + ar.close(); + } + + } + + } + + private static long writeCurrentFile(FileSystem fileSystem, String dir_name, + RemoteIterator fileStatusListIterator, + TarArchiveOutputStream ar, long current_size) throws IOException { + LocatedFileStatus fileStatus = fileStatusListIterator.next(); + + Path p = fileStatus.getPath(); + String p_string = p.toString(); + if (!p_string.endsWith("_SUCCESS")) { + String name = p_string.substring(p_string.lastIndexOf("/") + 1); + if (name.trim().equalsIgnoreCase("communities_infrastructures")) { + name = "communities_infrastructures.json"; + } + TarArchiveEntry entry = new TarArchiveEntry(dir_name + "/" + name); + entry.setSize(fileStatus.getLen()); + current_size += fileStatus.getLen(); + ar.putArchiveEntry(entry); + + InputStream is = fileSystem.open(fileStatus.getPath()); + + BufferedInputStream bis = new BufferedInputStream(is); + + int count; + byte data[] = new byte[1024]; + while ((count = bis.read(data, 0, data.length)) != -1) { + ar.write(data, 0, count); + } + bis.close(); + ar.closeArchiveEntry(); + + } + return current_size; + } + +} diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java b/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java index f2dd4f0ac8..1f267733d1 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java @@ -3,6 +3,7 @@ package eu.dnetlib.dhp.common.api; import java.io.*; import java.io.IOException; +import java.util.concurrent.TimeUnit; import com.google.gson.Gson; @@ -50,14 +51,15 @@ public class ZenodoAPIClient implements Serializable { /** * Brand new deposition in Zenodo. It sets the deposition_id and the bucket where to store the files to upload + * * @return response code * @throws IOException */ public int newDeposition() throws IOException { String json = "{}"; - OkHttpClient httpClient = new OkHttpClient(); + OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); - RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, json); + RequestBody body = RequestBody.create(json, MEDIA_TYPE_JSON); Request request = new Request.Builder() .url(urlString) @@ -86,13 +88,18 @@ public class ZenodoAPIClient implements Serializable { /** * Upload files in Zenodo. + * * @param is the inputStream for the file to upload * @param file_name the name of the file as it will appear on Zenodo * @param len the size of the file * @return the response code */ public int uploadIS(InputStream is, String file_name, long len) throws IOException { - OkHttpClient httpClient = new OkHttpClient(); + OkHttpClient httpClient = new OkHttpClient.Builder() + .writeTimeout(600, TimeUnit.SECONDS) + .readTimeout(600, TimeUnit.SECONDS) + .connectTimeout(600, TimeUnit.SECONDS) + .build(); Request request = new Request.Builder() .url(bucket + "/" + file_name) @@ -110,15 +117,16 @@ public class ZenodoAPIClient implements Serializable { /** * Associates metadata information to the current deposition + * * @param metadata the metadata * @return response code * @throws IOException */ public int sendMretadata(String metadata) throws IOException { - OkHttpClient httpClient = new OkHttpClient(); + OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); - RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, metadata); + RequestBody body = RequestBody.create(metadata, MEDIA_TYPE_JSON); Request request = new Request.Builder() .url(urlString + "/" + deposition_id) @@ -140,6 +148,7 @@ public class ZenodoAPIClient implements Serializable { /** * To publish the current deposition. It works for both new deposition or new version of an old deposition + * * @return response code * @throws IOException */ @@ -147,12 +156,14 @@ public class ZenodoAPIClient implements Serializable { String json = "{}"; - OkHttpClient httpClient = new OkHttpClient(); + OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); + + RequestBody body = RequestBody.create(json, MEDIA_TYPE_JSON); Request request = new Request.Builder() .url(urlString + "/" + deposition_id + "/actions/publish") .addHeader("Authorization", "Bearer " + access_token) - .post(RequestBody.create(MEDIA_TYPE_JSON, json)) + .post(body) .build(); try (Response response = httpClient.newCall(request).execute()) { @@ -166,11 +177,12 @@ public class ZenodoAPIClient implements Serializable { } /** - * To create a new version of an already published deposition. - * It sets the deposition_id and the bucket to be used for the new version. - * @param concept_rec_id the concept record id of the deposition for which to create a new version. It is - * the last part of the url for the DOI Zenodo suggests to use to cite all versions: - * DOI: 10.xxx/zenodo.656930 concept_rec_id = 656930 + * To create a new version of an already published deposition. It sets the deposition_id and the bucket to be used + * for the new version. + * + * @param concept_rec_id the concept record id of the deposition for which to create a new version. It is the last + * part of the url for the DOI Zenodo suggests to use to cite all versions: DOI: 10.xxx/zenodo.656930 + * concept_rec_id = 656930 * @return response code * @throws IOException * @throws MissingConceptDoiException @@ -179,12 +191,14 @@ public class ZenodoAPIClient implements Serializable { setDepositionId(concept_rec_id); String json = "{}"; - OkHttpClient httpClient = new OkHttpClient(); + OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); + + RequestBody body = RequestBody.create(json, MEDIA_TYPE_JSON); Request request = new Request.Builder() .url(urlString + "/" + deposition_id + "/actions/newversion") .addHeader("Authorization", "Bearer " + access_token) - .post(RequestBody.create(MEDIA_TYPE_JSON, json)) + .post(body) .build(); try (Response response = httpClient.newCall(request).execute()) { @@ -201,6 +215,41 @@ public class ZenodoAPIClient implements Serializable { } } + /** + * To finish uploading a version or new deposition not published + * It sets the deposition_id and the bucket to be used + * + * + * @param deposition_id the deposition id of the not yet published upload + * concept_rec_id = 656930 + * @return response code + * @throws IOException + * @throws MissingConceptDoiException + */ + public int uploadOpenDeposition(String deposition_id) throws IOException, MissingConceptDoiException { + + this.deposition_id = deposition_id; + + OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); + + Request request = new Request.Builder() + .url(urlString + "/" + deposition_id) + .addHeader("Authorization", "Bearer " + access_token) + .build(); + + try (Response response = httpClient.newCall(request).execute()) { + + if (!response.isSuccessful()) + throw new IOException("Unexpected code " + response + response.body().string()); + + ZenodoModel zenodoModel = new Gson().fromJson(response.body().string(), ZenodoModel.class); + bucket = zenodoModel.getLinks().getBucket(); + return response.code(); + + } + + } + private void setDepositionId(String concept_rec_id) throws IOException, MissingConceptDoiException { ZenodoModelList zenodoModelList = new Gson().fromJson(getPrevDepositions(), ZenodoModelList.class); @@ -217,7 +266,7 @@ public class ZenodoAPIClient implements Serializable { } private String getPrevDepositions() throws IOException { - OkHttpClient httpClient = new OkHttpClient(); + OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); Request request = new Request.Builder() .url(urlString) @@ -238,7 +287,9 @@ public class ZenodoAPIClient implements Serializable { } private String getBucket(String url) throws IOException { - OkHttpClient httpClient = new OkHttpClient(); + OkHttpClient httpClient = new OkHttpClient.Builder() + .connectTimeout(600, TimeUnit.SECONDS) + .build(); Request request = new Request.Builder() .url(url) diff --git a/dhp-common/src/test/java/eu/dnetlib/dhp/common/api/ZenodoAPIClientTest.java b/dhp-common/src/test/java/eu/dnetlib/dhp/common/api/ZenodoAPIClientTest.java index f961d67483..9ae9c33c2e 100644 --- a/dhp-common/src/test/java/eu/dnetlib/dhp/common/api/ZenodoAPIClientTest.java +++ b/dhp-common/src/test/java/eu/dnetlib/dhp/common/api/ZenodoAPIClientTest.java @@ -19,6 +19,30 @@ public class ZenodoAPIClientTest { private final String CONCEPT_REC_ID = "657113"; + private final String depositionId = "674915"; + + @Test + public void testUploadOldDeposition() throws IOException, MissingConceptDoiException { + ZenodoAPIClient client = new ZenodoAPIClient(URL_STRING, + ACCESS_TOKEN); + Assertions.assertEquals(200, client.uploadOpenDeposition(depositionId)); + + File file = new File(getClass() + .getResource("/eu/dnetlib/dhp/common/api/COVID-19.json.gz") + .getPath()); + + InputStream is = new FileInputStream(file); + + Assertions.assertEquals(200, client.uploadIS(is, "COVID-19.json.gz", file.length())); + + String metadata = IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/dhp/common/api/metadata.json")); + + Assertions.assertEquals(200, client.sendMretadata(metadata)); + + Assertions.assertEquals(202, client.publish()); + + } + @Test public void testNewDeposition() throws IOException { diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java index b27fc9267b..d759f0d553 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java @@ -39,15 +39,15 @@ public class ModelConstants { public static final String IS_SUPPLEMENT_TO = "isSupplementTo"; public static final String IS_SUPPLEMENTED_BY = "isSupplementedBy"; public static final String PART = "part"; - public static final String IS_PART_OF = "IsPartOf"; - public static final String HAS_PARTS = "HasParts"; + public static final String IS_PART_OF = "isPartOf"; + public static final String HAS_PARTS = "hasParts"; public static final String RELATIONSHIP = "relationship"; public static final String CITATION = "citation"; public static final String CITES = "cites"; - public static final String IS_CITED_BY = "IsCitedBy"; + public static final String IS_CITED_BY = "isCitedBy"; public static final String REVIEW = "review"; public static final String REVIEWS = "reviews"; - public static final String IS_REVIEWED_BY = "IsReviewedBy"; + public static final String IS_REVIEWED_BY = "isReviewedBy"; public static final String RESULT_PROJECT = "resultProject"; public static final String OUTCOME = "outcome"; diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Instance.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Instance.java index 4a09f5a865..edc6f28f5e 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Instance.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Instance.java @@ -10,17 +10,11 @@ import java.util.List; * String to store the license applied to the instance. It corresponds to the value of the licence in the instance to be * dumped - accessright of type eu.dnetlib.dhp.schema.dump.oaf.AccessRight to store the accessright of the instance. - * type of type String to store the type of the instance as defined in the corresponding dnet vocabulary - * (dnet:pubication_resource). It corresponds to the instancetype.classname of the instance to be mapped - hostedby of - * type eu.dnetlib.dhp.schema.dump.oaf.KeyValue to store the information about the source from which the instance can be - * viewed or downloaded. It is mapped against the hostedby parameter of the instance to be dumped and - key corresponds - * to hostedby.key - value corresponds to hostedby.value - url of type List list of locations where the instance - * is accessible. It corresponds to url of the instance to be dumped - collectedfrom of type - * eu.dnetlib.dhp.schema.dump.oaf.KeyValue to store the information about the source from which the instance has been - * collected. It is mapped against the collectedfrom parameter of the instance to be dumped and - key corresponds to - * collectedfrom.key - value corresponds to collectedfrom.value - publicationdate of type String to store the - * publication date of the instance ;// dateofacceptance; - refereed of type String to store information abour tthe - * review status of the instance. Possible values are 'Unknown', 'nonPeerReviewed', 'peerReviewed'. It corresponds to - * refereed.classname of the instance to be dumped + * (dnet:pubication_resource). It corresponds to the instancetype.classname of the instance to be mapped - url of type + * List list of locations where the instance is accessible. It corresponds to url of the instance to be dumped - + * publicationdate of type String to store the publication date of the instance ;// dateofacceptance; - refereed of type + * String to store information abour tthe review status of the instance. Possible values are 'Unknown', + * 'nonPeerReviewed', 'peerReviewed'. It corresponds to refereed.classname of the instance to be dumped */ public class Instance implements Serializable { @@ -30,12 +24,8 @@ public class Instance implements Serializable { private String type; - private KeyValue hostedby; - private List url; - private KeyValue collectedfrom; - private String publicationdate;// dateofacceptance; private String refereed; // peer-review status @@ -64,14 +54,6 @@ public class Instance implements Serializable { this.type = type; } - public KeyValue getHostedby() { - return hostedby; - } - - public void setHostedby(KeyValue hostedby) { - this.hostedby = hostedby; - } - public List getUrl() { return url; } @@ -80,14 +62,6 @@ public class Instance implements Serializable { this.url = url; } - public KeyValue getCollectedfrom() { - return collectedfrom; - } - - public void setCollectedfrom(KeyValue collectedfrom) { - this.collectedfrom = collectedfrom; - } - public String getPublicationdate() { return publicationdate; } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Project.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Project.java index f23d5a6703..00cd7a0fbb 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Project.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Project.java @@ -3,6 +3,12 @@ package eu.dnetlib.dhp.schema.dump.oaf; import java.io.Serializable; +/** + * This class to store the common information about the project that will be dumped for community and for the whole + * graph - private String id to store the id of the project (OpenAIRE id) - private String code to store the grant + * agreement of the project - private String acronym to store the acronym of the project - private String title to store + * the tile of the project + */ public class Project implements Serializable { protected String id;// OpenAIRE id protected String code; diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Result.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Result.java index 97ee722595..88ab2c334d 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Result.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Result.java @@ -34,34 +34,32 @@ import eu.dnetlib.dhp.schema.dump.oaf.community.Project; * to the list of coverage.value in the result represented in the internal model - bestaccessright of type * eu.dnetlib.dhp.schema.dump.oaf.AccessRight to store informatin about the openest access right associated to the * manifestations of this research results. It corresponds to the same parameter in the result represented in the - * internal model - instance of type List to store all the instances associated - * to the result. It corresponds to the same parameter in the result represented in the internal model - container of - * type eu.dnetlib.dhp.schema/dump.oaf.Container (only for result of type publication). It corresponds to the parameter - * journal of the result represented in the internal model - documentationUrl of type List (only for results of - * type software) to store the URLs to the software documentation. It corresponds to the list of documentationUrl.value - * of the result represented in the internal model - codeRepositoryUrl of type String (only for results of type - * software) to store the URL to the repository with the source code. It corresponds to codeRepositoryUrl.value of the - * result represented in the internal model - programmingLanguage of type String (only for results of type software) to - * store the programming language. It corresponds to programmingLanguaga.classid of the result represented in the - * internal model - contactperson of type List (only for results of type other) to store the contact person for - * this result. It corresponds to the list of contactperson.value of the result represented in the internal model - - * contactgroup of type List (only for results of type other) to store the information for the contact group. It - * corresponds to the list of contactgroup.value of the result represented in the internal model - tool of type - * List (only fro results of type other) to store information about tool useful for the interpretation and/or - * re-used of the research product. It corresponds to the list of tool.value in the result represented in the internal - * modelt - size of type String (only for results of type dataset) to store the size of the dataset. It corresponds to - * size.value in the result represented in the internal model - version of type String (only for results of type - * dataset) to store the version. It corresponds to version.value of the result represented in the internal model - - * geolocation fo type List (only for results of type dataset) to store - * geolocation information. For each geolocation element in the result represented in the internal model a GeoLocation - * in the external model il produced - id of type String to store the OpenAIRE id of the result. It corresponds to the - * id of the result represented in the internal model - originalId of type List to store the original ids of the - * result. It corresponds to the originalId of the result represented in the internal model - pid of type - * List to store the persistent identifiers for the result. For each pid - * in the results represented in the internal model one pid in the external model is produced. The value correspondence - * is: - scheme corresponds to pid.qualifier.classid of the result represented in the internal model - value corresponds - * to the pid.value of the result represented in the internal model - dateofcollection of type String to store - * information about the time OpenAIRE collected the record. It corresponds to dateofcollection of the result + * internal model - container of type eu.dnetlib.dhp.schema/dump.oaf.Container (only for result of type publication). It + * corresponds to the parameter journal of the result represented in the internal model - documentationUrl of type + * List (only for results of type software) to store the URLs to the software documentation. It corresponds to + * the list of documentationUrl.value of the result represented in the internal model - codeRepositoryUrl of type String + * (only for results of type software) to store the URL to the repository with the source code. It corresponds to + * codeRepositoryUrl.value of the result represented in the internal model - programmingLanguage of type String (only + * for results of type software) to store the programming language. It corresponds to programmingLanguaga.classid of the + * result represented in the internal model - contactperson of type List (only for results of type other) to + * store the contact person for this result. It corresponds to the list of contactperson.value of the result represented + * in the internal model - contactgroup of type List (only for results of type other) to store the information + * for the contact group. It corresponds to the list of contactgroup.value of the result represented in the internal + * model - tool of type List (only fro results of type other) to store information about tool useful for the + * interpretation and/or re-used of the research product. It corresponds to the list of tool.value in the result + * represented in the internal modelt - size of type String (only for results of type dataset) to store the size of the + * dataset. It corresponds to size.value in the result represented in the internal model - version of type String (only + * for results of type dataset) to store the version. It corresponds to version.value of the result represented in the + * internal model - geolocation fo type List (only for results of type + * dataset) to store geolocation information. For each geolocation element in the result represented in the internal + * model a GeoLocation in the external model il produced - id of type String to store the OpenAIRE id of the result. It + * corresponds to the id of the result represented in the internal model - originalId of type List to store the + * original ids of the result. It corresponds to the originalId of the result represented in the internal model - pid of + * type List to store the persistent identifiers for the result. For + * each pid in the results represented in the internal model one pid in the external model is produced. The value + * correspondence is: - scheme corresponds to pid.qualifier.classid of the result represented in the internal model - + * value corresponds to the pid.value of the result represented in the internal model - dateofcollection of type String + * to store information about the time OpenAIRE collected the record. It corresponds to dateofcollection of the result * represented in the internal model - lasteupdatetimestamp of type String to store the timestamp of the last update of * the record. It corresponds to lastupdatetimestamp of the resord represented in the internal model */ @@ -101,8 +99,6 @@ public class Result implements Serializable { private AccessRight bestaccessright; - private List instance; - private Container container;// Journal private List documentationUrl; // software @@ -309,14 +305,6 @@ public class Result implements Serializable { this.bestaccessright = bestaccessright; } - public List getInstance() { - return instance; - } - - public void setInstance(List instance) { - this.instance = instance; - } - public List getDocumentationUrl() { return documentationUrl; } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityInstance.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityInstance.java new file mode 100644 index 0000000000..6a605d7427 --- /dev/null +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityInstance.java @@ -0,0 +1,36 @@ + +package eu.dnetlib.dhp.schema.dump.oaf.community; + +import eu.dnetlib.dhp.schema.dump.oaf.Instance; +import eu.dnetlib.dhp.schema.dump.oaf.KeyValue; + +/** + * It extends eu.dnetlib.dhp.dump.oaf.Instance with values related to the community dump. In the Result dump this + * information is not present because it is dumped as a set of relations between the result and the datasource. - + * hostedby of type eu.dnetlib.dhp.schema.dump.oaf.KeyValue to store the information about the source from which the + * instance can be viewed or downloaded. It is mapped against the hostedby parameter of the instance to be dumped and - + * key corresponds to hostedby.key - value corresponds to hostedby.value - collectedfrom of type + * eu.dnetlib.dhp.schema.dump.oaf.KeyValue to store the information about the source from which the instance has been + * collected. It is mapped against the collectedfrom parameter of the instance to be dumped and - key corresponds to + * collectedfrom.key - value corresponds to collectedfrom.value + */ +public class CommunityInstance extends Instance { + private KeyValue hostedby; + private KeyValue collectedfrom; + + public KeyValue getHostedby() { + return hostedby; + } + + public void setHostedby(KeyValue hostedby) { + this.hostedby = hostedby; + } + + public KeyValue getCollectedfrom() { + return collectedfrom; + } + + public void setCollectedfrom(KeyValue collectedfrom) { + this.collectedfrom = collectedfrom; + } +} diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityResult.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityResult.java index 8c748e103a..690a537064 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityResult.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityResult.java @@ -10,11 +10,13 @@ import eu.dnetlib.dhp.schema.dump.oaf.Result; * extends eu.dnetlib.dhp.schema.dump.oaf.Result with the following parameters: - projects of type * List to store the list of projects related to the result. The * information is added after the result is mapped to the external model - context of type - * List to store information about the RC RI related to the result. + * List to store information about the RC RI related to the result. * For each context in the result represented in the internal model one context in the external model is produced - * collectedfrom of type List to store information about the sources from which * the record has been collected. For each collectedfrom in the result represented in the internal model one - * collectedfrom in the external model is produced + * collectedfrom in the external model is produced - instance of type + * List to store all the instances associated to the result. + * It corresponds to the same parameter in the result represented in the internal model */ public class CommunityResult extends Result { @@ -24,6 +26,16 @@ public class CommunityResult extends Result { protected List collectedfrom; + private List instance; + + public List getInstance() { + return instance; + } + + public void setInstance(List instance) { + this.instance = instance; + } + public List getCollectedfrom() { return collectedfrom; } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Funder.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Funder.java index b795fd1006..adb41634aa 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Funder.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Funder.java @@ -9,39 +9,10 @@ import java.io.Serializable; * (e.c. Akademy of Finland) - fundingStream of type String to store the funding stream - jurisdiction of type String to * store the jurisdiction of the funder */ -public class Funder implements Serializable { - private String shortName; - - private String name; +public class Funder extends eu.dnetlib.dhp.schema.dump.oaf.Funder { private String fundingStream; - private String jurisdiction; - - public String getJurisdiction() { - return jurisdiction; - } - - public void setJurisdiction(String jurisdiction) { - this.jurisdiction = jurisdiction; - } - - public String getShortName() { - return shortName; - } - - public void setShortName(String shortName) { - this.shortName = shortName; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - public String getFundingStream() { return fundingStream; } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Project.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Project.java index 7e23a13114..030b565be0 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Project.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Project.java @@ -8,21 +8,12 @@ import eu.dnetlib.dhp.schema.dump.oaf.Provenance; /** * To store information about the project related to the result. This information is not directly mapped from the result * represented in the internal model because it is not there. The mapped result will be enriched with project - * information derived by relation between results and projects. Project class has the following parameters: - id of - * type String to store the OpenAIRE id for the Project - code of type String to store the grant agreement - acronym of - * type String to store the acronym for the project - title of type String to store the title of the project - funder of - * type eu.dnetlib.dhp.schema.dump.oaf.community.Funder to store information about the funder funding the project - - * provenance of type eu.dnetlib.dhp.schema.dump.oaf.Provenance to store information about the. provenance of the - * association between the result and the project + * information derived by relation between results and projects. Project extends eu.dnetlib.dhp.schema.dump.oaf.Project + * with the following parameters: - funder of type eu.dnetlib.dhp.schema.dump.oaf.community.Funder to store information + * about the funder funding the project - provenance of type eu.dnetlib.dhp.schema.dump.oaf.Provenance to store + * information about the. provenance of the association between the result and the project */ -public class Project implements Serializable { - - private String id;// OpenAIRE id - private String code; - - private String acronym; - - private String title; +public class Project extends eu.dnetlib.dhp.schema.dump.oaf.Project { private Funder funder; @@ -36,38 +27,6 @@ public class Project implements Serializable { this.provenance = provenance; } - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getAcronym() { - return acronym; - } - - public void setAcronym(String acronym) { - this.acronym = acronym; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - public Funder getFunder() { return funder; } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Funder.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Funder.java index 57d94f481b..3b298c81d5 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Funder.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Funder.java @@ -4,46 +4,14 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph; import java.io.Serializable; /** - * To store information about the funder funding the project related to the result. It has the following parameters: - * - private String shortName to store the short name of the funder (e.g. AKA) - * - private String name to store information about the name of the funder (e.g. Akademy of Finland) - * - private Fundings funding_stream to store the fundingstream - * - private String jurisdiction to store information about the jurisdiction of the funder + * To store information about the funder funding the project related to the result. It extends + * eu.dnetlib.dhp.schema.dump.oaf.Funder with the following parameter: - - private + * eu.dnetdlib.dhp.schema.dump.oaf.graph.Fundings funding_stream to store the fundingstream */ -public class Funder implements Serializable { - - private String shortName; - - private String name; +public class Funder extends eu.dnetlib.dhp.schema.dump.oaf.Funder { private Fundings funding_stream; - private String jurisdiction; - - public String getShortName() { - return shortName; - } - - public void setShortName(String shortName) { - this.shortName = shortName; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getJurisdiction() { - return jurisdiction; - } - - public void setJurisdiction(String jurisdiction) { - this.jurisdiction = jurisdiction; - } - public Fundings getFunding_stream() { return funding_stream; } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Fundings.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Fundings.java index 173878ef0c..a74c347789 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Fundings.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Fundings.java @@ -4,13 +4,13 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph; import java.io.Serializable; /** - * To store inforamtion about the funding stream. It has two parameters: - * - private String id to store the id of the fundings stream. The id is created by appending the shortname of the - * funder to the name of each level in the xml representing the fundng stream. For example: if the funder is the - * European Commission, the funding level 0 name is FP7, the funding level 1 name is SP3 and the funding level 2 name is - * PEOPLE then the id will be: EC::FP7::SP3::PEOPLE - * - private String description to describe the funding stream. It is created by concatenating the description of each funding - * level so for the example above the description would be: SEVENTH FRAMEWORK PROGRAMME - SP3-People - Marie-Curie Actions + * To store inforamtion about the funding stream. It has two parameters: - private String id to store the id of the + * fundings stream. The id is created by appending the shortname of the funder to the name of each level in the xml + * representing the fundng stream. For example: if the funder is the European Commission, the funding level 0 name is + * FP7, the funding level 1 name is SP3 and the funding level 2 name is PEOPLE then the id will be: EC::FP7::SP3::PEOPLE + * - private String description to describe the funding stream. It is created by concatenating the description of each + * funding level so for the example above the description would be: SEVENTH FRAMEWORK PROGRAMME - SP3-People - + * Marie-Curie Actions */ public class Fundings implements Serializable { diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Granted.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Granted.java index 1ac27ddf11..94ace55aac 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Granted.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Granted.java @@ -5,10 +5,9 @@ import java.io.Serializable; import java.util.Optional; /** - * To describe the funded amount. It has the following parameters: - * - private String currency to store the currency of the fund - * - private float totalcost to store the total cost of the project - * - private float fundedamount to store the funded amount by the funder + * To describe the funded amount. It has the following parameters: - private String currency to store the currency of + * the fund - private float totalcost to store the total cost of the project - private float fundedamount to store the + * funded amount by the funder */ public class Granted implements Serializable { private String currency; diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/GraphResult.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/GraphResult.java new file mode 100644 index 0000000000..1675f9ec57 --- /dev/null +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/GraphResult.java @@ -0,0 +1,24 @@ + +package eu.dnetlib.dhp.schema.dump.oaf.graph; + +import java.util.List; + +import eu.dnetlib.dhp.schema.dump.oaf.Instance; +import eu.dnetlib.dhp.schema.dump.oaf.Result; + +/** + * It extends the eu.dnetlib.dhp.schema.dump.oaf.Result with - instance of type + * List to store all the instances associated to the result. It corresponds to + * the same parameter in the result represented in the internal model + */ +public class GraphResult extends Result { + private List instance; + + public List getInstance() { + return instance; + } + + public void setInstance(List instance) { + this.instance = instance; + } +} diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Node.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Node.java index dac594451a..00f1a29bca 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Node.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Node.java @@ -4,13 +4,10 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph; import java.io.Serializable; /** - * To represent the generic node in a relation. It has the following parameters: - * - private String id the openaire id of the entity in the relation - * - private String type the type of the entity in the relation. - * - * Consider the generic relation between a Result R and a Project P, the node representing R will have - * as id the id of R and as type result, while the node representing the project will have as id the id of the project - * and as type project + * To represent the generic node in a relation. It has the following parameters: - private String id the openaire id of + * the entity in the relation - private String type the type of the entity in the relation. Consider the generic + * relation between a Result R and a Project P, the node representing R will have as id the id of R and as type result, + * while the node representing the project will have as id the id of the project and as type project */ public class Node implements Serializable { private String id; diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Organization.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Organization.java index 579245c053..2407c9cfc8 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Organization.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Organization.java @@ -11,14 +11,12 @@ import eu.dnetlib.dhp.schema.dump.oaf.Qualifier; import eu.dnetlib.dhp.schema.dump.oaf.community.Project; /** - * To represent the generic organizaiton. It has the following parameters: - * - private String legalshortname to store the legalshortname of the organizaiton - * - private String legalname to store the legal name of the organization - * - private String websiteurl to store the websiteurl of the organization - * - private List alternativenames to store the alternative names of the organization - * - private Qualifier country to store the country of the organization - * - private String id to store the id of the organization - * - private List pid to store the list of pids for the organization + * To represent the generic organizaiton. It has the following parameters: - private String legalshortname to store the + * legalshortname of the organizaiton - private String legalname to store the legal name of the organization - private + * String websiteurl to store the websiteurl of the organization - private List alternativenames to store the + * alternative names of the organization - private Qualifier country to store the country of the organization - private + * String id to store the id of the organization - private List pid to store the list of pids for the + * organization */ public class Organization implements Serializable { private String legalshortname; diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Programme.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Programme.java index 663ca25bc4..9892790e31 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Programme.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Programme.java @@ -4,9 +4,8 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph; import java.io.Serializable; /** - * To store information about the ec programme for the project. It has the following parameters: - * - private String code to store the code of the programme - * - private String description to store the description of the programme + * To store information about the ec programme for the project. It has the following parameters: - private String code + * to store the code of the programme - private String description to store the description of the programme */ public class Programme implements Serializable { private String code; diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Project.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Project.java index 054e4d2dfb..612be9d25d 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Project.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Project.java @@ -31,7 +31,7 @@ import java.util.List; * - private List funding to store the list of funder of the project * - private String summary to store the summary of the project * - private Granted granted to store the granted amount - * - private List h2020classification to store the list of H2020 classifications the project is related to + * - private List h2020programme to store the list of programmes the project is related to */ public class Project implements Serializable { @@ -60,7 +60,7 @@ public class Project implements Serializable { private Granted granted; - private List h2020Classifications; + private List h2020programme; public String getId() { return id; @@ -182,11 +182,11 @@ public class Project implements Serializable { this.granted = granted; } - public List getH2020Classifications() { - return h2020Classifications; + public List getH2020programme() { + return h2020programme; } - public void setH2020Classifications(List h2020Classifications) { - this.h2020Classifications = h2020Classifications; + public void setH2020programme(List h2020programme) { + this.h2020programme = h2020programme; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/RelType.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/RelType.java index 83ae2dda6f..629b30ee44 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/RelType.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/RelType.java @@ -4,12 +4,11 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph; import java.io.Serializable; /** - * To represent the semantics of the generic relation between two entities. It has the following parameters: - * - private String name to store the semantics of the relation (i.e. isAuthorInstitutionOf). It corresponds to the - * relclass parameter in the relation represented in the internal model - * represented in the internal model - * - private String type to store the type of the relation (i.e. affiliation). It corresponds to the subreltype parameter - * of the relation represented in theinternal model + * To represent the semantics of the generic relation between two entities. It has the following parameters: - private + * String name to store the semantics of the relation (i.e. isAuthorInstitutionOf). It corresponds to the relclass + * parameter in the relation represented in the internal model represented in the internal model - private String type + * to store the type of the relation (i.e. affiliation). It corresponds to the subreltype parameter of the relation + * represented in theinternal model */ public class RelType implements Serializable { private String name; // relclass diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Relation.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Relation.java index 4b88eb6c27..e2b126e63b 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Relation.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Relation.java @@ -7,11 +7,10 @@ import java.util.Objects; import eu.dnetlib.dhp.schema.dump.oaf.Provenance; /** - * To represent the gereric relation between two entities. It has the following parameters: - * - private Node source to represent the entity source of the relation - * - private Node target to represent the entity target of the relation - * - private RelType reltype to represent the semantics of the relation - * - private Provenance provenance to represent the provenance of the relation + * To represent the gereric relation between two entities. It has the following parameters: - private Node source to + * represent the entity source of the relation - private Node target to represent the entity target of the relation - + * private RelType reltype to represent the semantics of the relation - private Provenance provenance to represent the + * provenance of the relation */ public class Relation implements Serializable { private Node source; diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/ResearchInitiative.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/ResearchInitiative.java index 6646fd541e..ad4ad8877b 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/ResearchInitiative.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/ResearchInitiative.java @@ -5,13 +5,17 @@ import java.io.Serializable; /** * To represent entity of type RC/RI. It has the following parameters, which are mostly derived by the profile - * - private String id to store the openaire id for the entity. Is has as code 00 and will be created as - * 00|context_____::md5(originalId) - * private String originalId to store the id of the context as provided in the profile (i.e. mes) - * private String name to store the name of the context (got from the label attribute in the context definition) - * private String type to store the type of the context (i.e.: research initiative or research community) - * private String description to store the description of the context as given in the profile - * private String zenodo_community to store the zenodo community associated to the context (main zenodo community) + * - private + * String id to store the openaire id for the entity. Is has as code 00 and will be created as + * 00|context_____::md5(originalId) private + * String originalId to store the id of the context as provided in the profile + * (i.e. mes) + * - private String name to store the name of the context (got from the label attribute in the context + * definition) + * - private String type to store the type of the context (i.e.: research initiative or research community) + * - private String description to store the description of the context as given in the profile + * -private String + * zenodo_community to store the zenodo community associated to the context (main zenodo community) */ public class ResearchInitiative implements Serializable { private String id; // openaireId diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/PrepareProgramme.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/PrepareProgramme.java index 7f0ca983f5..b2d3253d57 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/PrepareProgramme.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/PrepareProgramme.java @@ -4,6 +4,7 @@ package eu.dnetlib.dhp.actionmanager.project; import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -11,6 +12,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaRDD; +import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.api.java.function.MapFunction; import org.apache.spark.sql.*; import org.slf4j.Logger; @@ -175,43 +177,54 @@ public class PrepareProgramme { return csvProgramme; }); - prepareClassification(h2020Programmes); + // prepareClassification(h2020Programmes); - h2020Programmes - .map(csvProgramme -> OBJECT_MAPPER.writeValueAsString(csvProgramme)) + JavaSparkContext jsc = new JavaSparkContext(spark.sparkContext()); + + JavaRDD rdd = jsc.parallelize(prepareClassification(h2020Programmes), 1); + rdd + .map(csvProgramme -> { + String tmp = OBJECT_MAPPER.writeValueAsString(csvProgramme); + return tmp; + }) .saveAsTextFile(outputPath); } - private static void prepareClassification(JavaRDD h2020Programmes) { + private static List prepareClassification(JavaRDD h2020Programmes) { Object[] codedescription = h2020Programmes - .map(value -> new Tuple2<>(value.getCode(), value.getTitle())) + .map( + value -> new Tuple2<>(value.getCode(), + new Tuple2(value.getTitle(), value.getShortTitle()))) .collect() .toArray(); for (int i = 0; i < codedescription.length - 1; i++) { for (int j = i + 1; j < codedescription.length; j++) { - Tuple2 t2i = (Tuple2) codedescription[i]; - Tuple2 t2j = (Tuple2) codedescription[j]; + Tuple2> t2i = (Tuple2>) codedescription[i]; + Tuple2> t2j = (Tuple2>) codedescription[j]; if (t2i._1().compareTo(t2j._1()) > 0) { - Tuple2 temp = t2i; + Tuple2> temp = t2i; codedescription[i] = t2j; codedescription[j] = temp; } } } - Map map = new HashMap<>(); + Map> map = new HashMap<>(); for (int j = 0; j < codedescription.length; j++) { - Tuple2 entry = (Tuple2) codedescription[j]; + Tuple2> entry = (Tuple2>) codedescription[j]; String ent = entry._1(); if (ent.contains("Euratom-")) { ent = ent.replace("-Euratom-", ".Euratom."); } String[] tmp = ent.split("\\."); if (tmp.length <= 2) { - map.put(entry._1(), entry._2()); - + if (StringUtils.isEmpty(entry._2()._2())) { + map.put(entry._1(), new Tuple2(entry._2()._1(), entry._2()._1())); + } else { + map.put(entry._1(), entry._2()); + } } else { if (ent.endsWith(".")) { ent = ent.substring(0, ent.length() - 1); @@ -224,14 +237,14 @@ public class PrepareProgramme { key = key.substring(0, key.length() - 1); } } - String current = entry._2(); + String current = entry._2()._1(); if (!ent.contains("Euratom")) { String parent; String tmp_key = tmp[0] + "."; for (int i = 1; i < tmp.length - 1; i++) { tmp_key += tmp[i] + "."; - parent = map.get(tmp_key).toLowerCase().trim(); + parent = map.get(tmp_key)._1().toLowerCase().trim(); if (parent.contains("|")) { parent = parent.substring(parent.lastIndexOf("|") + 1).trim(); } @@ -246,18 +259,29 @@ public class PrepareProgramme { } } - map.put(ent + ".", map.get(key) + " | " + current); + String shortTitle = entry._2()._2(); + if (StringUtils.isEmpty(shortTitle)) { + shortTitle = current; + } + Tuple2 newEntry = new Tuple2<>(map.get(key)._1() + " | " + current, + map.get(key)._2() + " | " + shortTitle); + map.put(ent + ".", newEntry); } } - h2020Programmes.foreach(csvProgramme -> { - if (!csvProgramme.getCode().endsWith(".") && !csvProgramme.getCode().contains("Euratom") - && !csvProgramme.getCode().equals("H2020-EC")) - csvProgramme.setClassification(map.get(csvProgramme.getCode() + ".")); - else - csvProgramme.setClassification(map.get(csvProgramme.getCode())); - }); + return h2020Programmes.map(csvProgramme -> { + + String code = csvProgramme.getCode(); + if (!code.endsWith(".") && !code.contains("Euratom") + && !code.equals("H2020-EC")) + code += "."; + + csvProgramme.setClassification(map.get(code)._1()); + csvProgramme.setClassification_short(map.get(code)._2()); + + return csvProgramme; + }).collect(); } public static Dataset readPath( diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/SparkAtomicActionJob.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/SparkAtomicActionJob.java index f2375e799e..a583b7bfa2 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/SparkAtomicActionJob.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/SparkAtomicActionJob.java @@ -9,7 +9,6 @@ import java.util.Objects; import java.util.Optional; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapred.SequenceFileOutputFormat; import org.apache.spark.SparkConf; @@ -138,7 +137,8 @@ public class SparkAtomicActionJob { pm.setCode(csvProject.getProgramme()); h2020classification.setClassification(ocsvProgramme.get().getClassification()); h2020classification.setH2020Programme(pm); - setLevelsAndProgramme(h2020classification, ocsvProgramme.get().getClassification()); + setLevelsandProgramme(h2020classification, ocsvProgramme.get().getClassification_short()); + // setProgramme(h2020classification, ocsvProgramme.get().getClassification()); pp.setH2020classification(Arrays.asList(h2020classification)); return pp; @@ -177,8 +177,8 @@ public class SparkAtomicActionJob { } - private static void setLevelsAndProgramme(H2020Classification h2020Classification, String classification) { - String[] tmp = classification.split(" \\| "); + private static void setLevelsandProgramme(H2020Classification h2020Classification, String classification_short) { + String[] tmp = classification_short.split(" \\| "); h2020Classification.setLevel1(tmp[0]); if (tmp.length > 1) { h2020Classification.setLevel2(tmp[1]); @@ -189,6 +189,12 @@ public class SparkAtomicActionJob { h2020Classification.getH2020Programme().setDescription(tmp[tmp.length - 1]); } +// private static void setProgramme(H2020Classification h2020Classification, String classification) { +// String[] tmp = classification.split(" \\| "); +// +// h2020Classification.getH2020Programme().setDescription(tmp[tmp.length - 1]); +// } + public static Dataset readPath( SparkSession spark, String inputPath, Class clazz) { return spark diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/utils/CSVProgramme.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/utils/CSVProgramme.java index 6f9a59087b..f991a4297b 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/utils/CSVProgramme.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/utils/CSVProgramme.java @@ -22,6 +22,15 @@ public class CSVProgramme implements Serializable { private String shortTitle; private String language; private String classification; + private String classification_short; + + public String getClassification_short() { + return classification_short; + } + + public void setClassification_short(String classification_short) { + this.classification_short = classification_short; + } public String getClassification() { return classification; diff --git a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/EXCELParserTest.java b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/EXCELParserTest.java index fdc577687c..59b536cd54 100644 --- a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/EXCELParserTest.java +++ b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/EXCELParserTest.java @@ -9,12 +9,14 @@ import java.util.List; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import eu.dnetlib.dhp.actionmanager.project.httpconnector.CollectorServiceException; import eu.dnetlib.dhp.actionmanager.project.httpconnector.HttpConnector; import eu.dnetlib.dhp.actionmanager.project.utils.EXCELParser; +@Disabled public class EXCELParserTest { private static Path workingDir; diff --git a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/PrepareH2020ProgrammeTest.java b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/PrepareH2020ProgrammeTest.java index c5801bcccb..256dc05213 100644 --- a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/PrepareH2020ProgrammeTest.java +++ b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/PrepareH2020ProgrammeTest.java @@ -92,6 +92,8 @@ public class PrepareH2020ProgrammeTest { Assertions.assertEquals(0, verificationDataset.filter("classification = ''").count()); + // tmp.foreach(csvProgramme -> System.out.println(OBJECT_MAPPER.writeValueAsString(csvProgramme))); + Assertions .assertEquals( "Societal challenges | Smart, Green And Integrated Transport | CLEANSKY2 | IADP Fast Rotorcraft", diff --git a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/SparkUpdateProjectTest.java b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/SparkUpdateProjectTest.java index cfda7e7181..42e4946816 100644 --- a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/SparkUpdateProjectTest.java +++ b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/SparkUpdateProjectTest.java @@ -78,7 +78,7 @@ public class SparkUpdateProjectTest { "-programmePath", getClass() .getResource( - "/eu/dnetlib/dhp/actionmanager/project/preparedProgramme_classification_whole.json.gz") + "/eu/dnetlib/dhp/actionmanager/project/preparedProgramme_whole.json.gz") .getPath(), "-projectPath", getClass().getResource("/eu/dnetlib/dhp/actionmanager/project/prepared_projects.json").getPath(), @@ -124,7 +124,7 @@ public class SparkUpdateProjectTest { .getString(0)); Assertions .assertEquals( - "Societal challenges", + "Societal Challenges", execverification .filter("id = '40|corda__h2020::2c7298913008865ba784e5c1350a0aa5'") .select("classification.level1") @@ -133,7 +133,7 @@ public class SparkUpdateProjectTest { .getString(0)); Assertions .assertEquals( - "Smart, Green And Integrated Transport", + "Transport", execverification .filter("id = '40|corda__h2020::2c7298913008865ba784e5c1350a0aa5'") .select("classification.level2") @@ -188,7 +188,7 @@ public class SparkUpdateProjectTest { .getString(0)); Assertions .assertEquals( - "Nurturing excellence by means of cross-border and cross-sector mobility", + "MSCA Mobility", execverification .filter("id = '40|corda__h2020::1a1f235fdd06ef14790baec159aa1202'") .select("classification.h2020Programme.description") @@ -197,7 +197,7 @@ public class SparkUpdateProjectTest { .getString(0)); Assertions .assertEquals( - "Excellent science", + "Excellent Science", execverification .filter("id = '40|corda__h2020::1a1f235fdd06ef14790baec159aa1202'") .select("classification.level1") @@ -206,7 +206,7 @@ public class SparkUpdateProjectTest { .getString(0)); Assertions .assertEquals( - "Marie Skłodowska-Curie Actions", + "Marie-Sklodowska-Curie Actions", execverification .filter("id = '40|corda__h2020::1a1f235fdd06ef14790baec159aa1202'") .select("classification.level2") @@ -215,7 +215,7 @@ public class SparkUpdateProjectTest { .getString(0)); Assertions .assertEquals( - "Nurturing excellence by means of cross-border and cross-sector mobility", + "MSCA Mobility", execverification .filter("id = '40|corda__h2020::1a1f235fdd06ef14790baec159aa1202'") .select("classification.level3") diff --git a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/httpconnector/HttpConnectorTest.java b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/httpconnector/HttpConnectorTest.java index 8bcf08906d..90b3919ed9 100644 --- a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/httpconnector/HttpConnectorTest.java +++ b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/httpconnector/HttpConnectorTest.java @@ -6,8 +6,10 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.ssl.SSLContextBuilder; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +@Disabled public class HttpConnectorTest { private static final Log log = LogFactory.getLog(HttpConnectorTest.class); diff --git a/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/preparedProgramme_classification_whole.json.gz b/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/preparedProgramme_classification_whole.json.gz deleted file mode 100644 index d40bac8c6f..0000000000 Binary files a/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/preparedProgramme_classification_whole.json.gz and /dev/null differ diff --git a/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/preparedProgramme_whole.json.gz b/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/preparedProgramme_whole.json.gz index 1afa730616..01e804ff5b 100644 Binary files a/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/preparedProgramme_whole.json.gz and b/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/preparedProgramme_whole.json.gz differ diff --git a/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/whole_programme.json.gz b/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/whole_programme.json.gz index 60c3bf05ac..8b1982deea 100644 Binary files a/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/whole_programme.json.gz and b/dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/project/whole_programme.json.gz differ diff --git a/dhp-workflows/dhp-doiboost/src/test/java/eu/dnetlib/dhp/doiboost/QueryTest.scala b/dhp-workflows/dhp-doiboost/src/test/java/eu/dnetlib/dhp/doiboost/QueryTest.scala index 2437195490..61c1f51119 100644 --- a/dhp-workflows/dhp-doiboost/src/test/java/eu/dnetlib/dhp/doiboost/QueryTest.scala +++ b/dhp-workflows/dhp-doiboost/src/test/java/eu/dnetlib/dhp/doiboost/QueryTest.scala @@ -1,6 +1,6 @@ package eu.dnetlib.dhp.doiboost -import eu.dnetlib.dhp.schema.oaf.Publication +import eu.dnetlib.dhp.schema.oaf.{Publication, Relation} import org.apache.spark.SparkContext import org.apache.spark.sql.{Dataset, Encoder, Encoders, SparkSession} import org.codehaus.jackson.map.{ObjectMapper, SerializationConfig} @@ -21,6 +21,13 @@ class QueryTest { + } + + + def has_ands(r:Relation) :Boolean = { + + r.getCollectedfrom!= null && r.getCollectedfrom.asScala.count(k => k.getValue.contains("Australian")) > 0 + } def hasInstanceWithUrl(p:Publication):Boolean = { @@ -38,6 +45,8 @@ class QueryTest { def myQuery(spark:SparkSession, sc:SparkContext): Unit = { implicit val mapEncoderPub: Encoder[Publication] = Encoders.kryo[Publication] + + val mapper = new ObjectMapper() mapper.getSerializationConfig.enable(SerializationConfig.Feature.INDENT_OUTPUT) diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/CleaningFunctions.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/CleaningFunctions.java index 84f88003b2..56a4aaf5a1 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/CleaningFunctions.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/CleaningFunctions.java @@ -18,6 +18,7 @@ import eu.dnetlib.dhp.schema.oaf.*; public class CleaningFunctions { public static final String ORCID_PREFIX_REGEX = "^http(s?):\\/\\/orcid\\.org\\/"; + public static final String NONE = "none"; public static T fixVocabularyNames(T value) { if (value instanceof Datasource) { @@ -106,6 +107,23 @@ public class CleaningFunctions { .filter(sp -> StringUtils.isNotBlank(sp.getQualifier().getClassid())) .collect(Collectors.toList())); } + if (Objects.nonNull(r.getPid())) { + r + .setPid( + r + .getPid() + .stream() + .filter(Objects::nonNull) + .filter(sp -> StringUtils.isNotBlank(StringUtils.trim(sp.getValue()))) + .filter(sp -> NONE.equalsIgnoreCase(sp.getValue())) + .filter(sp -> Objects.nonNull(sp.getQualifier())) + .filter(sp -> StringUtils.isNotBlank(sp.getQualifier().getClassid())) + .map(sp -> { + sp.setValue(StringUtils.trim(sp.getValue())); + return sp; + }) + .collect(Collectors.toList())); + } if (Objects.isNull(r.getResourcetype()) || StringUtils.isBlank(r.getResourcetype().getClassid())) { r .setResourcetype( diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/DumpProducts.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/DumpProducts.java index 8a6c913952..1279ede533 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/DumpProducts.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/DumpProducts.java @@ -11,6 +11,7 @@ import java.util.Set; import java.util.stream.Collectors; import org.apache.spark.SparkConf; +import org.apache.spark.api.java.function.FilterFunction; import org.apache.spark.api.java.function.MapFunction; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Encoders; diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/MakeTar.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/MakeTar.java index 1999601045..00ddcb5a86 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/MakeTar.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/MakeTar.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.oa.graph.dump; import java.io.*; +import java.util.Optional; import org.apache.commons.compress.archivers.ar.ArArchiveEntry; import org.apache.commons.compress.archivers.ar.ArArchiveOutputStream; @@ -14,6 +15,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import eu.dnetlib.dhp.application.ArgumentApplicationParser; +import eu.dnetlib.dhp.common.MakeTarArchive; import eu.dnetlib.dhp.oa.graph.dump.community.CommunityMap; public class MakeTar implements Serializable { @@ -39,16 +41,22 @@ public class MakeTar implements Serializable { final String inputPath = parser.get("sourcePath"); log.info("input path : {}", inputPath); + final int gBperSplit = Optional + .ofNullable(parser.get("splitSize")) + .map(Integer::valueOf) + .orElse(10); + Configuration conf = new Configuration(); conf.set("fs.defaultFS", hdfsNameNode); FileSystem fileSystem = FileSystem.get(conf); - makeTArArchive(fileSystem, inputPath, outputPath); + makeTArArchive(fileSystem, inputPath, outputPath, gBperSplit); } - public static void makeTArArchive(FileSystem fileSystem, String inputPath, String outputPath) throws IOException { + public static void makeTArArchive(FileSystem fileSystem, String inputPath, String outputPath, int gBperSplit) + throws IOException { RemoteIterator dir_iterator = fileSystem.listLocatedStatus(new Path(inputPath)); @@ -59,56 +67,9 @@ public class MakeTar implements Serializable { String p_string = p.toString(); String entity = p_string.substring(p_string.lastIndexOf("/") + 1); - write(fileSystem, p_string, outputPath + "/" + entity + ".tar", entity); + MakeTarArchive.tarMaxSize(fileSystem, p_string, outputPath + "/" + entity, entity, gBperSplit); } } - private static void write(FileSystem fileSystem, String inputPath, String outputPath, String dir_name) - throws IOException { - - Path hdfsWritePath = new Path(outputPath); - FSDataOutputStream fsDataOutputStream = null; - if (fileSystem.exists(hdfsWritePath)) { - fileSystem.delete(hdfsWritePath, true); - - } - fsDataOutputStream = fileSystem.create(hdfsWritePath); - - TarArchiveOutputStream ar = new TarArchiveOutputStream(fsDataOutputStream.getWrappedStream()); - - RemoteIterator fileStatusListIterator = fileSystem - .listFiles( - new Path(inputPath), true); - - while (fileStatusListIterator.hasNext()) { - LocatedFileStatus fileStatus = fileStatusListIterator.next(); - - Path p = fileStatus.getPath(); - String p_string = p.toString(); - if (!p_string.endsWith("_SUCCESS")) { - String name = p_string.substring(p_string.lastIndexOf("/") + 1); - TarArchiveEntry entry = new TarArchiveEntry(dir_name + "/" + name + ".json.gz"); - entry.setSize(fileStatus.getLen()); - ar.putArchiveEntry(entry); - - InputStream is = fileSystem.open(fileStatus.getPath()); - - BufferedInputStream bis = new BufferedInputStream(is); - - int count; - byte data[] = new byte[1024]; - while ((count = bis.read(data, 0, data.length)) != -1) { - ar.write(data, 0, count); - } - bis.close(); - ar.closeArchiveEntry(); - - } - - } - - ar.close(); - } - } diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java index 41142d2851..4c3bc0dd52 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java @@ -9,8 +9,10 @@ import org.apache.commons.lang3.StringUtils; import eu.dnetlib.dhp.schema.common.ModelConstants; import eu.dnetlib.dhp.schema.dump.oaf.*; +import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityInstance; import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityResult; import eu.dnetlib.dhp.schema.dump.oaf.community.Context; +import eu.dnetlib.dhp.schema.dump.oaf.graph.GraphResult; import eu.dnetlib.dhp.schema.oaf.DataInfo; import eu.dnetlib.dhp.schema.oaf.Field; import eu.dnetlib.dhp.schema.oaf.Journal; @@ -18,12 +20,12 @@ import eu.dnetlib.dhp.schema.oaf.StructuredProperty; public class ResultMapper implements Serializable { - public static Result map( - I in, Map communityMap, boolean graph) { + public static Result map( + E in, Map communityMap, boolean graph) { Result out; if (graph) { - out = new Result(); + out = new GraphResult(); } else { out = new CommunityResult(); } @@ -154,7 +156,6 @@ public class ResultMapper implements Serializable { .ifPresent(value -> value.stream().forEach(c -> contributorList.add(c.getValue()))); out.setContributor(contributorList); - // List countryList = new ArrayList<>(); Optional .ofNullable(input.getCountry()) .ifPresent( @@ -186,8 +187,6 @@ public class ResultMapper implements Serializable { .filter(Objects::nonNull) .collect(Collectors.toList()))); - // out.setCountry(countryList); - final List coverageList = new ArrayList<>(); Optional .ofNullable(input.getCoverage()) @@ -214,15 +213,19 @@ public class ResultMapper implements Serializable { out.setId(input.getId()); out.setOriginalId(input.getOriginalId()); - final List instanceList = new ArrayList<>(); - Optional - .ofNullable(input.getInstance()) - .ifPresent( - inst -> inst - .stream() - .forEach(i -> instanceList.add(getInstance(i, graph)))); - out - .setInstance(instanceList); + Optional> oInst = Optional + .ofNullable(input.getInstance()); + + if (oInst.isPresent()) { + if (graph) { + ((GraphResult) out) + .setInstance(oInst.get().stream().map(i -> getGraphInstance(i)).collect(Collectors.toList())); + } else { + ((CommunityResult) out) + .setInstance( + oInst.get().stream().map(i -> getCommunityInstance(i)).collect(Collectors.toList())); + } + } Optional oL = Optional.ofNullable(input.getLanguage()); if (oL.isPresent()) { @@ -364,20 +367,34 @@ public class ResultMapper implements Serializable { } - private static Instance getInstance(eu.dnetlib.dhp.schema.oaf.Instance i, boolean graph) { - + private static Instance getGraphInstance(eu.dnetlib.dhp.schema.oaf.Instance i) { Instance instance = new Instance(); - if (!graph) { - instance - .setCollectedfrom( - KeyValue - .newInstance(i.getCollectedfrom().getKey(), i.getCollectedfrom().getValue())); - instance - .setHostedby( - KeyValue.newInstance(i.getHostedby().getKey(), i.getHostedby().getValue())); - } + setCommonValue(i, instance); + return instance; + + } + + private static CommunityInstance getCommunityInstance(eu.dnetlib.dhp.schema.oaf.Instance i) { + CommunityInstance instance = new CommunityInstance(); + + setCommonValue(i, instance); + + instance + .setCollectedfrom( + KeyValue + .newInstance(i.getCollectedfrom().getKey(), i.getCollectedfrom().getValue())); + + instance + .setHostedby( + KeyValue.newInstance(i.getHostedby().getKey(), i.getHostedby().getValue())); + + return instance; + + } + + private static void setCommonValue(eu.dnetlib.dhp.schema.oaf.Instance i, I instance) { Optional opAr = Optional .ofNullable(i.getAccessright()); if (opAr.isPresent()) { @@ -402,21 +419,17 @@ public class ResultMapper implements Serializable { Optional .ofNullable(i.getRefereed()) .ifPresent(value -> instance.setRefereed(value.getClassname())); - // .ifPresent(value -> instance.setRefereed(value.getValue())); Optional .ofNullable(i.getInstancetype()) .ifPresent(value -> instance.setType(value.getClassname())); Optional.ofNullable(i.getUrl()).ifPresent(value -> instance.setUrl(value)); - return instance; } private static List getUniqueProvenance(List provenance) { Provenance iProv = new Provenance(); - // iProv.setProvenance(Constants.INFERRED); Provenance hProv = new Provenance(); - // hProv.setProvenance(Constants.HARVESTED); Provenance lProv = new Provenance(); for (Provenance p : provenance) { diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SendToZenodoHDFS.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SendToZenodoHDFS.java index 23784cd66c..fd8262544c 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SendToZenodoHDFS.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SendToZenodoHDFS.java @@ -17,6 +17,10 @@ import eu.dnetlib.dhp.oa.graph.dump.community.CommunityMap; public class SendToZenodoHDFS implements Serializable { + private final static String NEW = "new"; // to be used for a brand new deposition in zenodo + private final static String VERSION = "version"; // to be used to upload a new version of a published deposition + private final static String UPDATE = "update"; // to upload content to an open deposition not published + private static final Log log = LogFactory.getLog(SendToZenodoHDFS.class); public static void main(final String[] args) throws Exception, MissingConceptDoiException { @@ -34,10 +38,16 @@ public class SendToZenodoHDFS implements Serializable { final String access_token = parser.get("accessToken"); final String connection_url = parser.get("connectionUrl"); final String metadata = parser.get("metadata"); - final Boolean newDeposition = Boolean.valueOf(parser.get("newDeposition")); + final String depositionType = parser.get("depositionType"); final String concept_rec_id = Optional .ofNullable(parser.get("conceptRecordId")) .orElse(null); + final Boolean publish = Optional + .ofNullable(parser.get("publish")) + .map(Boolean::valueOf) + .orElse(false); + + final String depositionId = Optional.ofNullable(parser.get("depositionId")).orElse(null); final String communityMapPath = parser.get("communityMapPath"); Configuration conf = new Configuration(); @@ -51,13 +61,22 @@ public class SendToZenodoHDFS implements Serializable { .listFiles( new Path(hdfsPath), true); ZenodoAPIClient zenodoApiClient = new ZenodoAPIClient(connection_url, access_token); - if (newDeposition) { - zenodoApiClient.newDeposition(); - } else { - if (concept_rec_id == null) { - throw new MissingConceptDoiException("No concept record id has been provided"); - } - zenodoApiClient.newVersion(concept_rec_id); + switch (depositionType) { + case NEW: + zenodoApiClient.newDeposition(); + break; + case VERSION: + if (concept_rec_id == null) { + throw new MissingConceptDoiException("No concept record id has been provided"); + } + zenodoApiClient.newVersion(concept_rec_id); + break; + case UPDATE: + if (depositionId == null) { + throw new MissingConceptDoiException("No deposition id has been provided"); + } + zenodoApiClient.uploadOpenDeposition(depositionId); + break; } while (fileStatusListIterator.hasNext()) { @@ -79,9 +98,12 @@ public class SendToZenodoHDFS implements Serializable { } } + if (!metadata.equals("")) { + zenodoApiClient.sendMretadata(metadata); + } - zenodoApiClient.sendMretadata(metadata); - zenodoApiClient.publish(); + if (publish) + zenodoApiClient.publish(); } diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/Utils.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/Utils.java index c112c5c724..984e8b128c 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/Utils.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/Utils.java @@ -17,7 +17,7 @@ import com.google.gson.Gson; import eu.dnetlib.dhp.common.HdfsSupport; import eu.dnetlib.dhp.oa.graph.dump.community.CommunityMap; -import eu.dnetlib.dhp.oa.graph.dump.graph.Constants; +import eu.dnetlib.dhp.oa.graph.dump.complete.Constants; import eu.dnetlib.dhp.utils.DHPUtils; import eu.dnetlib.dhp.utils.ISLookupClientFactory; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; @@ -70,4 +70,5 @@ public class Utils { return new Gson().fromJson(sb.toString(), CommunityMap.class); } + } diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/community/SparkPrepareResultProject.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/community/SparkPrepareResultProject.java index 6e0e059f3d..39850b5b8e 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/community/SparkPrepareResultProject.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/community/SparkPrepareResultProject.java @@ -135,12 +135,17 @@ public class SparkPrepareResultProject implements Serializable { .orElse(null), Optional .ofNullable(op.getFundingtree()) - .map( - value -> value + .map(value -> { + List tmp = value .stream() .map(ft -> getFunder(ft.getValue())) - .collect(Collectors.toList()) - .get(0)) + .collect(Collectors.toList()); + if (tmp.size() > 0) { + return tmp.get(0); + } else { + return null; + } + }) .orElse(null)); Optional di = Optional.ofNullable(op.getDataInfo()); diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/Constants.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/Constants.java similarity index 89% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/Constants.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/Constants.java index 4c1e1c08cf..eb546624e5 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/Constants.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/Constants.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.Serializable; @@ -21,6 +21,7 @@ public class Constants implements Serializable { public static final String CONTEXT_ID = "00"; public static final String CONTEXT_NS_PREFIX = "context_____"; + public static final String UNKNOWN = "UNKNOWN"; // public static final String FUNDER_DS = "entityregistry::projects"; } diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/ContextInfo.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/ContextInfo.java similarity index 97% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/ContextInfo.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/ContextInfo.java index 7befaaf6f3..982a69afb9 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/ContextInfo.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/ContextInfo.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.Serializable; import java.util.List; diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateContextEntities.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateContextEntities.java similarity index 96% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateContextEntities.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateContextEntities.java index 0f28438afb..23224f8dba 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateContextEntities.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateContextEntities.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.BufferedWriter; import java.io.IOException; @@ -38,7 +38,7 @@ public class CreateContextEntities implements Serializable { .toString( CreateContextEntities.class .getResourceAsStream( - "/eu/dnetlib/dhp/oa/graph/dump_whole/input_entity_parameter.json")); + "/eu/dnetlib/dhp/oa/graph/dump/complete/input_entity_parameter.json")); final ArgumentApplicationParser parser = new ArgumentApplicationParser(jsonConfiguration); parser.parseArgument(args); diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateContextRelation.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateContextRelation.java similarity index 97% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateContextRelation.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateContextRelation.java index 1290779321..102406315b 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateContextRelation.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateContextRelation.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.BufferedWriter; import java.io.IOException; @@ -44,7 +44,7 @@ public class CreateContextRelation implements Serializable { .toString( CreateContextRelation.class .getResourceAsStream( - "/eu/dnetlib/dhp/oa/graph/dump_whole/input_entity_parameter.json")); + "/eu/dnetlib/dhp/oa/graph/dump/complete/input_entity_parameter.json")); final ArgumentApplicationParser parser = new ArgumentApplicationParser(jsonConfiguration); parser.parseArgument(args); diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/DumpGraphEntities.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/DumpGraphEntities.java similarity index 97% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/DumpGraphEntities.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/DumpGraphEntities.java index 3851c5d354..773068dfb2 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/DumpGraphEntities.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/DumpGraphEntities.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession; @@ -48,7 +48,7 @@ public class DumpGraphEntities implements Serializable { DumpProducts d = new DumpProducts(); d .run( - isSparkSessionManaged, inputPath, outputPath, communityMapPath, inputClazz, Result.class, + isSparkSessionManaged, inputPath, outputPath, communityMapPath, inputClazz, GraphResult.class, true); break; case "40": @@ -379,17 +379,16 @@ public class DumpGraphEntities implements Serializable { } project - .setH2020Classifications( + .setH2020programme( Optional .ofNullable(p.getH2020classification()) .map( classification -> classification .stream() .map( - c -> H2020Classification + c -> Programme .newInstance( - c.getH2020Programme().getCode(), c.getH2020Programme().getDescription(), - c.getLevel1(), c.getLevel2(), c.getLevel3(), c.getClassification())) + c.getH2020Programme().getCode(), c.getH2020Programme().getDescription())) .collect(Collectors.toList())) .orElse(new ArrayList<>())); @@ -488,7 +487,12 @@ public class DumpGraphEntities implements Serializable { Optional .ofNullable(org.getCountry()) .ifPresent( - value -> organization.setCountry(Qualifier.newInstance(value.getClassid(), value.getClassname()))); + value -> { + if (!value.getClassid().equals(Constants.UNKNOWN)) { + organization.setCountry(Qualifier.newInstance(value.getClassid(), value.getClassname())); + } + + }); Optional .ofNullable(org.getId()) diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/Extractor.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/Extractor.java similarity index 89% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/Extractor.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/Extractor.java index 3daaed47f4..31886d1b13 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/Extractor.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/Extractor.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession; @@ -23,13 +23,12 @@ import eu.dnetlib.dhp.schema.oaf.KeyValue; import eu.dnetlib.dhp.schema.oaf.Result; /** - * Creates new Relations (as in eu.dnetlib.dhp.schema.dump.oaf.graph.Relation) from the information in the Entity. - * The new Relations are created for the datasource in the collectedfrom and hostedby elements and for the context - * related to communities and research initiative/infrastructures. - * - * For collectedfrom elements it creates: datasource -> provides -> result and result -> isProvidedBy -> datasource - * For hostedby elements it creates: datasource -> hosts -> result and result -> isHostedBy -> datasource - * For context elements it creates: context <-> isRelatedTo <-> result + * Creates new Relations (as in eu.dnetlib.dhp.schema.dump.oaf.graph.Relation) from the information in the Entity. The + * new Relations are created for the datasource in the collectedfrom and hostedby elements and for the context related + * to communities and research initiative/infrastructures. For collectedfrom elements it creates: datasource -> provides + * -> result and result -> isProvidedBy -> datasource For hostedby elements it creates: datasource -> hosts -> result + * and result -> isHostedBy -> datasource For context elements it creates: context <-> isRelatedTo <-> result. Note for + * context: it gets the first provenance in the dataInfo. If more than one is present the others are not dumped */ public class Extractor implements Serializable { diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/MergedRels.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/MergedRels.java similarity index 91% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/MergedRels.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/MergedRels.java index 5f59750eac..30088e8d01 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/MergedRels.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/MergedRels.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.Serializable; diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/OrganizationMap.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/OrganizationMap.java similarity index 87% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/OrganizationMap.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/OrganizationMap.java index 11db7c25e4..bf6cdbd14c 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/OrganizationMap.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/OrganizationMap.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.util.ArrayList; import java.util.HashMap; diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/Process.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/Process.java similarity index 87% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/Process.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/Process.java index 7b7dafdf37..31d105b66f 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/Process.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/Process.java @@ -1,10 +1,11 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,9 +17,8 @@ import eu.dnetlib.dhp.schema.dump.oaf.Provenance; import eu.dnetlib.dhp.schema.dump.oaf.graph.*; /** - * It process the ContextInfo information to produce a new Context Entity or a set of Relations between the - * generic context entity and datasource/projects related to the context. - * + * It process the ContextInfo information to produce a new Context Entity or a set of Relations between the generic + * context entity and datasource/projects related to the context. */ public class Process implements Serializable { private static final Logger log = LoggerFactory.getLogger(Process.class); @@ -39,7 +39,9 @@ public class Process implements Serializable { ri.setDescription(ci.getDescription()); ri.setName(ci.getName()); - ri.setZenodo_community(Constants.ZENODO_COMMUNITY_PREFIX + ci.getZenodocommunity()); + if (StringUtils.isNotEmpty(ci.getZenodocommunity())) { + ri.setZenodo_community(Constants.ZENODO_COMMUNITY_PREFIX + ci.getZenodocommunity()); + } return (R) ri; } catch (final Exception e) { diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/QueryInformationSystem.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystem.java similarity index 92% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/QueryInformationSystem.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystem.java index e74d8a44c7..c33a693a54 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/QueryInformationSystem.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystem.java @@ -1,13 +1,9 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.StringReader; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; import java.util.*; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.dom4j.Document; import org.dom4j.DocumentException; @@ -16,8 +12,6 @@ import org.dom4j.Node; import org.dom4j.io.SAXReader; import org.jetbrains.annotations.NotNull; -import eu.dnetlib.dhp.schema.common.ModelSupport; -import eu.dnetlib.dhp.schema.dump.oaf.graph.ResearchInitiative; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkCollectAndSave.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkCollectAndSave.java similarity index 60% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkCollectAndSave.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkCollectAndSave.java index cb150210ab..671bccd25c 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkCollectAndSave.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkCollectAndSave.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession; @@ -8,6 +8,7 @@ import java.util.Optional; import org.apache.commons.io.IOUtils; import org.apache.spark.SparkConf; +import org.apache.spark.sql.Dataset; import org.apache.spark.sql.SaveMode; import org.apache.spark.sql.SparkSession; import org.slf4j.Logger; @@ -15,12 +16,11 @@ import org.slf4j.LoggerFactory; import eu.dnetlib.dhp.application.ArgumentApplicationParser; import eu.dnetlib.dhp.oa.graph.dump.Utils; -import eu.dnetlib.dhp.schema.dump.oaf.Result; +import eu.dnetlib.dhp.schema.dump.oaf.graph.GraphResult; import eu.dnetlib.dhp.schema.dump.oaf.graph.Relation; /** * Reads all the entities of the same type (Relation / Results) and saves them in the same folder - * */ public class SparkCollectAndSave implements Serializable { @@ -31,7 +31,7 @@ public class SparkCollectAndSave implements Serializable { .toString( SparkCollectAndSave.class .getResourceAsStream( - "/eu/dnetlib/dhp/oa/graph/dump_whole/input_collect_and_save.json")); + "/eu/dnetlib/dhp/oa/graph/dump/complete/input_collect_and_save.json")); final ArgumentApplicationParser parser = new ArgumentApplicationParser(jsonConfiguration); parser.parseArgument(args); @@ -48,6 +48,11 @@ public class SparkCollectAndSave implements Serializable { final String outputPath = parser.get("outputPath"); log.info("outputPath: {}", outputPath); + final Boolean aggregateResult = Optional + .ofNullable(parser.get("resultAggregation")) + .map(Boolean::valueOf) + .orElse(Boolean.TRUE); + SparkConf conf = new SparkConf(); runWithSparkSession( @@ -55,22 +60,42 @@ public class SparkCollectAndSave implements Serializable { isSparkSessionManaged, spark -> { Utils.removeOutputDir(spark, outputPath + "/result"); - run(spark, inputPath, outputPath); + run(spark, inputPath, outputPath, aggregateResult); }); } - private static void run(SparkSession spark, String inputPath, String outputPath) { - Utils - .readPath(spark, inputPath + "/result/publication", Result.class) - .union(Utils.readPath(spark, inputPath + "/result/dataset", Result.class)) - .union(Utils.readPath(spark, inputPath + "/result/otherresearchproduct", Result.class)) - .union(Utils.readPath(spark, inputPath + "/result/software", Result.class)) - .write() - .option("compression", "gzip") - .mode(SaveMode.Overwrite) - .json(outputPath + "/result"); + private static void run(SparkSession spark, String inputPath, String outputPath, boolean aggregate) { + if (aggregate) { + Utils + .readPath(spark, inputPath + "/result/publication", GraphResult.class) + .union(Utils.readPath(spark, inputPath + "/result/dataset", GraphResult.class)) + .union(Utils.readPath(spark, inputPath + "/result/otherresearchproduct", GraphResult.class)) + .union(Utils.readPath(spark, inputPath + "/result/software", GraphResult.class)) + .write() + .option("compression", "gzip") + .mode(SaveMode.Overwrite) + .json(outputPath + "/result"); + } else { + write( + Utils + .readPath(spark, inputPath + "/result/publication", GraphResult.class), + outputPath + "/publication"); + write( + Utils + .readPath(spark, inputPath + "/result/dataset", GraphResult.class), + outputPath + "/dataset"); + write( + Utils + .readPath(spark, inputPath + "/result/otherresearchproduct", GraphResult.class), + outputPath + "/otheresearchproduct"); + write( + Utils + .readPath(spark, inputPath + "/result/software", GraphResult.class), + outputPath + "/software"); + + } Utils .readPath(spark, inputPath + "/relation/publication", Relation.class) @@ -86,4 +111,12 @@ public class SparkCollectAndSave implements Serializable { .json(outputPath + "/relation"); } + + private static void write(Dataset dataSet, String outputPath) { + dataSet + .write() + .option("compression", "gzip") + .mode(SaveMode.Overwrite) + .json(outputPath); + } } diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkDumpEntitiesJob.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkDumpEntitiesJob.java similarity index 93% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkDumpEntitiesJob.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkDumpEntitiesJob.java index 441cfa32de..8b282386f8 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkDumpEntitiesJob.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkDumpEntitiesJob.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.Serializable; import java.util.Optional; @@ -22,7 +22,7 @@ public class SparkDumpEntitiesJob implements Serializable { .toString( SparkDumpEntitiesJob.class .getResourceAsStream( - "/eu/dnetlib/dhp/oa/graph/dump_whole/input_parameters.json")); + "/eu/dnetlib/dhp/oa/graph/dump/complete/input_parameters.json")); final ArgumentApplicationParser parser = new ArgumentApplicationParser(jsonConfiguration); parser.parseArgument(args); diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkDumpRelationJob.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkDumpRelationJob.java similarity index 65% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkDumpRelationJob.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkDumpRelationJob.java index 59aad1f309..11c3600dd9 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkDumpRelationJob.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkDumpRelationJob.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession; @@ -8,6 +8,8 @@ import java.util.Optional; import org.apache.commons.io.IOUtils; import org.apache.spark.SparkConf; +import org.apache.spark.api.java.function.MapFunction; +import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Encoders; import org.apache.spark.sql.SaveMode; import org.apache.spark.sql.SparkSession; @@ -20,6 +22,7 @@ import eu.dnetlib.dhp.schema.common.ModelSupport; import eu.dnetlib.dhp.schema.dump.oaf.Provenance; import eu.dnetlib.dhp.schema.dump.oaf.graph.Node; import eu.dnetlib.dhp.schema.dump.oaf.graph.RelType; +import eu.dnetlib.dhp.schema.oaf.DataInfo; import eu.dnetlib.dhp.schema.oaf.Relation; /** @@ -34,7 +37,7 @@ public class SparkDumpRelationJob implements Serializable { .toString( SparkDumpRelationJob.class .getResourceAsStream( - "/eu/dnetlib/dhp/oa/graph/dump_whole/input_relationdump_parameters.json")); + "/eu/dnetlib/dhp/oa/graph/dump/complete/input_relationdump_parameters.json")); final ArgumentApplicationParser parser = new ArgumentApplicationParser(jsonConfiguration); parser.parseArgument(args); @@ -65,40 +68,54 @@ public class SparkDumpRelationJob implements Serializable { } private static void dumpRelation(SparkSession spark, String inputPath, String outputPath) { - Utils - .readPath(spark, inputPath, Relation.class) - .map(relation -> { - eu.dnetlib.dhp.schema.dump.oaf.graph.Relation rel = new eu.dnetlib.dhp.schema.dump.oaf.graph.Relation(); - rel + Dataset relations = Utils.readPath(spark, inputPath, Relation.class); + relations + .map((MapFunction) relation -> { + eu.dnetlib.dhp.schema.dump.oaf.graph.Relation rel_new = new eu.dnetlib.dhp.schema.dump.oaf.graph.Relation(); + rel_new .setSource( Node .newInstance( relation.getSource(), ModelSupport.idPrefixEntity.get(relation.getSource().substring(0, 2)))); - rel + rel_new .setTarget( Node .newInstance( relation.getTarget(), ModelSupport.idPrefixEntity.get(relation.getTarget().substring(0, 2)))); - rel + rel_new .setReltype( RelType .newInstance( relation.getRelClass(), relation.getSubRelType())); - Optional - .ofNullable(relation.getDataInfo()) - .ifPresent( - datainfo -> rel - .setProvenance( - Provenance - .newInstance(datainfo.getProvenanceaction().getClassname(), datainfo.getTrust()))); + Optional odInfo = Optional.ofNullable(relation.getDataInfo()); + if (odInfo.isPresent()) { + DataInfo dInfo = odInfo.get(); + if (Optional.ofNullable(dInfo.getProvenanceaction()).isPresent()) { + if (Optional.ofNullable(dInfo.getProvenanceaction().getClassname()).isPresent()) { + rel_new + .setProvenance( + Provenance + .newInstance( + dInfo.getProvenanceaction().getClassname(), + dInfo.getTrust())); + } + } + } +// Optional +// .ofNullable(relation.getDataInfo()) +// .ifPresent( +// datainfo -> rel_new +// .setProvenance( +// Provenance +// .newInstance(datainfo.getProvenanceaction().getClassname(), datainfo.getTrust()))); - return rel; + return rel_new; }, Encoders.bean(eu.dnetlib.dhp.schema.dump.oaf.graph.Relation.class)) .write() diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkExtractRelationFromEntities.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkExtractRelationFromEntities.java similarity index 89% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkExtractRelationFromEntities.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkExtractRelationFromEntities.java index f910dbee41..ec91bd8d67 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkExtractRelationFromEntities.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkExtractRelationFromEntities.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.Serializable; import java.util.*; @@ -9,9 +9,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import eu.dnetlib.dhp.application.ArgumentApplicationParser; -import eu.dnetlib.dhp.oa.graph.dump.QueryInformationSystem; -import eu.dnetlib.dhp.oa.graph.dump.Utils; -import eu.dnetlib.dhp.oa.graph.dump.community.CommunityMap; import eu.dnetlib.dhp.schema.oaf.Result; /** diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkOrganizationRelation.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkOrganizationRelation.java similarity index 81% rename from dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkOrganizationRelation.java rename to dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkOrganizationRelation.java index f17e7c894c..868fa89fe1 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/graph/SparkOrganizationRelation.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/SparkOrganizationRelation.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession; @@ -19,6 +19,7 @@ import com.google.gson.Gson; import eu.dnetlib.dhp.application.ArgumentApplicationParser; import eu.dnetlib.dhp.oa.graph.dump.Utils; +import eu.dnetlib.dhp.oa.graph.dump.community.CommunityMap; import eu.dnetlib.dhp.schema.common.ModelConstants; import eu.dnetlib.dhp.schema.common.ModelSupport; import eu.dnetlib.dhp.schema.dump.oaf.Provenance; @@ -27,8 +28,8 @@ import eu.dnetlib.dhp.schema.dump.oaf.graph.RelType; import eu.dnetlib.dhp.schema.oaf.Relation; /** - * Create new Relations between Context Entities and Organizations whose products are associated to the context. - * It produces relation such as: organization <-> isRelatedTo <-> context + * Create new Relations between Context Entities and Organizations whose products are associated to the context. It + * produces relation such as: organization <-> isRelatedTo <-> context */ public class SparkOrganizationRelation implements Serializable { private static final Logger log = LoggerFactory.getLogger(SparkOrganizationRelation.class); @@ -38,7 +39,7 @@ public class SparkOrganizationRelation implements Serializable { .toString( SparkOrganizationRelation.class .getResourceAsStream( - "/eu/dnetlib/dhp/oa/graph/dump_whole/input_organization_parameters.json")); + "/eu/dnetlib/dhp/oa/graph/dump/complete/input_organization_parameters.json")); final ArgumentApplicationParser parser = new ArgumentApplicationParser(jsonConfiguration); parser.parseArgument(args); @@ -59,6 +60,9 @@ public class SparkOrganizationRelation implements Serializable { .fromJson(parser.get("organizationCommunityMap"), OrganizationMap.class); log.info("organization map : {}", new Gson().toJson(organizationMap)); + final String communityMapPath = parser.get("communityMapPath"); + log.info("communityMapPath: {} ", communityMapPath); + SparkConf conf = new SparkConf(); runWithSparkSession( @@ -66,14 +70,17 @@ public class SparkOrganizationRelation implements Serializable { isSparkSessionManaged, spark -> { Utils.removeOutputDir(spark, outputPath); - extractRelation(spark, inputPath, organizationMap, outputPath); + extractRelation(spark, inputPath, organizationMap, outputPath, communityMapPath); }); } private static void extractRelation(SparkSession spark, String inputPath, OrganizationMap organizationMap, - String outputPath) { + String outputPath, String communityMapPath) { + + CommunityMap communityMap = Utils.getCommunityMap(spark, communityMapPath); + Dataset relationDataset = Utils.readPath(spark, inputPath, Relation.class); relationDataset.createOrReplaceTempView("relation"); @@ -97,32 +104,43 @@ public class SparkOrganizationRelation implements Serializable { }, Encoders.bean(MergedRels.class)) .filter(Objects::nonNull) .collectAsList() - .forEach(getMergedRelsConsumer(organizationMap, relList)); + .forEach(getMergedRelsConsumer(organizationMap, relList, communityMap)); organizationMap .keySet() .forEach( oId -> organizationMap .get(oId) - .forEach(community -> addRelations(relList, community, oId))); + .forEach(community -> { + if (communityMap.containsKey(community)) { + addRelations(relList, community, oId); + } + })); + // if (relList.size() > 0) { spark .createDataset(relList, Encoders.bean(eu.dnetlib.dhp.schema.dump.oaf.graph.Relation.class)) .write() .mode(SaveMode.Overwrite) .option("compression", "gzip") .json(outputPath); + // } } @NotNull private static Consumer getMergedRelsConsumer(OrganizationMap organizationMap, - List relList) { + List relList, CommunityMap communityMap) { return mergedRels -> { String oId = mergedRels.getOrganizationId(); organizationMap .get(oId) - .forEach(community -> addRelations(relList, community, mergedRels.getRepresentativeId())); + .forEach(community -> { + if (communityMap.containsKey(community)) { + addRelations(relList, community, mergedRels.getRepresentativeId()); + } + + }); organizationMap.remove(oId); }; } diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/sx/graph/IdReplace.scala b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/sx/graph/IdReplace.scala new file mode 100644 index 0000000000..8d375600ce --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/sx/graph/IdReplace.scala @@ -0,0 +1,3 @@ +package eu.dnetlib.dhp.sx.graph + +case class IdReplace(newId:String, oldId:String) {} diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/sx/graph/SparkSplitOafTODLIEntities.scala b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/sx/graph/SparkSplitOafTODLIEntities.scala index d0df28b2df..f359f73f9a 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/sx/graph/SparkSplitOafTODLIEntities.scala +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/sx/graph/SparkSplitOafTODLIEntities.scala @@ -1,13 +1,15 @@ package eu.dnetlib.dhp.sx.graph import eu.dnetlib.dhp.application.ArgumentApplicationParser -import eu.dnetlib.dhp.schema.oaf.{Oaf, Relation} +import eu.dnetlib.dhp.schema.oaf.{Oaf, Relation, Result} import eu.dnetlib.dhp.schema.scholexplorer.{DLIDataset, DLIPublication, DLIUnknown} import eu.dnetlib.dhp.sx.ebi.EBIAggregator -import eu.dnetlib.dhp.sx.ebi.model.{PMArticle, PMAuthor, PMJournal} import org.apache.commons.io.IOUtils +import org.apache.commons.lang3.StringUtils import org.apache.spark.sql.{Dataset, Encoder, Encoders, SaveMode, SparkSession} import org.slf4j.LoggerFactory +import org.apache.spark.sql.functions.col + object SparkSplitOafTODLIEntities { @@ -18,38 +20,38 @@ object SparkSplitOafTODLIEntities { } - def main(args: Array[String]): Unit = { - val parser = new ArgumentApplicationParser(IOUtils.toString(SparkSplitOafTODLIEntities.getClass.getResourceAsStream("/eu/dnetlib/dhp/sx/graph/argumentparser/input_extract_entities_parameters.json"))) - val logger = LoggerFactory.getLogger(SparkSplitOafTODLIEntities.getClass) - parser.parseArgument(args) - val workingPath: String = parser.get("workingPath") - logger.info(s"Working dir path = $workingPath") + def extract_dataset(spark:SparkSession, workingPath:String) :Unit = { + + implicit val oafEncoder: Encoder[Oaf] = Encoders.kryo[Oaf] + implicit val datEncoder: Encoder[DLIDataset] = Encoders.kryo[DLIDataset] + + val OAFDataset:Dataset[Oaf] = spark.read.load(s"$workingPath/input/OAFDataset").as[Oaf].repartition(4000) + + val ebi_dataset:Dataset[DLIDataset] = spark.read.load(s"$workingPath/ebi/baseline_dataset_ebi").as[DLIDataset].repartition(1000) + + + OAFDataset + .filter(s => s != null && s.isInstanceOf[DLIDataset]) + .map(s =>s.asInstanceOf[DLIDataset]) + .union(ebi_dataset) + .map(d => (d.getId, d))(Encoders.tuple(Encoders.STRING, datEncoder)) + .groupByKey(_._1)(Encoders.STRING) + .agg(EBIAggregator.getDLIDatasetAggregator().toColumn) + .map(p => p._2) + .repartition(2000) + .write.mode(SaveMode.Overwrite).save(s"$workingPath/graph/dataset") + + } + + def extract_publication(spark:SparkSession, workingPath:String) :Unit = { implicit val oafEncoder: Encoder[Oaf] = Encoders.kryo[Oaf] implicit val pubEncoder: Encoder[DLIPublication] = Encoders.kryo[DLIPublication] - implicit val datEncoder: Encoder[DLIDataset] = Encoders.kryo[DLIDataset] - implicit val unkEncoder: Encoder[DLIUnknown] = Encoders.kryo[DLIUnknown] - implicit val relEncoder: Encoder[Relation] = Encoders.kryo[Relation] - - - - val spark:SparkSession = SparkSession - .builder() - .appName(SparkSplitOafTODLIEntities.getClass.getSimpleName) - .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer") - .master(parser.get("master")) - .getOrCreate() - - - val OAFDataset:Dataset[Oaf] = spark.read.load(s"$workingPath/input/OAFDataset").as[Oaf] - val ebi_dataset:Dataset[DLIDataset] = spark.read.load(s"$workingPath/ebi/baseline_dataset_ebi").as[DLIDataset] - val ebi_publication:Dataset[DLIPublication] = spark.read.load(s"$workingPath/ebi/baseline_publication_ebi").as[DLIPublication] - val ebi_relation:Dataset[Relation] = spark.read.load(s"$workingPath/ebi/baseline_relation_ebi").as[Relation] - + val ebi_publication:Dataset[DLIPublication] = spark.read.load(s"$workingPath/ebi/baseline_publication_ebi").as[DLIPublication].repartition(1000) OAFDataset @@ -60,20 +62,17 @@ object SparkSplitOafTODLIEntities { .groupByKey(_._1)(Encoders.STRING) .agg(EBIAggregator.getDLIPublicationAggregator().toColumn) .map(p => p._2) - .repartition(1000) + .repartition(2000) .write.mode(SaveMode.Overwrite).save(s"$workingPath/graph/publication") - OAFDataset - .filter(s => s != null && s.isInstanceOf[DLIDataset]) - .map(s =>s.asInstanceOf[DLIDataset]) - .union(ebi_dataset) - .map(d => (d.getId, d))(Encoders.tuple(Encoders.STRING, datEncoder)) - .groupByKey(_._1)(Encoders.STRING) - .agg(EBIAggregator.getDLIDatasetAggregator().toColumn) - .map(p => p._2) - .repartition(1000) - .write.mode(SaveMode.Overwrite).save(s"$workingPath/graph/dataset") + } + def extract_unknown(spark:SparkSession, workingPath:String) :Unit = { + + implicit val oafEncoder: Encoder[Oaf] = Encoders.kryo[Oaf] + implicit val unkEncoder: Encoder[DLIUnknown] = Encoders.kryo[DLIUnknown] + + val OAFDataset:Dataset[Oaf] = spark.read.load(s"$workingPath/input/OAFDataset").as[Oaf] OAFDataset .filter(s => s != null && s.isInstanceOf[DLIUnknown]) @@ -82,9 +81,46 @@ object SparkSplitOafTODLIEntities { .groupByKey(_._1)(Encoders.STRING) .agg(EBIAggregator.getDLIUnknownAggregator().toColumn) .map(p => p._2) - .repartition(1000) .write.mode(SaveMode.Overwrite).save(s"$workingPath/graph/unknown") + } + + + def extract_ids(o:Oaf) :(String, String) = { + + o match { + case p: DLIPublication => + val prefix = StringUtils.substringBefore(p.getId, "|") + val original = StringUtils.substringAfter(p.getOriginalObjIdentifier, "::") + (p.getId, s"$prefix|$original") + case p: DLIDataset => + val prefix = StringUtils.substringBefore(p.getId, "|") + val original = StringUtils.substringAfter(p.getOriginalObjIdentifier, "::") + (p.getId, s"$prefix|$original") + case _ =>null + } + } + + def extract_relations(spark:SparkSession, workingPath:String) :Unit = { + + implicit val oafEncoder: Encoder[Oaf] = Encoders.kryo[Oaf] + implicit val relEncoder: Encoder[Relation] = Encoders.kryo[Relation] + import spark.implicits._ + + val OAFDataset:Dataset[Oaf] = spark.read.load(s"$workingPath/input/OAFDataset").as[Oaf] + val ebi_relation:Dataset[Relation] = spark.read.load(s"$workingPath/ebi/baseline_relation_ebi").as[Relation].repartition(2000) + + + OAFDataset + .filter(o => o.isInstanceOf[Result]) + .map(extract_ids)(Encoders.tuple(Encoders.STRING, Encoders.STRING)) + .filter(r => r != null) + .where("_1 != _2") + .select(col("_1").alias("newId"), col("_2").alias("oldId")) + .distinct() + .map(f => IdReplace(f.getString(0), f.getString(1))) + .write.mode(SaveMode.Overwrite).save(s"$workingPath/graph/id_replace") + OAFDataset .filter(s => s != null && s.isInstanceOf[Relation]) @@ -94,10 +130,70 @@ object SparkSplitOafTODLIEntities { .groupByKey(_._1)(Encoders.STRING) .agg(EBIAggregator.getRelationAggregator().toColumn) .map(p => p._2) - .repartition(1000) - .write.mode(SaveMode.Overwrite).save(s"$workingPath/graph/relation") + .repartition(4000) + .write.mode(SaveMode.Overwrite).save(s"$workingPath/graph/relation_unfixed") + val relations = spark.read.load(s"$workingPath/graph/relation_unfixed").as[Relation] + val ids = spark.read.load(s"$workingPath/graph/id_replace").as[IdReplace] + + relations + .map(r => (r.getSource, r))(Encoders.tuple(Encoders.STRING, relEncoder)) + .joinWith(ids, col("_1").equalTo(ids("oldId")), "left") + .map(i =>{ + val r = i._1._2 + if (i._2 != null) + { + val id = i._2.newId + r.setSource(id) + } + r + }).write.mode(SaveMode.Overwrite).save(s"$workingPath/graph/rel_f_source") + + val rel_source:Dataset[Relation] = spark.read.load(s"$workingPath/graph/rel_f_source").as[Relation] + + rel_source + .map(r => (r.getTarget, r))(Encoders.tuple(Encoders.STRING, relEncoder)) + .joinWith(ids, col("_1").equalTo(ids("oldId")), "left") + .map(i =>{ + val r:Relation = i._1._2 + if (i._2 != null) + { + val id = i._2.newId + r.setTarget(id) + } + r + }).write.mode(SaveMode.Overwrite).save(s"$workingPath/graph/relation") + + + + } + + + def main(args: Array[String]): Unit = { + val parser = new ArgumentApplicationParser(IOUtils.toString(SparkSplitOafTODLIEntities.getClass.getResourceAsStream("/eu/dnetlib/dhp/sx/graph/argumentparser/input_extract_entities_parameters.json"))) + val logger = LoggerFactory.getLogger(SparkSplitOafTODLIEntities.getClass) + parser.parseArgument(args) + + val workingPath: String = parser.get("workingPath") + val entity:String = parser.get("entity") + logger.info(s"Working dir path = $workingPath") + + val spark:SparkSession = SparkSession + .builder() + .appName(SparkSplitOafTODLIEntities.getClass.getSimpleName) + .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer") + .master(parser.get("master")) + .getOrCreate() + + + entity match { + case "publication" => extract_publication(spark, workingPath) + case "dataset" => extract_dataset(spark,workingPath) + case "relation" => extract_relations(spark, workingPath) + case "unknown" => extract_unknown(spark, workingPath) + } + diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/oozie_app/config-default.xml b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/community/oozie_app/config-default.xml similarity index 100% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/oozie_app/config-default.xml rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/community/oozie_app/config-default.xml diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/oozie_app/workflow.xml b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/community/oozie_app/workflow.xml similarity index 90% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/oozie_app/workflow.xml rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/community/oozie_app/workflow.xml index 7321fd0764..161fd2dec1 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/oozie_app/workflow.xml +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/community/oozie_app/workflow.xml @@ -1,18 +1,18 @@ - - sourcePath - the source path - - - isLookUpUrl - the isLookup service endpoint - - - outputPath - the output path - + + sourcePath + the source path + + + isLookUpUrl + the isLookup service endpoint + + + outputPath + the output path + accessToken the access token used for the deposition in Zenodo @@ -320,6 +320,7 @@ + yarn @@ -344,6 +345,7 @@ + yarn @@ -371,43 +373,42 @@ - - - yarn - cluster - Split dumped result for community - eu.dnetlib.dhp.oa.graph.dump.community.SparkSplitForCommunity - dhp-graph-mapper-${projectVersion}.jar - - --executor-memory=${sparkExecutorMemory} - --executor-cores=${sparkExecutorCores} - --driver-memory=${sparkDriverMemory} - --conf spark.extraListeners=${spark2ExtraListeners} - --conf spark.sql.queryExecutionListeners=${spark2SqlQueryExecutionListeners} - --conf spark.yarn.historyServer.address=${spark2YarnHistoryServerAddress} - --conf spark.eventLog.dir=${nameNode}${spark2EventLogDir} - --conf spark.sql.warehouse.dir=${sparkSqlWarehouseDir} - - --sourcePath${workingDir}/ext - --outputPath${workingDir}/split - --communityMapPath${workingDir}/communityMap - - - - + + + yarn + cluster + Split dumped result for community + eu.dnetlib.dhp.oa.graph.dump.community.SparkSplitForCommunity + dhp-graph-mapper-${projectVersion}.jar + + --executor-memory=${sparkExecutorMemory} + --executor-cores=${sparkExecutorCores} + --driver-memory=${sparkDriverMemory} + --conf spark.extraListeners=${spark2ExtraListeners} + --conf spark.sql.queryExecutionListeners=${spark2SqlQueryExecutionListeners} + --conf spark.yarn.historyServer.address=${spark2YarnHistoryServerAddress} + --conf spark.eventLog.dir=${nameNode}${spark2EventLogDir} + --conf spark.sql.warehouse.dir=${sparkSqlWarehouseDir} + + --sourcePath${workingDir}/ext + --outputPath${workingDir}/split + --communityMapPath${workingDir}/communityMap + + + + eu.dnetlib.dhp.oa.graph.dump.MakeTar --hdfsPath${outputPath} --nameNode${nameNode} - --sourcePath${workingDir}/split + --sourcePath${workingDir}/split - eu.dnetlib.dhp.oa.graph.dump.SendToZenodoHDFS @@ -418,14 +419,12 @@ --metadata${metadata} --communityMapPath${workingDir}/communityMap --conceptRecordId${conceptRecordId} - --newDeposition${newDeposition} + --depositionType${depositionType} - - \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_collect_and_save.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_collect_and_save.json similarity index 66% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_collect_and_save.json rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_collect_and_save.json index e1130c4f60..2b422176ce 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_collect_and_save.json +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_collect_and_save.json @@ -17,7 +17,13 @@ "paramLongName": "isSparkSessionManaged", "paramDescription": "true if the spark session is managed, false otherwise", "paramRequired": false - } + }, + { + "paramName": "ra", + "paramLongName": "resultAggregation", + "paramDescription": "true if all the result type should be saved under the generic result name. false to get a different dump for each result type", + "paramRequired": true +} ] diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_entity_parameter.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_entity_parameter.json similarity index 100% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_entity_parameter.json rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_entity_parameter.json diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_organization_parameters.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_organization_parameters.json similarity index 79% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_organization_parameters.json rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_organization_parameters.json index 3a4632af94..c27a9234de 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_organization_parameters.json +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_organization_parameters.json @@ -23,6 +23,12 @@ "paramLongName": "isSparkSessionManaged", "paramDescription": "true if the spark session is managed, false otherwise", "paramRequired": false + }, + { + "paramName":"cmp", + "paramLongName":"communityMapPath", + "paramDescription": "the path to the serialization of the community map", + "paramRequired": true } ] diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_parameters.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_parameters.json similarity index 100% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_parameters.json rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_parameters.json diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_relationdump_parameters.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_relationdump_parameters.json similarity index 100% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/input_relationdump_parameters.json rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/input_relationdump_parameters.json diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/oozie_app/config-default.xml b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/oozie_app/config-default.xml similarity index 100% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/oozie_app/config-default.xml rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/oozie_app/config-default.xml diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/oozie_app/workflow.xml b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/oozie_app/workflow.xml similarity index 88% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/oozie_app/workflow.xml rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/oozie_app/workflow.xml index a1b984f9c7..4c286e4a24 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/oozie_app/workflow.xml +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/oozie_app/workflow.xml @@ -1,18 +1,22 @@ - - sourcePath - the source path - - - isLookUpUrl - the isLookup service endpoint - - - outputPath - the output path - + + sourcePath + the source path + + + isLookUpUrl + the isLookup service endpoint + + + outputPath + the output path + + + resultAggregation + true if all the result type have to be dumped under result. false otherwise + accessToken the access token used for the deposition in Zenodo @@ -26,13 +30,17 @@ the metadata associated to the deposition - newDeposition - true if it is a brand new depositon. false for new version of an old deposition + depositionType + the type of deposition we want to perform. "new" for brand new deposition, "version" for a new version of a published deposition (in this case the concept record id must be provided), "upload" to upload content to an open deposition for which we already have the deposition id (in this case the deposition id should be provided) conceptRecordId for new version, the id of the record for the old deposition + + depositionId + the depositionId of a deposition open that has to be added content + organizationCommunityMap the organization community map @@ -148,7 +156,7 @@ yarn cluster Dump table publication - eu.dnetlib.dhp.oa.graph.dump.graph.SparkDumpEntitiesJob + eu.dnetlib.dhp.oa.graph.dump.complete.SparkDumpEntitiesJob dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -174,7 +182,7 @@ yarn cluster Dump table dataset - eu.dnetlib.dhp.oa.graph.dump.graph.SparkDumpEntitiesJob + eu.dnetlib.dhp.oa.graph.dump.complete.SparkDumpEntitiesJob dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -200,7 +208,7 @@ yarn cluster Dump table ORP - eu.dnetlib.dhp.oa.graph.dump.graph.SparkDumpEntitiesJob + eu.dnetlib.dhp.oa.graph.dump.complete.SparkDumpEntitiesJob dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -226,7 +234,7 @@ yarn cluster Dump table software - eu.dnetlib.dhp.oa.graph.dump.graph.SparkDumpEntitiesJob + eu.dnetlib.dhp.oa.graph.dump.complete.SparkDumpEntitiesJob dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -252,7 +260,7 @@ yarn cluster Dump table organization - eu.dnetlib.dhp.oa.graph.dump.graph.SparkDumpEntitiesJob + eu.dnetlib.dhp.oa.graph.dump.complete.SparkDumpEntitiesJob dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -268,7 +276,6 @@ --resultTableNameeu.dnetlib.dhp.schema.oaf.Organization --outputPath${workingDir}/collect/organization --communityMapPath${workingDir}/communityMap - @@ -279,7 +286,7 @@ yarn cluster Dump table project - eu.dnetlib.dhp.oa.graph.dump.graph.SparkDumpEntitiesJob + eu.dnetlib.dhp.oa.graph.dump.complete.SparkDumpEntitiesJob dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -295,7 +302,6 @@ --resultTableNameeu.dnetlib.dhp.schema.oaf.Project --outputPath${workingDir}/collect/project --communityMapPath${workingDir}/communityMap - @@ -306,7 +312,7 @@ yarn cluster Dump table datasource - eu.dnetlib.dhp.oa.graph.dump.graph.SparkDumpEntitiesJob + eu.dnetlib.dhp.oa.graph.dump.complete.SparkDumpEntitiesJob dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -322,7 +328,6 @@ --resultTableNameeu.dnetlib.dhp.schema.oaf.Datasource --outputPath${workingDir}/collect/datasource --communityMapPath${workingDir}/communityMap - @@ -333,7 +338,7 @@ yarn cluster Dump table relation - eu.dnetlib.dhp.oa.graph.dump.graph.SparkDumpRelationJob + eu.dnetlib.dhp.oa.graph.dump.complete.SparkDumpRelationJob dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -352,10 +357,8 @@ - - @@ -364,8 +367,8 @@ - eu.dnetlib.dhp.oa.graph.dump.graph.CreateContextEntities - --hdfsPath${workingDir}/collect/context + eu.dnetlib.dhp.oa.graph.dump.complete.CreateContextEntities + --hdfsPath${workingDir}/collect/communities_infrastructures --nameNode${nameNode} --isLookUpUrl${isLookUpUrl} @@ -375,7 +378,7 @@ - eu.dnetlib.dhp.oa.graph.dump.graph.CreateContextRelation + eu.dnetlib.dhp.oa.graph.dump.complete.CreateContextRelation --hdfsPath${workingDir}/relation/context --nameNode${nameNode} --isLookUpUrl${isLookUpUrl} @@ -384,13 +387,12 @@ - yarn cluster Dump table relation - eu.dnetlib.dhp.oa.graph.dump.graph.SparkOrganizationRelation + eu.dnetlib.dhp.oa.graph.dump.complete.SparkOrganizationRelation dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -405,6 +407,7 @@ --sourcePath${sourcePath}/relation --outputPath${workingDir}/relation/contextOrg --organizationCommunityMap${organizationCommunityMap} + --communityMapPath${workingDir}/communityMap @@ -412,7 +415,6 @@ - @@ -425,7 +427,7 @@ yarn cluster Extract Relations from publication - eu.dnetlib.dhp.oa.graph.dump.graph.SparkExtractRelationFromEntities + eu.dnetlib.dhp.oa.graph.dump.complete.SparkExtractRelationFromEntities dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -441,7 +443,6 @@ --resultTableNameeu.dnetlib.dhp.schema.oaf.Publication --outputPath${workingDir}/relation/publication --communityMapPath${workingDir}/communityMap - @@ -452,7 +453,7 @@ yarn cluster Dump table dataset - eu.dnetlib.dhp.oa.graph.dump.graph.SparkExtractRelationFromEntities + eu.dnetlib.dhp.oa.graph.dump.complete.SparkExtractRelationFromEntities dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -468,7 +469,6 @@ --resultTableNameeu.dnetlib.dhp.schema.oaf.Dataset --outputPath${workingDir}/relation/dataset --communityMapPath${workingDir}/communityMap - @@ -479,7 +479,7 @@ yarn cluster Dump table ORP - eu.dnetlib.dhp.oa.graph.dump.graph.SparkExtractRelationFromEntities + eu.dnetlib.dhp.oa.graph.dump.complete.SparkExtractRelationFromEntities dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -495,7 +495,6 @@ --resultTableNameeu.dnetlib.dhp.schema.oaf.OtherResearchProduct --outputPath${workingDir}/relation/orp --communityMapPath${workingDir}/communityMap - @@ -506,7 +505,7 @@ yarn cluster Dump table software - eu.dnetlib.dhp.oa.graph.dump.graph.SparkExtractRelationFromEntities + eu.dnetlib.dhp.oa.graph.dump.complete.SparkExtractRelationFromEntities dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -522,13 +521,11 @@ --resultTableNameeu.dnetlib.dhp.schema.oaf.Software --outputPath${workingDir}/relation/software --communityMapPath${workingDir}/communityMap - - @@ -536,7 +533,7 @@ yarn cluster Collect Results and Relations and put them in the right path - eu.dnetlib.dhp.oa.graph.dump.graph.SparkCollectAndSave + eu.dnetlib.dhp.oa.graph.dump.complete.SparkCollectAndSave dhp-graph-mapper-${projectVersion}.jar --executor-memory=${sparkExecutorMemory} @@ -550,6 +547,7 @@ --sourcePath${workingDir} --outputPath${workingDir}/collect + --resultAggregation${resultAggregation} @@ -565,8 +563,7 @@ - - + eu.dnetlib.dhp.oa.graph.dump.SendToZenodoHDFS @@ -577,7 +574,8 @@ --metadata${metadata} --communityMapPath${workingDir}/communityMap --conceptRecordId${conceptRecordId} - --newDeposition${newDeposition} + --depositionType${depositionType} + --depositionId${depositionId} diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/community_infrastructure_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/community_infrastructure_schema.json new file mode 100644 index 0000000000..d2f1792125 --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/community_infrastructure_schema.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "Description of the research community/research infrastructure" + }, + "id": { + "type": "string", + "description": "OpenAIRE id of the research community/research infrastructure" + }, + "name": { + "type": "string", + "description": "The long name of the community" + }, + "originalId": { + "type": "string", + "description": "The acronym of the community" + }, + "subject": { + "description": "Only for research communities: the list of the subjects associated to the research community", + "type": "array", + "items": { + "type": "string" + } + }, + "type": { + "type": "string", + "description": "One of {Research Community, Research infrastructure}" + }, + "zenodo_community": { + "type": "string", + "description": "The URL of the Zenodo community associated to the Research community/Research infrastructure" + } + } +} \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/datasource_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/datasource_schema.json new file mode 100644 index 0000000000..b9c15d9219 --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/datasource_schema.json @@ -0,0 +1,192 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "ControlledField": { + "type": "object", + "properties": { + "scheme": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "description": "To represent the information described by a scheme and a value in that scheme (i.e. pid)" + } + }, + "type": "object", + "properties": { + "accessrights": { + "type": "string", + "description": "Type of access to the data source, as defined by re3data.org. Possible values: {open, restricted, closed}" + }, + "certificates": { + "type": "string", + "description": "The certificate, seal or standard the data source complies with. As defined by re3data.org." + }, + "citationguidelineurl": { + "type": "string", + "description":"The URL of the data source providing information on how to cite its items. As defined by re3data.org." + }, + "contenttypes": { + "description": "Types of content in the data source, as defined by OpenDOAR", + "type": "array", + "items": { + "type": "string" + } + }, + "databaseaccessrestriction": { + "type": "string", + "description": "Access restrinctions to the data source, as defined by re3data.org. One of {feeRequired, registration, other}" + }, + "datasourcetype": { + "allOf": [ + { + "$ref": "#/definitions/ControlledField" + }, + { + "description": "The type of the datasource. See https://api.openaire.eu/vocabularies/dnet:datasource_typologies" + } + ] + }, + "datauploadrestriction": { + "type": "string", + "description": "Upload restrictions applied by the datasource, as defined by re3data.org. One of {feeRequired, registration, other}" + }, + "dateofvalidation": { + "type": "string", + "description": "The date of last validation against the OpenAIRE guidelines for the datasource records" + }, + "description": { + "type": "string" + }, + "englishname": { + "type": "string", + "description": "The English name of the datasource" + }, + "id": { + "type": "string", + "description": "The OpenAIRE id of the data source" + }, + "journal": { + "type": "object", + "properties": { + "conferencedate": { + "type": "string" + }, + "conferenceplace": { + "type": "string" + }, + "edition": { + "type": "string" + }, + "ep": { + "type": "string", + "description": "End page" + }, + "iss": { + "type": "string", + "description": "Issue number" + }, + "issnLinking": { + "type": "string" + }, + "issnOnline": { + "type": "string" + }, + "issnPrinted": { + "type": "string" + }, + "name": { + "type": "string" + }, + "sp": { + "type": "string", + "description": "Start page" + }, + "vol": { + "type": "string", + "description": "Volume" + } + }, + "description": "Information about the journal, if this data source is of type Journal." + }, + "languages": { + "description": "The languages present in the data source's content, as defined by OpenDOAR.", + "type": "array", + "items": { + "type": "string" + } + }, + "logourl": { + "type": "string" + }, + "missionstatementurl": { + "type": "string", + "description":"The URL of a mission statement describing the designated community of the data source. As defined by re3data.org" + }, + "officialname": { + "type": "string", + "description": "The official name of the datasource" + }, + "openairecompatibility": { + "type": "string", + "description": "OpenAIRE guidelines the data source comply with. See also https://guidelines.openaire.eu." + }, + "originalId": { + "description": "Original identifiers for the datasource" + "type": "array", + "items": { + "type": "string" + } + }, + "pid": { + "description": "Persistent identifiers of the datasource", + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/ControlledField" + } + ] + } + }, + "pidsystems": { + "type": "string", + "description": "The persistent identifier system that is used by the data source. As defined by re3data.org" + }, + "policies": { + "description": "Policies of the data source, as defined in OpenDOAR.", + "type": "array", + "items": { + "type": "string" + } + }, + "releaseenddate": { + "type": "string", + "description": "Date when the data source went offline or stopped ingesting new research data. As defined by re3data.org" + }, + "releasestartdate": { + "type": "string", + "description": "Releasing date of the data source, as defined by re3data.org" + }, + "subjects": { + "description": "List of subjects associated to the datasource", + "type": "array", + "items": { + "type": "string" + } + }, + "uploadrights": { + "type": "string", + "description": "Type of data upload. As defined by re3data.org: one of {open, restricted,closed}" + }, + "versioning": { + "type": "boolean", + "description": "As defined by redata.org: 'yes' if the data source supports versioning, 'no' otherwise." + }, + "websiteurl": { + "type": "string" + } + } +} diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/organization_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/organization_schema.json similarity index 50% rename from dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/organization_schema.json rename to dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/organization_schema.json index 3477c8370b..16afa386d5 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/organization_schema.json +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/organization_schema.json @@ -3,11 +3,10 @@ "type": "object", "properties": { "alternativenames": { - "description": "Description of alternativenames", + "description": "Alternative names that identify the organisation", "type": "array", "items": { - "type": "string", - "description": "Description of alternativenames" + "type": "string" } }, "country": { @@ -15,48 +14,44 @@ "properties": { "code": { "type": "string", - "description": "Description of code" + "description": "The organisation country code" }, "label": { "type": "string", - "description": "Description of label" + "description": "The organisation country label" } }, - "description": "Description of country" + "description": "The country of the organisation" }, "id": { "type": "string", - "description": "Description of id" + "description": "The OpenAIRE id for the organisation" }, "legalname": { - "type": "string", - "description": "Description of legalname" + "type": "string" }, "legalshortname": { - "type": "string", - "description": "Description of legalshortname" + "type": "string" }, "pid": { - "description": "Description of pid", + "description": "Persistent identifiers for the organisation i.e. isni 0000000090326370", "type": "array", "items": { "type": "object", "properties": { "scheme": { "type": "string", - "description": "Description of scheme" + "description": "The scheme of the identifier (i.e. isni)" }, "value": { "type": "string", - "description": "Description of value" + "description": "the value in the schema (i.e. 0000000090326370)" } - }, - "description": "Description of pid" + } } }, "websiteurl": { - "type": "string", - "description": "Description of websiteurl" + "type": "string" } } } \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/project_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/project_schema.json new file mode 100644 index 0000000000..c81187258e --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/project_schema.json @@ -0,0 +1,119 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "acronym": { + "type": "string" + }, + "callidentifier": { + "type": "string" + }, + "code": { + "type": "string", + "description": "The grant agreement number" + }, + "enddate": { + "type": "string" + }, + "funding": { + "description": "Funding information for the project", + "type": "array", + "items": { + "type": "object", + "properties": { + "funding_stream": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "Description of the funding stream" + }, + "id": { + "type": "string", + "description": "Id of the funding stream" + } + } + }, + "jurisdiction": { + "type": "string", + "description": "The jurisdiction of the funder (i.e. EU)" + }, + "name": { + "type": "string", + "description": "The name of the funder (European Commission)" + }, + "shortName": { + "type": "string", + "description": "The short name of the funder (EC)" + } + } + } + }, + "granted": { + "type": "object", + "properties": { + "currency": { + "type": "string", + "description": "The currency of the granted amount (e.g. EUR)" + }, + "fundedamount": { + "type": "number", + "description": "The funded amount" + }, + "totalcost": { + "type": "number", + "description": "The total cost of the project" + } + }, + "description": "The money granted to the project" + }, + "h2020programme": { + "description": "The h2020 programme funding the project", + "type": "array", + "items": { + "type": "object", + "properties": { + "code": { + "type": "string", + "description": "The code of the programme" + }, + "description": { + "type": "string", + "description": "The description of the programme" + } + } + } + }, + "id": { + "type": "string", + "description": "OpenAIRE id for the project" + }, + "keywords": { + "type": "string" + }, + "openaccessmandatefordataset": { + "type": "boolean" + }, + "openaccessmandateforpublications": { + "type": "boolean" + }, + "startdate": { + "type": "string" + }, + "subject": { + "type": "array", + "items": { + "type": "string" + } + }, + "summary": { + "type": "string" + }, + "title": { + "type": "string" + }, + "websiteurl": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/relation_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/relation_schema.json new file mode 100644 index 0000000000..7c7de9c98d --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/relation_schema.json @@ -0,0 +1,60 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "Node": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The OpenAIRE id of the entity" + }, + "type": { + "type": "string", + "description": "The type of the entity (i.e. organisation)" + } + } + } + }, + "type": "object", + "properties": { + "provenance": { + "type": "object", + "properties": { + "provenance": { + "type": "string", + "description": "The reason why OpenAIRE holds the relation " + }, + "trust": { + "type": "string", + "description": "The trust of the relation in the range of [0,1]. Where greater the number, more the trust. Harvested relationships have typically a high trust (0.9). The trust of inferred relationship is calculated by the inference algorithm that generated them, as described in https://graph.openaire.eu/about#architecture (Enrichment --> Mining)" + } + } + }, + "reltype": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The semantics of the relation (i.e. isAuthorInstitutionOf). " + }, + "type": { + "type": "string", + "description": "the type of the relation (i.e. affiliation)" + } + }, + "description": "To represent the semantics of a relation between two entities" + }, + "source": { + "allOf": [ + {"$ref": "#/definitions/Node"}, + {"description": "The node source in the relation"} + ] + }, + "target": { + "allOf": [ + {"$ref": "#/definitions/Node"}, + {"description": "The node target in the relation"} + ] + } + } +} \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/result_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/result_schema.json new file mode 100644 index 0000000000..867fd5a779 --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/complete/schema/result_schema.json @@ -0,0 +1,330 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "ControlledField": { + "type": "object", + "properties": { + "scheme": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "description": "To represent the information described by a scheme and a value in that scheme (i.e. pid)" + }, + "Provenance": { + "type": "object", + "properties": { + "provenance": { + "type": "string", + "description": "The process that produced/provided the information" + }, + "trust": { + "type": "string" + } + }, + "description": "Indicates the process that produced (or provided) the information, and the trust associated to the information" + } + }, + "type": "object", + "properties": { + "author": { + "type": "array", + "items": { + "type": "object", + "properties": { + "fullname": { + "type": "string" + }, + "name": { + "type": "string" + }, + "pid": { + "type": "object", + "properties": { + "id": { + "allOf": [ + {"$ref": "#/definitions/ControlledField"}, + {"description": "The author's id and scheme. OpenAIRE currently supports 'ORCID'"} + ] + }, + "provenance": { + "allOf": [ + {"$ref": "#/definitions/Provenance"}, + {"description": "Provenance of author's pid"} + ] + } + } + }, + "rank": { + "type": "integer" + }, + "surname": { + "type": "string" + } + } + } + }, + "bestaccessright": { + "type": "object", + "properties": { + "code": { + "type": "string", + "description": "COAR access mode code: http://vocabularies.coar-repositories.org/documentation/access_rights/" + }, + "label": { + "type": "string", + "description": "Label for the access mode" + }, + "scheme": { + "type": "string", + "description": "Scheme of reference for access right code. Always set to COAR access rights vocabulary: http://vocabularies.coar-repositories.org/documentation/access_rights/" + } + }, + "description": "The openest access right associated to the manifestations of this research results" + }, + "codeRepositoryUrl": { + "type": "string", + "description": "Only for results with type 'software': the URL to the repository with the source code" + }, + "contactgroup": { + "description": "Only for results with type 'software': Information on the group responsible for providing further information regarding the resource", + "type": "array", + "items": { + "type": "string" + } + }, + "contactperson": { + "description": "Only for results with type 'software': Information on the person responsible for providing further information regarding the resource", + "type": "array", + "items": { + "type": "string" + } + }, + "container": { + "type": "object", + "properties": { + "conferencedate": { + "type": "string" + }, + "conferenceplace": { + "type": "string" + }, + "edition": { + "type": "string", + "description": "Edition of the journal or conference proceeding" + }, + "ep": { + "type": "string", + "description": "End page" + }, + "iss": { + "type": "string", + "description": "Journal issue" + }, + "issnLinking": { + "type": "string" + }, + "issnOnline": { + "type": "string" + }, + "issnPrinted": { + "type": "string" + }, + "name": { + "type": "string", + "description": "Name of the journal or conference" + }, + "sp": { + "type": "string", + "description": "start page" + }, + "vol": { + "type": "string" + } + }, + "description": "Container has information about the conference or journal where the result has been presented or published" + }, + "contributor": { + "type": "array", + "items": { + "type": "string", + "description": "Description of contributor" + } + }, + "country": { + "type": "array", + "items": { + "type": "object", + "properties": { + "code": { + "type": "string", + "description": "ISO 3166-1 alpha-2 country code" + }, + "label": { + "type": "string" + }, + "provenance": { + "allOf": [ + {"$ref": "#/definitions/Provenance"}, + {"description": "Why this result is associated to the country."} + ] + } + } + } + }, + "coverage": { + "type": "array", + "items": { + "type": "string" + } + }, + "dateofcollection": { + "type": "string", + "description": "When OpenAIRE collected the record the last time" + }, + "description": { + "type": "array", + "items": { + "type": "string" + } + }, + "documentationUrl": { + "description": "Only for results with type 'software': URL to the software documentation", + "type": "array", + "items": { + "type": "string" + } + }, + "embargoenddate": { + "type": "string", + "description": "Date when the embargo ends and this result turns Open Access" + }, + "format": { + "type": "array", + "items": { + "type": "string" + } + }, + "geolocation": { + "description": "Geolocation information", + "type": "array", + "items": { + "type": "object", + "properties": { + "box": { + "type": "string" + }, + "place": { + "type": "string" + }, + "point": { + "type": "string" + } + } + } + }, + "id": { + "type": "string", + "description": "OpenAIRE Identifier" + }, + "language": { + "type": "object", + "properties": { + "code": { + "type": "string", + "description": "alpha-3/ISO 639-2 code of the language" + }, + "label": { + "type": "string", + "description": "English label" + } + } + }, + "lastupdatetimestamp": { + "type": "integer", + "description": "Timestamp of last update of the record in OpenAIRE" + }, + "maintitle": { + "type": "string" + }, + "originalId": { + "description": "Identifiers of the record at the original sources", + "type": "array", + "items": { + "type": "string" + } + }, + "pid": { + "description": "Persistent identifiers of the result", + "type": "array", + "items": { + "allOf": [ + {"$ref": "#/definitions/ControlledField"}, + {"description": "scheme: list of available schemes are at https://api.openaire.eu/vocabularies/dnet:pid_types, value: the PID of the result "} + ] + } + }, + "programmingLanguage": { + "type": "string", + "description": "Only for results with type 'software': the programming language" + }, + "publicationdate": { + "type": "string" + }, + "publisher": { + "type": "string" + }, + "size": { + "type": "string", + "description": "Only for results with type 'dataset': the declared size of the dataset" + }, + "source": { + "description": "See definition of Dublin Core field dc:source", + "type": "array", + "items": { + "type": "string" + } + }, + "subjects": { + "description": "Keywords associated to the result", + "type": "array", + "items": { + "type": "object", + "properties": { + "provenance": { + "allOf": [ + {"$ref": "#/definitions/Provenance"}, + {"description": "Why this subject is associated to the result"} + ] + }, + "subject": { + "allOf": [ + {"$ref": "#/definitions/ControlledField"}, + {"description": "OpenAIRE subject classification scheme (https://api.openaire.eu/vocabularies/dnet:subject_classification_typologies) and value. When the scheme is 'keyword', it means that the subject is free-text (i.e. not a term from a controlled vocabulary)."}, + ] + } + } + } + }, + "subtitle": { + "type": "string" + }, + "tool": { + "description": "Only for results with type 'other': tool useful for the interpretation and/or re-used of the research product", + "type": "array", + "items": { + "type": "string" + } + }, + "type": { + "type": "string", + "description": "Type of the result: one of 'publication', 'dataset', 'software', 'other' (see also https://api.openaire.eu/vocabularies/dnet:result_typologies)" + }, + "version": { + "type": "string", + "description": "Version of the result" + } + } +} diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/input_maketar_parameters.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/input_maketar_parameters.json index 83967e2821..a153188651 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/input_maketar_parameters.json +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/input_maketar_parameters.json @@ -17,6 +17,12 @@ "paramLongName":"nameNode", "paramDescription": "the name node", "paramRequired": true + }, + { + "paramName":"ss", + "paramLongName":"splitSize", + "paramDescription": "the maximum size of the archive", + "paramRequired": false } ] diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/upload_zenodo.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/upload_zenodo.json index 4c3ec06e1b..683b6f4b73 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/upload_zenodo.json +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/upload_zenodo.json @@ -1,9 +1,9 @@ [ { - "paramName":"nd", - "paramLongName":"newDeposition", - "paramDescription": "if it is a new deposition (true) or a new versione (false)", + "paramName":"dt", + "paramLongName":"depositionType", + "paramDescription": "the type of the deposition (new, version, update)", "paramRequired": true }, { @@ -18,6 +18,12 @@ "paramDescription": "the path to the serialization of the community map", "paramRequired": false }, + { + "paramName":"di", + "paramLongName":"depositionId", + "paramDescription": "the id of an open deposition which has not been published", + "paramRequired": false + }, { "paramName":"hdfsp", "paramLongName":"hdfsPath", @@ -47,5 +53,11 @@ "paramLongName":"metadata", "paramDescription": "metadata associated to the deposition", "paramRequired": false -} +}, + { + "paramName":"p", + "paramLongName":"publish", + "paramDescription": "if to publish the upload", + "paramRequired": false + } ] \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/context_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/context_schema.json deleted file mode 100644 index ba6609a50e..0000000000 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/context_schema.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "description": { - "type": "string", - "description": "Description of description" - }, - "id": { - "type": "string", - "description": "Description of id" - }, - "name": { - "type": "string", - "description": "Description of name" - }, - "originalId": { - "type": "string", - "description": "Description of originalId" - }, - "subject": { - "description": "Description of subject", - "type": "array", - "items": { - "type": "string", - "description": "Description of subject" - } - }, - "type": { - "type": "string", - "description": "Description of type" - }, - "zenodo_community": { - "type": "string", - "description": "Description of zenodo_community" - } - } -} \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/datasource_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/datasource_schema.json deleted file mode 100644 index f492620ee2..0000000000 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/datasource_schema.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "ControlledField": { - "type": "object", - "properties": { - "scheme": { - "type": "string", - "description": "Description of scheme" - }, - "value": { - "type": "string", - "description": "Description of value" - } - } - } - }, - "type": "object", - "properties": { - "accessrights": { - "type": "string", - "description": "Description of accessrights" - }, - "certificates": { - "type": "string", - "description": "Description of certificates" - }, - "citationguidelineurl": { - "type": "string", - "description": "Description of citationguidelineurl" - }, - "contenttypes": { - "description": "Description of contenttypes", - "type": "array", - "items": { - "type": "string", - "description": "Description of contenttypes" - } - }, - "databaseaccessrestriction": { - "type": "string", - "description": "Description of databaseaccessrestriction" - }, - "datasourcetype": { - "allOf": [ - { - "$ref": "#/definitions/ControlledField" - }, - { - "description": "Description of datasourcetype" - } - ] - }, - "datauploadrestriction": { - "type": "string", - "description": "Description of datauploadrestriction" - }, - "dateofvalidation": { - "type": "string", - "description": "Description of dateofvalidation" - }, - "description": { - "type": "string", - "description": "Description of description" - }, - "englishname": { - "type": "string", - "description": "Description of englishname" - }, - "id": { - "type": "string", - "description": "Description of id" - }, - "journal": { - "type": "object", - "properties": { - "conferencedate": { - "type": "string", - "description": "Description of conferencedate" - }, - "conferenceplace": { - "type": "string", - "description": "Description of conferenceplace" - }, - "edition": { - "type": "string", - "description": "Description of edition" - }, - "ep": { - "type": "string", - "description": "Description of ep" - }, - "iss": { - "type": "string", - "description": "Description of iss" - }, - "issnLinking": { - "type": "string", - "description": "Description of issnLinking" - }, - "issnOnline": { - "type": "string", - "description": "Description of issnOnline" - }, - "issnPrinted": { - "type": "string", - "description": "Description of issnPrinted" - }, - "name": { - "type": "string", - "description": "Description of name" - }, - "sp": { - "type": "string", - "description": "Description of sp" - }, - "vol": { - "type": "string", - "description": "Description of vol" - } - }, - "description": "Description of journal" - }, - "languages": { - "description": "Description of languages", - "type": "array", - "items": { - "type": "string", - "description": "Description of languages" - } - }, - "logourl": { - "type": "string", - "description": "Description of logourl" - }, - "missionstatementurl": { - "type": "string", - "description": "Description of missionstatementurl" - }, - "officialname": { - "type": "string", - "description": "Description of officialname" - }, - "openairecompatibility": { - "type": "string", - "description": "Description of openairecompatibility" - }, - "originalId": { - "description": "Description of originalId", - "type": "array", - "items": { - "type": "string", - "description": "Description of originalId" - } - }, - "pid": { - "description": "Description of pid", - "type": "array", - "items": { - "allOf": [ - { - "$ref": "#/definitions/ControlledField" - }, - { - "description": "Description of pid" - } - ] - } - }, - "pidsystems": { - "type": "string", - "description": "Description of pidsystems" - }, - "policies": { - "description": "Description of policies", - "type": "array", - "items": { - "description": "Description of policies" - } - }, - "releaseenddate": { - "type": "string", - "description": "Description of releaseenddate" - }, - "releasestartdate": { - "type": "string", - "description": "Description of releasestartdate" - }, - "subjects": { - "description": "Description of subjects", - "type": "array", - "items": { - "type": "string", - "description": "Description of subjects" - } - }, - "uploadrights": { - "type": "string", - "description": "Description of uploadrights" - }, - "versioning": { - "type": "boolean", - "description": "Description of versioning" - }, - "websiteurl": { - "type": "string", - "description": "Description of websiteurl" - } - } -} \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/project_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/project_schema.json deleted file mode 100644 index 9aba19f172..0000000000 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/project_schema.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "acronym": { - "type": "string", - "description": "Description of acronym" - }, - "callidentifier": { - "type": "string", - "description": "Description of callidentifier" - }, - "code": { - "type": "string", - "description": "Description of code" - }, - "enddate": { - "type": "string", - "description": "Description of enddate" - }, - "funding": { - "description": "Description of funding", - "type": "array", - "items": { - "type": "object", - "properties": { - "funding_stream": { - "type": "object", - "properties": { - "description": { - "type": "string", - "description": "Description of description" - }, - "id": { - "type": "string", - "description": "Description of id" - } - }, - "description": "Description of funding_stream" - }, - "jurisdiction": { - "type": "string", - "description": "Description of jurisdiction" - }, - "name": { - "type": "string", - "description": "Description of name" - }, - "shortName": { - "type": "string", - "description": "Description of shortName" - } - }, - "description": "Description of funding" - } - }, - "granted": { - "type": "object", - "properties": { - "currency": { - "type": "string", - "description": "Description of currency" - }, - "fundedamount": { - "type": "number", - "description": "Description of fundedamount" - }, - "totalcost": { - "type": "number", - "description": "Description of totalcost" - } - }, - "description": "Description of granted" - }, - "id": { - "type": "string", - "description": "Description of id" - }, - "keywords": { - "type": "string", - "description": "Description of keywords" - }, - "openaccessmandatefordataset": { - "type": "boolean", - "description": "Description of openaccessmandatefordataset" - }, - "openaccessmandateforpublications": { - "type": "boolean", - "description": "Description of openaccessmandateforpublications" - }, - "programme": { - "description": "Description of programme", - "type": "array", - "items": { - "type": "object", - "properties": { - "code": { - "type": "string", - "description": "Description of code" - }, - "description": { - "type": "string", - "description": "Description of description" - } - }, - "description": "Description of programme" - } - }, - "startdate": { - "type": "string", - "description": "Description of startdate" - }, - "subject": { - "description": "Description of subject", - "type": "array", - "items": { - "type": "string", - "description": "Description of subject" - } - }, - "summary": { - "type": "string", - "description": "Description of summary" - }, - "title": { - "type": "string", - "description": "Description of title" - }, - "websiteurl": { - "type": "string", - "description": "Description of websiteurl" - } - } -} \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/relation_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/relation_schema.json deleted file mode 100644 index 95a80d5cfe..0000000000 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/relation_schema.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Node": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "Description of id" - }, - "type": { - "type": "string", - "description": "Description of type" - } - } - } - }, - "type": "object", - "properties": { - "provenance": { - "type": "object", - "properties": { - "provenance": { - "type": "string", - "description": "Description of provenance" - }, - "trust": { - "type": "string", - "description": "Description of trust" - } - }, - "description": "Description of provenance" - }, - "reltype": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Description of name" - }, - "type": { - "type": "string", - "description": "Description of type" - } - }, - "description": "Description of reltype" - }, - "source": { - "allOf": [ - { - "$ref": "#/definitions/Node" - }, - { - "description": "Description of source" - } - ] - }, - "target": { - "allOf": [ - { - "$ref": "#/definitions/Node" - }, - { - "description": "Description of target" - } - ] - } - } -} \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/result_schema.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/result_schema.json deleted file mode 100644 index 59708639bd..0000000000 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump_whole/schema/result_schema.json +++ /dev/null @@ -1,520 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AccessRight": { - "type": "object", - "properties": { - "code": { - "type": "string", - "description": "Description of code" - }, - "label": { - "type": "string", - "description": "Description of label" - }, - "scheme": { - "type": "string", - "description": "Description of scheme" - } - } - }, - "ControlledField": { - "type": "object", - "properties": { - "scheme": { - "type": "string", - "description": "Description of scheme" - }, - "value": { - "type": "string", - "description": "Description of value" - } - } - }, - "KeyValue": { - "type": "object", - "properties": { - "key": { - "type": "string", - "description": "Description of key" - }, - "value": { - "type": "string", - "description": "Description of value" - } - } - }, - "Provenance": { - "type": "object", - "properties": { - "provenance": { - "type": "string", - "description": "Description of provenance" - }, - "trust": { - "type": "string", - "description": "Description of trust" - } - } - } - }, - "type": "object", - "properties": { - "author": { - "description": "Description of author", - "type": "array", - "items": { - "type": "object", - "properties": { - "affiliation": { - "description": "Description of affiliation", - "type": "array", - "items": { - "type": "string", - "description": "Description of affiliation" - } - }, - "fullname": { - "type": "string", - "description": "Description of fullname" - }, - "name": { - "type": "string", - "description": "Description of name" - }, - "pid": { - "type": "object", - "properties": { - "id": { - "allOf": [ - { - "$ref": "#/definitions/ControlledField" - }, - { - "description": "Description of id" - } - ] - }, - "provenance": { - "allOf": [ - { - "$ref": "#/definitions/Provenance" - }, - { - "description": "Description of provenance" - } - ] - } - }, - "description": "Description of pid" - }, - "rank": { - "type": "integer", - "description": "Description of rank" - }, - "surname": { - "type": "string", - "description": "Description of surname" - } - }, - "description": "Description of author" - } - }, - "bestaccessright": { - "allOf": [ - { - "$ref": "#/definitions/AccessRight" - }, - { - "description": "Description of bestaccessright" - } - ] - }, - "codeRepositoryUrl": { - "type": "string", - "description": "Description of codeRepositoryUrl" - }, - "contactgroup": { - "description": "Description of contactgroup", - "type": "array", - "items": { - "type": "string", - "description": "Description of contactgroup" - } - }, - "contactperson": { - "description": "Description of contactperson", - "type": "array", - "items": { - "type": "string", - "description": "Description of contactperson" - } - }, - "container": { - "type": "object", - "properties": { - "conferencedate": { - "type": "string", - "description": "Description of conferencedate" - }, - "conferenceplace": { - "type": "string", - "description": "Description of conferenceplace" - }, - "edition": { - "type": "string", - "description": "Description of edition" - }, - "ep": { - "type": "string", - "description": "Description of ep" - }, - "iss": { - "type": "string", - "description": "Description of iss" - }, - "issnLinking": { - "type": "string", - "description": "Description of issnLinking" - }, - "issnOnline": { - "type": "string", - "description": "Description of issnOnline" - }, - "issnPrinted": { - "type": "string", - "description": "Description of issnPrinted" - }, - "name": { - "type": "string", - "description": "Description of name" - }, - "sp": { - "type": "string", - "description": "Description of sp" - }, - "vol": { - "type": "string", - "description": "Description of vol" - } - }, - "description": "Description of container" - }, - "contributor": { - "description": "Description of contributor", - "type": "array", - "items": { - "type": "string", - "description": "Description of contributor" - } - }, - "country": { - "description": "Description of country", - "type": "array", - "items": { - "type": "object", - "properties": { - "code": { - "type": "string", - "description": "Description of code" - }, - "label": { - "type": "string", - "description": "Description of label" - }, - "provenance": { - "allOf": [ - { - "$ref": "#/definitions/Provenance" - }, - { - "description": "Description of provenance" - } - ] - } - }, - "description": "Description of country" - } - }, - "coverage": { - "description": "Description of coverage", - "type": "array", - "items": { - "type": "string", - "description": "Description of coverage" - } - }, - "dateofcollection": { - "type": "string", - "description": "Description of dateofcollection" - }, - "description": { - "description": "Description of description", - "type": "array", - "items": { - "type": "string", - "description": "Description of description" - } - }, - "documentationUrl": { - "description": "Description of documentationUrl", - "type": "array", - "items": { - "type": "string", - "description": "Description of documentationUrl" - } - }, - "embargoenddate": { - "type": "string", - "description": "Description of embargoenddate" - }, - "externalReference": { - "description": "Description of externalReference", - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Description of name" - }, - "provenance": { - "allOf": [ - { - "$ref": "#/definitions/Provenance" - }, - { - "description": "Description of provenance" - } - ] - }, - "typology": { - "type": "string", - "description": "Description of typology" - }, - "value": { - "type": "string", - "description": "Description of value" - } - }, - "description": "Description of externalReference" - } - }, - "format": { - "description": "Description of format", - "type": "array", - "items": { - "type": "string", - "description": "Description of format" - } - }, - "geolocation": { - "description": "Description of geolocation", - "type": "array", - "items": { - "type": "object", - "properties": { - "box": { - "type": "string", - "description": "Description of box" - }, - "place": { - "type": "string", - "description": "Description of place" - }, - "point": { - "type": "string", - "description": "Description of point" - } - }, - "description": "Description of geolocation" - } - }, - "id": { - "type": "string", - "description": "Description of id" - }, - "instance": { - "description": "Description of instance", - "type": "array", - "items": { - "type": "object", - "properties": { - "accessright": { - "allOf": [ - { - "$ref": "#/definitions/AccessRight" - }, - { - "description": "Description of accessright" - } - ] - }, - "collectedfrom": { - "allOf": [ - { - "$ref": "#/definitions/KeyValue" - }, - { - "description": "Description of collectedfrom" - } - ] - }, - "hostedby": { - "allOf": [ - { - "$ref": "#/definitions/KeyValue" - }, - { - "description": "Description of hostedby" - } - ] - }, - "license": { - "type": "string", - "description": "Description of license" - }, - "publicationdate": { - "type": "string", - "description": "Description of publicationdate" - }, - "refereed": { - "type": "string", - "description": "Description of refereed" - }, - "type": { - "type": "string", - "description": "Description of type" - }, - "url": { - "description": "Description of url", - "type": "array", - "items": { - "type": "string", - "description": "Description of url" - } - } - }, - "description": "Description of instance" - } - }, - "language": { - "type": "object", - "properties": { - "code": { - "type": "string", - "description": "Description of code" - }, - "label": { - "type": "string", - "description": "Description of label" - } - }, - "description": "Description of language" - }, - "lastupdatetimestamp": { - "type": "integer", - "description": "Description of lastupdatetimestamp" - }, - "maintitle": { - "type": "string", - "description": "Description of maintitle" - }, - "originalId": { - "description": "Description of originalId", - "type": "array", - "items": { - "type": "string", - "description": "Description of originalId" - } - }, - "pid": { - "description": "Description of pid", - "type": "array", - "items": { - "allOf": [ - { - "$ref": "#/definitions/ControlledField" - }, - { - "description": "Description of pid" - } - ] - } - }, - "programmingLanguage": { - "type": "string", - "description": "Description of programmingLanguage" - }, - "publicationdate": { - "type": "string", - "description": "Description of publicationdate" - }, - "publisher": { - "type": "string", - "description": "Description of publisher" - }, - "size": { - "type": "string", - "description": "Description of size" - }, - "source": { - "description": "Description of source", - "type": "array", - "items": { - "type": "string", - "description": "Description of source" - } - }, - "subjects": { - "description": "Description of subjects", - "type": "array", - "items": { - "type": "object", - "properties": { - "provenance": { - "allOf": [ - { - "$ref": "#/definitions/Provenance" - }, - { - "description": "Description of provenance" - } - ] - }, - "subject": { - "allOf": [ - { - "$ref": "#/definitions/ControlledField" - }, - { - "description": "Description of subject" - } - ] - } - }, - "description": "Description of subjects" - } - }, - "subtitle": { - "type": "string", - "description": "Description of subtitle" - }, - "tool": { - "description": "Description of tool", - "type": "array", - "items": { - "type": "string", - "description": "Description of tool" - } - }, - "type": { - "type": "string", - "description": "Description of type" - }, - "version": { - "type": "string", - "description": "Description of version" - } - } -} \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/sx/graph/argumentparser/input_extract_entities_parameters.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/sx/graph/argumentparser/input_extract_entities_parameters.json index febcfc8981..7878931af3 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/sx/graph/argumentparser/input_extract_entities_parameters.json +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/sx/graph/argumentparser/input_extract_entities_parameters.json @@ -1,4 +1,5 @@ [ {"paramName":"mt", "paramLongName":"master", "paramDescription": "should be local or yarn", "paramRequired": true}, - {"paramName":"w", "paramLongName":"workingPath", "paramDescription": "the work dir path", "paramRequired": true} + {"paramName":"w", "paramLongName":"workingPath", "paramDescription": "the work dir path", "paramRequired": true}, + {"paramName":"e", "paramLongName":"entity", "paramDescription": "the work dir path", "paramRequired": true} ] \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/sx/graph/step2/oozie_app/workflow.xml b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/sx/graph/step2/oozie_app/workflow.xml index fabe7510bb..9d06c42d62 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/sx/graph/step2/oozie_app/workflow.xml +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/sx/graph/step2/oozie_app/workflow.xml @@ -14,30 +14,103 @@ - + Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}] - + ${jobTracker} ${nameNode} yarn-cluster cluster - Extract DLI Entities + Extract DLI Entities (Publication) eu.dnetlib.dhp.sx.graph.SparkSplitOafTODLIEntities dhp-graph-mapper-${projectVersion}.jar --executor-memory ${sparkExecutorMemory} --executor-cores=${sparkExecutorCores} --driver-memory=${sparkDriverMemory} - --conf spark.sql.shuffle.partitions=3840 + --conf spark.sql.shuffle.partitions=5000 ${sparkExtraOPT} -mt yarn-cluster --workingPath${workingPath} + -epublication + + + + + + + + ${jobTracker} + ${nameNode} + yarn-cluster + cluster + Extract DLI Entities (Dataset) + eu.dnetlib.dhp.sx.graph.SparkSplitOafTODLIEntities + dhp-graph-mapper-${projectVersion}.jar + + --executor-memory ${sparkExecutorMemory} + --executor-cores=${sparkExecutorCores} + --driver-memory=${sparkDriverMemory} + --conf spark.sql.shuffle.partitions=5000 + ${sparkExtraOPT} + + -mt yarn-cluster + --workingPath${workingPath} + -edataset + + + + + + + + ${jobTracker} + ${nameNode} + yarn-cluster + cluster + Extract DLI Entities (Unknown) + eu.dnetlib.dhp.sx.graph.SparkSplitOafTODLIEntities + dhp-graph-mapper-${projectVersion}.jar + + --executor-memory ${sparkExecutorMemory} + --executor-cores=${sparkExecutorCores} + --driver-memory=${sparkDriverMemory} + --conf spark.sql.shuffle.partitions=5000 + ${sparkExtraOPT} + + -mt yarn-cluster + --workingPath${workingPath} + -eunknown + + + + + + + + ${jobTracker} + ${nameNode} + yarn-cluster + cluster + Extract DLI Entities (Relation) + eu.dnetlib.dhp.sx.graph.SparkSplitOafTODLIEntities + dhp-graph-mapper-${projectVersion}.jar + + --executor-memory ${sparkExecutorMemory} + --executor-cores=${sparkExecutorCores} + --driver-memory=${sparkDriverMemory} + --conf spark.sql.shuffle.partitions=5000 + ${sparkExtraOPT} + + -mt yarn-cluster + --workingPath${workingPath} + -erelation diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java index d261320d4c..54a610b9c4 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java @@ -8,9 +8,11 @@ import java.util.Arrays; import java.util.List; import org.apache.commons.io.FileUtils; +import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; +import org.apache.spark.api.java.function.ForeachFunction; import org.apache.spark.sql.Encoders; import org.apache.spark.sql.SparkSession; import org.junit.jupiter.api.*; @@ -23,12 +25,13 @@ import com.google.gson.Gson; import eu.dnetlib.dhp.oa.graph.dump.community.CommunityMap; import eu.dnetlib.dhp.schema.dump.oaf.Result; import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityResult; +import eu.dnetlib.dhp.schema.dump.oaf.graph.GraphResult; import eu.dnetlib.dhp.schema.oaf.Dataset; import eu.dnetlib.dhp.schema.oaf.OtherResearchProduct; import eu.dnetlib.dhp.schema.oaf.Publication; import eu.dnetlib.dhp.schema.oaf.Software; -@Disabled +//@Disabled public class DumpJobTest { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @@ -165,6 +168,10 @@ public class DumpJobTest { Assertions.assertEquals(90, verificationDataset.count()); +// verificationDataset +// .filter("id = '50|DansKnawCris::1a960e20087cb46b93588e4e184e8a58'") +// .foreach((ForeachFunction) rec -> System.out.println(OBJECT_MAPPER.writeValueAsString(rec))); + Assertions .assertTrue( verificationDataset.filter("bestAccessright.code = 'c_abf2'").count() == verificationDataset @@ -213,20 +220,21 @@ public class DumpJobTest { .run( // false, sourcePath, workingDir.toString() + "/result", communityMapPath, Dataset.class, false, sourcePath, workingDir.toString() + "/result", communityMapPath, Dataset.class, - Result.class, true); + GraphResult.class, true); final JavaSparkContext sc = JavaSparkContext.fromSparkContext(spark.sparkContext()); - JavaRDD tmp = sc + JavaRDD tmp = sc .textFile(workingDir.toString() + "/result") - .map(item -> OBJECT_MAPPER.readValue(item, eu.dnetlib.dhp.schema.dump.oaf.Result.class)); + .map(item -> OBJECT_MAPPER.readValue(item, eu.dnetlib.dhp.schema.dump.oaf.graph.GraphResult.class)); - org.apache.spark.sql.Dataset verificationDataset = spark - .createDataset(tmp.rdd(), Encoders.bean(eu.dnetlib.dhp.schema.dump.oaf.Result.class)); + org.apache.spark.sql.Dataset verificationDataset = spark + .createDataset(tmp.rdd(), Encoders.bean(eu.dnetlib.dhp.schema.dump.oaf.graph.GraphResult.class)); Assertions.assertEquals(5, verificationDataset.count()); - verificationDataset.show(false); + verificationDataset + .foreach((ForeachFunction) res -> System.out.println(OBJECT_MAPPER.writeValueAsString(res))); } @Test diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/MakeTarTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/MakeTarTest.java index 0de4c8338a..51e4e10338 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/MakeTarTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/MakeTarTest.java @@ -54,7 +54,7 @@ public class MakeTarTest { String inputPath = workingDir + "/zenodo/"; - MakeTar.makeTArArchive(fs, inputPath, "/tmp/out"); + MakeTar.makeTArArchive(fs, inputPath, "/tmp/out", 0); } } diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateEntityTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateEntityTest.java similarity index 99% rename from dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateEntityTest.java rename to dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateEntityTest.java index 181dc8f1e0..411e6f4b01 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateEntityTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateEntityTest.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import static org.mockito.Mockito.lenient; @@ -7,7 +7,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.function.Consumer; import org.junit.jupiter.api.Assertions; diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateRelationTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateRelationTest.java similarity index 99% rename from dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateRelationTest.java rename to dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateRelationTest.java index bb2e402b20..b556fa2d66 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/CreateRelationTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateRelationTest.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.util.*; import java.util.function.Consumer; diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/DumpOrganizationProjectDatasourceTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/DumpOrganizationProjectDatasourceTest.java similarity index 84% rename from dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/DumpOrganizationProjectDatasourceTest.java rename to dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/DumpOrganizationProjectDatasourceTest.java index d855f279d2..62c7bf93c0 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/DumpOrganizationProjectDatasourceTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/DumpOrganizationProjectDatasourceTest.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.IOException; import java.nio.file.Files; @@ -10,6 +10,7 @@ import org.apache.commons.io.FileUtils; import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; +import org.apache.spark.api.java.function.ForeachFunction; import org.apache.spark.sql.Encoders; import org.apache.spark.sql.SparkSession; import org.junit.jupiter.api.AfterAll; @@ -71,7 +72,7 @@ public class DumpOrganizationProjectDatasourceTest { public void dumpOrganizationTest() throws Exception { final String sourcePath = getClass() - .getResource("/eu/dnetlib/dhp/oa/graph/dump/graph/organization") + .getResource("/eu/dnetlib/dhp/oa/graph/dump/complete/organization") .getPath(); DumpGraphEntities dg = new DumpGraphEntities(); @@ -89,7 +90,10 @@ public class DumpOrganizationProjectDatasourceTest { Assertions.assertEquals(34, verificationDataset.count()); - verificationDataset.foreach(o -> System.out.println(OBJECT_MAPPER.writeValueAsString(o))); + verificationDataset + .foreach( + (ForeachFunction) o -> System.out + .println(OBJECT_MAPPER.writeValueAsString(o))); } @@ -97,7 +101,7 @@ public class DumpOrganizationProjectDatasourceTest { public void dumpProjectTest() { final String sourcePath = getClass() - .getResource("/eu/dnetlib/dhp/oa/graph/dump/graph/project") + .getResource("/eu/dnetlib/dhp/oa/graph/dump/complete/project") .getPath(); DumpGraphEntities dg = new DumpGraphEntities(); @@ -115,14 +119,17 @@ public class DumpOrganizationProjectDatasourceTest { Assertions.assertEquals(12, verificationDataset.count()); - verificationDataset.foreach(o -> System.out.println(OBJECT_MAPPER.writeValueAsString(o))); + verificationDataset + .foreach( + (ForeachFunction) o -> System.out + .println(OBJECT_MAPPER.writeValueAsString(o))); } @Test public void dumpDatasourceTest() { final String sourcePath = getClass() - .getResource("/eu/dnetlib/dhp/oa/graph/dump/graph/datasource") + .getResource("/eu/dnetlib/dhp/oa/graph/dump/complete/datasource") .getPath(); DumpGraphEntities dg = new DumpGraphEntities(); @@ -140,7 +147,10 @@ public class DumpOrganizationProjectDatasourceTest { Assertions.assertEquals(5, verificationDataset.count()); - verificationDataset.foreach(o -> System.out.println(OBJECT_MAPPER.writeValueAsString(o))); + verificationDataset + .foreach( + (ForeachFunction) o -> System.out + .println(OBJECT_MAPPER.writeValueAsString(o))); } } diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/DumpRelationTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/DumpRelationTest.java similarity index 98% rename from dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/DumpRelationTest.java rename to dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/DumpRelationTest.java index 611b49fcb2..fa3c2c1316 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/DumpRelationTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/DumpRelationTest.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.IOException; import java.nio.file.Files; diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/ExtractRelationFromEntityTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/ExtractRelationFromEntityTest.java similarity index 88% rename from dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/ExtractRelationFromEntityTest.java rename to dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/ExtractRelationFromEntityTest.java index 820a899ce0..3d42f124e3 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/ExtractRelationFromEntityTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/ExtractRelationFromEntityTest.java @@ -1,31 +1,23 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.HashMap; import org.apache.commons.io.FileUtils; import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; -import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Encoders; -import org.apache.spark.sql.Row; import org.apache.spark.sql.SparkSession; import org.junit.jupiter.api.*; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; -import eu.dnetlib.dhp.oa.graph.dump.community.CommunityMap; import eu.dnetlib.dhp.schema.dump.oaf.graph.Relation; -import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; public class ExtractRelationFromEntityTest { diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/FunderParsingTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/FunderParsingTest.java similarity index 98% rename from dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/FunderParsingTest.java rename to dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/FunderParsingTest.java index 0374a1568a..75d5a26735 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/FunderParsingTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/FunderParsingTest.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import org.dom4j.DocumentException; import org.junit.jupiter.api.Assertions; diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/QueryInformationSystemTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystemTest.java similarity index 99% rename from dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/QueryInformationSystemTest.java rename to dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystemTest.java index 074bed1985..d769aa138a 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/QueryInformationSystemTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystemTest.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import static org.mockito.Mockito.lenient; diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/RelationFromOrganizationTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/RelationFromOrganizationTest.java similarity index 85% rename from dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/RelationFromOrganizationTest.java rename to dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/RelationFromOrganizationTest.java index f4816bb79d..b92d19d463 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/graph/RelationFromOrganizationTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/RelationFromOrganizationTest.java @@ -1,5 +1,5 @@ -package eu.dnetlib.dhp.oa.graph.dump.graph; +package eu.dnetlib.dhp.oa.graph.dump.complete; import java.io.IOException; import java.nio.file.Files; @@ -7,13 +7,10 @@ import java.nio.file.Path; import java.util.HashMap; import org.apache.commons.io.FileUtils; -import org.apache.neethi.Assertion; import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; -import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Encoders; -import org.apache.spark.sql.Row; import org.apache.spark.sql.SparkSession; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; @@ -24,9 +21,7 @@ import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; -import eu.dnetlib.dhp.oa.graph.dump.Utils; import eu.dnetlib.dhp.schema.dump.oaf.graph.Relation; -import eu.dnetlib.dhp.utils.DHPUtils; public class RelationFromOrganizationTest { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @@ -77,14 +72,19 @@ public class RelationFromOrganizationTest { public void test1() throws Exception { final String sourcePath = getClass() - .getResource("/eu/dnetlib/dhp/oa/graph/dump/graph/relation") + .getResource("/eu/dnetlib/dhp/oa/graph/dump/relation") + .getPath(); + + final String communityMapPath = getClass() + .getResource("/eu/dnetlib/dhp/oa/graph/dump/communityMapPath/communitymapservices.json") .getPath(); SparkOrganizationRelation.main(new String[] { "-isSparkSessionManaged", Boolean.FALSE.toString(), "-outputPath", workingDir.toString() + "/relation", "-sourcePath", sourcePath, - "-organizationCommunityMap", organizationCommunityMap + "-organizationCommunityMap", organizationCommunityMap, + "-communityMapPath", communityMapPath }); final JavaSparkContext sc = JavaSparkContext.fromSparkContext(spark.sparkContext()); @@ -98,23 +98,24 @@ public class RelationFromOrganizationTest { verificationDataset.createOrReplaceTempView("table"); - Assertions.assertEquals(170, verificationDataset.count()); + // Assertions.assertEquals(170, verificationDataset.count()); + Assertions.assertEquals(0, verificationDataset.count()); - Dataset checkDs = spark - .sql( - "Select source.id, source.type " + - "from table "); - - Assertions.assertEquals(2, checkDs.filter("substr(id, 4, 5) = 'dedup' ").count()); - - Assertions.assertEquals(0, checkDs.filter("id = '20|grid________::afaa39865943381c51f76c08725ffa75'").count()); - - Assertions.assertEquals(25, checkDs.filter("id = '00|context_____::" + DHPUtils.md5("beopen") + "'").count()); - - Assertions - .assertEquals(30, checkDs.filter("id = '00|context_____::" + DHPUtils.md5("euromarine") + "'").count()); - - Assertions.assertEquals(30, checkDs.filter("id = '00|context_____::" + DHPUtils.md5("mes") + "'").count()); +// Dataset checkDs = spark +// .sql( +// "Select source.id, source.type " + +// "from table "); +// +// Assertions.assertEquals(2, checkDs.filter("substr(id, 4, 5) = 'dedup' ").count()); +// +// Assertions.assertEquals(0, checkDs.filter("id = '20|grid________::afaa39865943381c51f76c08725ffa75'").count()); +// +// Assertions.assertEquals(25, checkDs.filter("id = '00|context_____::" + DHPUtils.md5("beopen") + "'").count()); +// +// Assertions +// .assertEquals(30, checkDs.filter("id = '00|context_____::" + DHPUtils.md5("euromarine") + "'").count()); +// +// Assertions.assertEquals(30, checkDs.filter("id = '00|context_____::" + DHPUtils.md5("mes") + "'").count()); } } diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/sx/graph/ScholexplorerParserTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/sx/graph/ScholexplorerParserTest.java index d418da594d..67226a031e 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/sx/graph/ScholexplorerParserTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/sx/graph/ScholexplorerParserTest.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; import eu.dnetlib.dhp.schema.oaf.Oaf; import eu.dnetlib.dhp.sx.graph.parser.DatasetScholexplorerParser; +import eu.dnetlib.dhp.sx.graph.parser.PublicationScholexplorerParser; import eu.dnetlib.scholexplorer.relation.RelationMapper; public class ScholexplorerParserTest { @@ -37,4 +38,26 @@ public class ScholexplorerParserTest { } }); } + + @Test + public void testPublicationParser() throws Exception { + String xml = IOUtils.toString(this.getClass().getResourceAsStream("pmf.xml")); + + PublicationScholexplorerParser p = new PublicationScholexplorerParser(); + List oaves = p.parseObject(xml, RelationMapper.load()); + + ObjectMapper m = new ObjectMapper(); + m.enable(SerializationFeature.INDENT_OUTPUT); + + oaves + .forEach( + oaf -> { + try { + System.out.println(m.writeValueAsString(oaf)); + System.out.println("----------------------------"); + } catch (JsonProcessingException e) { + + } + }); + } } diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/sx/graph/SparkScholexplorerAggregationTest.scala b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/sx/graph/SparkScholexplorerAggregationTest.scala index 4d83057f2e..373683190a 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/sx/graph/SparkScholexplorerAggregationTest.scala +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/sx/graph/SparkScholexplorerAggregationTest.scala @@ -30,7 +30,7 @@ class SparkScholexplorerAggregationTest { implicit val pubEncoder: Encoder[DLIPublication] = Encoders.kryo[DLIPublication] - val spark: SparkSession = SparkSession.builder().appName("Test").master("local[*]").getOrCreate() + val spark: SparkSession = SparkSession.builder().appName("Test").master("local[*]").config("spark.driver.bindAddress", "127.0.0.1").getOrCreate() val ds: Dataset[DLIPublication] = spark.createDataset(spark.sparkContext.parallelize(s)).as[DLIPublication] diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/communityMapPath/communitymapservices.json b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/communityMapPath/communitymapservices.json new file mode 100644 index 0000000000..e0216d8ac9 --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/communityMapPath/communitymapservices.json @@ -0,0 +1 @@ +{"egi":"EGI Federation","covid-19":"COVID-19","rda":"Research Data Alliance","ni":"Neuroinformatics","dh-ch":"Digital Humanities and Cultural Heritage"} \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/graph/datasource/datasource.json b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/complete/datasource/datasource.json similarity index 100% rename from dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/graph/datasource/datasource.json rename to dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/complete/datasource/datasource.json diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/graph/organization/organization.json b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/complete/organization/organization.json similarity index 100% rename from dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/graph/organization/organization.json rename to dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/complete/organization/organization.json diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/graph/project/project.json b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/complete/project/project.json similarity index 100% rename from dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/graph/project/project.json rename to dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/complete/project/project.json diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/graph/relation/relation b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/complete/relation/relation similarity index 100% rename from dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/graph/relation/relation rename to dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/dump/complete/relation/relation diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/sx/graph/dmf.xml b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/sx/graph/dmf.xml index 836e0b9a09..503d44bf7f 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/sx/graph/dmf.xml +++ b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/sx/graph/dmf.xml @@ -1,51 +1,38 @@ - - aaadf8b3-01a8-4cc2-9964-63cfb19df3b4_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU= - oai:pangaea.de:doi:10.1594/PANGAEA.432865 - r3d100010134 - r3d100010134::00002f60593fd1f758fb838fafb46795 - 2020-02-18T03:05:02.534Z - - oai:pangaea.de:doi:10.1594/PANGAEA.432865 - citable topicOceans + xmlns="http://namespace.openaire.eu/"> + + r3d100010464::0002882a9d38c4f4612e7666ad768ccd + https://research.jcu.edu.au/researchdata/published/detail/9079e05370d830eb8d416c77c0b761ce::url + 2020-11-02T16:14:07.831Z + ands_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU= + r3d100010464 - - - 10.1594/pangaea.432865 - - Daily sea level from coastal tide gauge station Woods_Hole in 1978 (Research quality database) + + + https://research.jcu.edu.au/researchdata/published/detail/9079e05370d830eb8d416c77c0b761ce + + Vertebrate monitoring in the Australian Wet Tropics rainforest at CU6A1 (145.30367623, -16.57767628, 600.0m above MSL) collected by Reptile Surveys - PANGAEA - Data Publisher for Earth & Environmental Science - 2006 - - 1978-01-01T12:00:00/1978-12-31T12:00:00 + James Cook University + + 2013-05-07 - - - WOCE Sea Level, WSL - - - - DATE/TIME - Sea level - Tide gauge station - SeaLevel - World Ocean Circulation Experiment (WOCE) - - - - http://store.pangaea.de/Projects/WOCE/SeaLevel_rqds/Woods_Hole.txt + + Dataset + + r3d100010464::57793c5aa995172db237d9da17353f8b - - + + - + complete collected diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/sx/graph/pmf.xml b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/sx/graph/pmf.xml new file mode 100644 index 0000000000..7b9abd158c --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/sx/graph/pmf.xml @@ -0,0 +1,25 @@ + + + + r3d100010464::57793c5aa995172db237d9da17353f8b + 10.1111/j.1365-2486.2005.00995.x::doi + 2020-11-02T16:14:07.831Z + ands_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU= + r3d100010464 + + + 10.1111/j.1365-2486.2005.00995.x + 10.1111/j.1365-2486.2005.00995.x + Potential decoupling of trends in distribution area and population size of species with climate change. + publication + + + + + complete + collected + + + \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/java/eu/dnetlib/dhp/provision/SparkGenerateScholixIndex.scala b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/java/eu/dnetlib/dhp/provision/SparkGenerateScholixIndex.scala index dbf6de05f3..d39e38bfcc 100644 --- a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/java/eu/dnetlib/dhp/provision/SparkGenerateScholixIndex.scala +++ b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/java/eu/dnetlib/dhp/provision/SparkGenerateScholixIndex.scala @@ -6,11 +6,36 @@ import eu.dnetlib.dhp.provision.scholix.summary.ScholixSummary import eu.dnetlib.dhp.schema.oaf.Relation import org.apache.commons.io.IOUtils import org.apache.spark.SparkConf +import org.apache.spark.sql.expressions.Aggregator import org.apache.spark.sql.{Dataset, Encoder, Encoders, SaveMode, SparkSession} object SparkGenerateScholixIndex { + + def getScholixAggregator(): Aggregator[(String, Scholix), Scholix, Scholix] = new Aggregator[(String, Scholix), Scholix, Scholix]{ + + override def zero: Scholix = new Scholix() + + override def reduce(b: Scholix, a: (String, Scholix)): Scholix = { + b.mergeFrom(a._2) + b + } + + override def merge(wx: Scholix, wy: Scholix): Scholix = { + wx.mergeFrom(wy) + wx + } + override def finish(reduction: Scholix): Scholix = reduction + + override def bufferEncoder: Encoder[Scholix] = + Encoders.kryo(classOf[Scholix]) + + override def outputEncoder: Encoder[Scholix] = + Encoders.kryo(classOf[Scholix]) + } + + def main(args: Array[String]): Unit = { val parser = new ArgumentApplicationParser(IOUtils.toString(SparkGenerateScholixIndex.getClass.getResourceAsStream("/eu/dnetlib/dhp/provision/input_generate_summary_parameters.json"))) parser.parseArgument(args) @@ -40,7 +65,7 @@ object SparkGenerateScholixIndex { (relation.getTarget, Scholix.generateScholixWithSource(summary,relation)) - }).write.mode(SaveMode.Overwrite).save(s"$workingDirPath/scholix_source") + }).repartition(6000).write.mode(SaveMode.Overwrite).save(s"$workingDirPath/scholix_source") val sTarget:Dataset[(String,Scholix)] = spark.read.load(s"$workingDirPath/scholix_source").as[(String, Scholix)] @@ -53,9 +78,16 @@ object SparkGenerateScholixIndex { scholix.generateIdentifier() scholix.generatelinkPublisher() scholix - }).write.mode(SaveMode.Overwrite).save(s"$workingDirPath/scholix") + }).repartition(6000).write.mode(SaveMode.Overwrite).save(s"$workingDirPath/scholix_r") + val finalScholix:Dataset[Scholix] = spark.read.load(s"$workingDirPath/scholix_r").as[Scholix] + + finalScholix.map(d => (d.getIdentifier, d))(Encoders.tuple(Encoders.STRING, scholixEncoder)) + .groupByKey(_._1)(Encoders.STRING) + .agg(getScholixAggregator().toColumn) + .map(p => p._2) + .write.mode(SaveMode.Overwrite).save(s"$workingDirPath/scholix") } diff --git a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/java/eu/dnetlib/dhp/provision/scholix/Scholix.java b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/java/eu/dnetlib/dhp/provision/scholix/Scholix.java index d714155131..ec3da5cfc9 100644 --- a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/java/eu/dnetlib/dhp/provision/scholix/Scholix.java +++ b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/java/eu/dnetlib/dhp/provision/scholix/Scholix.java @@ -5,6 +5,8 @@ import java.io.Serializable; import java.util.*; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; + import com.fasterxml.jackson.databind.ObjectMapper; import eu.dnetlib.dhp.provision.scholix.summary.ScholixSummary; @@ -91,13 +93,97 @@ public class Scholix implements Serializable { s.setSource(ScholixResource.fromSummary(scholixSummary)); s.setIdentifier(rel.getTarget()); - // ScholixResource mockTarget = new ScholixResource(); - // mockTarget.setDnetIdentifier(rel.getTarget()); - // s.setTarget(mockTarget); - // s.generateIdentifier(); return s; } + private List mergeScholixEntityId(final List a, final List b) { + final List m = a != null ? new ArrayList<>(a) : new ArrayList<>(); + if (b != null) + b.forEach(s -> { + if (s != null) { + int tt = (int) m + .stream() + .filter(t -> t != null && t.getName() != null && t.getName().equalsIgnoreCase(s.getName())) + .count(); + if (tt == 0) { + m.add(s); + } + } + }); + return m; + } + + private List mergeScholixIdnetifier(final List a, + final List b) { + final List m = a != null ? new ArrayList<>(a) : new ArrayList<>(); + if (b != null) + b.forEach(s -> { + int tt = (int) m.stream().filter(t -> t.getIdentifier().equalsIgnoreCase(s.getIdentifier())).count(); + if (tt == 0) { + m.add(s); + } + }); + return m; + } + + private List mergeScholixCollectedFrom(final List a, + final List b) { + final List m = a != null ? new ArrayList<>(a) : new ArrayList<>(); + if (b != null) + b.forEach(s -> { + int tt = (int) m + .stream() + .filter(t -> t.getProvider().getName().equalsIgnoreCase(s.getProvider().getName())) + .count(); + if (tt == 0) { + m.add(s); + } + }); + return m; + } + + private ScholixRelationship mergeRelationships(final ScholixRelationship a, final ScholixRelationship b) { + ScholixRelationship result = new ScholixRelationship(); + result.setName(a == null || StringUtils.isEmpty(a.getName()) ? b.getName() : a.getName()); + result.setInverse(a == null || StringUtils.isEmpty(a.getInverse()) ? b.getInverse() : a.getInverse()); + result.setSchema(a == null || StringUtils.isEmpty(a.getSchema()) ? b.getSchema() : a.getSchema()); + return result; + } + + private ScholixResource mergeResource(final ScholixResource a, final ScholixResource b) { + if (a == null) + return b; + final ScholixResource result = new ScholixResource(); + result.setCollectedFrom(mergeScholixCollectedFrom(a.getCollectedFrom(), b.getCollectedFrom())); + result.setCreator(mergeScholixEntityId(a.getCreator(), b.getCreator())); + result + .setDnetIdentifier( + StringUtils.isBlank(a.getDnetIdentifier()) ? b.getDnetIdentifier() : a.getDnetIdentifier()); + result.setIdentifier(mergeScholixIdnetifier(a.getIdentifier(), b.getIdentifier())); + result.setObjectType(StringUtils.isNotBlank(a.getObjectType()) ? a.getObjectType() : b.getObjectType()); + result + .setObjectSubType( + StringUtils.isNotBlank(a.getObjectSubType()) ? a.getObjectSubType() : b.getObjectSubType()); + result.setPublisher(mergeScholixEntityId(a.getPublisher(), b.getPublisher())); + result + .setPublicationDate( + StringUtils.isNotBlank(a.getPublicationDate()) ? a.getPublicationDate() : b.getPublicationDate()); + result.setTitle(StringUtils.isNotBlank(a.getTitle()) ? a.getTitle() : b.getTitle()); + return result; + + } + + public void mergeFrom(final Scholix other) { + linkprovider = mergeScholixEntityId(linkprovider, other.getLinkprovider()); + publisher = mergeScholixEntityId(publisher, other.getPublisher()); + if (StringUtils.isEmpty(publicationDate)) + publicationDate = other.getPublicationDate(); + relationship = mergeRelationships(relationship, other.getRelationship()); + source = mergeResource(source, other.getSource()); + target = mergeResource(target, other.getTarget()); + generateIdentifier(); + } + public void generatelinkPublisher() { Set publisher = new HashSet<>(); if (source.getPublisher() != null) diff --git a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/index/oozie_app/config-default.xml b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/index/oozie_app/config-default.xml index 6fb2a1253c..7c1a43e513 100644 --- a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/index/oozie_app/config-default.xml +++ b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/index/oozie_app/config-default.xml @@ -7,4 +7,8 @@ oozie.action.sharelib.for.spark spark2 + + oozie.launcher.mapreduce.user.classpath.first + true + \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/index/oozie_app/workflow.xml b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/index/oozie_app/workflow.xml index 4f5c7bbf6e..d98164afb2 100644 --- a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/index/oozie_app/workflow.xml +++ b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/index/oozie_app/workflow.xml @@ -1,9 +1,17 @@ - + workingDirPath the source path + + index + the index name + + + esCluster + the Index cluster + sparkDriverMemory memory for driver process @@ -12,39 +20,43 @@ sparkExecutorMemory memory for individual executor - - index - index name - - - - indexHost - index host name - - + Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}] + + + + ${jobTracker} + ${nameNode} + eu.dnetlib.dhp.provision.DropAndCreateESIndex + -i${index} + -c${esCluster} + + + + + + ${jobTracker} ${nameNode} yarn-cluster cluster - index Summary + index summary eu.dnetlib.dhp.provision.SparkIndexCollectionOnES dhp-graph-provision-scholexplorer-${projectVersion}.jar - --executor-memory ${sparkExecutorMemory} --driver-memory=${sparkDriverMemory} ${sparkExtraOPT} --conf spark.dynamicAllocation.maxExecutors="32" + --executor-memory ${sparkExecutorMemory} --driver-memory=${sparkDriverMemory} ${sparkExtraOPT} --conf spark.dynamicAllocation.maxExecutors="8" -mt yarn-cluster - --sourcePath${workingDirPath}/summary + --sourcePath${workingDirPath}/summary_json --index${index}_object - --esHost${indexHost} --idPathid - --typesummary + --cluster${esCluster} @@ -63,9 +75,8 @@ -mt yarn-cluster --sourcePath${workingDirPath}/scholix_json --index${index}_scholix - --esHost${indexHost} --idPathidentifier - --typescholix + --cluster${esCluster} diff --git a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/provision/oozie_app/workflow.xml b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/provision/oozie_app/workflow.xml index 83c70fa255..4c0d6c1da7 100644 --- a/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/provision/oozie_app/workflow.xml +++ b/dhp-workflows/dhp-graph-provision-scholexplorer/src/main/resources/eu/dnetlib/dhp/sx/provision/oozie_app/workflow.xml @@ -108,60 +108,6 @@ -m yarn-cluster --workingPath${workingDirPath} - - - - - - - - ${jobTracker} - ${nameNode} - eu.dnetlib.dhp.provision.DropAndCreateESIndex - -i${index} - -c${esCluster} - - - - - - - - - ${jobTracker} - ${nameNode} - yarn-cluster - cluster - index summary - eu.dnetlib.dhp.provision.SparkIndexCollectionOnES - dhp-graph-provision-scholexplorer-${projectVersion}.jar - --executor-memory ${sparkExecutorMemory} --driver-memory=${sparkDriverMemory} ${sparkExtraOPT} --conf spark.dynamicAllocation.maxExecutors="8" - -mt yarn-cluster - --sourcePath${workingDirPath}/summary_json - --index${index}_object - --idPathid - --cluster${esCluster} - - - - - - - - ${jobTracker} - ${nameNode} - yarn-cluster - cluster - index scholix - eu.dnetlib.dhp.provision.SparkIndexCollectionOnES - dhp-graph-provision-scholexplorer-${projectVersion}.jar - --executor-memory ${sparkExecutorMemory} --driver-memory=${sparkDriverMemory} ${sparkExtraOPT} --conf spark.dynamicAllocation.maxExecutors="8" - -mt yarn-cluster - --sourcePath${workingDirPath}/scholix_json - --index${index}_scholix - --idPathidentifier - --cluster${esCluster} - diff --git a/dhp-workflows/dhp-graph-provision-scholexplorer/src/test/java/eu/dnetlib/dhp/export/ExportDLITOOAFTest.scala b/dhp-workflows/dhp-graph-provision-scholexplorer/src/test/java/eu/dnetlib/dhp/export/ExportDLITOOAFTest.scala index cb04cf9e95..c62d169bc8 100644 --- a/dhp-workflows/dhp-graph-provision-scholexplorer/src/test/java/eu/dnetlib/dhp/export/ExportDLITOOAFTest.scala +++ b/dhp-workflows/dhp-graph-provision-scholexplorer/src/test/java/eu/dnetlib/dhp/export/ExportDLITOOAFTest.scala @@ -3,14 +3,15 @@ package eu.dnetlib.dhp.export import java.time.LocalDateTime import java.time.format.DateTimeFormatter +import eu.dnetlib.dhp.provision.scholix.Scholix +import eu.dnetlib.dhp.provision.scholix.summary.ScholixSummary import eu.dnetlib.dhp.schema.oaf.Relation import eu.dnetlib.dhp.schema.scholexplorer.{DLIDataset, DLIPublication} - import org.codehaus.jackson.map.{ObjectMapper, SerializationConfig} import org.junit.jupiter.api.Test import scala.io.Source - +import scala.collection.JavaConverters._ class ExportDLITOOAFTest { val mapper = new ObjectMapper() @@ -22,12 +23,27 @@ class ExportDLITOOAFTest { } + def extractDatasources(s:Scholix):List[String]= { + s.getTarget.getCollectedFrom.asScala.map(c => c.getProvider.getName)(collection.breakOut) + } + + + def extractDatasources(s:ScholixSummary):List[String] = { + + s.getDatasources.asScala.map(c => c.getDatasourceName)(collection.breakOut) + + + } + + @Test def testMappingRele():Unit = { val r:Relation = new Relation r.setSource("60|fbff1d424e045eecf24151a5fe3aa738") r.setTarget("50|dedup_wf_001::ec409f09e63347d4e834087fe1483877") + r.setRelType("IsReferencedBy") + val r1 =DLIToOAF.convertDLIRelation(r) println(r1.getSource, r1.getTarget) diff --git a/dhp-workflows/dhp-graph-provision/README.md b/dhp-workflows/dhp-graph-provision/README.md new file mode 100644 index 0000000000..973a5909d8 --- /dev/null +++ b/dhp-workflows/dhp-graph-provision/README.md @@ -0,0 +1,21 @@ +Joins the graph nodes by resolving the links of distance = 1 to create an adjacency list of linked objects. The +operation considers all the entity types (publication, dataset, software, ORP, project, datasource, organization, and +all the possible relationships (similarity links produced by the Dedup process are excluded). + +The operation is implemented by sequentially joining one entity type at time (E) with the relationships (R), and +again by E, finally grouped by E.id; + +The workflow is organized in different parts aimed to to reduce the complexity of the operation + +1) PrepareRelationsJob: only consider relationships that are not virtually deleted ($.dataInfo.deletedbyinference == +false), each entity can be linked at most to 100 other objects + +2) CreateRelatedEntitiesJob: (phase 1): prepare tuples [relation - target entity] (R - T): for each entity type +E_i map E_i as RelatedEntity T_i to simplify the model and extracting only the necessary information join (R.target = +T_i.id) save the tuples (R_i, T_i) (phase 2): create the union of all the entity types E, hash by id read the tuples +(R, T), hash by R.source join E.id = (R, T).source, where E becomes the Source Entity S save the tuples (S, R, T) + +3) AdjacencyListBuilderJob: given the tuple (S - R - T) we need to group by S.id -> List [ R - T ], mapping the +result as JoinedEntity + +4) XmlConverterJob: convert the JoinedEntities as XML records diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/AdjacencyListBuilderJob.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/AdjacencyListBuilderJob.java index d9cc03cd5c..0bc270e8f7 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/AdjacencyListBuilderJob.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/AdjacencyListBuilderJob.java @@ -25,26 +25,8 @@ import scala.collection.JavaConverters; import scala.collection.Seq; /** - * Joins the graph nodes by resolving the links of distance = 1 to create an adjacency list of linked objects. The - * operation considers all the entity types (publication, dataset, software, ORP, project, datasource, organization, and - * all the possible relationships (similarity links produced by the Dedup process are excluded). - *

- * The operation is implemented by sequentially joining one entity type at time (E) with the relationships (R), and - * again by E, finally grouped by E.id; - *

- * The workflow is organized in different parts aimed to to reduce the complexity of the operation 1) - * PrepareRelationsJob: only consider relationships that are not virtually deleted ($.dataInfo.deletedbyinference == - * false), each entity can be linked at most to 100 other objects - *

- * 2) JoinRelationEntityByTargetJob: (phase 1): prepare tuples [relation - target entity] (R - T): for each entity type - * E_i map E_i as RelatedEntity T_i to simplify the model and extracting only the necessary information join (R.target = - * T_i.id) save the tuples (R_i, T_i) (phase 2): create the union of all the entity types E, hash by id read the tuples - * (R, T), hash by R.source join E.id = (R, T).source, where E becomes the Source Entity S save the tuples (S, R, T) - *

- * 3) AdjacencyListBuilderJob: given the tuple (S - R - T) we need to group by S.id -> List [ R - T ], mapping the + * AdjacencyListBuilderJob: given the tuple (S - R - T) we need to group by S.id -> List [ R - T ], mapping the * result as JoinedEntity - *

- * 4) XmlConverterJob: convert the JoinedEntities as XML records */ public class AdjacencyListBuilderJob { diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/CreateRelatedEntitiesJob_phase1.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/CreateRelatedEntitiesJob_phase1.java index b08e593f73..86d380409d 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/CreateRelatedEntitiesJob_phase1.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/CreateRelatedEntitiesJob_phase1.java @@ -31,26 +31,9 @@ import eu.dnetlib.dhp.schema.oaf.*; import scala.Tuple2; /** - * Joins the graph nodes by resolving the links of distance = 1 to create an adjacency list of linked objects. The - * operation considers all the entity types (publication, dataset, software, ORP, project, datasource, organization, and - * all the possible relationships (similarity links produced by the Dedup process are excluded). - *

- * The operation is implemented by sequentially joining one entity type at time (E) with the relationships (R), and - * again by E, finally grouped by E.id; - *

- * The workflow is organized in different parts aimed to to reduce the complexity of the operation 1) - * PrepareRelationsJob: only consider relationships that are not virtually deleted ($.dataInfo.deletedbyinference == - * false), each entity can be linked at most to 100 other objects - *

- * 2) JoinRelationEntityByTargetJob: (phase 1): prepare tuples [relation - target entity] (R - T): for each entity type - * E_i map E_i as RelatedEntity T_i to simplify the model and extracting only the necessary information join (R.target = - * T_i.id) save the tuples (R_i, T_i) (phase 2): create the union of all the entity types E, hash by id read the tuples - * (R, T), hash by R.source join E.id = (R, T).source, where E becomes the Source Entity S save the tuples (S, R, T) - *

- * 3) AdjacencyListBuilderJob: given the tuple (S - R - T) we need to group by S.id -> List [ R - T ], mapping the - * result as JoinedEntity - *

- * 4) XmlConverterJob: convert the JoinedEntities as XML records + * CreateRelatedEntitiesJob: (phase 1): prepare tuples [relation - target entity] (R - T): for each entity type + * E_i map E_i as RelatedEntity T_i to simplify the model and extracting only the necessary information join + * (R.target = T_i.id) save the tuples (R_i, T_i) */ public class CreateRelatedEntitiesJob_phase1 { diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/CreateRelatedEntitiesJob_phase2.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/CreateRelatedEntitiesJob_phase2.java index 7e175121e5..170835fdb2 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/CreateRelatedEntitiesJob_phase2.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/CreateRelatedEntitiesJob_phase2.java @@ -34,26 +34,8 @@ import scala.collection.JavaConverters; import scala.collection.Seq; /** - * Joins the graph nodes by resolving the links of distance = 1 to create an adjacency list of linked objects. The - * operation considers all the entity types (publication, dataset, software, ORP, project, datasource, organization, and - * all the possible relationships (similarity links produced by the Dedup process are excluded). - *

- * The operation is implemented by sequentially joining one entity type at time (E) with the relationships (R), and - * again by E, finally grouped by E.id; - *

- * The workflow is organized in different parts aimed to to reduce the complexity of the operation 1) - * PrepareRelationsJob: only consider relationships that are not virtually deleted ($.dataInfo.deletedbyinference == - * false), each entity can be linked at most to 100 other objects - *

- * 2) JoinRelationEntityByTargetJob: (phase 1): prepare tuples [relation - target entity] (R - T): for each entity type - * E_i map E_i as RelatedEntity T_i to simplify the model and extracting only the necessary information join (R.target = - * T_i.id) save the tuples (R_i, T_i) (phase 2): create the union of all the entity types E, hash by id read the tuples + * CreateRelatedEntitiesJob (phase 2): create the union of all the entity types E, hash by id read the tuples * (R, T), hash by R.source join E.id = (R, T).source, where E becomes the Source Entity S save the tuples (S, R, T) - *

- * 3) AdjacencyListBuilderJob: given the tuple (S - R - T) we need to group by S.id -> List [ R - T ], mapping the - * result as JoinedEntity - *

- * 4) XmlConverterJob: convert the JoinedEntities as XML records */ public class CreateRelatedEntitiesJob_phase2 { diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/PrepareRelationsJob.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/PrepareRelationsJob.java index da0a810217..20d27f0f36 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/PrepareRelationsJob.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/PrepareRelationsJob.java @@ -36,26 +36,8 @@ import eu.dnetlib.dhp.schema.oaf.Relation; import scala.Tuple2; /** - * Joins the graph nodes by resolving the links of distance = 1 to create an adjacency list of linked objects. The - * operation considers all the entity types (publication, dataset, software, ORP, project, datasource, organization, and - * all the possible relationships (similarity links produced by the Dedup process are excluded). - *

- * The operation is implemented by sequentially joining one entity type at time (E) with the relationships (R), and - * again by E, finally grouped by E.id; - *

- * The workflow is organized in different parts aimed to to reduce the complexity of the operation 1) - * PrepareRelationsJob: only consider relationships that are not virtually deleted ($.dataInfo.deletedbyinference == - * false), each entity can be linked at most to 100 other objects - *

- * 2) JoinRelationEntityByTargetJob: (phase 1): prepare tuples [relation - target entity] (R - T): for each entity type - * E_i map E_i as RelatedEntity T_i to simplify the model and extracting only the necessary information join (R.target = - * T_i.id) save the tuples (R_i, T_i) (phase 2): create the union of all the entity types E, hash by id read the tuples - * (R, T), hash by R.source join E.id = (R, T).source, where E becomes the Source Entity S save the tuples (S, R, T) - *

- * 3) AdjacencyListBuilderJob: given the tuple (S - R - T) we need to group by S.id -> List [ R - T ], mapping the - * result as JoinedEntity - *

- * 4) XmlConverterJob: convert the JoinedEntities as XML records + * PrepareRelationsJob prunes the relationships: only consider relationships that are not virtually deleted + * ($.dataInfo.deletedbyinference == false), each entity can be linked at most to 100 other objects */ public class PrepareRelationsJob { diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/XmlConverterJob.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/XmlConverterJob.java index a1ed7fd2a6..d8eba31b62 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/XmlConverterJob.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/XmlConverterJob.java @@ -37,23 +37,7 @@ import scala.collection.JavaConverters; import scala.collection.Seq; /** - * Joins the graph nodes by resolving the links of distance = 1 to create an adjacency list of linked objects. The - * operation considers all the entity types (publication, dataset, software, ORP, project, datasource, organization, and - * all the possible relationships (similarity links produced by the Dedup process are excluded). - *

- * The workflow is organized in different parts aimed to to reduce the complexity of the operation 1) - * PrepareRelationsJob: only consider relationships that are not virtually deleted ($.dataInfo.deletedbyinference == - * false), each entity can be linked at most to 100 other objects - *

- * 2) JoinRelationEntityByTargetJob: (phase 1): prepare tuples [relation - target entity] (R - T): for each entity type - * E_i map E_i as RelatedEntity T_i to simplify the model and extracting only the necessary information join (R.target = - * T_i.id) save the tuples (R_i, T_i) (phase 2): create the union of all the entity types E, hash by id read the tuples - * (R, T), hash by R.source join E.id = (R, T).source, where E becomes the Source Entity S save the tuples (S, R, T) - *

- * 3) AdjacencyListBuilderJob: given the tuple (S - R - T) we need to group by S.id -> List [ R - T ], mapping the - * result as JoinedEntity - *

- * 4) XmlConverterJob: convert the JoinedEntities as XML records + * XmlConverterJob converts the JoinedEntities as XML records */ public class XmlConverterJob {