Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot
This commit is contained in:
commit
120f26f948
|
@ -15,6 +15,6 @@ public interface DMPDao extends Dao<DMP, UUID> {
|
|||
|
||||
List<IDLabelPair> listAllIDsLabels();
|
||||
|
||||
|
||||
List<DMP> getDMPsOfUser(String userID);
|
||||
|
||||
}
|
|
@ -41,6 +41,24 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DMP> getDMPsOfUser(String userID) {
|
||||
|
||||
String queryString = "select dmp from DMP dmp where dmp.creator.id=:userid and dmp.status >= 0";
|
||||
TypedQuery<DMP> typedQuery = entityManager.createQuery(queryString, DMP.class);
|
||||
typedQuery.setParameter("userid", UUID.fromString(userID));
|
||||
try {
|
||||
return typedQuery.getResultList();
|
||||
}
|
||||
catch(Exception ex) { //no need to distinguish between exceptions for the moment
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,4 +13,6 @@ public interface ProjectDao extends Dao<Project, UUID> {
|
|||
|
||||
public List<IDLabelPair> listAllIDsLabels();
|
||||
|
||||
public List<Project> getProjectsOfUser(String userID);
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@ import javax.persistence.TypedQuery;
|
|||
import org.hibernate.query.Query;
|
||||
|
||||
import dao.JpaDao;
|
||||
import entities.DMP;
|
||||
import entities.Project;
|
||||
import entities.responses.IDLabelPair;
|
||||
|
||||
|
@ -39,4 +40,23 @@ public class ProjectDaoImpl extends JpaDao<Project, UUID> implements ProjectDao
|
|||
}
|
||||
|
||||
|
||||
public List<Project> getProjectsOfUser(String userID){
|
||||
|
||||
String queryString = "select p from Project p where p.creationUser.id=:userid and project.status >= 0";
|
||||
TypedQuery<Project> typedQuery = entityManager.createQuery(queryString, Project.class);
|
||||
typedQuery.setParameter("userid", UUID.fromString(userID));
|
||||
try {
|
||||
return typedQuery.getResultList();
|
||||
}
|
||||
catch(Exception ex) { //no need to distinguish between exceptions for the moment
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -77,6 +77,11 @@ public class DMP implements Serializable {
|
|||
private DMPProfile profile;
|
||||
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "\"Creator\"", nullable = true)
|
||||
private UserInfo creator;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"DMPOrganisation\"",
|
||||
joinColumns={@JoinColumn(name="\"DMP\"", referencedColumnName="\"ID\"")},
|
||||
|
@ -126,6 +131,15 @@ public class DMP implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public UserInfo getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
|
||||
public void setCreator(UserInfo creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
|
|
|
@ -106,6 +106,10 @@ public class Dataset implements Serializable {
|
|||
@Column(name = "\"Modified\"")
|
||||
private Date modified = new Date();
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "\"Creator\"", nullable = true)
|
||||
private UserInfo creator;
|
||||
|
||||
@Column(name = "\"Description\"")
|
||||
private String description;
|
||||
|
||||
|
@ -114,12 +118,19 @@ public class Dataset implements Serializable {
|
|||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public UserInfo getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(UserInfo creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -80,9 +80,11 @@ public class Project implements Serializable {
|
|||
@Column(name = "\"Status\"", nullable = false)
|
||||
private Short status;
|
||||
|
||||
@Type(type="org.hibernate.type.PostgresUUIDType")
|
||||
@Column(name = "\"CreationUser\"")
|
||||
private UUID creationUser;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
||||
private UserInfo creationUser;
|
||||
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
private Date created = null;
|
||||
|
@ -212,13 +214,12 @@ public class Project implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public UUID getCreationUser() {
|
||||
public UserInfo getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
|
||||
|
||||
public void setCreationUser(UUID creationUser) {
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,6 @@ public class DMPs {
|
|||
addNullAndForeignElems(previousDmp, dmp);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
DMP updatedDMP = dMPDao.update(dmp);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(updatedDMP));
|
||||
|
@ -233,7 +232,8 @@ public class DMPs {
|
|||
}
|
||||
|
||||
try {
|
||||
List<DMP> nonDeleted = userInfoDao.getDmpsOfUser(userID);
|
||||
//List<DMP> nonDeleted = userInfoDao.getDmpsOfUser(userID);
|
||||
List<DMP> nonDeleted = dMPDao.getDMPsOfUser(userID);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(nonDeleted));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -262,6 +262,8 @@ public class DMPs {
|
|||
|
||||
dmp.setId(null);
|
||||
|
||||
dmp.setCreator(userInfo);
|
||||
|
||||
Set<UserInfo> users = new HashSet<UserInfo>();
|
||||
users.add(userInfo);
|
||||
dmp.setUsers(users);
|
||||
|
|
|
@ -16,6 +16,7 @@ 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.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
@ -43,6 +44,7 @@ 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;
|
||||
|
@ -51,6 +53,7 @@ import entities.DatasetProfileRuleset;
|
|||
import entities.DatasetProfileViewstyle;
|
||||
import entities.Organisation;
|
||||
import entities.Project;
|
||||
import entities.UserInfo;
|
||||
import helpers.SafeCleanAttribs;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
|
@ -73,6 +76,7 @@ public class Datasets {
|
|||
@Autowired private RegistryDao registryDao;
|
||||
@Autowired private ResearcherDao researcherDao;
|
||||
@Autowired private ServiceDao serviceDao;
|
||||
@Autowired private UserInfoDao userInfoDao;
|
||||
|
||||
|
||||
// FETCH BY DATASET(S)
|
||||
|
@ -124,10 +128,27 @@ public class Datasets {
|
|||
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> createDataset(@RequestBody Dataset dataset) {
|
||||
|
||||
|
||||
|
||||
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");
|
||||
|
||||
|
||||
|
||||
dataset.setId(null);
|
||||
dataset.setCreated(new Date());
|
||||
dataset.setModified(new Date());
|
||||
dataset.setStatus(new Short("0"));
|
||||
dataset.setCreator(userInfo);
|
||||
try {
|
||||
dataset = datasetDao.create(dataset);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(dataset));
|
||||
|
|
|
@ -219,6 +219,17 @@ public class Projects {
|
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There's no such a user on the system. You shouldn't be here");
|
||||
|
||||
|
||||
try {
|
||||
List<Project> userProjects = projectDao.getProjectsOfUser(userID);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(userProjects));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* OLD ONE
|
||||
Map<UUID, Project> userProjects = new HashMap<UUID, Project>();
|
||||
|
||||
userInfo.getDmps().forEach( dmp -> {
|
||||
|
@ -232,6 +243,7 @@ public class Projects {
|
|||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -257,7 +269,7 @@ public class Projects {
|
|||
|
||||
project.setId(null);
|
||||
project.setStatus(new Short("0"));
|
||||
project.setCreationUser(userInfo.getId());
|
||||
project.setCreationUser(userInfo);
|
||||
project.setCreated(new Date());
|
||||
project.setModified(new Date());
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
##########################Security##########################################
|
||||
#security.portmapping.http = 7081
|
||||
#security.portmapping.https = 7444
|
||||
##########################/Security########################################
|
||||
|
||||
##########################Persistence##########################################
|
||||
persistence.jdbc.driver = org.postgresql.Driver
|
||||
persistence.jdbc.url = jdbc:postgresql://HOST:PORT/DB
|
||||
persistence.dbusername = USER
|
||||
persistence.dbpassword = PASS
|
||||
##########################/Persistence##########################################
|
||||
|
||||
###################Allowed Proxy Service Host ############################
|
||||
proxy.allowed.host = https://eestore.paas2.uninett.no
|
||||
#######################################################
|
||||
|
||||
########################Persistence/Hibernate Generic#############################
|
||||
persistence.hibernate.show_sql = false
|
||||
persistence.hibernate.hbm2dll = validate
|
||||
persistence.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
|
||||
#persistence.hibernate.dialect = org.hibernate.spatial.dialect.postgis.PostgisDialect
|
||||
########################Persistence/Hibernate Generic#############################
|
||||
|
||||
|
||||
########################Persistence/Hibernate/Batch##############################
|
||||
persistence.hibernate.jdbc.batch_size = 30
|
||||
persistence.hibernate.order_inserts = true
|
||||
persistence.hibernate.order_updates = true
|
||||
persistence.hibernate.batch_versioned_data = true
|
||||
persistence.hibernate.jdbc.batch_versioned_data = DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION
|
||||
########################Persistence/Hibernate/Batch##############################
|
||||
|
||||
|
||||
########################Persistence/Hibernate/Connection pool####################
|
||||
persistence.hibernate.connectionpool.provider_class = org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
|
||||
persistence.hibernate.connectionpool.c3p0.min_size = 5
|
||||
persistence.hibernate.connectionpool.c3p0.max_size = 100
|
||||
persistence.hibernate.connectionpool.c3p0.timeout = 0
|
||||
persistence.hibernate.connectionpool.c3p0.max_statements = 50
|
||||
persistence.hibernate.connectionpool.c3p0.acquire_retry_attempts = 30
|
||||
persistence.hibernate.connectionpool.c3p0.acquire_retry_delay = 1000
|
||||
persistence.hibernate.connectionpool.c3p0.idle_test_period = 3000
|
||||
persistence.hibernate.connectionpool.c3p0.break_after_acquire_failure = false
|
||||
persistence.hibernate.connectionpool.c3p0.idle_connection_test_period = 3600
|
||||
persistence.hibernate.connectionpool.c3p0.test_connection_on_checkin = true
|
||||
persistence.hibernate.connectionpool.c3p0.test_connection_on_checkout = false
|
||||
persistence.hibernate.connectionpool.c3p0.preferred_test_query = select 1
|
||||
########################Persistence/Hibernate/Connection pool####################
|
|
@ -50,6 +50,7 @@ CREATE TABLE "DMP" (
|
|||
"Version" integer NOT NULL,
|
||||
"Project" uuid NOT NULL,
|
||||
"ProfileData" xml,
|
||||
"Creator" uuid not null,
|
||||
"Status" smallint not null default 0,
|
||||
"Created" timestamp not null default NOW(),
|
||||
"Modified" timestamp not null default NOW(),
|
||||
|
@ -116,6 +117,7 @@ CREATE TABLE "Dataset" (
|
|||
"Uri" character varying(250),
|
||||
"Properties" xml,
|
||||
"Reference" xml,
|
||||
"Creator" uuid not null,
|
||||
"Status" smallint not null default 0,
|
||||
"Created" timestamp not null default NOW(),
|
||||
"Modified" timestamp not null default NOW(),
|
||||
|
@ -535,6 +537,12 @@ ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_user FOREIGN KEY (usr) REFEREN
|
|||
ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_dmp FOREIGN KEY (dmp) REFERENCES "DMP"("ID");
|
||||
|
||||
|
||||
ALTER TABLE "DMP" ADD CONSTRAINT fk_dmp_creator FOREIGN KEY ("Creator") REFERENCES "UserInfo"(id);
|
||||
ALTER TABLE "Dataset" ADD CONSTRAINT fk_dataset_creator FOREIGN KEY ("Creator") REFERENCES "UserInfo"(id);
|
||||
ALTER TABLE "Project" ADD CONSTRAINT fk_project_creator FOREIGN KEY ("CreationUser") REFERENCES "UserInfo"(id);
|
||||
|
||||
|
||||
|
||||
ALTER TABLE "UserInfo" OWNER TO dmptool;
|
||||
ALTER TABLE "UserAuth" OWNER TO dmptool;
|
||||
ALTER TABLE "UserDMP" OWNER TO dmptool;
|
||||
|
|
Loading…
Reference in New Issue