imported dnet-datasource-manager-common in dnet-core-components

This commit is contained in:
Claudio Atzori 2019-06-19 12:03:25 +02:00
parent 7e202d3d79
commit 00ff29e05f
22 changed files with 1636 additions and 0 deletions

View File

@ -64,6 +64,10 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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<AP extends ApiParam> implements Comparable<Api<AP>> {
@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<AP> 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<AP> getApiParams() {
return apiParams;
}
public Api<AP> setId(final String id) {
this.id = id;
return this;
}
public Api<AP> setProtocol(final String protocol) {
this.protocol = protocol;
return this;
}
public Api<AP> setDatasource(final String datasource) {
this.datasource = datasource;
return this;
}
public Api<AP> setContentdescription(final String contentdescription) {
this.contentdescription = contentdescription;
return this;
}
public Api<AP> setActive(final Boolean active) {
this.active = active;
return this;
}
public Api<AP> setRemovable(final Boolean removable) {
this.removable = removable;
return this;
}
public Api<AP> setTypology(final String typology) {
this.typology = typology;
return this;
}
public Api<AP> setCompatibility(final String compatibility) {
this.compatibility = compatibility;
return this;
}
public Api<AP> setCompatibilityOverrided(final boolean compatibilityOverrided) {
this.compatibilityOverrided = compatibilityOverrided;
return this;
}
public Api<AP> setMetadataIdentifierPath(final String metadataIdentifierPath) {
this.metadataIdentifierPath = metadataIdentifierPath;
return this;
}
public Api<AP> setLastCollectionTotal(final Integer lastCollectionTotal) {
this.lastCollectionTotal = lastCollectionTotal;
return this;
}
public Api<AP> setLastCollectionDate(final Timestamp lastCollectionDate) {
this.lastCollectionDate = lastCollectionDate;
return this;
}
public Api<AP> setLastCollectionMdid(final String lastCollectionMdid) {
this.lastCollectionMdid = lastCollectionMdid;
return this;
}
public Api<AP> setLastAggregationTotal(final Integer lastAggregationTotal) {
this.lastAggregationTotal = lastAggregationTotal;
return this;
}
public Api<AP> setLastAggregationDate(final Timestamp lastAggregationDate) {
this.lastAggregationDate = lastAggregationDate;
return this;
}
public Api<AP> setLastAggregationMdid(final String lastAggregationMdid) {
this.lastAggregationMdid = lastAggregationMdid;
return this;
}
public Api<AP> setLastDownloadTotal(final Integer lastDownloadTotal) {
this.lastDownloadTotal = lastDownloadTotal;
return this;
}
public Api<AP> setLastDownloadDate(final Timestamp lastDownloadDate) {
this.lastDownloadDate = lastDownloadDate;
return this;
}
public Api<AP> setLastDownloadObjid(final String lastDownloadObjid) {
this.lastDownloadObjid = lastDownloadObjid;
return this;
}
public Api<AP> setLastValidationJob(final String lastValidationJob) {
this.lastValidationJob = lastValidationJob;
return this;
}
public Api<AP> setBaseurl(final String baseurl) {
this.baseurl = baseurl;
return this;
}
public Api<AP> setApiParams(final Set<AP> 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<AP> a) {
return ComparisonChain.start()
.compare(getId(), a.getId())
.result();
}
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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<A extends Api> 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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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<ORG extends Organization, ID extends Identity> {
@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<ORG> organizations;
@ManyToMany(
cascade = { CascadeType.PERSIST, CascadeType.MERGE },
fetch = FetchType.LAZY )
@JoinTable(
name = "dsm_datasourcepids",
joinColumns = @JoinColumn(name = "datasource"),
inverseJoinColumns = @JoinColumn(name = "pid"))
protected Set<ID> 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<ORG> getOrganizations() {
return organizations;
}
public Set<ID> getIdentities() {
return identities;
}
public Datasource<ORG, ID> setId(final String id) {
this.id = id;
return this;
}
public Datasource<ORG, ID> setOfficialname(final String officialname) {
this.officialname = officialname;
return this;
}
public Datasource<ORG, ID> setEnglishname(final String englishname) {
this.englishname = englishname;
return this;
}
public Datasource<ORG, ID> setWebsiteurl(final String websiteurl) {
this.websiteurl = websiteurl;
return this;
}
public Datasource<ORG, ID> setLogourl(final String logourl) {
this.logourl = logourl;
return this;
}
public Datasource<ORG, ID> setContactemail(final String contactemail) {
this.contactemail = contactemail;
return this;
}
public Datasource<ORG, ID> setLatitude(final Double latitude) {
this.latitude = latitude;
return this;
}
public Datasource<ORG, ID> setLongitude(final Double longitude) {
this.longitude = longitude;
return this;
}
public Datasource<ORG, ID> setTimezone(final String timezone) {
this.timezone = timezone;
return this;
}
public Datasource<ORG, ID> setNamespaceprefix(final String namespaceprefix) {
this.namespaceprefix = namespaceprefix;
return this;
}
public Datasource<ORG, ID> setLanguages(final String languages) {
this.languages = languages;
return this;
}
public Datasource<ORG, ID> setOd_contenttypes(final String od_contenttypes) {
this.od_contenttypes = od_contenttypes;
return this;
}
public Datasource<ORG, ID> setCollectedfrom(final String collectedfrom) {
this.collectedfrom = collectedfrom;
return this;
}
public Datasource<ORG, ID> setDateofvalidation(final Date dateofvalidation) {
this.dateofvalidation = dateofvalidation;
return this;
}
public Datasource<ORG, ID> setTypology(final String typology) {
this.typology = typology;
return this;
}
public Datasource<ORG, ID> setProvenanceaction(final String provenanceaction) {
this.provenanceaction = provenanceaction;
return this;
}
public Datasource<ORG, ID> setDateofcollection(final Date dateofcollection) {
this.dateofcollection = dateofcollection;
return this;
}
public Datasource<ORG, ID> setPlatform(final String platform) {
this.platform = platform;
return this;
}
public Datasource<ORG, ID> setActivationId(final String activationId) {
this.activationId = activationId;
return this;
}
public Datasource<ORG, ID> setDescription(final String description) {
this.description = description;
return this;
}
public Datasource<ORG, ID> setReleasestartdate(final Date releasestartdate) {
this.releasestartdate = releasestartdate;
return this;
}
public Datasource<ORG, ID> setReleaseenddate(final Date releaseenddate) {
this.releaseenddate = releaseenddate;
return this;
}
public Datasource<ORG, ID> setMissionstatementurl(final String missionstatementurl) {
this.missionstatementurl = missionstatementurl;
return this;
}
public Datasource<ORG, ID> setDataprovider(final Boolean dataprovider) {
this.dataprovider = dataprovider;
return this;
}
public Datasource<ORG, ID> setServiceprovider(final Boolean serviceprovider) {
this.serviceprovider = serviceprovider;
return this;
}
public Datasource<ORG, ID> setDatabaseaccesstype(final String databaseaccesstype) {
this.databaseaccesstype = databaseaccesstype;
return this;
}
public Datasource<ORG, ID> setDatauploadtype(final String datauploadtype) {
this.datauploadtype = datauploadtype;
return this;
}
public Datasource<ORG, ID> setDatabaseaccessrestriction(final String databaseaccessrestriction) {
this.databaseaccessrestriction = databaseaccessrestriction;
return this;
}
public Datasource<ORG, ID> setDatauploadrestriction(final String datauploadrestriction) {
this.datauploadrestriction = datauploadrestriction;
return this;
}
public Datasource<ORG, ID> setVersioning(final Boolean versioning) {
this.versioning = versioning;
return this;
}
public Datasource<ORG, ID> setCitationguidelineurl(final String citationguidelineurl) {
this.citationguidelineurl = citationguidelineurl;
return this;
}
public Datasource<ORG, ID> setQualitymanagementkind(final String qualitymanagementkind) {
this.qualitymanagementkind = qualitymanagementkind;
return this;
}
public Datasource<ORG, ID> setPidsystems(final String pidsystems) {
this.pidsystems = pidsystems;
return this;
}
public Datasource<ORG, ID> setCertificates(final String certificates) {
this.certificates = certificates;
return this;
}
public Datasource<ORG, ID> setAggregator(final String aggregator) {
this.aggregator = aggregator;
return this;
}
public Datasource<ORG, ID> setIssn(final String issn) {
this.issn = issn;
return this;
}
public Datasource<ORG, ID> setEissn(final String eissn) {
this.eissn = eissn;
return this;
}
public Datasource<ORG, ID> setLissn(final String lissn) {
this.lissn = lissn;
return this;
}
public Datasource<ORG, ID> setRegisteredby(final String registeredby) {
this.registeredby = registeredby;
return this;
}
public Datasource setRegistrationdate(final Date registrationdate) {
this.registrationdate = registrationdate;
return this;
}
public Datasource<ORG, ID> setSubjects(final String subjects) {
this.subjects = subjects;
return this;
}
public Datasource<ORG, ID> setManaged(final Boolean managed) {
this.managed = managed;
return this;
}
public Datasource<ORG, ID> setOrganizations(final Set<ORG> organizations) {
this.organizations = organizations;
return this;
}
public Datasource<ORG, ID> setIdentities(final Set<ID> 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;
}
}

View File

@ -0,0 +1,25 @@
package eu.dnetlib.enabling.datasources.common;
import java.util.List;
public interface DatasourceManagerCommon<DS extends Datasource<?, ?>, API extends Api<?>> {
DS getDs(String id) throws DsmException;
List<? extends API> 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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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<DS extends Datasource<?, ?>, API extends Api<?>> extends DatasourceManagerCommon<DS, API> {
Set<String> listManagedDatasourceIds() throws DsmRuntimeException;
List<SimpleDatasource> searchDatasourcesByType(String type) throws DsmException;
List<? extends SearchApisEntry> searchApis(String field, Object value) throws DsmException;
List<? extends BrowsableField> listBrowsableFields() throws DsmException;
List<? extends BrowseTerm> 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<String, String> params) throws DsmException;
boolean isRemovable(String dsId, String apiId) throws DsmException;
void regenerateProfiles() throws DsmException;
}

View File

@ -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<DS extends Datasource<?, ?>> {
@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<DS> 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<DS> setId(final String id) {
this.id = id;
return this;
}
public Organization<DS> setLegalshortname(final String legalshortname) {
this.legalshortname = legalshortname;
return this;
}
public Organization<DS> setLegalname(final String legalname) {
this.legalname = legalname;
return this;
}
public Organization<DS> setWebsiteurl(final String websiteurl) {
this.websiteurl = websiteurl;
return this;
}
public Organization<DS> setLogourl(final String logourl) {
this.logourl = logourl;
return this;
}
public Organization<DS> setCountry(final String country) {
this.country = country;
return this;
}
public Organization<DS> setCollectedfrom(final String collectedfrom) {
this.collectedfrom = collectedfrom;
return this;
}
public Organization<DS> setDateofcollection(final Date dateofcollection) {
this.dateofcollection = dateofcollection;
return this;
}
public Organization<DS> setProvenanceaction(final String provenanceaction) {
this.provenanceaction = provenanceaction;
return this;
}
public Set<DS> getDatasources() {
return datasources;
}
public void setDatasources(final Set<DS> datasources) {
this.datasources = datasources;
}
}

View File

@ -0,0 +1,139 @@
package eu.dnetlib.enabling.datasources.common;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class SearchApisEntry implements Comparable<SearchApisEntry> {
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;
}
}

View File

@ -0,0 +1,68 @@
package eu.dnetlib.enabling.datasources.common;
import java.util.HashSet;
import java.util.Set;
public class SimpleDatasource implements Comparable<SimpleDatasource> {
private String id;
private String name;
private String typology;
private String origId;
private Set<String> 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<String> getApis() {
return apis;
}
public void setApis(final Set<String> apis) {
this.apis = apis;
}
@Override
public int compareTo(final SimpleDatasource e) {
return getName().compareTo(e.getName());
}
}

11
pom.xml
View File

@ -13,6 +13,7 @@
<module>dnet-core-services</module>
<module>dnet-information-service</module>
<module>dnet-data-services</module>
<module>dnet-modular-ui</module>
</modules>
@ -326,6 +327,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
@ -361,6 +367,11 @@
<artifactId>commons-csv</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.2.3</version>
</dependency>
<!-- Apache Solr -->