diff --git a/dnet-core-components/pom.xml b/dnet-core-components/pom.xml index 18ff3db..5ee47cd 100644 --- a/dnet-core-components/pom.xml +++ b/dnet-core-components/pom.xml @@ -64,6 +64,10 @@ com.google.code.gson gson + + javax.persistence + persistence-api + log4j diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/AggregationInfo.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/AggregationInfo.java new file mode 100644 index 0000000..a663329 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/AggregationInfo.java @@ -0,0 +1,46 @@ +package eu.dnetlib.enabling.datasources.common; + +public abstract class AggregationInfo { + + private int numberOfRecords; + + private String date; + + private AggregationStage aggregationStage; + + private boolean indexedVersion = false; + + public AggregationInfo() {} + + public int getNumberOfRecords() { + return numberOfRecords; + } + + public void setNumberOfRecords(final int numberOfRecords) { + this.numberOfRecords = numberOfRecords; + } + + public String getDate() { + return date; + } + + public void setDate(final String date) { + this.date = date; + } + + public AggregationStage getAggregationStage() { + return aggregationStage; + } + + public void setAggregationStage(final AggregationStage aggregationStage) { + this.aggregationStage = aggregationStage; + } + + public boolean isIndexedVersion() { + return indexedVersion; + } + + public void setIndexedVersion(final boolean indexedVersion) { + this.indexedVersion = indexedVersion; + } +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/AggregationStage.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/AggregationStage.java new file mode 100644 index 0000000..07d38bc --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/AggregationStage.java @@ -0,0 +1,26 @@ +package eu.dnetlib.enabling.datasources.common; + +/** + * Created by claudio on 12/09/16. + */ +public enum AggregationStage { + COLLECT, TRANSFORM; + + public static AggregationStage parse(final String s) { + switch (s) { + case "collect": + case "collection": + case "COLLECT": + case "COLLECTION": + return AggregationStage.COLLECT; + case "transform": + case "transformation": + case "TRANSFORM": + case "TRANSFORMATION": + case "transformDatasets": + case "transformPublications": + return AggregationStage.TRANSFORM; + } + throw new IllegalArgumentException("invalid AggregationStage: " + s); + } +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Api.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Api.java new file mode 100644 index 0000000..c82037d --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Api.java @@ -0,0 +1,306 @@ +package eu.dnetlib.enabling.datasources.common; + +import java.sql.Timestamp; +import java.util.Objects; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import javax.persistence.OneToMany; +import javax.persistence.Transient; + +import com.google.common.collect.ComparisonChain; +import com.google.common.collect.Sets; +import com.google.gson.Gson; + +/** + * Api + */ +@MappedSuperclass +public class Api implements Comparable> { + + @Id + protected String id = null; + protected String protocol = null; + protected String datasource = null; + protected String contentdescription = null; + protected Boolean active = false; + protected Boolean removable = true; + protected String typology = null; + protected String compatibility; + + @Transient + protected boolean compatibilityOverrided = false; + + @Column(name = "metadata_identifier_path") + protected String metadataIdentifierPath; + + @Column(name = "last_collection_total") + protected Integer lastCollectionTotal; + + @Column(name = "last_collection_date") + protected Timestamp lastCollectionDate; + + @Column(name = "last_collection_mdid") + protected String lastCollectionMdid; + + @Column(name = "last_aggregation_total") + protected Integer lastAggregationTotal; + + @Column(name = "last_aggregation_date") + protected Timestamp lastAggregationDate; + + @Column(name = "last_aggregation_mdid") + protected String lastAggregationMdid; + + @Column(name = "last_download_total") + protected Integer lastDownloadTotal; + + @Column(name = "last_download_date") + protected Timestamp lastDownloadDate; + + @Column(name = "last_download_objid") + protected String lastDownloadObjid; + + @Column(name = "last_validation_job") + protected String lastValidationJob; + protected String baseurl = null; + + @OneToMany(mappedBy = "id.api", cascade = CascadeType.ALL, fetch = FetchType.EAGER) + protected Set apiParams = Sets.newHashSet(); + + public Api() {} + + public String getId() { + return id; + } + + public String getProtocol() { + return protocol; + } + + public String getDatasource() { + return datasource; + } + + public String getContentdescription() { + return contentdescription; + } + + public Boolean getActive() { + return active; + } + + public Boolean getRemovable() { + return removable; + } + + public String getTypology() { + return typology; + } + + public String getCompatibility() { + return compatibility; + } + + public boolean isCompatibilityOverrided() { + return compatibilityOverrided; + } + + public String getMetadataIdentifierPath() { + return metadataIdentifierPath; + } + + public Integer getLastCollectionTotal() { + return lastCollectionTotal; + } + + public Timestamp getLastCollectionDate() { + return lastCollectionDate; + } + + public String getLastCollectionMdid() { + return lastCollectionMdid; + } + + public Integer getLastAggregationTotal() { + return lastAggregationTotal; + } + + public Timestamp getLastAggregationDate() { + return lastAggregationDate; + } + + public String getLastAggregationMdid() { + return lastAggregationMdid; + } + + public Integer getLastDownloadTotal() { + return lastDownloadTotal; + } + + public Timestamp getLastDownloadDate() { + return lastDownloadDate; + } + + public String getLastDownloadObjid() { + return lastDownloadObjid; + } + + public String getLastValidationJob() { + return lastValidationJob; + } + + public String getBaseurl() { + return baseurl; + } + + public Set getApiParams() { + return apiParams; + } + + public Api setId(final String id) { + this.id = id; + return this; + } + + public Api setProtocol(final String protocol) { + this.protocol = protocol; + return this; + } + + public Api setDatasource(final String datasource) { + this.datasource = datasource; + return this; + } + + public Api setContentdescription(final String contentdescription) { + this.contentdescription = contentdescription; + return this; + } + + public Api setActive(final Boolean active) { + this.active = active; + return this; + } + + public Api setRemovable(final Boolean removable) { + this.removable = removable; + return this; + } + + public Api setTypology(final String typology) { + this.typology = typology; + return this; + } + + public Api setCompatibility(final String compatibility) { + this.compatibility = compatibility; + return this; + } + + public Api setCompatibilityOverrided(final boolean compatibilityOverrided) { + this.compatibilityOverrided = compatibilityOverrided; + return this; + } + + public Api setMetadataIdentifierPath(final String metadataIdentifierPath) { + this.metadataIdentifierPath = metadataIdentifierPath; + return this; + } + + public Api setLastCollectionTotal(final Integer lastCollectionTotal) { + this.lastCollectionTotal = lastCollectionTotal; + return this; + } + + public Api setLastCollectionDate(final Timestamp lastCollectionDate) { + this.lastCollectionDate = lastCollectionDate; + return this; + } + + public Api setLastCollectionMdid(final String lastCollectionMdid) { + this.lastCollectionMdid = lastCollectionMdid; + return this; + } + + public Api setLastAggregationTotal(final Integer lastAggregationTotal) { + this.lastAggregationTotal = lastAggregationTotal; + return this; + } + + public Api setLastAggregationDate(final Timestamp lastAggregationDate) { + this.lastAggregationDate = lastAggregationDate; + return this; + } + + public Api setLastAggregationMdid(final String lastAggregationMdid) { + this.lastAggregationMdid = lastAggregationMdid; + return this; + } + + public Api setLastDownloadTotal(final Integer lastDownloadTotal) { + this.lastDownloadTotal = lastDownloadTotal; + return this; + } + + public Api setLastDownloadDate(final Timestamp lastDownloadDate) { + this.lastDownloadDate = lastDownloadDate; + return this; + } + + public Api setLastDownloadObjid(final String lastDownloadObjid) { + this.lastDownloadObjid = lastDownloadObjid; + return this; + } + + public Api setLastValidationJob(final String lastValidationJob) { + this.lastValidationJob = lastValidationJob; + return this; + } + + public Api setBaseurl(final String baseurl) { + this.baseurl = baseurl; + return this; + } + + public Api setApiParams(final Set apiParams) { + this.apiParams = apiParams; + return this; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + final Api api = (Api) o; + return Objects.equals(this.id, api.id); + } + + /* + * (non-Javadoc) + * + * @see eu.dnetlib.openaire.exporter.model.datasource.db.ApiInterface#hashCode() + */ + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + return new Gson().toJson(this); + } + + @Override + public int compareTo(final Api a) { + return ComparisonChain.start() + .compare(getId(), a.getId()) + .result(); + } + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/ApiParam.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/ApiParam.java new file mode 100644 index 0000000..48f95fa --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/ApiParam.java @@ -0,0 +1,13 @@ +package eu.dnetlib.enabling.datasources.common; + +public interface ApiParam { + + String getValue(); + + void setValue(String value); + + String getParam(); + + void setParam(String param); + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/ApiParamImpl.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/ApiParamImpl.java new file mode 100644 index 0000000..acbb041 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/ApiParamImpl.java @@ -0,0 +1,27 @@ +package eu.dnetlib.enabling.datasources.common; + +public class ApiParamImpl implements ApiParam { + + private String param; + private String value; + + @Override + public String getParam() { + return param; + } + + @Override + public void setParam(final String param) { + this.param = param; + } + + @Override + public String getValue() { + return value; + } + + @Override + public void setValue(final String value) { + this.value = value; + } +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/ApiParamKey.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/ApiParamKey.java new file mode 100644 index 0000000..7827bfc --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/ApiParamKey.java @@ -0,0 +1,65 @@ +package eu.dnetlib.enabling.datasources.common; + +import java.io.Serializable; +import java.util.Objects; + +import javax.persistence.Embeddable; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.MappedSuperclass; + +import com.google.common.collect.ComparisonChain; + +/** + * Created by claudio on 13/04/2017. + */ +@Embeddable +@MappedSuperclass +public class ApiParamKey implements Serializable { + + /** + * + */ + protected static final long serialVersionUID = 1640636806392015938L; + + @ManyToOne + @JoinColumn(name = "api") + protected A api = null; + + protected String param; + + public ApiParamKey() {} + + public String getParam() { + return param; + } + + public ApiParamKey setParam(final String param) { + this.param = param; + return this; + } + + public A getApi() { + return api; + } + + public void setApi(final A api) { + this.api = api; + } + + public int hashCode() { + return Objects.hash(getParam(), getApi().getId()); + } + + @Override + public boolean equals(final Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + ApiParamKey apk = (ApiParamKey) o; + return ComparisonChain.start() + .compare(getParam(), apk.getParam()) + .compare(getApi(), apk.getApi()) + .result() == 0; + } + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/BrowsableField.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/BrowsableField.java new file mode 100644 index 0000000..a7d03de --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/BrowsableField.java @@ -0,0 +1,31 @@ +package eu.dnetlib.enabling.datasources.common; + +public class BrowsableField { + + private String id; + private String label; + + public BrowsableField() {} + + public BrowsableField(String id, String label) { + this.id = id; + this.label = label; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/BrowseTerm.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/BrowseTerm.java new file mode 100644 index 0000000..f208ae4 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/BrowseTerm.java @@ -0,0 +1,13 @@ +package eu.dnetlib.enabling.datasources.common; + +public interface BrowseTerm { + + String getTerm(); + + void setTerm(String term); + + long getTotal(); + + void setTotal(long total); + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/BrowseTermImpl.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/BrowseTermImpl.java new file mode 100644 index 0000000..3d0d854 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/BrowseTermImpl.java @@ -0,0 +1,30 @@ +package eu.dnetlib.enabling.datasources.common; + +public class BrowseTermImpl implements BrowseTerm { + + private String term; + private long total; + + public BrowseTermImpl() {} + + public BrowseTermImpl(final String term, final int total) { + this.term = term; + this.total = total; + } + + public String getTerm() { + return term; + } + + public void setTerm(final String term) { + this.term = term; + } + + public long getTotal() { + return total; + } + + public void setTotal(final long total) { + this.total = total; + } +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Datasource.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Datasource.java new file mode 100755 index 0000000..78fbda7 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Datasource.java @@ -0,0 +1,513 @@ +package eu.dnetlib.enabling.datasources.common; + +import java.sql.Date; +import java.util.Set; +import javax.persistence.*; + +/** + * Datasource + */ +@MappedSuperclass +public class Datasource { + + @Id + protected String id; + + @Column(nullable = false) + protected String officialname; + protected String englishname; + protected String websiteurl; + protected String logourl; + protected String contactemail; + protected Double latitude; + protected Double longitude; + protected String timezone; + + @Column(name = "namespaceprefix", columnDefinition = "bpchar(12)", nullable = false, updatable = false) + protected String namespaceprefix; + + protected String languages; + + protected String od_contenttypes; + protected String collectedfrom; + protected Date dateofvalidation; + protected String typology; + protected String provenanceaction; + protected Date dateofcollection; + protected String platform; + + @Column(name = "activationid") + protected String activationId; + protected String description; + + protected Date releasestartdate; + protected Date releaseenddate; + protected String missionstatementurl; + protected Boolean dataprovider; + protected Boolean serviceprovider; + + protected String databaseaccesstype; + protected String datauploadtype; + protected String databaseaccessrestriction; + protected String datauploadrestriction; + + protected Boolean versioning; + protected String citationguidelineurl; + protected String qualitymanagementkind; + protected String pidsystems; + + protected String certificates; + protected String aggregator; + + protected String issn; + protected String eissn; + protected String lissn; + + protected String registeredby; + + private Date registrationdate; + + protected String subjects; + + protected Boolean managed; + + @Column(name = "consenttermsofuse") + protected Boolean consentTermsOfUse; + + @Column(name = "fulltextdownload") + protected Boolean fullTextDownload; + + @ManyToMany( + cascade = { CascadeType.PERSIST, CascadeType.MERGE }, + fetch = FetchType.LAZY) + @JoinTable( + name = "dsm_datasource_organization", + joinColumns = @JoinColumn(name="datasource"), + inverseJoinColumns = @JoinColumn(name="organization")) + protected Set organizations; + + @ManyToMany( + cascade = { CascadeType.PERSIST, CascadeType.MERGE }, + fetch = FetchType.LAZY ) + @JoinTable( + name = "dsm_datasourcepids", + joinColumns = @JoinColumn(name = "datasource"), + inverseJoinColumns = @JoinColumn(name = "pid")) + protected Set identities; + + public Datasource() {} + + public String getId() { + return id; + } + + public String getOfficialname() { + return officialname; + } + + public String getEnglishname() { + return englishname; + } + + public String getWebsiteurl() { + return websiteurl; + } + + public String getLogourl() { + return logourl; + } + + public String getContactemail() { + return contactemail; + } + + public Double getLatitude() { + return latitude; + } + + public Double getLongitude() { + return longitude; + } + + public String getTimezone() { + return timezone; + } + + public String getNamespaceprefix() { + return namespaceprefix; + } + + public String getLanguages() { + return languages; + } + + public String getOd_contenttypes() { + return od_contenttypes; + } + + public String getCollectedfrom() { + return collectedfrom; + } + + public Date getDateofvalidation() { + return dateofvalidation; + } + + public String getTypology() { + return typology; + } + + public String getProvenanceaction() { + return provenanceaction; + } + + public Date getDateofcollection() { + return dateofcollection; + } + + public String getPlatform() { + return platform; + } + + public String getActivationId() { + return activationId; + } + + public String getDescription() { + return description; + } + + public Date getReleasestartdate() { + return releasestartdate; + } + + public Date getReleaseenddate() { + return releaseenddate; + } + + public String getMissionstatementurl() { + return missionstatementurl; + } + + public Boolean getDataprovider() { + return dataprovider; + } + + public Boolean getServiceprovider() { + return serviceprovider; + } + + public String getDatabaseaccesstype() { + return databaseaccesstype; + } + + public String getDatauploadtype() { + return datauploadtype; + } + + public String getDatabaseaccessrestriction() { + return databaseaccessrestriction; + } + + public String getDatauploadrestriction() { + return datauploadrestriction; + } + + public Boolean getVersioning() { + return versioning; + } + + public String getCitationguidelineurl() { + return citationguidelineurl; + } + + public String getQualitymanagementkind() { + return qualitymanagementkind; + } + + public String getPidsystems() { + return pidsystems; + } + + public String getCertificates() { + return certificates; + } + + public String getAggregator() { + return aggregator; + } + + public String getIssn() { + return issn; + } + + public String getEissn() { + return eissn; + } + + public String getLissn() { + return lissn; + } + + public String getRegisteredby() { + return registeredby; + } + + public Date getRegistrationdate() { + return registrationdate; + } + + public String getSubjects() { + return subjects; + } + + public Boolean getManaged() { + return managed; + } + + public Set getOrganizations() { + return organizations; + } + + public Set getIdentities() { + return identities; + } + + public Datasource setId(final String id) { + this.id = id; + return this; + } + + public Datasource setOfficialname(final String officialname) { + this.officialname = officialname; + return this; + } + + public Datasource setEnglishname(final String englishname) { + this.englishname = englishname; + return this; + } + + public Datasource setWebsiteurl(final String websiteurl) { + this.websiteurl = websiteurl; + return this; + } + + public Datasource setLogourl(final String logourl) { + this.logourl = logourl; + return this; + } + + public Datasource setContactemail(final String contactemail) { + this.contactemail = contactemail; + return this; + } + + public Datasource setLatitude(final Double latitude) { + this.latitude = latitude; + return this; + } + + public Datasource setLongitude(final Double longitude) { + this.longitude = longitude; + return this; + } + + public Datasource setTimezone(final String timezone) { + this.timezone = timezone; + return this; + } + + public Datasource setNamespaceprefix(final String namespaceprefix) { + this.namespaceprefix = namespaceprefix; + return this; + } + + public Datasource setLanguages(final String languages) { + this.languages = languages; + return this; + } + + public Datasource setOd_contenttypes(final String od_contenttypes) { + this.od_contenttypes = od_contenttypes; + return this; + } + + public Datasource setCollectedfrom(final String collectedfrom) { + this.collectedfrom = collectedfrom; + return this; + } + + public Datasource setDateofvalidation(final Date dateofvalidation) { + this.dateofvalidation = dateofvalidation; + return this; + } + + public Datasource setTypology(final String typology) { + this.typology = typology; + return this; + } + + public Datasource setProvenanceaction(final String provenanceaction) { + this.provenanceaction = provenanceaction; + return this; + } + + public Datasource setDateofcollection(final Date dateofcollection) { + this.dateofcollection = dateofcollection; + return this; + } + + public Datasource setPlatform(final String platform) { + this.platform = platform; + return this; + } + + public Datasource setActivationId(final String activationId) { + this.activationId = activationId; + return this; + } + + public Datasource setDescription(final String description) { + this.description = description; + return this; + } + + public Datasource setReleasestartdate(final Date releasestartdate) { + this.releasestartdate = releasestartdate; + return this; + } + + public Datasource setReleaseenddate(final Date releaseenddate) { + this.releaseenddate = releaseenddate; + return this; + } + + public Datasource setMissionstatementurl(final String missionstatementurl) { + this.missionstatementurl = missionstatementurl; + return this; + } + + public Datasource setDataprovider(final Boolean dataprovider) { + this.dataprovider = dataprovider; + return this; + } + + public Datasource setServiceprovider(final Boolean serviceprovider) { + this.serviceprovider = serviceprovider; + return this; + } + + public Datasource setDatabaseaccesstype(final String databaseaccesstype) { + this.databaseaccesstype = databaseaccesstype; + return this; + } + + public Datasource setDatauploadtype(final String datauploadtype) { + this.datauploadtype = datauploadtype; + return this; + } + + public Datasource setDatabaseaccessrestriction(final String databaseaccessrestriction) { + this.databaseaccessrestriction = databaseaccessrestriction; + return this; + } + + public Datasource setDatauploadrestriction(final String datauploadrestriction) { + this.datauploadrestriction = datauploadrestriction; + return this; + } + + public Datasource setVersioning(final Boolean versioning) { + this.versioning = versioning; + return this; + } + + public Datasource setCitationguidelineurl(final String citationguidelineurl) { + this.citationguidelineurl = citationguidelineurl; + return this; + } + + public Datasource setQualitymanagementkind(final String qualitymanagementkind) { + this.qualitymanagementkind = qualitymanagementkind; + return this; + } + + public Datasource setPidsystems(final String pidsystems) { + this.pidsystems = pidsystems; + return this; + } + + public Datasource setCertificates(final String certificates) { + this.certificates = certificates; + return this; + } + + public Datasource setAggregator(final String aggregator) { + this.aggregator = aggregator; + return this; + } + + public Datasource setIssn(final String issn) { + this.issn = issn; + return this; + } + + public Datasource setEissn(final String eissn) { + this.eissn = eissn; + return this; + } + + public Datasource setLissn(final String lissn) { + this.lissn = lissn; + return this; + } + + public Datasource setRegisteredby(final String registeredby) { + this.registeredby = registeredby; + return this; + } + + public Datasource setRegistrationdate(final Date registrationdate) { + this.registrationdate = registrationdate; + return this; + } + + public Datasource setSubjects(final String subjects) { + this.subjects = subjects; + return this; + } + + public Datasource setManaged(final Boolean managed) { + this.managed = managed; + return this; + } + + public Datasource setOrganizations(final Set organizations) { + this.organizations = organizations; + return this; + } + + public Datasource setIdentities(final Set identities) { + this.identities = identities; + return this; + } + + public Boolean getConsentTermsOfUse() { + return consentTermsOfUse; + } + + public void setConsentTermsOfUse(Boolean consentTermsOfUse) { + this.consentTermsOfUse = consentTermsOfUse; + } + + public Boolean getFullTextDownload() { + return fullTextDownload; + } + + public void setFullTextDownload(Boolean fullTextDownload) { + this.fullTextDownload = fullTextDownload; + } + + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DatasourceManagerCommon.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DatasourceManagerCommon.java new file mode 100644 index 0000000..ed2f2a7 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DatasourceManagerCommon.java @@ -0,0 +1,25 @@ +package eu.dnetlib.enabling.datasources.common; + +import java.util.List; + +public interface DatasourceManagerCommon, API extends Api> { + + DS getDs(String id) throws DsmException; + + List getApis(String dsId) throws DsmException; + + void deleteDs(String dsId) throws DsmException; + + void deleteApi(String dsId, String apiId) throws DsmException; + + void addApi(API api) throws DsmException; + + void setManaged(String id, boolean managed) throws DsmException; + + boolean isManaged(String id) throws DsmException; + + void saveDs(DS datasource) throws DsmException; + + void updateCompliance(String dsId, String apiId, String compliance, boolean override) throws DsmException; + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmException.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmException.java new file mode 100755 index 0000000..8fe94ac --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmException.java @@ -0,0 +1,38 @@ +package eu.dnetlib.enabling.datasources.common; + +public class DsmException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 8980196353591772127L; + + private int code; + + public DsmException(int code, String msg) { + super(msg); + this.code = code; + } + + public DsmException(int code, Throwable e) { + super(e); + this.code = code; + } + + public DsmException(int code, String msg, Throwable e) { + super(msg, e); + this.code = code; + } + + public DsmException(String msg) { + this(500, msg); + } + + public int getCode() { + return code; + } + + public void setCode(final int code) { + this.code = code; + } +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmForbiddenException.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmForbiddenException.java new file mode 100644 index 0000000..a3c9b9a --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmForbiddenException.java @@ -0,0 +1,34 @@ +package eu.dnetlib.enabling.datasources.common; + +public class DsmForbiddenException extends Exception { + + private int code; + + public DsmForbiddenException(int code, String msg) { + super(msg); + this.code = code; + } + + public DsmForbiddenException(int code, Throwable e) { + super(e); + this.code = code; + } + + public DsmForbiddenException(int code, String msg, Throwable e) { + super(msg, e); + this.code = code; + } + + public DsmForbiddenException(String msg) { + this(403, msg); + } + + public int getCode() { + return code; + } + + public void setCode(final int code) { + this.code = code; + } + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmNotFoundException.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmNotFoundException.java new file mode 100755 index 0000000..5d07eba --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmNotFoundException.java @@ -0,0 +1,33 @@ +package eu.dnetlib.enabling.datasources.common; + +public class DsmNotFoundException extends Exception { + + private int code; + + public DsmNotFoundException(int code, String msg) { + super(msg); + this.code = code; + } + + public DsmNotFoundException(int code, Throwable e) { + super(e); + this.code = code; + } + + public DsmNotFoundException(int code, String msg, Throwable e) { + super(msg, e); + this.code = code; + } + + public DsmNotFoundException(String msg) { + this(404, msg); + } + + public int getCode() { + return code; + } + + public void setCode(final int code) { + this.code = code; + } +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmRuntimeException.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmRuntimeException.java new file mode 100755 index 0000000..03e9b30 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/DsmRuntimeException.java @@ -0,0 +1,22 @@ +package eu.dnetlib.enabling.datasources.common; + +public class DsmRuntimeException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 8980196353591772127L; + + public DsmRuntimeException(String msg) { + super(msg); + } + + public DsmRuntimeException(String msg, Throwable e) { + super(msg, e); + } + + public DsmRuntimeException(Throwable e) { + super(e); + } + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Identity.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Identity.java new file mode 100644 index 0000000..10ea7fa --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Identity.java @@ -0,0 +1,37 @@ +package eu.dnetlib.enabling.datasources.common; + +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; + +/** + * Created by claudio on 13/04/2017. + */ +@MappedSuperclass +public class Identity { + + @Id + protected String pid; + + protected String issuertype; + + public Identity() {} + + public String getPid() { + return this.pid; + } + + public String getIssuertype() { + return this.issuertype; + } + + public Identity setPid(final String pid) { + this.pid = pid; + return this; + } + + public Identity setIssuertype(final String issuertype) { + this.issuertype = issuertype; + return this; + } + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/LocalDatasourceManager.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/LocalDatasourceManager.java new file mode 100644 index 0000000..49242f0 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/LocalDatasourceManager.java @@ -0,0 +1,38 @@ +package eu.dnetlib.enabling.datasources.common; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public interface LocalDatasourceManager, API extends Api> extends DatasourceManagerCommon { + + Set listManagedDatasourceIds() throws DsmRuntimeException; + + List searchDatasourcesByType(String type) throws DsmException; + + List searchApis(String field, Object value) throws DsmException; + + List listBrowsableFields() throws DsmException; + + List browseField(String field) throws DsmException; + + void setActive(String dsId, String apiId, boolean active) throws DsmException; + + boolean isActive(String dsId, String apiId) throws DsmException; + + void setLastCollectionInfo(String dsId, String apiId, String mdId, Integer size, Date date) throws DsmException; + + void setLastAggregationInfo(String dsId, String apiId, String mdId, Integer size, Date date) throws DsmException; + + void setLastDownloadInfo(String dsId, String apiId, String objId, Integer size, Date date) throws DsmException; + + void setLastValidationJob(String dsId, String apiId, String jobId) throws DsmException; + + void updateApiDetails(String dsId, String apiId, String metadataIdentifierPath, String baseUrl, Map params) throws DsmException; + + boolean isRemovable(String dsId, String apiId) throws DsmException; + + void regenerateProfiles() throws DsmException; + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Organization.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Organization.java new file mode 100644 index 0000000..4f501eb --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/Organization.java @@ -0,0 +1,117 @@ +package eu.dnetlib.enabling.datasources.common; + +import java.sql.Date; +import java.util.Set; +import javax.persistence.*; + +@MappedSuperclass +public class Organization> { + + @Id + protected String id; + protected String legalshortname; + protected String legalname; + protected String websiteurl; + protected String logourl; + + protected String country; + protected String collectedfrom; + + protected Date dateofcollection; + protected String provenanceaction; + + @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER, mappedBy = "organizations") + protected Set datasources; + + public Organization() {} + + public String getId() { + return id; + } + + public String getLegalshortname() { + return legalshortname; + } + + public String getLegalname() { + return legalname; + } + + public String getWebsiteurl() { + return websiteurl; + } + + public String getLogourl() { + return logourl; + } + + public String getCountry() { + return country; + } + + public String getCollectedfrom() { + return collectedfrom; + } + + public Date getDateofcollection() { + return dateofcollection; + } + + public String getProvenanceaction() { + return provenanceaction; + } + + public Organization setId(final String id) { + this.id = id; + return this; + } + + public Organization setLegalshortname(final String legalshortname) { + this.legalshortname = legalshortname; + return this; + } + + public Organization setLegalname(final String legalname) { + this.legalname = legalname; + return this; + } + + public Organization setWebsiteurl(final String websiteurl) { + this.websiteurl = websiteurl; + return this; + } + + public Organization setLogourl(final String logourl) { + this.logourl = logourl; + return this; + } + + public Organization setCountry(final String country) { + this.country = country; + return this; + } + + public Organization setCollectedfrom(final String collectedfrom) { + this.collectedfrom = collectedfrom; + return this; + } + + public Organization setDateofcollection(final Date dateofcollection) { + this.dateofcollection = dateofcollection; + return this; + } + + public Organization setProvenanceaction(final String provenanceaction) { + this.provenanceaction = provenanceaction; + return this; + } + + public Set getDatasources() { + return datasources; + } + + public void setDatasources(final Set datasources) { + this.datasources = datasources; + } + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/SearchApisEntry.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/SearchApisEntry.java new file mode 100644 index 0000000..80a42b5 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/SearchApisEntry.java @@ -0,0 +1,139 @@ +package eu.dnetlib.enabling.datasources.common; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class SearchApisEntry implements Comparable { + + private String id; + private String compliance; + private String protocol; + private boolean active; + private String repoId = "unknown"; + private String repoName = "unknown"; + private String alternativeName = "unknown"; + private String repoOrganization = "unknown"; + private String repoCountry = "-"; + private String repoPrefix = ""; + private String aggrDate = ""; + private int aggrTotal = 0; + + public SearchApisEntry() {} + + public SearchApisEntry(final String id, final String compliance, final String protocol, final boolean active, final String repoId, + final String repoName, final String repoCountry, + final String repoPrefix, final String aggrDate, final int aggrTotal) { + this.id = id; + this.compliance = compliance; + this.protocol = protocol; + this.active = active; + this.repoId = repoId; + this.repoName = repoName; + this.repoCountry = repoCountry; + this.repoPrefix = repoPrefix; + this.aggrDate = aggrDate; + this.aggrTotal = aggrTotal; + } + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getCompliance() { + return compliance; + } + + public void setCompliance(final String compliance) { + this.compliance = compliance; + } + + public boolean isActive() { + return active; + } + + public void setActive(final boolean active) { + this.active = active; + } + + public String getRepoId() { + return repoId; + } + + public void setRepoId(final String repoId) { + this.repoId = repoId; + } + + public String getRepoName() { + return repoName; + } + + public void setRepoName(final String repoName) { + this.repoName = repoName; + } + + public String getRepoCountry() { + return repoCountry; + } + + public void setRepoCountry(final String repoCountry) { + this.repoCountry = repoCountry; + } + + public String getRepoPrefix() { + return repoPrefix; + } + + public void setRepoPrefix(final String repoPrefix) { + this.repoPrefix = repoPrefix; + } + + @Override + public int compareTo(final SearchApisEntry e) { + return compliance.compareTo(e.getCompliance()); + } + + public String getAggrDate() { + return aggrDate; + } + + public void setAggrDate(final String aggrDate) { + this.aggrDate = aggrDate; + } + + public int getAggrTotal() { + return aggrTotal; + } + + public void setAggrTotal(final int aggrTotal) { + this.aggrTotal = aggrTotal; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(final String protocol) { + this.protocol = protocol; + } + + public String getAlternativeName() { + return alternativeName; + } + + public void setAlternativeName(String alternativeName) { + this.alternativeName = alternativeName; + } + + public String getRepoOrganization() { + return repoOrganization; + } + + public void setRepoOrganization(String repoOrganization) { + this.repoOrganization = repoOrganization; + } + +} diff --git a/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/SimpleDatasource.java b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/SimpleDatasource.java new file mode 100644 index 0000000..122b116 --- /dev/null +++ b/dnet-core-components/src/main/java/eu/dnetlib/enabling/datasources/common/SimpleDatasource.java @@ -0,0 +1,68 @@ +package eu.dnetlib.enabling.datasources.common; + +import java.util.HashSet; +import java.util.Set; + +public class SimpleDatasource implements Comparable { + + private String id; + private String name; + private String typology; + private String origId; + private Set apis = new HashSet<>(); + private boolean valid; + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public boolean isValid() { + return valid; + } + + public void setValid(final boolean valid) { + this.valid = valid; + } + + public String getTypology() { + return typology; + } + + public void setTypology(final String typology) { + this.typology = typology; + } + + public String getOrigId() { + return origId; + } + + public void setOrigId(final String origId) { + this.origId = origId; + } + + public Set getApis() { + return apis; + } + + public void setApis(final Set apis) { + this.apis = apis; + } + + @Override + public int compareTo(final SimpleDatasource e) { + return getName().compareTo(e.getName()); + } + +} diff --git a/pom.xml b/pom.xml index 245b516..6ad47bd 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ dnet-core-services dnet-information-service dnet-data-services + dnet-modular-ui @@ -326,6 +327,11 @@ + + javax.persistence + persistence-api + 1.0 + commons-collections commons-collections @@ -361,6 +367,11 @@ commons-csv 1.4 + + org.apache.maven + maven-model + 3.2.3 +