add PidSystemDbEntry

This commit is contained in:
Michele Artini 2022-04-07 08:05:39 +02:00
parent 9308ab35f0
commit a6709a3878
4 changed files with 121 additions and 2 deletions

View File

@ -13,7 +13,7 @@ import eu.dnetlib.openaire.dsm.domain.RequestSort;
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
import eu.dnetlib.openaire.vocabularies.Country;
public interface DatasourceDao<DS extends Datasource<?, ?>, API extends Api<?>> extends DatasourceManagerCommon<DS, API> {
public interface DatasourceDao<DS extends Datasource<?, ?, ?>, API extends Api<?>> extends DatasourceManagerCommon<DS, API> {
// DATASOURCE

View File

@ -16,7 +16,7 @@ import eu.dnetlib.enabling.datasources.common.Datasource;
@DynamicUpdate
@SelectBeforeUpdate
@Table(name = "dsm_services")
public class DatasourceDbEntry extends Datasource<OrganizationDbEntry, IdentityDbEntry> {
public class DatasourceDbEntry extends Datasource<OrganizationDbEntry, IdentityDbEntry, PidSystemDbEntry> {
@Transient
private String openaireId;

View File

@ -0,0 +1,57 @@
package eu.dnetlib.openaire.dsm.domain.db;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;
import com.fasterxml.jackson.annotation.JsonIgnore;
import eu.dnetlib.enabling.datasources.common.PidSystem;
/**
* Created by claudio on 13/04/2017.
*/
@Entity
@DynamicUpdate
@SelectBeforeUpdate
@Table(name = "dsm_pid_systems")
public class PidSystemDbEntry implements PidSystem {
@EmbeddedId
protected PidSystemKeyDbEntry id;
public PidSystem setId(final PidSystemKeyDbEntry id) {
this.id = id;
return this;
}
@JsonIgnore
public PidSystemKeyDbEntry getId() {
return id;
}
@Override
public String getType() {
return id.getType();
}
@Override
public void setType(final String type) {
id.setType(type);
}
@Override
public String getScheme() {
return id.getScheme();
}
@Override
public void setScheme(final String scheme) {
id.setScheme(scheme);
}
}

View File

@ -0,0 +1,62 @@
package eu.dnetlib.openaire.dsm.domain.db;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Embeddable;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import eu.dnetlib.enabling.datasources.common.PidSystem;
@Embeddable
@JsonIgnoreProperties(ignoreUnknown = true)
public class PidSystemKeyDbEntry implements PidSystem, Serializable {
private static final long serialVersionUID = 1L;
private String service;
private String type;
private String scheme;
public String getService() {
return service;
}
public void setService(final String service) {
this.service = service;
}
@Override
public String getType() {
return type;
}
@Override
public void setType(final String type) {
this.type = type;
}
@Override
public String getScheme() {
return scheme;
}
@Override
public void setScheme(final String scheme) {
this.scheme = scheme;
}
@Override
public int hashCode() {
return Objects.hash(scheme, service, type);
}
@Override
public boolean equals(final Object obj) {
if (this == obj) { return true; }
if (!(obj instanceof PidSystemKeyDbEntry)) { return false; }
final PidSystemKeyDbEntry other = (PidSystemKeyDbEntry) obj;
return Objects.equals(scheme, other.scheme) && Objects.equals(service, other.service) && Objects.equals(type, other.type);
}
}