# Conflicts:
#	dmp-frontend/src/app/form/dynamic-form.component.html
This commit is contained in:
Diamantis Tziotzios 2017-12-11 10:12:12 +02:00
commit 38241fe955
48 changed files with 479 additions and 223 deletions

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.2.11.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss:jandex:2.0.3.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.0" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-c3p0:5.2.11.Final" level="project" />
<orderEntry type="library" name="Maven: com.mchange:c3p0:0.9.5.2" level="project" />
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:javax.servlet-api:3.0.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-orm:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:4.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:4.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:4.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:jstl:1.2" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.2.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-hibernate5:2.8.4" level="project" />
<orderEntry type="library" name="Maven: javax.transaction:jta:1.1" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20160810" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat:tomcat-jdbc:7.0.35" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat:tomcat-juli:7.0.35" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.google.code.gson:gson:2.8.2" level="project" />
<orderEntry type="library" name="Maven: org.postgresql:postgresql:9.4.1212" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:jcl-over-slf4j:1.7.12" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.12" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:slf4j-log4j12:1.7.12" level="project" />
<orderEntry type="library" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
<orderEntry type="library" name="Maven: net.minidev:json-smart:2.3" level="project" />
<orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
<orderEntry type="library" name="Maven: com.google.apis:google-api-services-oauth2:v2-rev75-1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.api-client:google-api-client:1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.oauth-client:google-oauth-client:1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava-jdk5:13.0" level="project" />
<orderEntry type="library" name="Maven: com.google.http-client:google-http-client-jackson2:1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.http-client:google-http-client:1.19.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.oauth-client:google-oauth-client-jetty:1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.oauth-client:google-oauth-client-java6:1.19.0" level="project" />
<orderEntry type="library" name="Maven: org.mortbay.jetty:jetty:6.1.26" level="project" />
<orderEntry type="library" name="Maven: org.mortbay.jetty:jetty-util:6.1.26" level="project" />
<orderEntry type="library" name="Maven: org.mortbay.jetty:servlet-api:2.5-20081211" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:23.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
</component>
</module>

View File

@ -6,7 +6,7 @@ import java.util.UUID;
import dao.Dao;
import entities.DataRepository;
import entities.responses.IDLabelPair;
import models.dataset.criteria.Criteria;
import models.criteria.Criteria;
public interface DataRepositoryDao extends Dao<DataRepository, UUID> {

View File

@ -13,9 +13,8 @@ import org.hibernate.query.Query;
import dao.JpaDao;
import entities.DataRepository;
import entities.Registry;
import entities.responses.IDLabelPair;
import models.dataset.criteria.Criteria;
import models.criteria.Criteria;
public class DataRepositoryDaoImpl extends JpaDao<DataRepository, UUID> implements DataRepositoryDao {

View File

@ -5,7 +5,9 @@ import java.util.UUID;
import dao.Dao;
import entities.Organisation;
import entities.Registry;
import entities.responses.IDLabelPair;
import models.criteria.Criteria;
public interface OrganisationDao extends Dao<Organisation, UUID> {
@ -13,4 +15,7 @@ public interface OrganisationDao extends Dao<Organisation, UUID> {
List<IDLabelPair> listAllIDsLabels();
List<Organisation> listBy(Criteria<Organisation> criteria);
}

View File

@ -5,7 +5,12 @@ import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import entities.Registry;
import models.criteria.Criteria;
import org.hibernate.query.Query;
import dao.JpaDao;
@ -38,5 +43,15 @@ public class OrganisationDaoImpl extends JpaDao<Organisation, UUID> implements O
}
@Override
public List<Organisation> listBy(Criteria<Organisation> criteria) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Organisation> criteriaQuery = criteriaBuilder .createQuery(Organisation.class);
Root<Organisation> root = criteriaQuery.from(Organisation.class);
criteriaQuery.where(criteriaBuilder.equal(root.get("reference"), criteria.getLike()));
TypedQuery<Organisation> typedQuery = entityManager.createQuery(criteriaQuery);
return typedQuery.getResultList();
}
}

View File

@ -4,11 +4,9 @@ import java.util.List;
import java.util.UUID;
import dao.Dao;
import entities.DataRepository;
import entities.Registry;
import entities.Researcher;
import entities.responses.IDLabelPair;
import models.dataset.criteria.Criteria;
import models.criteria.Criteria;
public interface RegistryDao extends Dao<Registry, UUID> {

View File

@ -12,11 +12,9 @@ import javax.persistence.criteria.Root;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.DataRepository;
import entities.Registry;
import entities.Researcher;
import entities.responses.IDLabelPair;
import models.dataset.criteria.Criteria;
import models.criteria.Criteria;
public class RegistryDaoImpl extends JpaDao<Registry, UUID> implements RegistryDao {

View File

@ -4,8 +4,10 @@ import java.util.List;
import java.util.UUID;
import dao.Dao;
import entities.Registry;
import entities.Researcher;
import entities.responses.IDLabelPair;
import models.criteria.Criteria;
public interface ResearcherDao extends Dao<Researcher, UUID> {
@ -15,4 +17,7 @@ public interface ResearcherDao extends Dao<Researcher, UUID> {
Researcher getResearcherByEmail(String email);
List<Researcher> listBy(Criteria<Researcher> criteria);
}

View File

@ -5,7 +5,12 @@ import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import entities.Registry;
import models.criteria.Criteria;
import org.hibernate.query.Query;
import dao.JpaDao;
@ -49,5 +54,15 @@ public class ResearcherDaoImpl extends JpaDao<Researcher, UUID> implements Resea
return null;
}
@Override
public List<Researcher> listBy(Criteria<Researcher> criteria) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Researcher> criteriaQuery = criteriaBuilder .createQuery(Researcher.class);
Root<Researcher> root = criteriaQuery.from(Researcher.class);
criteriaQuery.where(criteriaBuilder.equal(root.get("reference"), criteria.getLike()));
TypedQuery<Researcher> typedQuery = entityManager.createQuery(criteriaQuery);
return typedQuery.getResultList();
}
}

View File

@ -4,10 +4,9 @@ import java.util.List;
import java.util.UUID;
import dao.Dao;
import entities.DataRepository;
import entities.Service;
import entities.responses.IDLabelPair;
import models.dataset.criteria.Criteria;
import models.criteria.Criteria;
public interface ServiceDao extends Dao<Service, UUID> {

View File

@ -12,11 +12,9 @@ import javax.persistence.criteria.Root;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.DataRepository;
import entities.Registry;
import entities.Service;
import entities.responses.IDLabelPair;
import models.dataset.criteria.Criteria;
import models.criteria.Criteria;
public class ServiceDaoImpl extends JpaDao<Service, UUID> implements ServiceDao {

View File

@ -37,7 +37,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
@Entity
@Table(name="\"DMP\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope = DMP.class)
public class DMP implements Serializable {
public class DMP implements Serializable,DataEntity {
private static final long serialVersionUID = -8263056535208547615L;

View File

@ -0,0 +1,4 @@
package entities;
public interface DataEntity {
}

View File

@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
@Entity
@Table(name="\"DataRepository\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class DataRepository implements Serializable {
public class DataRepository implements Serializable,DataEntity {
private static final long serialVersionUID = 4162323701450468639L;

View File

@ -32,7 +32,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
@Entity
@Table(name="\"Dataset\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Dataset implements Serializable {
public class Dataset implements Serializable,DataEntity {
private static final long serialVersionUID = 3575723814399553259L;

View File

@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
@Entity
@Table(name="\"Organisation\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Organisation implements Serializable {
public class Organisation implements Serializable,DataEntity {
private static final long serialVersionUID = 3614146195740867782L;

View File

@ -35,7 +35,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
@Entity
@Table(name="\"Project\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Project implements Serializable {
public class Project implements Serializable,DataEntity {
private static final long serialVersionUID = -767048645098311154L;

View File

@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
@Entity
@Table(name="\"Registry\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Registry implements Serializable {
public class Registry implements Serializable,DataEntity {
private static final long serialVersionUID = -277572262583178090L;

View File

@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
@Entity
@Table(name="\"Researcher\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Researcher implements Serializable {
public class Researcher implements Serializable,DataEntity {
private static final long serialVersionUID = -2513186824704729896L;

View File

@ -32,7 +32,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
@Entity
@Table(name="\"Service\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Service implements Serializable {
public class Service implements Serializable,DataEntity {
private static final long serialVersionUID = 163279108676904730L;

View File

@ -0,0 +1,8 @@
package models;
import entities.DataEntity;
public interface DataModel<T extends DataEntity> {
void fromDataModel(T entity) throws InstantiationException, IllegalAccessException;
T toDataModel();
}

View File

@ -1,6 +1,8 @@
package models.dataset.criteria;
package models.criteria;
public abstract class Criteria<T> {
import entities.DataEntity;
public abstract class Criteria<T extends DataEntity> {
private String like;
public String getLike() {

View File

@ -1,4 +1,4 @@
package models.dataset.criteria;
package models.criteria;
import entities.DataRepository;

View File

@ -0,0 +1,6 @@
package models.criteria;
import entities.Organisation;
public class OrganisationCriteria extends Criteria<Organisation> {
}

View File

@ -1,4 +1,4 @@
package models.dataset.criteria;
package models.criteria;
import entities.Registry;

View File

@ -0,0 +1,6 @@
package models.criteria;
import entities.Researcher;
public class ResearcherCriteria extends Criteria<Researcher> {
}

View File

@ -1,4 +1,4 @@
package models.dataset.criteria;
package models.criteria;
import entities.Service;

View File

@ -1,8 +1,10 @@
package models.dataset;
import models.DataModel;
import java.util.Date;
public class DataRepository {
public class DataRepository implements DataModel<entities.DataRepository>{
private String pid;
private String name;
private String uri;

View File

@ -1,11 +1,13 @@
package models.dataset;
import models.DataModel;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
public class Dataset {
public class Dataset implements DataModel<entities.Dataset>{
private UUID id;
private String label;
private String reference;
@ -72,7 +74,7 @@ public class Dataset {
this.dataRepositories = dataRepositories;
}
public void fromDataModel(entities.DataRepository entity){
public void fromDataModel(entities.Dataset entity){
}

View File

@ -1,6 +1,8 @@
package models.dataset;
public class Registry {
import models.DataModel;
public class Registry implements DataModel<entities.Registry>{
public void fromDataModel(entities.Registry entity){

View File

@ -1,6 +1,8 @@
package models.dataset;
public class Service {
import models.DataModel;
public class Service implements DataModel<entities.Service>{
public void fromDataModel(entities.Service entity){
}

View File

@ -0,0 +1,110 @@
package models.dmp;
import com.sun.org.apache.regexp.internal.RE;
import entities.*;
import entities.Project;
import models.DataModel;
import utilities.builders.DomainModelConverter;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
public class DataManagementPlan implements DataModel<DMP>{
private UUID id;
private String label;
private UUID previous;
private int version;
private int status;
private models.dmp.Project project;
private List<Organisation> organizations;
private List<Researcher> researchers;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public UUID getPrevious() {
return previous;
}
public void setPrevious(UUID previous) {
this.previous = previous;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public List<Organisation> getOrganizations() {
return organizations;
}
public void setOrganizations(List<Organisation> organizations) {
this.organizations = organizations;
}
public List<Researcher> getResearchers() {
return researchers;
}
public void setResearchers(List<Researcher> researchers) {
this.researchers = researchers;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public models.dmp.Project getProject() {
return project;
}
public void setProject(models.dmp.Project project) {
this.project = project;
}
@Override
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
this.id = entity.getId();
this.organizations =new DomainModelConverter<entities.Organisation,Organisation>().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class);
this.researchers =new DomainModelConverter<entities.Researcher,Researcher>().fromDataModel(entity.getResearchers().stream().collect(Collectors.toList()),Researcher.class);
this.version = entity.getVersion();
this.previous = entity.getPrevious();
this.label = entity.getLabel();
this.project = new models.dmp.Project();
this.project.fromDataModel(entity.getProject());
}
@Override
public DMP toDataModel() {
DMP dataManagementPlanEntity = new DMP();
dataManagementPlanEntity.setId(this.id);
dataManagementPlanEntity.setOrganisations(new HashSet<entities.Organisation>(new DomainModelConverter<entities.Organisation,Organisation>().toDataModel(this.organizations)));
dataManagementPlanEntity.setResearchers(new HashSet<entities.Researcher>(new DomainModelConverter<entities.Researcher,Researcher>().toDataModel(this.researchers)));
dataManagementPlanEntity.setVersion(this.version);
dataManagementPlanEntity.setPrevious(this.previous);
dataManagementPlanEntity.setLabel(this.label);
return dataManagementPlanEntity;
}
}

View File

@ -0,0 +1,54 @@
package models.dmp;
import models.DataModel;
import java.util.Date;
public class Organisation implements DataModel<entities.Organisation> {
private String pid;
private String name;
private String uri;
private int status;
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
@Override
public void fromDataModel(entities.Organisation entity) {
this.pid = entity.getReference();
this.name = entity.getLabel();
this.uri = entity.getUri();
}
@Override
public entities.Organisation toDataModel() {
entities.Organisation organisationEntity = new entities.Organisation();
organisationEntity.setReference(this.pid);
organisationEntity.setLabel(this.name);
organisationEntity.setUri(this.uri);
organisationEntity.setCreated(new Date());
organisationEntity.setStatus((short)this.status);
return organisationEntity;
}
}

View File

@ -0,0 +1,29 @@
package models.dmp;
import models.DataModel;
import java.util.UUID;
public class Project implements DataModel<entities.Project>{
private UUID id;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
@Override
public void fromDataModel(entities.Project entity) {
this.id = entity.getId();
}
@Override
public entities.Project toDataModel() {
entities.Project project = new entities.Project();
project.setId(this.id);
return project;
}
}

View File

@ -0,0 +1,62 @@
package models.dmp;
import models.DataModel;
import java.util.Date;
public class Researcher implements DataModel<entities.Researcher> {
private String pid;
private String name;
private String uri;
private int status;
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
@Override
public void fromDataModel(entities.Researcher entity) {
this.pid = entity.getReference();
this.name = entity.getLabel();
this.status = entity.getStatus();
this.uri = entity.getUri();
}
@Override
public entities.Researcher toDataModel() {
entities.Researcher researcher = new entities.Researcher();
researcher.setReference(this.pid);
researcher.setLabel(this.name);
researcher.setCreated(new Date());
researcher.setStatus((short)this.status);
return researcher;
}
}

View File

@ -1,16 +1,16 @@
package rest.entities;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
import models.criteria.DataRepositoryCriteria;
import models.criteria.OrganisationCriteria;
import models.criteria.ResearcherCriteria;
import models.criteria.ServiceCriteria;
import models.dmp.DataManagementPlan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -20,16 +20,9 @@ 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.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;
import dao.entities.DMPDao;
import dao.entities.DMPProfileDao;
import dao.entities.DataRepositoryDao;
@ -44,16 +37,11 @@ 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;
import utilities.builders.DomainModelConverter;
@RestController
@ -94,7 +82,9 @@ public class DMPs {
public @ResponseBody ResponseEntity<Object> getDMP(@PathVariable("id") String id){
try {
DMP dmp = dMPDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(dmp));
DataManagementPlan dataManagementPlan = new DataManagementPlan();
dataManagementPlan.fromDataModel(dmp);
return ResponseEntity.status(HttpStatus.OK).body(dataManagementPlan);
}
catch(Exception ex) {
ex.printStackTrace();
@ -243,7 +233,7 @@ public class DMPs {
}
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/createofuser" }, produces="text/plain", consumes = "application/json")
public @ResponseBody ResponseEntity<Object> createDmpOfUser(@RequestBody DMP dmp){
public @ResponseBody ResponseEntity<Object> createDmpOfUser(@RequestBody DataManagementPlan dataManagementPlan){
String userID = null;
@ -259,11 +249,31 @@ public class DMPs {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There's no such a user on the system. You shouldn't be here");
try {
DMP dmp = dataManagementPlan.toDataModel();
if(dmp.getOrganisations()!=null&&!dmp.getOrganisations().isEmpty()){
for(entities.Organisation organisation: dmp.getOrganisations()){
OrganisationCriteria criteria = new OrganisationCriteria();
criteria.setLike(organisation.getReference());
List<entities.Organisation> entries = this.organisationDao.listBy(criteria);
if(entries!=null&&!entries.isEmpty())organisation.setId(entries.get(0).getId());
else organisation = this.organisationDao.create(organisation);
}
}
if(dmp.getResearchers()!=null&&!dmp.getResearchers().isEmpty()){
for(entities.Researcher researcher : dmp.getResearchers()){
ResearcherCriteria criteria = new ResearcherCriteria();
criteria.setLike(researcher.getReference());
List<entities.Researcher> entries = this.researcherDao.listBy(criteria);
if(entries!=null&&!entries.isEmpty())researcher.setId(entries.get(0).getId());
else researcher = this.researcherDao.create(researcher);
}
}
dmp.setId(null);
dmp.setCreator(userInfo);
dmp.setProject(this.projectDao.read(dataManagementPlan.getProject().getId()));
Set<UserInfo> users = new HashSet<UserInfo>();
users.add(userInfo);
dmp.setUsers(users);

View File

@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.google.gson.JsonObject;
import dao.entities.DatasetDao;
import dao.entities.DatasetProfileDao;

View File

@ -1,23 +1,13 @@
package rest.entities;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Date;
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;
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.security.core.context.SecurityContextHolder;
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;
@ -27,11 +17,6 @@ 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.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.entities.DMPDao;
import dao.entities.DMPProfileDao;
import dao.entities.DataRepositoryDao;
@ -46,20 +31,14 @@ 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.DatasetProfileViewstyle;
import entities.Organisation;
import entities.Project;
import entities.UserInfo;
import helpers.SafeCleanAttribs;
import helpers.SerializerProvider;
import helpers.Transformers;
import models.dataset.criteria.DataRepositoryCriteria;
import models.dataset.criteria.RegistryCriteria;
import models.dataset.criteria.ServiceCriteria;
import models.criteria.DataRepositoryCriteria;
import models.criteria.RegistryCriteria;
import models.criteria.ServiceCriteria;
import responses.RestResponse;

View File

@ -179,10 +179,10 @@ public class Projects {
p.setId(project.getId());
try {
projectDao.delete(p);
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted Project entity!\"}");
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted Researcher entity!\"}");
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete Project!\"}");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete Researcher!\"}");
}
}
@ -199,7 +199,7 @@ public class Projects {
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted project!\"}");
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete Project!\"}");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete Researcher!\"}");
}
}
@ -212,7 +212,7 @@ public class Projects {
Set<DMP> dmps = projectDao.read(project.getId()).getDmps();
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(dmps));
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create Project!\"}");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create Researcher!\"}");
}
}
@ -250,10 +250,10 @@ public class Projects {
/*
* OLD ONE
Map<UUID, Project> userProjects = new HashMap<UUID, Project>();
Map<UUID, Researcher> userProjects = new HashMap<UUID, Researcher>();
userInfo.getDmps().forEach( dmp -> {
Project proj = dmp.getProject();
Researcher proj = dmp.getProject();
userProjects.put(proj.getId(), proj);
});
@ -320,7 +320,7 @@ public class Projects {
// @Transactional
// @RequestMapping(method = RequestMethod.POST, value = { "/project/updateofuser" }, produces="text/plain")
// public @ResponseBody ResponseEntity<Object> updateProjectOfUser(@RequestBody Project project){
// public @ResponseBody ResponseEntity<Object> updateProjectOfUser(@RequestBody Researcher project){
//
// if(project.getId()==null)
// return ResponseEntity.status(HttpStatus.NOT_MODIFIED).body("Cannot update, id was null");

View File

@ -0,0 +1,28 @@
package utilities.builders;
import entities.DataEntity;
import models.DataModel;
import java.util.LinkedList;
import java.util.List;
public class DomainModelConverter<T extends DataEntity,U extends DataModel<T>> {
public List<T> toDataModel(List<U> models){
List<T> entities = new LinkedList<>();
for(U model : models){
entities.add(model.toDataModel());
}
return entities;
}
public List<U> fromDataModel(List<T> entities,Class<U> clazz) throws IllegalAccessException, InstantiationException {
List<U> models = new LinkedList<>();
for(T entity:entities){
U model = clazz.newInstance();
model.fromDataModel(entity);
models.add(model);
}
return models;
}
}

View File

@ -190,9 +190,12 @@ export class DmpComponent implements OnInit {
editDmp(item) {
this.dmp = Object.assign({}, item);
this.dmp.project = item.project.id;
this.serverService.getDmp(item.id).subscribe(result=>{
this.dmp = result;
this.dmp.project = result.project.id
$("#newDmpModal").modal("show");
})
}
cloneDmp(item) {

View File

@ -1,8 +1,8 @@
import { PaginationService } from './pagination/pagination-service';
import { VisibilityRulesService } from '../visibility-rules/visibility-rules.service';
import { VisibilityRulesService } from '../visibility-rules/visibility-rules.service';
import { TestModel } from '../testModel/testmodel';
import { DatasetModel } from '../models/DatasetModel';
import { Rule } from '../models/Rule';
import { Section } from '../models/Section';
import { JsonSerializer } from '../utilities/JsonSerializer';
import { Component, Input, OnInit, AfterViewChecked, ViewChild, forwardRef, ViewEncapsulation } from '@angular/core';
@ -67,12 +67,12 @@ export class DynamicFormComponent implements OnInit {
visibleSidebar: boolean = false;
private progressbar: boolean = false;
private currentPage: number;
private fragment: string;
constructor(private serverService: ServerService, private router: Router, private pdfService: PDFService,
private _location: Location, private route: ActivatedRoute, private tokenService: TokenService
, private visibilityRulesService: VisibilityRulesService
, private paginationService:PaginationService
) {
this.datasetId = route.snapshot.params['id'];
}
@ -88,12 +88,25 @@ export class DynamicFormComponent implements OnInit {
response => {
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel);
this.pages = this.getPages(this.dataModel);
this.createPagination();
//this.createPagination();
this.form = this.dataModel.buildForm();
this.visibilityRulesService.formGroup = this.form;
let rules: Rule[] = new JsonSerializer<Rule>().fromJSONArray(response.rules, Rule);
this.visibilityRulesService.buildVisibilityRules(rules)
this.progressbar = true;
this.route.fragment.subscribe((fragment: string) => {
if (fragment && document.querySelector('#' + fragment)) {
document.querySelector('#' + fragment).scrollIntoView();
this.visibleSidebar = true;
}
});
this.route.queryParams.subscribe((params) => {
if (params && "page" in params && !isNaN(params["page"]))
this.currentPage = Number.parseInt(params["page"]);
//this.visibleSidebar = true;
});
},
error => {
console.log("Could not load dmp");
@ -127,16 +140,19 @@ export class DynamicFormComponent implements OnInit {
return pageSet;
}
createPagination() {
this.pages.forEach(item => {
this.stepperItems.push({
label: '',
command: (event: any) => {
this.paginationService.setCurrentIndex(event.index)
}
})
})
shouldDisplaySection(section: Section): Boolean {
return section.page == this.currentPage;
}
//createPagination() {
// this.pages.forEach(item => {
// this.stepperItems.push({
// label: '',
// command: (event: any) => {
// this.paginationService.setCurrentIndex(event.index)
// }
// })
// })
//}
/* scrollToElemID(elemID) {
scroll("#" + elemID);
}

View File

@ -1,18 +1,10 @@
import { PaginationService } from '../pagination/pagination-service';
import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router';
import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router';
export class BaseTableOfContent {
constructor(public router: Router, public route: ActivatedRoute, public paginationService: PaginationService) {
this.route.fragment.subscribe((fragment: string) => {
setTimeout(function() {
if (fragment) document.querySelector('#' + fragment).scrollIntoView();
}, );
})
}
constructor(public router: Router, public route: ActivatedRoute) { }
scrollToId(elementId, page: number) {
this.paginationService.setCurrentIndex(page-1);
this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { fragment: elementId });
//this.paginationService.setCurrentIndex(page-1);
this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { fragment: elementId, queryParams: { page: page } });
}
}

View File

@ -1,5 +1,4 @@
import { PaginationService } from '../../pagination/pagination-service';
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
import { BaseTableOfContent } from '../base-table-of-content.component';
import { CompositeField } from '../../../models/CompositeField';
import { Field } from '../../../models/Field';
@ -18,7 +17,7 @@ export class TableOfContentsFieldComponent extends BaseTableOfContent{
@Input() index:number;
@Input() public path:string;
@Input() public page: number;
constructor(public router: Router, public route: ActivatedRoute,private visibilityRulesService: VisibilityRulesService,public paginationService:PaginationService) {
super(router, route,paginationService)
constructor(public router: Router, public route: ActivatedRoute,private visibilityRulesService: VisibilityRulesService) {
super(router, route)
}
}

View File

@ -1,5 +1,4 @@
import { PaginationService } from '../../pagination/pagination-service';
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
import { BaseTableOfContent } from '../base-table-of-content.component';
import { CompositeField } from '../../../models/CompositeField';
import { FieldGroup } from '../../../models/FieldGroup';
@ -21,7 +20,7 @@ export class TableOfContentsFieldSetComponent extends BaseTableOfContent {
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
constructor(public router: Router, public route: ActivatedRoute,private visibilityRulesService: VisibilityRulesService,public paginationService:PaginationService) {
super(router, route,paginationService)
constructor(public router: Router, public route: ActivatedRoute,private visibilityRulesService: VisibilityRulesService) {
super(router, route)
}
}

View File

@ -1,5 +1,4 @@
import { PaginationService } from '../../pagination/pagination-service';
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
import { BaseTableOfContent } from '../base-table-of-content.component';
import { FieldGroup } from '../../../models/FieldGroup';
import { Section } from '../../../models/Section';
@ -23,8 +22,8 @@ export class TableOfContentsGroupComponent extends BaseTableOfContent {
setPage:EventEmitter<number> = new EventEmitter<number>();
*/
constructor(public router: Router, public route: ActivatedRoute,private visibilityRulesService: VisibilityRulesService,public paginationService:PaginationService) {
super(router, route,paginationService)
constructor(public router: Router, public route: ActivatedRoute,private visibilityRulesService: VisibilityRulesService) {
super(router, route)
}

View File

@ -1,5 +1,4 @@
import { PaginationService } from '../../pagination/pagination-service';
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
import { BaseTableOfContent } from '../base-table-of-content.component';
import { Section } from '../../../models/Section';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
@ -19,8 +18,8 @@ export class TableOfContentsSectionComponent extends BaseTableOfContent implemen
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
constructor(public router: Router,public route:ActivatedRoute,private visibilityRulesService: VisibilityRulesService,public paginationService:PaginationService){
super(router,route,paginationService)
constructor(public router: Router,public route:ActivatedRoute,private visibilityRulesService: VisibilityRulesService){
super(router,route)
}
ngOnInit() {

View File

@ -18,7 +18,7 @@ export class RestBase {
protocol: string = "http";
hostname: string ="192.168.32.103"
hostname: string ="localhost"
port: number = 8080;
webappname: string = "dmp-backend";