Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot

This commit is contained in:
annampak 2017-11-20 10:46:27 +02:00
commit ba4b885787
44 changed files with 580 additions and 141 deletions

View File

@ -15,6 +15,6 @@ public interface DMPDao extends Dao<DMP, UUID> {
List<IDLabelPair> listAllIDsLabels(); List<IDLabelPair> listAllIDsLabels();
List<DMP> getDMPsOfUser(String userID);
} }

View File

@ -41,6 +41,24 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
.collect(Collectors.toList()); .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;
}
}
} }

View File

@ -13,4 +13,6 @@ public interface ProjectDao extends Dao<Project, UUID> {
public List<IDLabelPair> listAllIDsLabels(); public List<IDLabelPair> listAllIDsLabels();
public List<Project> getProjectsOfUser(String userID);
} }

View File

@ -9,6 +9,7 @@ import javax.persistence.TypedQuery;
import org.hibernate.query.Query; import org.hibernate.query.Query;
import dao.JpaDao; import dao.JpaDao;
import entities.DMP;
import entities.Project; import entities.Project;
import entities.responses.IDLabelPair; import entities.responses.IDLabelPair;
@ -38,5 +39,24 @@ public class ProjectDaoImpl extends JpaDao<Project, UUID> implements ProjectDao
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
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;
}
}
} }

View File

@ -1,13 +1,17 @@
package dao.entities; package dao.entities;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import dao.Dao; import dao.Dao;
import entities.DMP;
import entities.UserInfo; import entities.UserInfo;
public interface UserInfoDao extends Dao<UserInfo, UUID> { public interface UserInfoDao extends Dao<UserInfo, UUID> {
public UserInfo getByIdAndMail(String identification, String email); public UserInfo getUserInfo(String userID);
public UserInfo getByIdAndMail(String id, String email);
public UserInfo getByMail(String email); public UserInfo getByMail(String email);
@ -15,4 +19,6 @@ public interface UserInfoDao extends Dao<UserInfo, UUID> {
public UserInfo getByUsername(String username); public UserInfo getByUsername(String username);
public List<DMP> getDmpsOfUser(String userID);
} }

View File

@ -1,12 +1,14 @@
package dao.entities; package dao.entities;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import javax.persistence.NoResultException; import javax.persistence.NoResultException;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
import dao.JpaDao; import dao.JpaDao;
import entities.DMP;
import entities.UserInfo; import entities.UserInfo;
import entities.security.UserAuth; import entities.security.UserAuth;
@ -21,10 +23,25 @@ public class UserInfoDaoImpl extends JpaDao<UserInfo, UUID> implements UserInfoD
@Override @Override
public UserInfo getByIdAndMail(String identification, String email) { public UserInfo getUserInfo(String userID) {
String queryString = "FROM UserInfo userInfo where userInfo.identification = :userInfoID and userInfo.email = :userInfoEmail"; String queryString = "FROM UserInfo userInfo where userInfo.id = :userInfoID";
TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class); TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
typedQuery.setParameter("userInfoID", identification); typedQuery.setParameter("userInfoID", UUID.fromString(userID));
try {
return typedQuery.getSingleResult();
}
catch(NoResultException ex) {
return null;
}
}
@Override
public UserInfo getByIdAndMail(String id, String email) {
String queryString = "FROM UserInfo userInfo where userInfo.id = :userInfoID and userInfo.email = :userInfoEmail";
TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
typedQuery.setParameter("userInfoID", UUID.fromString(id));
typedQuery.setParameter("userInfoEmail", email); typedQuery.setParameter("userInfoEmail", email);
try { try {
return typedQuery.getSingleResult(); return typedQuery.getSingleResult();
@ -80,6 +97,23 @@ public class UserInfoDaoImpl extends JpaDao<UserInfo, UUID> implements UserInfoD
} }
} }
@Override
public List<DMP> getDmpsOfUser(String userID) {
String queryString = "select dmp from DMP dmp join dmp.users user where user.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;
}
}

View File

@ -36,7 +36,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
@Entity @Entity
@Table(name="\"DMP\"") @Table(name="\"DMP\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id") @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope = DMP.class)
public class DMP implements Serializable { public class DMP implements Serializable {
@ -77,6 +77,11 @@ public class DMP implements Serializable {
private DMPProfile profile; private DMPProfile profile;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Creator\"")
private UserInfo creator;
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinTable(name="\"DMPOrganisation\"", @JoinTable(name="\"DMPOrganisation\"",
joinColumns={@JoinColumn(name="\"DMP\"", referencedColumnName="\"ID\"")}, joinColumns={@JoinColumn(name="\"DMP\"", referencedColumnName="\"ID\"")},
@ -125,7 +130,16 @@ public class DMP implements Serializable {
this.description = description; this.description = description;
} }
public UserInfo getCreator() {
return creator;
}
public void setCreator(UserInfo creator) {
this.creator = creator;
}
public Short getStatus() { public Short getStatus() {
return status; return status;

View File

@ -106,6 +106,10 @@ public class Dataset implements Serializable {
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
private Date modified = new Date(); private Date modified = new Date();
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Creator\"", nullable = true)
private UserInfo creator;
@Column(name = "\"Description\"") @Column(name = "\"Description\"")
private String description; private String description;
@ -113,13 +117,20 @@ public class Dataset implements Serializable {
public String getDescription() { public String getDescription() {
return description; return description;
} }
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
public UserInfo getCreator() {
return creator;
}
public void setCreator(UserInfo creator) {
this.creator = creator;
}
public Short getStatus() { public Short getStatus() {
return status; return status;
} }

View File

@ -14,6 +14,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
@ -81,6 +82,11 @@ public class Project implements Serializable {
private Short status; private Short status;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"CreationUser\"", nullable = true)
private UserInfo creationUser;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
private Date created = null; private Date created = null;
@ -207,10 +213,19 @@ public class Project implements Serializable {
public void setDmps(Set<DMP> dmps) { public void setDmps(Set<DMP> dmps) {
this.dmps = dmps; this.dmps = dmps;
} }
public UserInfo getCreationUser() {
public String toString() { return creationUser;
}
public void setCreationUser(UserInfo creationUser) {
this.creationUser = creationUser;
}
public String toString() {
try { try {
return new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(this).replace("\"", "&quot;"); return new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(this).replace("\"", "&quot;");
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {

View File

@ -85,10 +85,11 @@ public class UserInfo implements Serializable{
private Set<DMP> dmps; private Set<DMP> dmps;
/*
public Set<DMP> getDmpsNonDeleted(){ public Set<DMP> getDmpsNonDeleted(){
return getDmps().parallelStream().filter(dmp -> dmp.getStatus()>=0).collect(Collectors.toSet()); return getDmps().parallelStream().filter(dmp -> dmp.getStatus()>=0).collect(Collectors.toSet());
} }
*/
public Set<DMP> getDmps() { public Set<DMP> getDmps() {
return dmps; return dmps;

View File

@ -13,6 +13,7 @@ public class SafeCleanAttribs {
newdmp.setId(dmp.getId()); newdmp.setId(dmp.getId());
dataset.setDmp(newdmp); dataset.setDmp(newdmp);
} }
} }
} }

View File

@ -153,7 +153,6 @@ public class DMPs {
addNullAndForeignElems(previousDmp, dmp); addNullAndForeignElems(previousDmp, dmp);
try { try {
DMP updatedDMP = dMPDao.update(dmp); DMP updatedDMP = dMPDao.update(dmp);
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(updatedDMP)); return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(updatedDMP));
@ -232,13 +231,9 @@ public class DMPs {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("You have not logged in. You shouldn't be here"); 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 { try {
Set<DMP> nonDeleted = userInfo.getDmpsNonDeleted(); //List<DMP> nonDeleted = userInfoDao.getDmpsOfUser(userID);
List<DMP> nonDeleted = dMPDao.getDMPsOfUser(userID);
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(nonDeleted)); return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(nonDeleted));
} }
catch(Exception ex) { catch(Exception ex) {
@ -267,6 +262,8 @@ public class DMPs {
dmp.setId(null); dmp.setId(null);
dmp.setCreator(userInfo);
Set<UserInfo> users = new HashSet<UserInfo>(); Set<UserInfo> users = new HashSet<UserInfo>();
users.add(userInfo); users.add(userInfo);
dmp.setUsers(users); dmp.setUsers(users);

View File

@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -43,6 +44,7 @@ import dao.entities.ProjectDao;
import dao.entities.RegistryDao; import dao.entities.RegistryDao;
import dao.entities.ResearcherDao; import dao.entities.ResearcherDao;
import dao.entities.ServiceDao; import dao.entities.ServiceDao;
import dao.entities.UserInfoDao;
import entities.DMP; import entities.DMP;
import entities.DMPProfile; import entities.DMPProfile;
import entities.Dataset; import entities.Dataset;
@ -51,6 +53,7 @@ import entities.DatasetProfileRuleset;
import entities.DatasetProfileViewstyle; import entities.DatasetProfileViewstyle;
import entities.Organisation; import entities.Organisation;
import entities.Project; import entities.Project;
import entities.UserInfo;
import helpers.SafeCleanAttribs; import helpers.SafeCleanAttribs;
import helpers.SerializerProvider; import helpers.SerializerProvider;
import helpers.Transformers; import helpers.Transformers;
@ -73,6 +76,7 @@ public class Datasets {
@Autowired private RegistryDao registryDao; @Autowired private RegistryDao registryDao;
@Autowired private ResearcherDao researcherDao; @Autowired private ResearcherDao researcherDao;
@Autowired private ServiceDao serviceDao; @Autowired private ServiceDao serviceDao;
@Autowired private UserInfoDao userInfoDao;
// FETCH BY DATASET(S) // FETCH BY DATASET(S)
@ -124,15 +128,36 @@ public class Datasets {
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/create" }, consumes = "application/json", produces="application/json") @RequestMapping(method = RequestMethod.POST, value = { "/dataset/create" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> createDataset(@RequestBody Dataset dataset) { 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.setId(null);
dataset.setCreated(new Date()); dataset.setCreated(new Date());
dataset.setModified(new Date()); dataset.setModified(new Date());
dataset.setStatus(new Short("0")); dataset.setStatus(new Short("0"));
dataset.setCreator(userInfo);
if("".equals(dataset.getReference())) dataset.setReference(null);
if("".equals(dataset.getProperties())) dataset.setProperties(null);
try { try {
dataset = datasetDao.create(dataset); dataset = datasetDao.create(dataset);
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(dataset)); return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(dataset));
} }
catch(Exception e) { catch(Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Could not create or update Dataset! Reason: " + e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Could not create or update Dataset! Reason: " + e.getMessage());
} }
@ -151,6 +176,9 @@ public class Datasets {
SafeCleanAttribs.clean(dataset); SafeCleanAttribs.clean(dataset);
if("".equals(dataset.getReference())) dataset.setReference(null);
if("".equals(dataset.getProperties())) dataset.setProperties(null);
try { try {
dataset = datasetDao.update(dataset); dataset = datasetDao.update(dataset);
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(dataset)); return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(dataset));

View File

@ -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"); 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>(); Map<UUID, Project> userProjects = new HashMap<UUID, Project>();
userInfo.getDmps().forEach( dmp -> { userInfo.getDmps().forEach( dmp -> {
@ -232,6 +243,7 @@ public class Projects {
catch(Exception ex) { catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
} }
*/
} }
@ -257,24 +269,25 @@ public class Projects {
project.setId(null); project.setId(null);
project.setStatus(new Short("0")); project.setStatus(new Short("0"));
project.setCreationUser(userInfo);
project.setCreated(new Date()); project.setCreated(new Date());
project.setModified(new Date()); project.setModified(new Date());
Project newproj = projectDao.create(project); Project newproj = projectDao.create(project);
DMP newdmp = new DMP(); // DMP newdmp = new DMP();
newdmp.setId(null); // newdmp.setId(null);
newdmp.setLabel("Auto-Generated"); // newdmp.setLabel("Auto-Generated");
newdmp.setCreated(new Date()); // newdmp.setCreated(new Date());
newdmp.setVersion(1); // newdmp.setVersion(1);
newdmp.setStatus(new Short("0")); // newdmp.setStatus(new Short("0"));
newdmp.setProject(newproj); // newdmp.setProject(newproj);
//
Set<UserInfo> users = new HashSet<UserInfo>(); // Set<UserInfo> users = new HashSet<UserInfo>();
users.add(userInfo); // users.add(userInfo);
newdmp.setUsers(users); // newdmp.setUsers(users);
//
newdmp = dMPDao.create(newdmp); // newdmp = dMPDao.create(newdmp);
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(newproj)); return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(newproj));
} }

View File

@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -36,6 +37,7 @@ import dao.entities.ProjectDao;
import dao.entities.RegistryDao; import dao.entities.RegistryDao;
import dao.entities.ResearcherDao; import dao.entities.ResearcherDao;
import dao.entities.ServiceDao; import dao.entities.ServiceDao;
import dao.entities.UserInfoDao;
import entities.DMP; import entities.DMP;
import entities.DMPProfile; import entities.DMPProfile;
import entities.DataRepository; import entities.DataRepository;
@ -47,6 +49,7 @@ import entities.Project;
import entities.Registry; import entities.Registry;
import entities.Researcher; import entities.Researcher;
import entities.Service; import entities.Service;
import entities.UserInfo;
import helpers.SerializerProvider; import helpers.SerializerProvider;
import helpers.Transformers; import helpers.Transformers;
import responses.RestResponse; import responses.RestResponse;
@ -68,6 +71,38 @@ public class Users {
@Autowired private RegistryDao registryDao; @Autowired private RegistryDao registryDao;
@Autowired private ResearcherDao researcherDao; @Autowired private ResearcherDao researcherDao;
@Autowired private ServiceDao serviceDao; @Autowired private ServiceDao serviceDao;
@Autowired private UserInfoDao userInfoDao;
@RequestMapping(method = RequestMethod.GET, value = { "/user/whoami" }, produces="application/json;charset=UTF-8")
public @ResponseBody ResponseEntity<Object> whoami(){
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.getUserInfo(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 new ResponseEntity<Object>(SerializerProvider.toJson(userInfo), HttpStatus.OK);
}
catch(Exception ex) {
ex.printStackTrace();
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
}
}

View File

@ -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####################

View File

@ -65,16 +65,16 @@
</listener> </listener>
<context-param> <!-- THIS FILTER IS FOR SPRING SECURITY -->
<param-name>contextConfigLocation</param-name> <context-param>
<param-value>/WEB-INF/applicationContext.xml,/WEB-INF/spring-security.xml</param-value> <param-name>contextConfigLocation</param-name>
<!-- <param-value>/WEB-INF/applicationContext.xml</param-value> --> <param-value>/WEB-INF/applicationContext.xml,/WEB-INF/spring-security.xml</param-value>
</context-param> <!-- <param-value>/WEB-INF/applicationContext.xml</param-value> -->
<session-config> </context-param>
<session-timeout>30</session-timeout> <session-config>
</session-config> <session-timeout>30</session-timeout>
</session-config>
<!-- THIS FILTER IS FOR SPRING SECURITY -->
<filter> <filter>
<filter-name>springSecurityFilterChain</filter-name> <filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
@ -85,6 +85,23 @@
</filter-mapping> </filter-mapping>
<!-- THIS FILTER IS FOR SUPPORTING UNICODE CHARACTERS -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app> </web-app>

View File

@ -3,6 +3,7 @@ import static org.junit.Assert.*;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.junit.Before; import org.junit.Before;
@ -17,6 +18,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType; import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.databind.type.TypeFactory;
@ -201,7 +203,7 @@ public class TestRest {
} }
@Test //@Test
public void testDmpClone() { public void testDmpClone() {
System.out.println(dmpsService.getDmpsOfUser().getBody()); System.out.println(dmpsService.getDmpsOfUser().getBody());
@ -266,5 +268,40 @@ public class TestRest {
} }
@Test
public void testProject2() {
// String a = null;
// try {
// //a = (String)dmpsService.getDmpsOfUser().getBody();
//
// Set<DMP> dmps = new ObjectMapper().readValue(dmpsService.getDmpsOfUser().getBody().toString(), new TypeReference<Set<DMP>>(){});
// System.out.println(dmps);
//
//// Set<DMP> dmps = SerializerProvider.fromJson((String)dmpsService.getDmpsOfUser().getBody(), new TypeReference<Set<DMP>>(){});
// } catch (Exception e) {
//
// e.printStackTrace();
// }
CollectionType typeReference = TypeFactory.defaultInstance().constructCollectionType(List.class, DMP.class);
List<DMP> dmps = null;
try {
dmps = SerializerProvider.fromJson(dmpsService.getDmpsOfUser().getBody().toString(), typeReference) ;
System.out.println(dmps);
} catch (Exception e) {
e.printStackTrace();
fail("Should not have thrown any exception");
}
assertEquals("aaa", "aaa");
}
} }

View File

@ -50,6 +50,7 @@ CREATE TABLE "DMP" (
"Version" integer NOT NULL, "Version" integer NOT NULL,
"Project" uuid NOT NULL, "Project" uuid NOT NULL,
"ProfileData" xml, "ProfileData" xml,
"Creator" uuid not null,
"Status" smallint not null default 0, "Status" smallint not null default 0,
"Created" timestamp not null default NOW(), "Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(), "Modified" timestamp not null default NOW(),
@ -116,6 +117,7 @@ CREATE TABLE "Dataset" (
"Uri" character varying(250), "Uri" character varying(250),
"Properties" xml, "Properties" xml,
"Reference" xml, "Reference" xml,
"Creator" uuid not null,
"Status" smallint not null default 0, "Status" smallint not null default 0,
"Created" timestamp not null default NOW(), "Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(), "Modified" timestamp not null default NOW(),
@ -214,6 +216,7 @@ CREATE TABLE "Project" (
"Abbreviation" character varying(50), "Abbreviation" character varying(50),
"Reference" xml, "Reference" xml,
"Uri" character varying(250), "Uri" character varying(250),
"CreationUser" uuid not null,
"Status" smallint not null default 0, "Status" smallint not null default 0,
"Created" timestamp not null default NOW(), "Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(), "Modified" timestamp not null default NOW(),
@ -534,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 "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 "UserInfo" OWNER TO dmptool;
ALTER TABLE "UserAuth" OWNER TO dmptool; ALTER TABLE "UserAuth" OWNER TO dmptool;
ALTER TABLE "UserDMP" OWNER TO dmptool; ALTER TABLE "UserDMP" OWNER TO dmptool;

View File

@ -1,7 +1,7 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { PageNotFoundComponent } from './not-found.component'; import { PageNotFoundComponent } from './not-found.component';
import { EmptyComponent } from './empty.component'; import { HomepageComponent } from './homepage/homepage.component';
import { DynamicFormComponent } from './form/dynamic-form.component'; import { DynamicFormComponent } from './form/dynamic-form.component';
import { AuthGuard } from './guards/auth.guard'; import { AuthGuard } from './guards/auth.guard';
import { ProjectsComponent } from './projects/projects.component'; import { ProjectsComponent } from './projects/projects.component';
@ -10,6 +10,8 @@ import { DmpComponent } from './dmps/dmp.component';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { UserWorkspaceComponent } from './user-workspace/user-workspace.component'; import { UserWorkspaceComponent } from './user-workspace/user-workspace.component';
import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component'; import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component';
import { DmpDetailedComponent } from './viewers/dmp-detailed/dmp-detailed.component';
const appRoutes: Routes = [ const appRoutes: Routes = [
//{ path: 'dynamic-form/:id', component: DynamicFormComponent, canActivate: [AuthGuard] }, //{ path: 'dynamic-form/:id', component: DynamicFormComponent, canActivate: [AuthGuard] },
@ -18,8 +20,9 @@ const appRoutes: Routes = [
{ path: 'login', component: MainSignInComponent}, { path: 'login', component: MainSignInComponent},
{ path: 'projects', component: ProjectsComponent}, { path: 'projects', component: ProjectsComponent},
{ path: 'dmps', component: DmpComponent}, { path: 'dmps', component: DmpComponent},
{ path: 'dmp', component: DmpDetailedComponent },
{ path: 'workspace', component: UserWorkspaceComponent}, { path: 'workspace', component: UserWorkspaceComponent},
{ path: 'welcome', component: EmptyComponent}, { path: 'welcome', component: HomepageComponent},
{ path: '', redirectTo: '/login', pathMatch: 'full' }, { path: '', redirectTo: '/login', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }, { path: '**', component: PageNotFoundComponent },
/* /*

View File

@ -22,7 +22,7 @@
<span class="caret"></span></a> <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a class="cursor" (click)="goToDMPs()">My DMPs</a></li> <li><a class="cursor" (click)="goToDMPs()">My DMPs</a></li>
<li><a class="cursor" (click)="goToProjects()">My Projects</a></li> <li><a class="cursor" (click)="goToProjects()">Projects</a></li>
</ul> </ul>
</li> </li>

View File

@ -22,7 +22,7 @@ import { DynamicFormGroupComponent } from './form/dynamic-form-group/dynamic-for
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
import { AuthGuard } from './guards/auth.guard'; import { AuthGuard } from './guards/auth.guard';
import { PageNotFoundComponent } from './not-found.component'; import { PageNotFoundComponent } from './not-found.component';
import { EmptyComponent } from './empty.component'; import { HomepageComponent } from './homepage/homepage.component';
import { TocComponent } from './form/tableOfContents/toc.component'; import { TocComponent } from './form/tableOfContents/toc.component';
import { ConfirmationComponent } from './widgets/confirmation/confirmation.component'; import { ConfirmationComponent } from './widgets/confirmation/confirmation.component';
@ -70,6 +70,7 @@ import { AutocompleteRemoteComponent } from './form/fields/autocomplete-remote/a
import { Ng4LoadingSpinnerModule } from 'ng4-loading-spinner'; import { Ng4LoadingSpinnerModule } from 'ng4-loading-spinner';
import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component'; import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component';
import { DmpDetailedComponent } from './viewers/dmp-detailed/dmp-detailed.component';
@ -84,7 +85,7 @@ import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component';
GooggleSignInComponent, GooggleSignInComponent,
MainSignInComponent, MainSignInComponent,
PageNotFoundComponent, PageNotFoundComponent,
EmptyComponent, HomepageComponent,
ModalComponent, ModalComponent,
ProjectDetailComponent, ProjectDetailComponent,
ProjectsComponent, ProjectsComponent,
@ -101,7 +102,7 @@ import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component';
DatasetTableFilterPipe, DatasetTableFilterPipe,
DatasetStatusFilterPipe, DatasetStatusFilterPipe,
StatusToString, StatusToString,
BreadcrumbComponent BreadcrumbComponent, DmpDetailedComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View File

@ -40,4 +40,8 @@ tr.hover:hover > * {
.cursor-hand{ .cursor-hand{
cursor: pointer; cursor: pointer;
}
.hidden-keepspace{
visibility: hidden;
} }

View File

@ -60,6 +60,8 @@ export class DatasetsComponent implements OnInit {
dataSetValue: boolean = true; dataSetValue: boolean = true;
uriRegex = "/^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?$/i";
constructor( constructor(
@ -140,8 +142,11 @@ export class DatasetsComponent implements OnInit {
} }
else{ else{
this.dataset.dmp = { "id": this.dmpIdforDatasets }
this.dataset.profile = { "id": this.dataset.profile } this.dataset.dmp = { "id": this.dmpIdforDatasets };
this.dataset.profile = { "id": this.dataset.profile };
this.dataset.creator = {"id" : this.dataset.creator };
this.serverService.updateDatsetsProfile(this.dataset).subscribe( this.serverService.updateDatsetsProfile(this.dataset).subscribe(
response => { response => {
simple_notifier("success",null,"Dataset edited"); simple_notifier("success",null,"Dataset edited");
@ -203,6 +208,7 @@ export class DatasetsComponent implements OnInit {
//this.dataset.dmp = item.dmp; //this.dataset.dmp = item.dmp;
this.dataset.profile = item.profile==null ? null : item.profile.id; this.dataset.profile = item.profile==null ? null : item.profile.id;
this.dataset.id = item.id; this.dataset.id = item.id;
this.dataset.creator = item.creator;
$("#newDatasetModal").modal("show"); $("#newDatasetModal").modal("show");
} }
else if(event.toElement.id == "describeDataset"){ else if(event.toElement.id == "describeDataset"){
@ -245,7 +251,13 @@ export class DatasetsComponent implements OnInit {
this.getDatasets(); this.getDatasets();
}, },
err => { err => {
simple_notifier("danger",null,"Could not delete the dataset");
if(err.status>=200 && err.status<300)
simple_notifier("success",null,"Deleted dataset");
else
simple_notifier("danger",null,"Could not delete the dataset");
this.getDatasets();
} }
); );
} }

View File

@ -55,14 +55,14 @@
<tr *ngFor="let dataset of mf.data" class="hover"> <tr *ngFor="let dataset of mf.data" class="hover">
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{dataset.id}}</td> <td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{dataset.id}}</td>
<td>{{dataset?.label}}</td> <td>{{(dataset?.label?.length > 80) ? (dataset?.label | slice:0:80)+'...':(dataset?.label) }}</td>
<td>{{dataset?.uri}}</td> <td>{{(dataset?.uri?.length > 40) ? (dataset?.uri | slice:0:40)+'...':(dataset?.uri) }}</td>
<td>{{dataset?.profile?.label}}</td> <td>{{(dataset?.profile?.label?.length > 40) ? (dataset?.profile?.label | slice:0:40)+'...':(dataset?.profile?.label) }}</td>
<td>{{dataset?.description}}</td> <td>{{(dataset?.description?.length > 40) ? (dataset?.description | slice:0:40)+'...':(dataset?.description) }}</td>
<td>{{dataset?.created | date:'yyyy-MM-dd HH:mm:ss Z'}}</td> <td>{{dataset?.created | date:'yyyy-MM-dd HH:mm:ss Z'}}</td>
<td>{{dataset?.status | statusToString }}</td> <td>{{dataset?.status | statusToString }}</td>
<td> <td>
<a class="editGridColumn cursor-hand disabled" (click)="editRow(dataset, $event)"> <a [ngClass]="{'hidden-keepspace': dataset.status==2 }" class="editGridColumn cursor-hand disabled" (click)="editRow(dataset, $event)">
<i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit Properties" id="editDataset"></i></a> <i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit Properties" id="editDataset"></i></a>
<a class="editGridColumn cursor-hand" (click)="editRow(dataset, $event)"> <a class="editGridColumn cursor-hand" (click)="editRow(dataset, $event)">
<i class="fa fa-eraser fa-fw" data-toggle="modal" data-target="#delete-dataset-confirm" (click)="markDatasetForDelete(dataset)" title="delete Dataset"></i></a> <i class="fa fa-eraser fa-fw" data-toggle="modal" data-target="#delete-dataset-confirm" (click)="markDatasetForDelete(dataset)" title="delete Dataset"></i></a>
@ -87,31 +87,26 @@
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" >Dataset</h5> <h4 class="modal-title" id="modalLabel"><b>{{ dataset?.id ? "Edit Dataset" : "New Dataset" }}</b></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form #newProjectForm="ngForm" (ngSubmit)="SaveDataset()"> <form #newDatasetForm="ngForm" (ngSubmit)="SaveDataset()">
<div class="form-group"> <div class="form-group">
<label for="recipient-name" class="col-form-label">Dataset Profile:</label> <label for="recipient-name" class="col-form-label">Dataset Profile:</label>
<select class="form-control" id="datasetProfileDropDownKey" [(ngModel)]="dataset.profile" name="datasetProfileDropDown" <select class="form-control" id="datasetProfileDropDownKey" [(ngModel)]="dataset.profile" name="datasetProfileDropDown" #datasetfield>
#datasetfield> <option *ngFor="let opt of datasetProfileDropDown.options" [value]="opt.key">{{opt.value}}</option>
<option *ngFor="let opt of datasetProfileDropDown.options" [value]="opt.key">{{opt.value}}</option> </select>
</select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="label-name" class="form-control-label">Label:</label> <label for="label-name" class="form-control-label">Label:</label>
<input type="text" class="form-control" id="label-name" [(ngModel)]="dataset.label" name="label"> <input type="text" class="form-control" id="label-name" [(ngModel)]="dataset.label" name="label" required>
</div>
<div class="form-group">
<label for="abbreviation-text" class="form-control-label">DMP:</label>
<input class="form-control" id="abbreviation-text" [(ngModel)]="dataset.dmp" name="dmp" disabled>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="uri-text" class="form-control-label">Uri:</label> <label for="uri-text" class="form-control-label">Uri:</label>
<input class="form-control" id="uri-text" [(ngModel)]="dataset.uri" name="uri"> <input class="form-control" id="uri-text" [(ngModel)]="dataset.uri" name="uri" pattern="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="status-name" class="col-form-label">Status:</label> <label for="status-name" class="col-form-label">Status:</label>

View File

@ -61,4 +61,9 @@ tr.hover:hover > * {
.centered-text{ .centered-text{
text-align: center; text-align: center;
}
.url-like{
color: #0645AD;
cursor: pointer;
} }

View File

@ -45,7 +45,7 @@ export class DmpComponent implements OnInit{
showIDs : boolean = false; showIDs : boolean = false;
dmp : any = null; dmp : any;
@Input() projectsDropDown:DropdownField; @Input() projectsDropDown:DropdownField;
@Input() statusDropDown: DropdownField; @Input() statusDropDown: DropdownField;
@ -60,10 +60,9 @@ export class DmpComponent implements OnInit{
this.projectsDropDown = new DropdownField(); this.projectsDropDown = new DropdownField();
this.projectsDropDown.options = []; this.projectsDropDown.options = [];
this.statusDropDown = new DropdownField(); this.statusDropDown = new DropdownField();
this.statusDropDown.options= [{key:'', value:null},{key:'0', value:"Active"},{key:'1', value:"Inactive"}, {key:'2', value:"Submitted"}, {key:'3', value:"Cancel"}] this.statusDropDown.options= [{key:'', value:null},{key:'0', value:"Active"},{key:'1', value:"Inactive"}]
//this.projects = []; //this.projects = [];
this.dmp = this.clearDmp();
} }
@ -74,7 +73,7 @@ export class DmpComponent implements OnInit{
label: '', label: '',
previous:'', previous:'',
version:'', version:'',
profileData:'', //profileData:'',
//project: '', //project: '',
//profile:{} //profile:{}
} }
@ -101,17 +100,12 @@ export class DmpComponent implements OnInit{
} }
) )
} this.clearDmp();
showDMPDetails(dmp) {
console.log("Showing details for dmp : " + JSON.stringify(dmp));
// TODO: Add here code to show details of dmp.
//1. hide dmp table and show component for detailed dmp
//2. also edit the breadcrumb
} }
getDmps(muted? : boolean){ getDmps(muted? : boolean){
this.serverService.getDmpOfUser().subscribe( this.serverService.getDmpOfUser().subscribe(
response => { response => {
@ -146,6 +140,7 @@ export class DmpComponent implements OnInit{
updateDMP(){ updateDMP(){
this.dmp.project = {"id":this.dmp.project}; this.dmp.project = {"id":this.dmp.project};
this.dmp.creator = {"id": this.dmp.creator};
this.serverService.updateDmp(this.dmp) this.serverService.updateDmp(this.dmp)
.subscribe( .subscribe(
@ -198,7 +193,7 @@ export class DmpComponent implements OnInit{
newDmpForm(item){ newDmpForm(item){
this.dmp = this.clearDmp(); this.clearDmp();
$("#newDmpModal").modal("show"); $("#newDmpModal").modal("show");
} }
@ -222,7 +217,11 @@ export class DmpComponent implements OnInit{
this.getDmps(); this.getDmps();
}, },
(err: HttpErrorResponse) => { (err: HttpErrorResponse) => {
simple_notifier("danger",null,"Failed to delete the DMP"); if(err.status>=200 && err.status<300)
simple_notifier("success",null,"Successfully deleted the DMP");
else
simple_notifier("danger",null,"Failed to delete the DMP");
this.getDmps();
} }
); );
@ -264,6 +263,11 @@ export class DmpComponent implements OnInit{
this.router.navigate(['/dataset'], { queryParams: { "dmpid":item.id , "label":item.label}}); this.router.navigate(['/dataset'], { queryParams: { "dmpid":item.id , "label":item.label}});
} }
viewDetailedDMP(dmp){
console.log(dmp)
this.router.navigate(['/dmp'], { queryParams: { "dmpid":dmp.id, "label":dmp.label }});
}
} }

View File

@ -65,11 +65,11 @@
<tr *ngFor="let dmp of mf.data" class="hover"> <tr *ngFor="let dmp of mf.data" class="hover">
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{dmp?.id}}</td> <td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{dmp?.id}}</td>
<td>{{dmp?.label}}</td> <td class="url-like" (click)="viewDetailedDMP(dmp)">{{(dmp?.label?.length > 40) ? (dmp?.label | slice:0:40)+'...':(dmp?.label) }}</td>
<td style="width:20px;">{{dmp?.version}}</td> <td style="width:20px;">{{dmp?.version}}</td>
<td style="width:300px;">{{dmp?.previous}}</td> <td style="width:300px;">{{dmp?.previous}}</td>
<td>{{dmp?.project?.label}}</td> <td>{{(dmp?.project?.label?.length > 40) ? (dmp?.project?.label | slice:0:40)+'...':(dmp?.project?.label) }}</td>
<td>{{(dmp?.description?.length > 20) ? (dmp?.description | slice:0:20)+'...':(dmp?.description) }}</td> <td>{{(dmp?.description?.length > 40) ? (dmp?.description | slice:0:40)+'...':(dmp?.description) }}</td>
<td>{{dmp?.created | date:'yyyy-MM-dd HH:mm:ss Z'}}</td> <td>{{dmp?.created | date:'yyyy-MM-dd HH:mm:ss Z'}}</td>
<td>{{dmp?.status | statusToString }}</td> <td>{{dmp?.status | statusToString }}</td>
<td> <td>
@ -105,20 +105,20 @@
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header centered-text"> <div class="modal-header centered-text">
<h4 class="modal-title" id="exampleModalLabel"><b>{{ dmp?.id ? "Edit Data Management Plan" : "New Data Management Plan" }}</b></h4> <h4 class="modal-title" id="modalLabel"><b>{{ dmp?.id ? "Edit Data Management Plan" : "New Data Management Plan" }}</b></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form #newProjectForm="ngForm" (ngSubmit)="SaveNewDmp()"> <form #dmpForm="ngForm" (ngSubmit)="SaveNewDmp()">
<div class="form-group"> <div class="form-group">
<div class="form-group"> <div class="form-group">
<label for="label-name" class="form-control-label">Label:</label> <label for="label-name" class="form-control-label">Label:</label>
<input type="text" class="form-control" id="label-name" [ngModel]="dmp?.label" (ngModelChange)="dmp.label=$event" name="label"> <input type="text" class="form-control" id="label-name" [ngModel]="dmp?.label" (ngModelChange)="dmp.label=$event" name="label" required>
</div> </div>
<label for="recipient-name" class="col-form-label">Project:</label> <label for="recipient-name" class="col-form-label">Project:</label>
<select class="form-control" id="projectsDropDownKey" [ngModel]="dmp?.project" (ngModelChange)="dmp.project=$event" name="projectsDropDown"> <select class="form-control" id="projectsDropDownKey" [ngModel]="dmp?.project" (ngModelChange)="dmp.project=$event" name="projectsDropDown" required>
<option *ngFor="let opt of projectsDropDown.options" [value]="opt.key">{{opt.value}}</option> <option *ngFor="let opt of projectsDropDown.options" [value]="opt.key">{{opt.value}}</option>
</select> </select>
</div> </div>
@ -170,13 +170,13 @@
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">DMP</h5> <h4 class="modal-title" id="modalLabel"><b>Clone Data Management Plan</b></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form #newProjectForm="ngForm" (ngSubmit)="SaveNewDmp()"> <form #dmpForm="ngForm" (ngSubmit)="SaveNewDmp()">
<div class="form-group"> <div class="form-group">
<label for="label-name" class="form-control-label">Label:</label> <label for="label-name" class="form-control-label">Label:</label>
<input type="text" class="form-control" id="label-name" [ngModel]="dmp?.label" (ngModelChange)="dmp.label=$event" name="label"> <input type="text" class="form-control" id="label-name" [ngModel]="dmp?.label" (ngModelChange)="dmp.label=$event" name="label">
@ -201,7 +201,7 @@
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" (click)="cloneDMP(dmp);">Save Dmp</button> <button type="submit" class="btn btn-primary" [disabled]="!dmpForm.form.valid" (click)="cloneDMP(dmp);">Save Dmp</button>
</div> </div>
</div> </div>
</div> </div>
@ -229,5 +229,3 @@
<!-- Confirmation module- do not delete --> <!-- Confirmation module- do not delete -->
<confirmation [confirmationID]="'delete-dmp-confirm'" [confirmationTitle]="'Caution'" [confirmationDescr]="'This action will delete this DMP. Are you sure ? This is not revertable !'" (responseSender)="deleteDMP($event)"></confirmation> <confirmation [confirmationID]="'delete-dmp-confirm'" [confirmationTitle]="'Caution'" [confirmationDescr]="'This action will delete this DMP. Are you sure ? This is not revertable !'" (responseSender)="deleteDMP($event)"></confirmation>

View File

@ -1,6 +0,0 @@
import { Component } from '@angular/core';
@Component({
template: ''
})
export class EmptyComponent {}

View File

@ -44,7 +44,7 @@
<div > <div >
<div class="progress"> <div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow= "" aria-valuemin="0" aria-valuemax="100" [ngStyle]="{'width': dirtyValues + '%'}"> <div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow= "" aria-valuemin="0" aria-valuemax="100" [ngStyle]="{'width': dirtyValues + '%'}">
<!-- {{dirtyValues}}% --> <!-- {{dirtyValues}}% -->
</div> </div>
</div> </div>

View File

@ -238,6 +238,8 @@ export class DynamicFormComponent implements OnInit {
//data.properties = "<root><formValues><![CDATA["+JSON.stringify(this.form.value)+"]]></formValues><dataModel><![CDATA["+JSON.stringify(this.dataModel)+"]]></dataModel></root>"; //data.properties = "<root><formValues><![CDATA["+JSON.stringify(this.form.value)+"]]></formValues><dataModel><![CDATA["+JSON.stringify(this.dataModel)+"]]></dataModel></root>";
data.properties = JSON.stringify(this.form.value); data.properties = JSON.stringify(this.form.value);
data.profile = {"id": data.profile.id};
this.serverService.setDataset(data).subscribe( this.serverService.setDataset(data).subscribe(
(data) => { (data) => {
console.log("Updated dataset"); console.log("Updated dataset");

View File

@ -0,0 +1,12 @@
<div class="jumbotron">
<h1>Hello {{ userInfo?.name!=null ? userInfo?.name : userInfo?.email }}</h1>
<p>Welcome {{ userInfo?.created != userInfo?.lastloggedin ? "back" : "" }} to the <a href="https://en.wikipedia.org/wiki/Data_management_plan">Data Management Plans</a> application. </p>
<!--
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
-->
</div>
<!--
{{userInfo | json}}
-->

View File

@ -0,0 +1,32 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ServerService } from '../../app/services/server.service';
@Component({
selector: 'homepage',
templateUrl: './homepage.component.html',
styleUrls: ['./homepage.component.css'],
providers: []
})
export class HomepageComponent implements OnInit{
private userInfo: any;
constructor(private serverService: ServerService, private route: ActivatedRoute, private router: Router){
}
ngOnInit() {
this.serverService.whoami().subscribe(
userInfo => {
this.userInfo = userInfo;
},
error => {
}
);
}
}

View File

@ -6,22 +6,23 @@ import {Pipe, PipeTransform} from "@angular/core";
}) })
export class ProjectTableFilterPipe implements PipeTransform { export class ProjectTableFilterPipe implements PipeTransform {
transform(array: any[], query: string): any { transform(array: any[], query: string, userid : string, onlyMyProjects : boolean): any {
if (query) { if (query || userid) {
return _.filter(array, row => { return _.filter(array, row => {
return (
row.label.indexOf(query) > -1
//|| row.version == query if(onlyMyProjects){
//|| row.id.indexOf(query) > -1 return (row.label.indexOf(query) > -1) && (row.creationUser.id==userid);
) }
else{
return row.label.indexOf(query) > -1;
}
}); });
} }
return array; return array;
} }
} }

View File

@ -49,4 +49,14 @@ tr.hover:hover > * {
background-color:#337ab7; background-color:#337ab7;
color:white; color:white;
margin-top:15px; margin-top:15px;
} }
a{
cursor: pointer;
}
.not-active {
pointer-events: none;
cursor:not-allowed;
opacity: 0.5;
filter: alpha(opacity=50); /* For IE8 and earlier */
}

View File

@ -1,16 +1,21 @@
<meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com">
<table class="table table-striped" [mfData]="tableData | projectTableFilter : filterQuery" <table class="table table-striped" [mfData]="tableData | projectTableFilter : filterQuery : whoami?.id : onlyMyProjects"
#mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder"> #mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
<thead> <thead>
<tr> <tr>
<th colspan="1"> <th colspan="1">
<input class="form-control" [(ngModel)]="filterQuery" placeholder='Filter' /> <input class="form-control" [(ngModel)]="filterQuery" placeholder='Filter' />
</th> </th>
<th> <th style="width:50px;">
<button class="btn btn-default" (click)="getProjects('false')"> <button class="btn btn-default" (click)="getProjects('false')">
<span class="glyphicon glyphicon-refresh"></span> <span class="glyphicon glyphicon-refresh"></span>
</button> </button>
</th>
<th colspan="1">
<div class="checkbox">
<label><input type="checkbox" [(ngModel)]="onlyMyProjects" >Show only my projects</label>
</div>
</th> </th>
</tr> </tr>
<tr> <tr>
@ -24,10 +29,10 @@
<mfDefaultSorter by="abbreviation">Αbbreviation</mfDefaultSorter> <mfDefaultSorter by="abbreviation">Αbbreviation</mfDefaultSorter>
</th> </th>
<th> <th>
<mfDefaultSorter by="startDate">Start Date</mfDefaultSorter> <mfDefaultSorter by="startdate">Start Date</mfDefaultSorter>
</th> </th>
<th> <th>
<mfDefaultSorter by="endDate">End Date</mfDefaultSorter> <mfDefaultSorter by="enddate">End Date</mfDefaultSorter>
</th> </th>
<th> <th>
<mfDefaultSorter by="status">Status</mfDefaultSorter> <mfDefaultSorter by="status">Status</mfDefaultSorter>
@ -48,14 +53,22 @@
<tr *ngFor="let project of mf.data" class="hover"> <tr *ngFor="let project of mf.data" class="hover">
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{project?.id}}</td> <td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{project?.id}}</td>
<td>{{project?.label}}</td> <td>{{(project?.label?.length > 40) ? (project?.label | slice:0:40)+'...':(project?.label) }}</td>
<td>{{project?.abbreviation}}</td> <td>{{project?.abbreviation}}</td>
<td>{{project?.startdate | date:'yyyy-MM-dd HH:mm:ss Z' }}</td> <td>{{project?.startdate | date:'yyyy-MM-dd HH:mm:ss Z' }}</td>
<td>{{project?.enddate | date:'yyyy-MM-dd HH:mm:ss Z'}}</td> <td>{{project?.enddate | date:'yyyy-MM-dd HH:mm:ss Z'}}</td>
<td>{{project?.status | statusToString}}</td> <td>{{project?.status | statusToString}}</td>
<td>{{project?.description}}</td> <td>{{(project?.description?.length > 40) ? (project?.description | slice:0:40)+'...':(project?.description) }}</td>
<td><a href="#" class="editGridColumn" (click)="editRow(project, $event)"><i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit properties" id="editDMP"></i> <td>
<i class="fa fa-eraser fa-fw" data-toggle="tooltip" title="delete project"></i></a></td> <a [ngClass]="{'not-active': whoami?.id!=project?.creationUser?.id }" class="editGridColumn" (click)="editRow(project, $event)">
<i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit properties" id="editDMP" ></i>
</a>
<!--
<a>
<i class="fa fa-eraser fa-fw" data-toggle="tooltip" title="delete project"></i>
</a>
-->
</td>
</tr> </tr>
</tbody> </tbody>

View File

@ -59,6 +59,8 @@ export class ProjectsComponent implements OnInit{
project: any; project: any;
whoami: any;
onlyMyProjects : boolean = false;
options: DatepickerOptions = { options: DatepickerOptions = {
minYear: 1900, minYear: 1900,
@ -101,11 +103,22 @@ getEmptyProject(){
this.getProjects(); this.getProjects();
this.serverService.whoami().subscribe(
response => {
this.whoami = response;
console.log(this.whoami)
},
err => {
simple_notifier("danger",null,"Could not retrieve user config");
}
);
} }
getProjects(muted? : boolean){ getProjects(muted? : boolean){
this.serverService.getProjectsOfUser().subscribe( //this.serverService.getProjectsOfUser().subscribe(
this.serverService.getAllProjects().subscribe(
response => { response => {
this.tableData = response; this.tableData = response;
if(muted && muted!=true) if(muted && muted!=true)

View File

@ -17,20 +17,24 @@ export class RestBase {
protocol: string = "http";
hostname: string ="localhost"
port: number = 8080;
webappname: string = "dmp-backend";
/*
protocol: string = "http";
hostname: string ="dl010.madgik.di.uoa.gr"
port: number = 8080;
webappname: string = "dmp-backend";
/* protocol: string = "http";
hostname: string ="dl010.madgik.di.uoa.gr" ;//"localhost";//"dl010.madgik.di.uoa.gr";//
port: number = 8080;//8080;// protocol: string = "http";
webappname: string = "dmp-backend";//"dmp-backend-new";//*/ hostname: string = "dionysus.di.uoa.gr" ;
port: number = 7070;
webappname: string = "dmp-backend";
*/
protocol: string = "http";
hostname: string = "dionysus.di.uoa.gr" ;
port: number = 7070;
webappname: string = "dmp-backend";

View File

@ -99,7 +99,6 @@ export class ServerService {
return this.restBase.get("dmp/getofuser"); return this.restBase.get("dmp/getofuser");
} }
public createDmpForCurrentUser(data:any){ public createDmpForCurrentUser(data:any){
return this.restBase.post("dmp/createofuser", data); return this.restBase.post("dmp/createofuser", data);
} }
@ -140,6 +139,10 @@ public deleteDataset(dataset: any){
return this.restBase.post("dataset/softdelete", dataset); return this.restBase.post("dataset/softdelete", dataset);
} }
public whoami(){
return this.restBase.get("user/whoami");
}
/* /*
logOut() { logOut() {

View File

@ -0,0 +1,3 @@
<p>
Under construction
</p>

View File

@ -0,0 +1,18 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'dmp-detailed',
templateUrl: './dmp-detailed.component.html',
styleUrls: ['./dmp-detailed.component.css']
})
export class DmpDetailedComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View File

@ -33,10 +33,7 @@ export class BreadcrumbComponent implements OnInit {
//this.breadcrumbData.length = 0; //this.breadcrumbData.length = 0;
this.route.children.forEach( child => { this.route.children.forEach( child => {
let menuItem : MenuItem = this.guessMenuItemFromActivatedRoute(child, event); let menuItem : MenuItem = this.guessMenuItemFromActivatedRoute(child, event);
if(menuItem != null) { this.adaptBreadcrumbByMenuItem(menuItem);
this.adaptBreadcrumbByMenuItem(menuItem);
//this.breadcrumbData.push(menuItem);
}
}) })
} }
@ -55,7 +52,7 @@ export class BreadcrumbComponent implements OnInit {
let label = null; let label = null;
if(componentName == "ProjectsComponent") { if(componentName == "ProjectsComponent") {
label = "My Projects"; label = "Projects";
} }
if(componentName == "DmpComponent"){ if(componentName == "DmpComponent"){
label = "My Data Management Plans"; label = "My Data Management Plans";
@ -69,6 +66,10 @@ export class BreadcrumbComponent implements OnInit {
label = "Form of dataset '"+params["label"]+"'"; label = "Form of dataset '"+params["label"]+"'";
} }
if(componentName == "DmpDetailedComponent"){
label = "Details of DMP '"+params["label"]+"'";
}
if(label != null) if(label != null)
menuItem = {"label": label, "routerLink": url, "queryParams" : params }; menuItem = {"label": label, "routerLink": url, "queryParams" : params };
@ -81,6 +82,11 @@ export class BreadcrumbComponent implements OnInit {
adaptBreadcrumbByMenuItem(menuItem : MenuItem){ adaptBreadcrumbByMenuItem(menuItem : MenuItem){
if(menuItem==null){
this.breadcrumbData.length = 0;
return;
}
let breadcrumbDataNew: MenuItem[] = new Array<MenuItem>(); let breadcrumbDataNew: MenuItem[] = new Array<MenuItem>();
for(var i=0; i<this.breadcrumbData.length;i++){ for(var i=0; i<this.breadcrumbData.length;i++){
if(this.breadcrumbData[i].label == menuItem.label) if(this.breadcrumbData[i].label == menuItem.label)