imported module dnet-openaire-broker-common

This commit is contained in:
Michele Artini 2020-07-08 09:54:54 +02:00
parent f3b92a57f7
commit 29a2f1577c
20 changed files with 1118 additions and 11 deletions

View File

@ -4,9 +4,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>eu.dnetlib</groupId>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -77,9 +78,9 @@
<!-- Openaire -->
<dependency>
<groupId>eu.dnetlib</groupId>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-openaire-broker-common</artifactId>
<version>[3.0.4-SNAPSHOT, 4.0.0)</version>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -4,9 +4,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>eu.dnetlib</groupId>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,13 +3,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>eu.dnetlib</groupId>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-applications</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>eu.dnetlib</groupId>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<packaging>pom</packaging>

View File

@ -0,0 +1,35 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>libs</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dnet-openaire-broker-common</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
<scope>compile</scope>
</dependency>
<!-- Gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,38 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
public class OaBrokerAuthor implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1295190133654199196L;
private String fullname;
private String orcid;
public OaBrokerAuthor() {}
public String getFullname() {
return fullname;
}
public void setFullname(final String fullname) {
this.fullname = fullname;
}
public String getOrcid() {
return orcid;
}
public void setOrcid(final String orcid) {
this.orcid = orcid;
}
public OaBrokerAuthor(final String fullname, final String orcid) {
this.fullname = fullname;
this.orcid = orcid;
}
}

View File

@ -0,0 +1,67 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
import com.google.gson.GsonBuilder;
/**
* Created by claudio on 11/07/16.
*/
public class OaBrokerEventPayload implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5910606923372311229L;
private OaBrokerMainEntity result;
private OaBrokerMainEntity highlight;
private OaBrokerProvenance provenance;
private float trust;
public OaBrokerMainEntity getResult() {
return result;
}
public void setResult(final OaBrokerMainEntity result) {
this.result = result;
}
public OaBrokerMainEntity getHighlight() {
return highlight;
}
public void setHighlight(final OaBrokerMainEntity highlight) {
this.highlight = highlight;
}
public OaBrokerProvenance getProvenance() {
return provenance;
}
public void setProvenance(final OaBrokerProvenance provenance) {
this.provenance = provenance;
}
public float getTrust() {
return trust;
}
public void setTrust(final float trust) {
this.trust = trust;
}
public static OaBrokerEventPayload fromJSON(final String json) {
final GsonBuilder b = new GsonBuilder();
return b.create().fromJson(json, OaBrokerEventPayload.class);
}
public String toJSON() {
final GsonBuilder b = new GsonBuilder();
return b.create().toJson(this);
}
}

View File

@ -0,0 +1,55 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
/**
* Created by claudio on 22/07/16.
*/
public class OaBrokerExternalReference implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5528787961232948079L;
private String url;
private String sitename;
private String type;
private String refidentifier;
public String getUrl() {
return url;
}
public void setUrl(final String url) {
this.url = url;
}
public String getSitename() {
return sitename;
}
public void setSitename(final String sitename) {
this.sitename = sitename;
}
public String getType() {
return type;
}
public void setType(final String type) {
this.type = type;
}
public String getRefidentifier() {
return refidentifier;
}
public void setRefidentifier(final String refidentifier) {
this.refidentifier = refidentifier;
}
}

View File

@ -0,0 +1,71 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
import com.google.common.base.Objects;
/**
* Created by claudio on 22/07/16.
*/
public class OaBrokerInstance implements Serializable {
/**
*
*/
private static final long serialVersionUID = 4064188385743605220L;
private String url;
private String license;
private String hostedby;
private String instancetype;
public String getUrl() {
return url;
}
public void setUrl(final String url) {
this.url = url;
}
public String getLicense() {
return license;
}
public void setLicense(final String license) {
this.license = license;
}
public String getHostedby() {
return hostedby;
}
public void setHostedby(final String hostedby) {
this.hostedby = hostedby;
}
public String getInstancetype() {
return instancetype;
}
public void setInstancetype(final String instancetype) {
this.instancetype = instancetype;
}
@Override
public int hashCode() {
return Objects.hashCode(getUrl(), getLicense(), getHostedby(), getInstancetype());
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof OaBrokerInstance)) { return false; }
final OaBrokerInstance that = (OaBrokerInstance) obj;
return Objects.equal(getUrl(), that.getUrl()) &&
Objects.equal(getLicense(), that.getLicense()) &&
Objects.equal(getHostedby(), that.getHostedby()) &&
Objects.equal(getInstancetype(), that.getInstancetype());
}
}

View File

@ -0,0 +1,55 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
/**
* Created by claudio on 22/07/16.
*/
public class OaBrokerJournal implements Serializable {
/**
*
*/
private static final long serialVersionUID = 941929788063513440L;
private String name;
private String issn;
private String eissn;
private String lissn;
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getIssn() {
return issn;
}
public void setIssn(final String issn) {
this.issn = issn;
}
public String getEissn() {
return eissn;
}
public void setEissn(final String eissn) {
this.eissn = eissn;
}
public String getLissn() {
return lissn;
}
public void setLissn(final String lissn) {
this.lissn = lissn;
}
}

View File

@ -0,0 +1,247 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by claudio on 22/07/16.
*/
public class OaBrokerMainEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = -944960541904447441L;
private String openaireId;
private String originalId;
private String typology;
private List<String> titles = new ArrayList<>();
private List<String> abstracts = new ArrayList<>();
private String language;
private List<OaBrokerTypedValue> subjects = new ArrayList<>();
private List<OaBrokerAuthor> creators = new ArrayList<>();
private String publicationdate;
private String publisher;
private String embargoenddate;
private List<String> contributor = new ArrayList<>();
private OaBrokerJournal journal;
private String collectedFromId;
private String collectedFromName;
private String collectedFromType;
private List<OaBrokerTypedValue> pids = new ArrayList<>();
private List<OaBrokerInstance> instances = new ArrayList<>();
private List<OaBrokerExternalReference> externalReferences = new ArrayList<>();
private List<OaBrokerProject> projects = new ArrayList<>();
private List<OaBrokerRelatedDataset> datasets = new ArrayList<>();
private List<OaBrokerRelatedPublication> publications = new ArrayList<>();
private List<OaBrokerRelatedSoftware> softwares = new ArrayList<>();
public String getOpenaireId() {
return openaireId;
}
public void setOpenaireId(final String openaireId) {
this.openaireId = openaireId;
}
public String getOriginalId() {
return originalId;
}
public void setOriginalId(final String originalId) {
this.originalId = originalId;
}
public String getTypology() {
return typology;
}
public void setTypology(final String typology) {
this.typology = typology;
}
public List<String> getTitles() {
return titles;
}
public void setTitles(final List<String> titles) {
this.titles = titles;
}
public List<String> getAbstracts() {
return abstracts;
}
public void setAbstracts(final List<String> abstracts) {
this.abstracts = abstracts;
}
public String getLanguage() {
return language;
}
public void setLanguage(final String language) {
this.language = language;
}
public List<OaBrokerTypedValue> getSubjects() {
return subjects;
}
public void setSubjects(final List<OaBrokerTypedValue> subjects) {
this.subjects = subjects;
}
public List<OaBrokerAuthor> getCreators() {
return creators;
}
public void setCreators(final List<OaBrokerAuthor> creators) {
this.creators = creators;
}
public String getPublicationdate() {
return publicationdate;
}
public void setPublicationdate(final String publicationdate) {
this.publicationdate = publicationdate;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(final String publisher) {
this.publisher = publisher;
}
public String getEmbargoenddate() {
return embargoenddate;
}
public void setEmbargoenddate(final String embargoenddate) {
this.embargoenddate = embargoenddate;
}
public List<String> getContributor() {
return contributor;
}
public void setContributor(final List<String> contributor) {
this.contributor = contributor;
}
public OaBrokerJournal getJournal() {
return journal;
}
public void setJournal(final OaBrokerJournal journal) {
this.journal = journal;
}
public String getCollectedFromId() {
return collectedFromId;
}
public void setCollectedFromId(final String collectedFromId) {
this.collectedFromId = collectedFromId;
}
public String getCollectedFromName() {
return collectedFromName;
}
public void setCollectedFromName(final String collectedFromName) {
this.collectedFromName = collectedFromName;
}
public String getCollectedFromType() {
return collectedFromType;
}
public void setCollectedFromType(final String collectedFromType) {
this.collectedFromType = collectedFromType;
}
public List<OaBrokerTypedValue> getPids() {
return pids;
}
public void setPids(final List<OaBrokerTypedValue> pids) {
this.pids = pids;
}
public List<OaBrokerInstance> getInstances() {
return instances;
}
public void setInstances(final List<OaBrokerInstance> instances) {
this.instances = instances;
}
public List<OaBrokerExternalReference> getExternalReferences() {
return externalReferences;
}
public void setExternalReferences(final List<OaBrokerExternalReference> externalReferences) {
this.externalReferences = externalReferences;
}
public List<OaBrokerProject> getProjects() {
return projects;
}
public void setProjects(final List<OaBrokerProject> projects) {
this.projects = projects;
}
public List<OaBrokerRelatedDataset> getDatasets() {
return datasets;
}
public void setDatasets(final List<OaBrokerRelatedDataset> datasets) {
this.datasets = datasets;
}
public List<OaBrokerRelatedPublication> getPublications() {
return publications;
}
public void setPublications(final List<OaBrokerRelatedPublication> publications) {
this.publications = publications;
}
public List<OaBrokerRelatedSoftware> getSoftwares() {
return softwares;
}
public void setSoftwares(final List<OaBrokerRelatedSoftware> softwares) {
this.softwares = softwares;
}
}

View File

@ -0,0 +1,108 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
public class OaBrokerProject implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2080495225075576873L;
private String openaireId;
private String code;
private String acronym;
private String title;
private String funder;
private String fundingProgram;
private String jurisdiction;
public OaBrokerProject() {}
public OaBrokerProject(final String openaireId, final String code, final String acronym, final String title, final String funder,
final String fundingProgram, final String jurisdiction) {
this.openaireId = openaireId;
this.code = code;
this.acronym = acronym;
this.title = title;
this.funder = funder;
this.fundingProgram = fundingProgram;
this.jurisdiction = jurisdiction;
}
public String getOpenaireId() {
return openaireId;
}
public void setOpenaireId(final String openaireId) {
this.openaireId = openaireId;
}
public String getCode() {
return code;
}
public void setCode(final String code) {
this.code = code;
}
public String getAcronym() {
return acronym;
}
public void setAcronym(final String acronym) {
this.acronym = acronym;
}
public String getTitle() {
return title;
}
public void setTitle(final String title) {
this.title = title;
}
public String getFunder() {
return funder;
}
public void setFunder(final String funder) {
this.funder = funder;
}
public String getFundingProgram() {
return fundingProgram;
}
public void setFundingProgram(final String fundingProgram) {
this.fundingProgram = fundingProgram;
}
public String getJurisdiction() {
return jurisdiction;
}
public void setJurisdiction(final String jurisdiction) {
this.jurisdiction = jurisdiction;
}
public String asOpenaireProjectIdentifier() {
if (verifyManadatoryFields()) {
return String.format("info:eu-repo/grantAgreement/%s/%s/%s/%s/%s/%s",
funder,
fundingProgram,
code,
jurisdiction != null ? jurisdiction : "",
title != null ? title : "",
acronym != null ? acronym : "");
} else {
return "";
}
}
public boolean verifyManadatoryFields() {
return funder != null && fundingProgram != null && code != null
&& !funder.isEmpty() && !fundingProgram.isEmpty() && !code.isEmpty();
}
}

View File

@ -0,0 +1,64 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
/**
* Created by claudio on 26/07/16.
*/
public class OaBrokerProvenance implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2370917119345695230L;
private String id;
private String repositoryName;
private String repositoryType;
private String url;
public OaBrokerProvenance() {}
public OaBrokerProvenance(final String id, final String repositoryName, final String repositoryType, final String url) {
this.id = id;
this.repositoryName = repositoryName;
this.repositoryType = repositoryType;
this.url = url;
}
public String getId() {
return id;
}
public void setId(final String id) {
this.id = id;
}
public String getRepositoryName() {
return repositoryName;
}
public void setRepositoryName(final String repositoryName) {
this.repositoryName = repositoryName;
}
public String getRepositoryType() {
return repositoryType;
}
public void setRepositoryType(final String repositoryType) {
this.repositoryType = repositoryType;
}
public String getUrl() {
return url;
}
public void setUrl(final String url) {
this.url = url;
}
}

View File

@ -0,0 +1,83 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
import java.util.List;
public class OaBrokerRelatedDataset implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1623416039557371858L;
private String openaireId;
private String originalId;
private String title;
private String collectedFrom;
private List<OaBrokerTypedValue> pids;
private List<OaBrokerInstance> instances;
private String relType;
public String getOpenaireId() {
return openaireId;
}
public void setOpenaireId(final String openaireId) {
this.openaireId = openaireId;
}
public String getOriginalId() {
return originalId;
}
public void setOriginalId(final String originalId) {
this.originalId = originalId;
}
public String getTitle() {
return title;
}
public void setTitle(final String title) {
this.title = title;
}
public String getCollectedFrom() {
return collectedFrom;
}
public void setCollectedFrom(final String collectedFrom) {
this.collectedFrom = collectedFrom;
}
public List<OaBrokerTypedValue> getPids() {
return pids;
}
public void setPids(final List<OaBrokerTypedValue> pids) {
this.pids = pids;
}
public List<OaBrokerInstance> getInstances() {
return instances;
}
public void setInstances(final List<OaBrokerInstance> instances) {
this.instances = instances;
}
public String getRelType() {
return relType;
}
public void setRelType(final String relType) {
this.relType = relType;
}
}

View File

@ -0,0 +1,77 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
import java.util.List;
public class OaBrokerRelatedPublication implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6845435777531929885L;
private String openaireId;
private String originalId;
private String title;
private String collectedFrom;
private List<OaBrokerTypedValue> pids;
private List<OaBrokerInstance> instances;
private String relType;
public String getOpenaireId() {
return openaireId;
}
public void setOpenaireId(final String openaireId) {
this.openaireId = openaireId;
}
public String getOriginalId() {
return originalId;
}
public void setOriginalId(final String originalId) {
this.originalId = originalId;
}
public String getTitle() {
return title;
}
public void setTitle(final String title) {
this.title = title;
}
public String getCollectedFrom() {
return collectedFrom;
}
public void setCollectedFrom(final String collectedFrom) {
this.collectedFrom = collectedFrom;
}
public List<OaBrokerTypedValue> getPids() {
return pids;
}
public void setPids(final List<OaBrokerTypedValue> pids) {
this.pids = pids;
}
public List<OaBrokerInstance> getInstances() {
return instances;
}
public void setInstances(final List<OaBrokerInstance> instances) {
this.instances = instances;
}
public String getRelType() {
return relType;
}
public void setRelType(final String relType) {
this.relType = relType;
}
}

View File

@ -0,0 +1,72 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
public class OaBrokerRelatedSoftware implements Serializable {
/**
*
*/
private static final long serialVersionUID = 176600509589408338L;
private String openaireId;
private String name;
private String description;
private String landingPage;
private String repository;
public OaBrokerRelatedSoftware() {}
public OaBrokerRelatedSoftware(final String openaireId, final String name, final String description, final String landingPage, final String repository) {
this.openaireId = openaireId;
this.name = name;
this.description = description;
this.landingPage = landingPage;
this.repository = repository;
}
public String getOpenaireId() {
return openaireId;
}
public void setOpenaireId(final String openaireId) {
this.openaireId = openaireId;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
public String getLandingPage() {
return landingPage;
}
public void setLandingPage(final String landingPage) {
this.landingPage = landingPage;
}
public String getRepository() {
return repository;
}
public void setRepository(final String repository) {
this.repository = repository;
}
}

View File

@ -0,0 +1,42 @@
package eu.dnetlib.broker.objects;
import java.io.Serializable;
/**
* Created by claudio on 22/07/16.
*/
public class OaBrokerTypedValue implements Serializable {
/**
*
*/
private static final long serialVersionUID = 4797440344311785195L;
private String type;
private String value;
public OaBrokerTypedValue() {}
public OaBrokerTypedValue(final String type, final String value) {
this.type = type;
this.value = value;
}
public String getType() {
return type;
}
public void setType(final String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(final String value) {
this.value = value;
}
}

View File

@ -0,0 +1,65 @@
#!/bin/bash
echo
echo "Fixing events index..."
curl -XPUT 'http://localhost:9200/events/_mapping/event' -d '
{
"event" : {
"properties" : {
"map": {
"type": "nested",
"properties": {
"target_datasource_id": {
"type": "string",
"index": "not_analyzed"
},
"target_datasource_name": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
'
echo
echo
echo "Fixing notifications index..."
curl -XPUT 'http://localhost:9200/notifications/_mapping/notification' -d '
{
"notification" : {
"properties" : {
"map": {
"type": "nested",
"properties": {
"target_datasource_id": {
"type": "string",
"index": "not_analyzed"
},
"target_datasource_name": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
'
echo
echo
echo "Registering topic type: ENRICH/<cond>/<field>..."
curl "http://localhost:8080/api/topic-types/add" -d "name=ENRICH&expression=ENRICH%2F%3Ccond%3E%2F%3Cfield%3E&producerId=OpenAIRE&mapKeys=target_datasource_name"
echo
echo
echo "Registering topic type: ENRICH/<cond>/<field>/<subfield>..."
curl "http://localhost:8080/api/topic-types/add" -d "name=ENRICH_WITH_SUBFIELD&expression=ENRICH%2F%3Ccond%3E%2F%3Cfield%3E%2F%3Csubfield%3E&producerId=OpenAIRE&mapKeys=target_datasource_name"
echo
echo
echo "Registering topic type: ADD/<field>..."
curl "http://localhost:8080/api/topic-types/add" -d "name=ADD&expression=ADD%2F%3Cfield%3E&producerId=OpenAIRE&mapKeys=target_datasource_name"
echo
echo
echo

View File

@ -0,0 +1,23 @@
{
"query": {
"nested": {
"path": "map",
"query": {
"bool": {
"must": [
{
"match": {
"map.id": "id_1_33"
}
},
{
"match": {
"map.year": 2016
}
}
]
}
}
}
}
}

View File

@ -4,17 +4,19 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>eu.dnetlib</groupId>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-applications</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>eu.dnetlib</groupId>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>libs</artifactId>
<packaging>pom</packaging>
<modules>
<module>dnet-openaire-broker-common</module>
</modules>
</project>

View File

@ -10,7 +10,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>eu.dnetlib</groupId>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-applications</artifactId>
<version>3.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
@ -27,8 +27,8 @@
</licenses>
<modules>
<module>apps</module>
<module>libs</module>
<module>apps</module>
</modules>
<issueManagement>