Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot
This commit is contained in:
commit
51c67ef022
|
@ -142,6 +142,13 @@
|
|||
<version>2.8.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-hibernate5</artifactId>
|
||||
<version>2.8.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- Json <-> XML transformations -->
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ public interface DMPDao extends Dao<DMP, UUID> {
|
|||
|
||||
List<IDLabelPair> listAllIDsLabels();
|
||||
|
||||
List<DMP> listUserDMPs(String username);
|
||||
|
||||
|
||||
// public boolean createFromForm();
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.hibernate.query.Query;
|
|||
|
||||
import dao.JpaDao;
|
||||
import entities.DMP;
|
||||
import entities.UserInfo;
|
||||
import entities.responses.IDLabelPair;
|
||||
|
||||
public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
|
||||
|
@ -39,6 +40,23 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DMP> listUserDMPs(String username) {
|
||||
|
||||
// String queryString = "select ui from UserInfo ui join UserAuth ui.authentication ua where ua.username=:username";
|
||||
|
||||
|
||||
// TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
|
||||
// typedQuery.setParameter("username", username);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// @Override
|
||||
// public boolean createFromForm(Map<String,String> keyVals) {
|
||||
// String query = "insert into DMP () values"
|
||||
|
|
|
@ -9,7 +9,10 @@ public interface UserInfoDao extends Dao<UserInfo, UUID> {
|
|||
|
||||
public UserInfo getByIdAndMail(String identification, String email);
|
||||
|
||||
public UserInfo getByMail(String email);
|
||||
|
||||
public UserInfo getByAuthenticationId(String authentication);
|
||||
|
||||
public UserInfo getByUsername(String username);
|
||||
|
||||
}
|
|
@ -50,4 +50,38 @@ public class UserInfoDaoImpl extends JpaDao<UserInfo, UUID> implements UserInfoD
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public UserInfo getByMail(String email) {
|
||||
String queryString = "FROM UserInfo userInfo where userInfo.email = :email";
|
||||
TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
|
||||
typedQuery.setParameter("email", email);
|
||||
try {
|
||||
return typedQuery.getSingleResult();
|
||||
}
|
||||
catch(Exception ex) { //no need to distinguish between exceptions for the moment
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public UserInfo getByUsername(String username) {
|
||||
|
||||
String queryString = "select ui from UserInfo ui join UserAuth ui.authentication ua where ua.username=:username";
|
||||
TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
|
||||
typedQuery.setParameter("username", username);
|
||||
try {
|
||||
return typedQuery.getSingleResult();
|
||||
}
|
||||
catch(Exception ex) { //no need to distinguish between exceptions for the moment
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -20,10 +20,14 @@ import javax.persistence.Table;
|
|||
|
||||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
@ -31,14 +35,15 @@ import com.fasterxml.jackson.databind.SerializationFeature;
|
|||
|
||||
@Entity
|
||||
@Table(name="\"DMP\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DMP implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -8263056535208547615L;
|
||||
|
||||
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
|
@ -55,10 +60,11 @@ public class DMP implements Serializable {
|
|||
@Column(name = "\"Version\"")
|
||||
private Integer version;
|
||||
|
||||
@OneToOne(mappedBy = "dmp", fetch = FetchType.EAGER)
|
||||
private Dataset dataset;
|
||||
@OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
|
||||
private Set<Dataset> dataset;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
|
||||
@ManyToOne()
|
||||
@JoinColumn(name = "\"Project\"")
|
||||
private Project project;
|
||||
|
||||
|
@ -67,12 +73,12 @@ public class DMP implements Serializable {
|
|||
@Column(name = "\"ProfileData\"", columnDefinition = "xml", nullable = true)
|
||||
private String profileData;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"Profile\"")
|
||||
private DMPProfile profile;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"DMPOrganisation\"",
|
||||
joinColumns={@JoinColumn(name="\"DMP\"", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="\"Organisation\"", referencedColumnName="\"ID\"")}
|
||||
|
@ -80,7 +86,7 @@ public class DMP implements Serializable {
|
|||
private Set<Organisation> organisations;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"DMPResearcher\"",
|
||||
joinColumns={@JoinColumn(name="\"DMP\"", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="\"Researcher\"", referencedColumnName="\"ID\"")}
|
||||
|
@ -88,12 +94,21 @@ public class DMP implements Serializable {
|
|||
private Set<Researcher> researchers;
|
||||
|
||||
|
||||
// @OneToMany(fetch = FetchType.EAGER)
|
||||
// @JoinTable(name="\"UserDMP\"",
|
||||
// joinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")},
|
||||
// inverseJoinColumns={@JoinColumn(name="user", referencedColumnName="\"ID\"")}
|
||||
// )
|
||||
// private Set<UserInfo> users;
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"UserDMP\"",
|
||||
joinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="usr", referencedColumnName="id")}
|
||||
)
|
||||
private Set<UserInfo> users;
|
||||
|
||||
|
||||
public Set<UserInfo> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(Set<UserInfo> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -152,14 +167,14 @@ public class DMP implements Serializable {
|
|||
this.profile = profile;
|
||||
}
|
||||
|
||||
public Dataset getDataset() {
|
||||
public Set<Dataset> getDataset() {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
public void setDataset(Dataset dataset) {
|
||||
public void setDataset(Set<Dataset> dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
|
||||
public Set<Organisation> getOrganisations() {
|
||||
return organisations;
|
||||
}
|
||||
|
@ -177,13 +192,7 @@ public class DMP implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
// public Set<UserInfo> getUsers() {
|
||||
// return users;
|
||||
// }
|
||||
//
|
||||
// public void setUsers(Set<UserInfo> users) {
|
||||
// this.users = users;
|
||||
// }
|
||||
|
||||
|
||||
public String toString() {
|
||||
try {
|
||||
|
|
|
@ -11,15 +11,20 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DMPOrganisation\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DMPOrganisation implements Serializable {
|
||||
|
||||
|
||||
|
|
|
@ -14,15 +14,20 @@ import javax.persistence.OneToOne;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DMPProfile\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DMPProfile implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3213099144442689808L;
|
||||
|
@ -37,7 +42,7 @@ public class DMPProfile implements Serializable {
|
|||
private UUID id;
|
||||
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER, mappedBy = "profile")
|
||||
@OneToOne(fetch = FetchType.LAZY, mappedBy = "profile")
|
||||
private DMP dmp;
|
||||
|
||||
|
||||
|
|
|
@ -11,15 +11,20 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DMPResearcher\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DMPResearcher implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 135449857355252959L;
|
||||
|
|
|
@ -18,14 +18,19 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DataRepository\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DataRepository implements Serializable {
|
||||
|
||||
|
||||
|
|
|
@ -13,20 +13,26 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
@Entity(name = "Dataset")
|
||||
@Table(name="\"Dataset\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class Dataset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3575723814399553259L;
|
||||
|
@ -44,7 +50,7 @@ public class Dataset implements Serializable {
|
|||
private String label;
|
||||
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||
@JoinColumn(name = "\"DMP\"", nullable = true)
|
||||
private DMP dmp;
|
||||
|
@ -58,12 +64,13 @@ public class Dataset implements Serializable {
|
|||
private String properties;
|
||||
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||
@JoinColumn(name = "\"Profile\"", nullable = true)
|
||||
private DatasetProfile profile;
|
||||
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name="\"DatasetDataRepository\"",
|
||||
joinColumns={@JoinColumn(name="\"Dataset\"", referencedColumnName="\"ID\"")},
|
||||
|
|
|
@ -11,15 +11,20 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DatasetDataRepository\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DatasetDataRepository implements Serializable {
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package entities;
|
|||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
|
@ -11,6 +12,7 @@ import javax.persistence.FetchType;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
@ -20,13 +22,16 @@ import org.hibernate.annotations.Proxy;
|
|||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DatasetProfile\"")
|
||||
//@Proxy(lazy = false)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DatasetProfile implements Serializable {
|
||||
|
||||
|
||||
|
@ -44,8 +49,13 @@ public class DatasetProfile implements Serializable {
|
|||
@Column(name = "\"Label\"")
|
||||
private String label;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER, mappedBy = "profile")
|
||||
private Dataset dataset;
|
||||
// @OneToOne(fetch = FetchType.EAGER, mappedBy = "profile")
|
||||
// private Dataset dataset;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "profile")
|
||||
private Set<Dataset> dataset;
|
||||
|
||||
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||
|
@ -105,11 +115,13 @@ public class DatasetProfile implements Serializable {
|
|||
this.definition = definition;
|
||||
}
|
||||
|
||||
public Dataset getDataset() {
|
||||
|
||||
|
||||
public Set<Dataset> getDataset() {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
public void setDataset(Dataset dataset) {
|
||||
public void setDataset(Set<Dataset> dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,17 +14,22 @@ import javax.persistence.OneToOne;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.json.JSONObject;
|
||||
import org.json.XML;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DatasetProfileRuleset\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DatasetProfileRuleset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4249565129050898613L;
|
||||
|
|
|
@ -14,16 +14,21 @@ import javax.persistence.OneToOne;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.json.XML;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DatasetProfileViewstyle\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DatasetProfileViewstyle implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3251295258160291468L;
|
||||
|
|
|
@ -11,15 +11,20 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DatasetRegistry\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DatasetRegistry implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5594183793725819187L;
|
||||
|
|
|
@ -11,15 +11,20 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"DatasetService\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class DatasetService implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1469161193939096037L;
|
||||
|
|
|
@ -17,15 +17,20 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"Organisation\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class Organisation implements Serializable {
|
||||
|
||||
|
||||
|
@ -58,7 +63,7 @@ public class Organisation implements Serializable {
|
|||
private String definition;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"DMPOrganisation\"",
|
||||
joinColumns={@JoinColumn(name="\"Organisation\"", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="\"DMP\"", referencedColumnName="\"ID\"")}
|
||||
|
|
|
@ -16,10 +16,13 @@ import javax.persistence.OneToOne;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
@ -27,6 +30,8 @@ import com.fasterxml.jackson.databind.SerializationFeature;
|
|||
|
||||
@Entity
|
||||
@Table(name="\"Project\"")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
public class Project implements Serializable {
|
||||
|
||||
|
@ -42,8 +47,8 @@ public class Project implements Serializable {
|
|||
private UUID id;
|
||||
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER, mappedBy = "project")
|
||||
private DMP dmp;
|
||||
@OneToMany(mappedBy = "project")
|
||||
private Set<DMP> dmps;
|
||||
|
||||
|
||||
@Column(name = "\"Label\"")
|
||||
|
@ -111,14 +116,16 @@ public class Project implements Serializable {
|
|||
this.definition = definition;
|
||||
}
|
||||
|
||||
|
||||
public DMP getDMP() {
|
||||
return dmp;
|
||||
}
|
||||
|
||||
public void setDMP(DMP dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
public Set<DMP> getDmps() {
|
||||
return dmps;
|
||||
}
|
||||
|
||||
public void setDmps(Set<DMP> dmps) {
|
||||
this.dmps = dmps;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString() {
|
||||
try {
|
||||
|
@ -127,6 +134,7 @@ public class Project implements Serializable {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,15 +17,20 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"Registry\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class Registry implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -277572262583178090L;
|
||||
|
@ -57,7 +62,7 @@ public class Registry implements Serializable {
|
|||
private String definition;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name="\"DatasetRegistry\"",
|
||||
joinColumns={@JoinColumn(name="\"Registry\"", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="\"Dataset\"", referencedColumnName="\"ID\"")}
|
||||
|
|
|
@ -17,15 +17,20 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"Researcher\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class Researcher implements Serializable {
|
||||
|
||||
|
||||
|
@ -58,7 +63,7 @@ public class Researcher implements Serializable {
|
|||
private String reference;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"DMPResearcher\"",
|
||||
joinColumns={@JoinColumn(name="\"Researcher\"", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="\"DMP\"", referencedColumnName="\"ID\"")}
|
||||
|
|
|
@ -19,15 +19,20 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"Service\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class Service implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7243446610500174060L;
|
||||
|
|
|
@ -1,76 +1,81 @@
|
|||
//package entities;
|
||||
//
|
||||
//import java.io.Serializable;
|
||||
//import java.util.UUID;
|
||||
//
|
||||
//import javax.persistence.Column;
|
||||
//import javax.persistence.Entity;
|
||||
//import javax.persistence.GeneratedValue;
|
||||
//import javax.persistence.Id;
|
||||
//import javax.persistence.Table;
|
||||
//
|
||||
//import org.hibernate.annotations.GenericGenerator;
|
||||
//import org.hibernate.annotations.Type;
|
||||
//
|
||||
//import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
//import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
//
|
||||
//@Entity
|
||||
//@Table(name="\"UserInfo\"")
|
||||
//@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="autoid")
|
||||
//public class UserDMP implements Serializable{
|
||||
//
|
||||
// private static final long serialVersionUID = -4467370784003784660L;
|
||||
//
|
||||
//
|
||||
// @Id
|
||||
// @GeneratedValue
|
||||
// @GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
// @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
// private UUID id;
|
||||
//
|
||||
// @Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
// @Column(name = "user", nullable = false)
|
||||
// private UUID user;
|
||||
//
|
||||
// @Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
// @Column(name = "dmp", nullable = false)
|
||||
// private UUID dmp;
|
||||
//
|
||||
// @Column(name = "role")
|
||||
// private Integer role;
|
||||
//
|
||||
// public UUID getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// public void setId(UUID id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
//
|
||||
// public UUID getUser() {
|
||||
// return user;
|
||||
// }
|
||||
//
|
||||
// public void setUser(UUID user) {
|
||||
// this.user = user;
|
||||
// }
|
||||
//
|
||||
// public UUID getDmp() {
|
||||
// return dmp;
|
||||
// }
|
||||
//
|
||||
// public void setDmp(UUID dmp) {
|
||||
// this.dmp = dmp;
|
||||
// }
|
||||
//
|
||||
// public Integer getRole() {
|
||||
// return role;
|
||||
// }
|
||||
//
|
||||
// public void setRole(Integer role) {
|
||||
// this.role = role;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
package entities;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
@Entity
|
||||
@Table(name="\"UserDMP\"")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class UserDMP implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -4467370784003784660L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
@Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
@Column(name = "usr", nullable = false)
|
||||
private UUID usr;
|
||||
|
||||
@Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
@Column(name = "dmp", nullable = false)
|
||||
private UUID dmp;
|
||||
|
||||
@Column(name = "role")
|
||||
private Integer role;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public UUID getUsr() {
|
||||
return usr;
|
||||
}
|
||||
|
||||
public void setUsr(UUID usr) {
|
||||
this.usr = usr;
|
||||
}
|
||||
|
||||
public UUID getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
|
||||
public void setDmp(UUID dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public Integer getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,17 +19,22 @@ import javax.persistence.Temporal;
|
|||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
import entities.security.UserAuth;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"UserInfo\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class UserInfo implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1225151430484658395L;
|
||||
|
@ -73,13 +78,22 @@ public class UserInfo implements Serializable{
|
|||
@Column(name = "additionalinfo", columnDefinition = "xml", nullable = true)
|
||||
private String additionalinfo;
|
||||
|
||||
// @OneToMany(fetch = FetchType.EAGER)
|
||||
// @JoinTable(name="\"UserDMP\"",
|
||||
// joinColumns={@JoinColumn(name="user", referencedColumnName="\"ID\"")},
|
||||
// inverseJoinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")}
|
||||
// )
|
||||
// private Set<UserInfo> users;
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"UserDMP\"",
|
||||
joinColumns={@JoinColumn(name="usr", referencedColumnName="id")},
|
||||
inverseJoinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")}
|
||||
)
|
||||
private Set<DMP> dmps;
|
||||
|
||||
|
||||
public Set<DMP> getDmps() {
|
||||
return dmps;
|
||||
}
|
||||
|
||||
public void setDmps(Set<DMP> dmps) {
|
||||
this.dmps = dmps;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
|
|
|
@ -9,9 +9,18 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
@Entity
|
||||
@Table(name="\"UserAuth\"")
|
||||
//@Proxy(lazy = false)
|
||||
//@JsonInclude(Include.NON_NULL)
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id")
|
||||
public class UserAuth {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package helpers;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
|
||||
|
||||
|
||||
public class SerializerProvider {
|
||||
|
||||
|
||||
private static ObjectMapper objectMapper = new ObjectMapper()
|
||||
// .setSerializationInclusion(Include.NON_NULL)
|
||||
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.registerModule(new Hibernate5Module())
|
||||
;
|
||||
|
||||
|
||||
public static ObjectMapper getJsonSerializer() {
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package helpers;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
@ -80,6 +81,9 @@ public class Transformers {
|
|||
ds.setRegistries(new HashSet<Registry>(Arrays.asList(reg)));
|
||||
ds.setServices(new HashSet<Service>(Arrays.asList(ser)));
|
||||
|
||||
Set<Dataset> datasets = new HashSet<Dataset>();
|
||||
datasets.add(ds);
|
||||
|
||||
|
||||
DMP dmp = new DMP();
|
||||
dmp.setLabel(formData.getFirst("DMP.label"));
|
||||
|
@ -90,7 +94,7 @@ public class Transformers {
|
|||
dmp.setProfileData(formData.getFirst("DMP.profileData"));
|
||||
dmp.setProject(project);
|
||||
dmp.setVersion(Integer.parseInt(formData.getFirst("DMP.version")));
|
||||
dmp.setDataset(ds);
|
||||
dmp.setDataset(datasets);
|
||||
|
||||
|
||||
System.out.println(dmp);
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
package rest.entities;
|
||||
|
||||
import java.io.Console;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
@ -22,7 +19,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mchange.v2.sql.filter.SynchronizedFilterDataSource;
|
||||
|
||||
|
@ -38,13 +37,16 @@ import dao.entities.ProjectDao;
|
|||
import dao.entities.RegistryDao;
|
||||
import dao.entities.ResearcherDao;
|
||||
import dao.entities.ServiceDao;
|
||||
import dao.entities.UserInfoDao;
|
||||
import entities.DMP;
|
||||
import entities.DMPProfile;
|
||||
import entities.Dataset;
|
||||
import entities.DatasetProfile;
|
||||
import entities.DatasetProfileRuleset;
|
||||
import entities.Project;
|
||||
import entities.UserInfo;
|
||||
import entities.responses.IDLabelPair;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
@ -65,9 +67,11 @@ public class DMPs {
|
|||
@Autowired private RegistryDao registryDao;
|
||||
@Autowired private ResearcherDao researcherDao;
|
||||
@Autowired private ServiceDao serviceDao;
|
||||
@Autowired private UserInfoDao userInfoDao;
|
||||
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
|
||||
// FETCH BY DMP(S)
|
||||
|
||||
|
@ -75,20 +79,26 @@ public class DMPs {
|
|||
public @ResponseBody ResponseEntity<Object> listDMPs(){
|
||||
try {
|
||||
List<UUID> allIDs = dMPDao.listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmps/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> getDMP(@PathVariable("id") String id){
|
||||
try {
|
||||
System.out.println("Trying for id: "+ id);
|
||||
DMP dmp = dMPDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(dmp));
|
||||
System.out.println("tried, got : "+ dmp.getId());
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(dmp));
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(dmp);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -97,14 +107,37 @@ public class DMPs {
|
|||
public @ResponseBody ResponseEntity<Object> listDmpLabelID(){
|
||||
try {
|
||||
List<IDLabelPair> allIDLabels = dMPDao.listAllIDsLabels();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDLabels));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDLabels));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmp/ofuser" }, produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<Object> getDmpsOfUser(){
|
||||
|
||||
String userID = null;
|
||||
try {
|
||||
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
} catch(NullPointerException ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("You have not logged in. You shouldn't be here");
|
||||
}
|
||||
|
||||
UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||
|
||||
if(userInfo==null) //this should normally never happer
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There's no such a user on the system. You shouldn't be here");
|
||||
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(userInfo.getDmps()));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -112,6 +145,7 @@ public class DMPs {
|
|||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmp/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> getAllDMPs(){
|
||||
|
||||
try {
|
||||
List<DMP> allDMPs = dMPDao.getAll();
|
||||
|
||||
|
@ -136,7 +170,6 @@ public class DMPs {
|
|||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> setDMP(@RequestBody DMP dmp) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
DMP createdDmp = dMPDao.update(dmp);
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdDmp));
|
||||
|
@ -146,7 +179,7 @@ public class DMPs {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/set/full" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> setFullDMP(@RequestBody DMP dmp) {
|
||||
|
||||
|
@ -231,6 +264,8 @@ public class DMPs {
|
|||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/delete" }, consumes = "application/json", produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<Object> delete(@RequestBody DMP dmp) {
|
||||
|
@ -241,6 +276,7 @@ public class DMPs {
|
|||
dMPDao.delete(d);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete DMP!\"");
|
||||
}
|
||||
|
||||
|
@ -248,9 +284,7 @@ public class DMPs {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// OLD ONES, USED BY THE EMBEDDED (simple) UI OF THIS SERVICE
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/setDMPByForm" }, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<Object> setDMPByForm(@RequestBody MultiValueMap<String,String> formData) {
|
||||
|
@ -268,6 +302,7 @@ public class DMPs {
|
|||
dmp.getDataset().getProfile().getViewstyle().setDefinition(formData.getFirst("DatasetProfileViewStyle.definition"));
|
||||
return setDMP(dmp);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ import entities.Project;
|
|||
import entities.Registry;
|
||||
import entities.Researcher;
|
||||
import entities.Service;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class DataRepositories {
|
|||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
// MANAGE DATAREPOSITORy(IES)
|
||||
|
||||
|
@ -77,7 +78,7 @@ public class DataRepositories {
|
|||
public @ResponseBody ResponseEntity<Object> listDataRepositories(){
|
||||
try {
|
||||
List<UUID> allIDs = dataRepositoryDao.listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
|
@ -89,7 +90,7 @@ public class DataRepositories {
|
|||
public @ResponseBody ResponseEntity<Object> getDataRepository(@PathVariable("id") String id) {
|
||||
try {
|
||||
DataRepository dataRepository = dataRepositoryDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(dataRepository));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(dataRepository));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
|
|
|
@ -2,8 +2,11 @@ package rest.entities;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
|
@ -45,7 +48,9 @@ import entities.Dataset;
|
|||
import entities.DatasetProfile;
|
||||
import entities.DatasetProfileRuleset;
|
||||
import entities.DatasetProfileViewstyle;
|
||||
import entities.Organisation;
|
||||
import entities.Project;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
@ -67,7 +72,7 @@ public class Datasets {
|
|||
@Autowired private ResearcherDao researcherDao;
|
||||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
|
||||
// FETCH BY DATASET(S)
|
||||
|
@ -76,7 +81,7 @@ public class Datasets {
|
|||
public @ResponseBody ResponseEntity<Object> listDatasets(){
|
||||
try {
|
||||
List<UUID> allIDs = datasetDao.listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
|
@ -88,7 +93,7 @@ public class Datasets {
|
|||
public @ResponseBody ResponseEntity<Object> getDataset(@PathVariable("id") String id) {
|
||||
try {
|
||||
Dataset ds = datasetDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(ds));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(ds));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
|
@ -101,13 +106,25 @@ public class Datasets {
|
|||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/getAllDatasets" })
|
||||
public @ResponseBody ResponseEntity<Object> getAllDatasets(){
|
||||
|
||||
try {
|
||||
List<Dataset> allDatasets = datasetDao.getAll();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allDatasets));
|
||||
|
||||
//sorry for that, spring-jersey serialisation has issues when performed on tables, so -> custom
|
||||
List<String> datasetsStrL = allDatasets.parallelStream().map((datasetObj) -> {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(datasetObj);
|
||||
} catch (JsonProcessingException e) {
|
||||
return "";
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return new ResponseEntity<Object>("["+String.join(",", datasetsStrL)+"]", HttpStatus.OK);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -212,7 +229,7 @@ public class Datasets {
|
|||
public @ResponseBody ResponseEntity<Object> getDatasetProfile(@PathVariable("id") String id) {
|
||||
try {
|
||||
DatasetProfile profile = datasetProfileDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(profile));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(profile));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
|
@ -286,11 +303,13 @@ public class Datasets {
|
|||
|
||||
Dataset ds = new Dataset();
|
||||
ds.setId(UUID.fromString(datasetID));
|
||||
datasetProfile.setDataset(ds);
|
||||
Set<Dataset> datasets = new HashSet<Dataset>();
|
||||
datasets.add(ds);
|
||||
datasetProfile.setDataset(datasets);
|
||||
|
||||
try {
|
||||
datasetProfile = datasetProfileDao.create(datasetProfile);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(new ObjectMapper().writeValueAsString(datasetProfile));
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(datasetProfile));
|
||||
}
|
||||
catch(Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("FAILED: reason: "+e.getMessage());
|
||||
|
|
|
@ -48,6 +48,7 @@ import entities.Registry;
|
|||
import entities.Researcher;
|
||||
import entities.Service;
|
||||
import entities.responses.IDLabelPair;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class DmpProfiles {
|
|||
@Autowired private ResearcherDao researcherDao;
|
||||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
// MANAGE DMPPROFILE(S)
|
||||
|
||||
|
@ -77,7 +78,7 @@ public class DmpProfiles {
|
|||
public @ResponseBody ResponseEntity<Object> listDmpProfiles(){
|
||||
try {
|
||||
List<UUID> allIDs = dMPProfileDao.listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
|
@ -91,7 +92,7 @@ public class DmpProfiles {
|
|||
public @ResponseBody ResponseEntity<Object> getDmpProfile(@PathVariable("id") String id) {
|
||||
try {
|
||||
DMPProfile dmpProfile = dMPProfileDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(dmpProfile));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(dmpProfile));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
|
@ -104,7 +105,7 @@ public class DmpProfiles {
|
|||
public @ResponseBody ResponseEntity<Object> listLabelIds(){
|
||||
try {
|
||||
List<IDLabelPair> allIDs = dMPProfileDao.listAllIDsLabels();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
|
|
|
@ -47,6 +47,7 @@ import entities.Project;
|
|||
import entities.Registry;
|
||||
import entities.Researcher;
|
||||
import entities.Service;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class Organisations {
|
|||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
// MANAGE ORGANISATIONS(S)
|
||||
|
||||
|
@ -77,7 +78,7 @@ public class Organisations {
|
|||
public @ResponseBody ResponseEntity<Object> listOrganisations(){
|
||||
try {
|
||||
List<UUID> allIDs = organisationDao.listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
|
@ -89,7 +90,7 @@ public class Organisations {
|
|||
public @ResponseBody ResponseEntity<Object> getOrganisations(@PathVariable("id") String id) {
|
||||
try {
|
||||
Organisation organisation = organisationDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(organisation));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(organisation));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
|
|
|
@ -21,8 +21,11 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
|
||||
|
||||
import dao.entities.DMPDao;
|
||||
import dao.entities.DMPProfileDao;
|
||||
|
@ -48,6 +51,7 @@ import entities.Registry;
|
|||
import entities.Researcher;
|
||||
import entities.Service;
|
||||
import entities.responses.IDLabelPair;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
@ -70,7 +74,7 @@ public class Projects {
|
|||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
// MANAGE PROJECT(S)
|
||||
|
||||
|
@ -78,7 +82,7 @@ public class Projects {
|
|||
public @ResponseBody ResponseEntity<Object> listProjects(){
|
||||
try {
|
||||
List<UUID> allIDs = projectDao.listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
|
@ -89,7 +93,10 @@ public class Projects {
|
|||
public @ResponseBody ResponseEntity<Object> getProject(@PathVariable("id") String id) {
|
||||
try {
|
||||
Project project = projectDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(project));
|
||||
|
||||
System.out.println(project.getId().toString());
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(project));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
|
@ -101,7 +108,7 @@ public class Projects {
|
|||
public @ResponseBody ResponseEntity<Object> listLabelIds(){
|
||||
try {
|
||||
List<IDLabelPair> allIDs = projectDao.listAllIDsLabels();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
|
@ -154,6 +161,7 @@ public class Projects {
|
|||
projectDao.delete(p);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted Project entity!\"}");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete Project!\"}");
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ import entities.Registry;
|
|||
import entities.Researcher;
|
||||
import entities.Service;
|
||||
import entities.responses.IDLabelPair;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class Registries {
|
|||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
// MANAGE REGISTRY(IES)
|
||||
|
||||
|
@ -77,7 +78,7 @@ public class Registries {
|
|||
public @ResponseBody ResponseEntity<Object> listRegistries(){
|
||||
try {
|
||||
List<UUID> allIDs = registryDao.listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
|
@ -89,7 +90,7 @@ public class Registries {
|
|||
public @ResponseBody ResponseEntity<Object> getRegistries(@PathVariable("id") String id) {
|
||||
try {
|
||||
Registry registry = registryDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(registry));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(registry));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
|
|
|
@ -47,6 +47,7 @@ import entities.Project;
|
|||
import entities.Registry;
|
||||
import entities.Researcher;
|
||||
import entities.Service;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class Researchers {
|
|||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
// MANAGE RESEARCHER(S)
|
||||
|
||||
|
@ -77,7 +78,7 @@ public class Researchers {
|
|||
public @ResponseBody ResponseEntity<Object> listResearchers(){
|
||||
try {
|
||||
List<UUID> allIDs = researcherDao.listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(allIDs));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
|
@ -89,7 +90,7 @@ public class Researchers {
|
|||
public @ResponseBody ResponseEntity<Object> getResearchers(@PathVariable("id") String id) {
|
||||
try {
|
||||
Researcher researcher = researcherDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(researcher));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(researcher));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
|
@ -100,7 +101,7 @@ public class Researchers {
|
|||
public @ResponseBody ResponseEntity<Object> getResearcherByEmail(@RequestParam("email") String email){
|
||||
try {
|
||||
Researcher researcher = researcherDao.getResearcherByEmail(email);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(researcher));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(objectMapper.writeValueAsString(researcher));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||
|
|
|
@ -47,6 +47,7 @@ import entities.Project;
|
|||
import entities.Registry;
|
||||
import entities.Researcher;
|
||||
import entities.Service;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class Services {
|
|||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
// MANAGE SERVICE(S)
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
package rest.entities;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import dao.entities.DMPDao;
|
||||
import dao.entities.DMPProfileDao;
|
||||
import dao.entities.DataRepositoryDao;
|
||||
import dao.entities.DatasetDao;
|
||||
import dao.entities.DatasetProfileDao;
|
||||
import dao.entities.DatasetProfileRulesetDao;
|
||||
import dao.entities.DatasetProfileViewstyleDao;
|
||||
import dao.entities.OrganisationDao;
|
||||
import dao.entities.ProjectDao;
|
||||
import dao.entities.RegistryDao;
|
||||
import dao.entities.ResearcherDao;
|
||||
import dao.entities.ServiceDao;
|
||||
import entities.DMP;
|
||||
import entities.DMPProfile;
|
||||
import entities.DataRepository;
|
||||
import entities.Dataset;
|
||||
import entities.DatasetProfile;
|
||||
import entities.DatasetProfileRuleset;
|
||||
import entities.Organisation;
|
||||
import entities.Project;
|
||||
import entities.Registry;
|
||||
import entities.Researcher;
|
||||
import entities.Service;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Users {
|
||||
|
||||
@Autowired private DataRepositoryDao dataRepositoryDao;
|
||||
@Autowired private DatasetDao datasetDao;
|
||||
@Autowired private DatasetProfileDao datasetProfileDao;
|
||||
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
|
||||
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
|
||||
@Autowired private DMPDao dMPDao;
|
||||
@Autowired private DMPProfileDao dMPProfileDao;
|
||||
@Autowired private OrganisationDao organisationDao;
|
||||
@Autowired private ProjectDao projectDao;
|
||||
@Autowired private RegistryDao registryDao;
|
||||
@Autowired private ResearcherDao researcherDao;
|
||||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
|
||||
private ObjectMapper objectMapper = SerializerProvider.getJsonSerializer();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -44,21 +44,17 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|||
else
|
||||
throw new AuthenticationServiceException("The appropriate http headers have not been set. Please check!");
|
||||
|
||||
|
||||
UserInfo userInfo;
|
||||
try {
|
||||
tokenValidator.validateToken(token);
|
||||
userInfo = tokenValidator.validateToken(token);
|
||||
} catch (NonValidTokenException e) {
|
||||
System.out.println("Could not validate a user by his token! Reason: "+e.getMessage());
|
||||
throw new AuthenticationServiceException("Token validation failed - Not a valid token");
|
||||
}
|
||||
|
||||
//store to database if new
|
||||
// UserInfo existingUserInfo = userInfoDao.getByKey(userInfo.getId(), userInfo.getEmail());
|
||||
// if(existingUserInfo == null)
|
||||
// userInfoDao.create(userInfo);
|
||||
|
||||
// if reached this point, authentication is ok, so return just an instance with whatever.
|
||||
return new UsernamePasswordAuthenticationToken(authentication.getPrincipal(), authentication.getCredentials(), new ArrayList<>());
|
||||
// if reached this point, authentication is ok, so return just an instance where the principal is the UserInfo ID
|
||||
//(to have it at the webservices calls - it's ESSENTIAL) while the password can be whatever...
|
||||
return new UsernamePasswordAuthenticationToken(userInfo.getId(), authentication.getCredentials(), new ArrayList<>());
|
||||
|
||||
}
|
||||
else
|
||||
|
|
|
@ -3,8 +3,11 @@ package security.validators;
|
|||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload;
|
||||
|
@ -12,6 +15,7 @@ import com.google.api.client.http.HttpTransport;
|
|||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
|
||||
import dao.entities.UserInfoDao;
|
||||
import entities.UserInfo;
|
||||
import exceptions.NonValidTokenException;
|
||||
|
||||
|
@ -20,7 +24,13 @@ public class GoogleTokenValidator implements TokenValidator {
|
|||
private static final JacksonFactory jacksonFactory = new JacksonFactory();
|
||||
private static final HttpTransport transport = new NetHttpTransport();
|
||||
|
||||
private static final List<String> clientIDs = Arrays.asList("1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com");
|
||||
@Autowired private UserInfoDao userInfoDao;
|
||||
|
||||
|
||||
private static final List<String> clientIDs = Arrays.asList(
|
||||
"1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com",
|
||||
"1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com"
|
||||
);
|
||||
|
||||
private GoogleIdTokenVerifier verifier = null;
|
||||
|
||||
|
@ -35,7 +45,7 @@ public class GoogleTokenValidator implements TokenValidator {
|
|||
|
||||
|
||||
@Override
|
||||
public void validateToken(String token) throws NonValidTokenException {
|
||||
public UserInfo validateToken(String token) throws NonValidTokenException {
|
||||
|
||||
GoogleIdToken idToken = null;
|
||||
try {
|
||||
|
@ -54,15 +64,29 @@ public class GoogleTokenValidator implements TokenValidator {
|
|||
if(idToken == null) {
|
||||
throw new NonValidTokenException("Not a valid token");
|
||||
}
|
||||
// else {
|
||||
// Payload payload = idToken.getPayload();
|
||||
// UserInfo userInfo = new UserInfo(payload.getSubject(), payload.getEmail(),
|
||||
// payload.getEmailVerified(), (String)payload.get("name"), (String)payload.get("picture"),
|
||||
// (String)payload.get("locale"), (String)payload.get("family_name"), (String)payload.get("given_name"), "");
|
||||
// System.out.println(userInfo.toString());
|
||||
// return userInfo;
|
||||
// }
|
||||
|
||||
Payload payload = idToken.getPayload();
|
||||
|
||||
UserInfo userInfo = userInfoDao.getByMail(payload.getEmail());
|
||||
|
||||
if(userInfo == null) { //means not existing in db, so create one
|
||||
userInfo = new UserInfo();
|
||||
userInfo.setName((String)payload.get("name"));
|
||||
userInfo.setVerified_email(payload.getEmailVerified());
|
||||
userInfo.setEmail(payload.getEmail());
|
||||
userInfo.setCreated(new Date());
|
||||
userInfo.setLastloggedin(new Date());
|
||||
userInfo.setAuthorization_level(new Short("1"));
|
||||
userInfo.setUsertype(new Short("1"));
|
||||
userInfo = userInfoDao.create(userInfo);
|
||||
}
|
||||
else {
|
||||
userInfo.setLastloggedin(new Date());
|
||||
userInfo = userInfoDao.update(userInfo);
|
||||
}
|
||||
|
||||
return userInfo;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,18 +2,22 @@ package security.validators;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import dao.entities.UserInfoDao;
|
||||
import entities.UserInfo;
|
||||
import exceptions.NonValidTokenException;
|
||||
import security.TokenSessionManager;
|
||||
|
||||
public class NativeTokenValidator implements TokenValidator {
|
||||
|
||||
@Autowired private TokenSessionManager tokenSessionManager;
|
||||
@Autowired private UserInfoDao userInfoDao;
|
||||
|
||||
@Override
|
||||
public void validateToken(String token) throws NonValidTokenException {
|
||||
public UserInfo validateToken(String token) throws NonValidTokenException {
|
||||
String tokenUser = tokenSessionManager.getUser(token);
|
||||
if(tokenUser==null || tokenUser.isEmpty())
|
||||
throw new NonValidTokenException("Login session has expired! Need to login again!");
|
||||
return userInfoDao.getByUsername(tokenUser);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package security.validators;
|
||||
|
||||
import entities.UserInfo;
|
||||
import exceptions.NonValidTokenException;
|
||||
|
||||
public interface TokenValidator {
|
||||
|
||||
public void validateToken(String token) throws NonValidTokenException;
|
||||
public UserInfo validateToken(String token) throws NonValidTokenException;
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
<prop key="hibernate.hbm2ddl.auto">${persistence.hibernate.hbm2dll}</prop>
|
||||
<prop key="hibernate.dialect">${persistence.hibernate.dialect}</prop>
|
||||
|
||||
<prop key="hibernate.enable_lazy_load_no_trans">true</prop> <!-- USE WITH CAUTION -->
|
||||
|
||||
<prop key="hibernate.jdbc.batch_size">${persistence.hibernate.jdbc.batch_size}</prop>
|
||||
<prop key="hibernate.order_inserts">${persistence.hibernate.order_inserts}</prop>
|
||||
<prop key="hibernate.order_updates">${persistence.hibernate.order_updates}</prop>
|
||||
|
|
|
@ -67,21 +67,22 @@
|
|||
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>/WEB-INF/applicationContext.xml,/WEB-INF/spring-security.xml</param-value>
|
||||
<!-- <param-value>/WEB-INF/applicationContext.xml,/WEB-INF/spring-security.xml</param-value> -->
|
||||
<param-value>/WEB-INF/applicationContext.xml</param-value>
|
||||
</context-param>
|
||||
<session-config>
|
||||
<session-timeout>30</session-timeout>
|
||||
</session-config>
|
||||
|
||||
<!-- THIS FILTER IS FOR SPRING SECURITY -->
|
||||
<filter>
|
||||
<filter-name>springSecurityFilterChain</filter-name>
|
||||
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>springSecurityFilterChain</filter-name>
|
||||
<url-pattern>/rest/*</url-pattern>
|
||||
</filter-mapping>
|
||||
<!-- <filter> -->
|
||||
<!-- <filter-name>springSecurityFilterChain</filter-name> -->
|
||||
<!-- <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> -->
|
||||
<!-- </filter> -->
|
||||
<!-- <filter-mapping> -->
|
||||
<!-- <filter-name>springSecurityFilterChain</filter-name> -->
|
||||
<!-- <url-pattern>/rest/*</url-pattern> -->
|
||||
<!-- </filter-mapping> -->
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -450,9 +450,6 @@ ALTER TABLE ONLY "DatasetService"
|
|||
ADD CONSTRAINT "DatasetServiceServiceReference" FOREIGN KEY ("Service") REFERENCES "Service"("ID");
|
||||
|
||||
|
||||
DROP table if exists "UserDMP";
|
||||
DROP table if exists "UserInfo";
|
||||
DROP table if exists "UserAuth";
|
||||
|
||||
CREATE TABLE "UserInfo" (
|
||||
"id" uuid DEFAULT uuid_generate_v4() UNIQUE NOT NULL,
|
||||
|
@ -488,13 +485,13 @@ COMMENT ON COLUMN "UserAuth"."password" IS 'This field stores a password hash';
|
|||
|
||||
create table "UserDMP" (
|
||||
"id" uuid DEFAULT uuid_generate_v4() NOT NULL,
|
||||
"user" uuid NOT NULL,
|
||||
"usr" uuid NOT NULL,
|
||||
"dmp" uuid NOT NUll,
|
||||
"role" integer
|
||||
);
|
||||
|
||||
ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_user FOREIGN KEY ("user") REFERENCES "UserInfo"("id");
|
||||
ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_dmp FOREIGN KEY ("dmp") REFERENCES "DMP"("ID");
|
||||
ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_user FOREIGN KEY (usr) REFERENCES "UserInfo"("id");
|
||||
ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_dmp FOREIGN KEY (dmp) REFERENCES "DMP"("ID");
|
||||
|
||||
|
||||
ALTER TABLE "UserInfo" OWNER TO dmptool;
|
||||
|
|
Loading…
Reference in New Issue