Merge remote-tracking branch 'origin/refactorArgosModel' into Development

# Conflicts:
#	dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java
#	dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html
This commit is contained in:
Diamantis Tziotzios 2023-09-13 10:01:57 +03:00
commit cf6e041154
166 changed files with 6084 additions and 652 deletions

View File

@ -0,0 +1,6 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DMPProfile;
public class DataManagementPlanBlueprintCriteria extends Criteria<DMPProfile> {
}

View File

@ -1,13 +1,13 @@
package eu.eudat.data.dao.criteria; package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public class DatasetProfileCriteria extends Criteria<DatasetProfile> { public class DatasetProfileCriteria extends Criteria<DescriptionTemplate> {
public enum DatasetProfileFilter { public enum DatasetProfileFilter {
DMPs((short) 0), Datasets((short) 1); DMPs((short) 0), Datasets((short) 1);
@ -25,7 +25,7 @@ public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
case 1: case 1:
return Datasets; return Datasets;
default: default:
throw new RuntimeException("Unsupported DatasetProfile filter"); throw new RuntimeException("Unsupported DescriptionTemplate filter");
} }
} }
} }

View File

@ -1,11 +1,11 @@
package eu.eudat.data.dao.criteria; package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import java.util.UUID; import java.util.UUID;
public class DatasetProfileWizardCriteria extends Criteria<DatasetProfile> { public class DatasetProfileWizardCriteria extends Criteria<DescriptionTemplate> {
private UUID id; private UUID id;
public UUID getId() { public UUID getId() {

View File

@ -1,6 +1,7 @@
package eu.eudat.data.dao.entities; package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer; import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria; import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.DMPProfile; import eu.eudat.data.entities.DMPProfile;
@ -15,4 +16,6 @@ public interface DMPProfileDao extends DatabaseAccessLayer<DMPProfile, UUID> {
QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria); QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria);
QueryableList<DMPProfile> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria);
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.data.dao.entities; package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess; import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria; import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMPProfile; import eu.eudat.data.entities.DMPProfile;
@ -65,4 +66,13 @@ public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMP
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue()))); query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
return query; return query;
} }
@Override
public QueryableList<DMPProfile> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria){
QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
return query;
}
} }

View File

@ -3,7 +3,6 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess; import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DatasetExternalDataset; import eu.eudat.data.entities.DatasetExternalDataset;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;

View File

@ -2,20 +2,23 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer; import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria; import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public interface DatasetProfileDao extends DatabaseAccessLayer<DatasetProfile, UUID> { public interface DatasetProfileDao extends DatabaseAccessLayer<DescriptionTemplate, UUID> {
QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria); QueryableList<DescriptionTemplate> getWithCriteria(DatasetProfileCriteria criteria);
QueryableList<DatasetProfile> getAll(); QueryableList<DescriptionTemplate> getAll();
QueryableList<DatasetProfile> getAuthenticated(QueryableList<DatasetProfile> query, UUID principal, List<Integer> roles); QueryableList<DescriptionTemplate> getAuthenticated(QueryableList<DescriptionTemplate> query, UUID principal, List<Integer> roles);
List<DatasetProfile> getAllIds(); List<DescriptionTemplate> getAllIds();
Long countWithType(DescriptionTemplateType type);
} }

View File

@ -3,8 +3,8 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess; import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria; import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType; import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField; import eu.eudat.queryable.types.SelectionField;
@ -21,16 +21,16 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@Component("datasetProfileDao") @Component("datasetProfileDao")
public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implements DatasetProfileDao { public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> implements DatasetProfileDao {
@Autowired @Autowired
public DatasetProfileDaoImpl(DatabaseService<DatasetProfile> databaseService) { public DatasetProfileDaoImpl(DatabaseService<DescriptionTemplate> databaseService) {
super(databaseService); super(databaseService);
} }
@Override @Override
public QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria) { public QueryableList<DescriptionTemplate> getWithCriteria(DatasetProfileCriteria criteria) {
QueryableList<DatasetProfile> query = getDatabaseService().getQueryable(DatasetProfile.class); QueryableList<DescriptionTemplate> query = getDatabaseService().getQueryable(DescriptionTemplate.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
if (!criteria.getAllVersions()) if (!criteria.getAllVersions())
@ -63,9 +63,9 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
query.where(((builder, root) -> root.get("id").in(criteria.getIds()))); query.where(((builder, root) -> root.get("id").in(criteria.getIds())));
} }
if (criteria.getFinalized()) { if (criteria.getFinalized()) {
query.where(((builder, root) -> builder.equal(root.get("status"), DatasetProfile.Status.FINALIZED.getValue()))); query.where(((builder, root) -> builder.equal(root.get("status"), DescriptionTemplate.Status.FINALIZED.getValue())));
} else { } else {
query.where(((builder, root) -> builder.notEqual(root.get("status"), DatasetProfile.Status.DELETED.getValue()))); query.where(((builder, root) -> builder.notEqual(root.get("status"), DescriptionTemplate.Status.DELETED.getValue())));
} }
if (criteria.getPeriodStart() != null) if (criteria.getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart())); query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
@ -73,48 +73,48 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
} }
@Override @Override
public DatasetProfile createOrUpdate(DatasetProfile item) { public DescriptionTemplate createOrUpdate(DescriptionTemplate item) {
return this.getDatabaseService().createOrUpdate(item, DatasetProfile.class); return this.getDatabaseService().createOrUpdate(item, DescriptionTemplate.class);
} }
@Override @Override
public DatasetProfile find(UUID id) { public DescriptionTemplate find(UUID id) {
return getDatabaseService().getQueryable(DatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle(); return getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
} }
@Override @Override
public QueryableList<DatasetProfile> getAll() { public QueryableList<DescriptionTemplate> getAll() {
return getDatabaseService().getQueryable(DatasetProfile.class); return getDatabaseService().getQueryable(DescriptionTemplate.class);
} }
@Override @Override
public List<DatasetProfile> getAllIds(){ public List<DescriptionTemplate> getAllIds(){
return getDatabaseService().getQueryable(DatasetProfile.class).withFields(Collections.singletonList("id")).toList(); return getDatabaseService().getQueryable(DescriptionTemplate.class).withFields(Collections.singletonList("id")).toList();
} }
@Override @Override
public void delete(DatasetProfile item) { public void delete(DescriptionTemplate item) {
this.getDatabaseService().delete(item); this.getDatabaseService().delete(item);
} }
@Override @Override
public QueryableList<DatasetProfile> asQueryable() { public QueryableList<DescriptionTemplate> asQueryable() {
return this.getDatabaseService().getQueryable(DatasetProfile.class); return this.getDatabaseService().getQueryable(DescriptionTemplate.class);
} }
@Async @Async
@Override @Override
public CompletableFuture<DatasetProfile> createOrUpdateAsync(DatasetProfile item) { public CompletableFuture<DescriptionTemplate> createOrUpdateAsync(DescriptionTemplate item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }
@Override @Override
public DatasetProfile find(UUID id, String hint) { public DescriptionTemplate find(UUID id, String hint) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public QueryableList<DatasetProfile> getAuthenticated(QueryableList<DatasetProfile> query, UUID principal, List<Integer> roles) { public QueryableList<DescriptionTemplate> getAuthenticated(QueryableList<DescriptionTemplate> query, UUID principal, List<Integer> roles) {
if (roles != null && !roles.isEmpty()) { if (roles != null && !roles.isEmpty()) {
query.where((builder, root) -> { query.where((builder, root) -> {
Join userJoin = root.join("users", JoinType.LEFT); Join userJoin = root.join("users", JoinType.LEFT);
@ -126,4 +126,9 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
return query; return query;
} }
@Override
public Long countWithType(DescriptionTemplateType type) {
return this.getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("type"), type)).count();
}
} }

View File

@ -1,7 +1,6 @@
package eu.eudat.data.dao.entities; package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer; import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DatasetService; import eu.eudat.data.entities.DatasetService;
import java.util.UUID; import java.util.UUID;

View File

@ -2,8 +2,6 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess; import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DatasetExternalDataset;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DatasetService; import eu.eudat.data.entities.DatasetService;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@ -0,0 +1,10 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DescriptionTemplateType;
import java.util.UUID;
public interface DescriptionTemplateTypeDao extends DatabaseAccessLayer<DescriptionTemplateType, UUID> {
DescriptionTemplateType findFromName(String name);
}

View File

@ -0,0 +1,65 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("descriptionTemplateTypeDao")
public class DescriptionTemplateTypeDaoImpl extends DatabaseAccess<DescriptionTemplateType> implements DescriptionTemplateTypeDao {
@Autowired
public DescriptionTemplateTypeDaoImpl(DatabaseService<DescriptionTemplateType> databaseService) {
super(databaseService);
}
@Override
public DescriptionTemplateType findFromName(String name){
try {
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal(root.get("name"), name)).getSingle();
}
catch(Exception e){
return null;
}
}
@Override
@Transactional
public DescriptionTemplateType createOrUpdate(DescriptionTemplateType item) {
return this.getDatabaseService().createOrUpdate(item, DescriptionTemplateType.class);
}
@Override
public DescriptionTemplateType find(UUID id) {
return getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
}
@Override
public void delete(DescriptionTemplateType item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DescriptionTemplateType> asQueryable() {
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.notEqual((root.get("status")), DescriptionTemplateType.Status.DELETED.getValue()));
}
@Async
@Override
public CompletableFuture<DescriptionTemplateType> createOrUpdateAsync(DescriptionTemplateType item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DescriptionTemplateType find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,9 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DMPDatasetProfile;
import java.util.UUID;
public interface DmpDatasetProfileDao extends DatabaseAccessLayer<DMPDatasetProfile, UUID> {
}

View File

@ -0,0 +1,52 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Content;
import eu.eudat.data.entities.DMPDatasetProfile;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Service("dmpDatasetProfileDao")
public class DmpDatasetProfileDaoImpl extends DatabaseAccess<DMPDatasetProfile> implements DmpDatasetProfileDao {
@Autowired
public DmpDatasetProfileDaoImpl(DatabaseService<DMPDatasetProfile> databaseService) {
super(databaseService);
}
@Override
public DMPDatasetProfile createOrUpdate(DMPDatasetProfile item) {
return this.getDatabaseService().createOrUpdate(item, DMPDatasetProfile.class);
}
@Override
@Async
public CompletableFuture<DMPDatasetProfile> createOrUpdateAsync(DMPDatasetProfile item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DMPDatasetProfile find(UUID id) {
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public DMPDatasetProfile find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(DMPDatasetProfile item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DMPDatasetProfile> asQueryable() {
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class);
}
}

View File

@ -112,12 +112,8 @@ public class DMP implements DataEntity<DMP, UUID> {
/*@Type(type = "eu.eudat.configurations.typedefinition.XMLType") /*@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true) @Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
private String associatedDmps;*/ private String associatedDmps;*/
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY, mappedBy = "dmp")
@JoinTable(name = "\"DMPDatasetProfile\"", private Set<DMPDatasetProfile> associatedDmps;
joinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")}
)
private Set<DatasetProfile> associatedDmps;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@ -274,10 +270,10 @@ public class DMP implements DataEntity<DMP, UUID> {
this.grant = grant; this.grant = grant;
} }
public Set<DatasetProfile> getAssociatedDmps() { public Set<DMPDatasetProfile> getAssociatedDmps() {
return associatedDmps; return associatedDmps;
} }
public void setAssociatedDmps(Set<DatasetProfile> associatedDmps) { public void setAssociatedDmps(Set<DMPDatasetProfile> associatedDmps) {
this.associatedDmps = associatedDmps; this.associatedDmps = associatedDmps;
} }

View File

@ -0,0 +1,76 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"DMPDatasetProfile\"")
public class DMPDatasetProfile implements DataEntity<DMPDatasetProfile, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@ManyToOne
@JoinColumn(name = "\"dmp\"")
private DMP dmp;
@ManyToOne
@JoinColumn(name = "\"datasetprofile\"")
private DescriptionTemplate datasetprofile;
@Column(name = "\"data\"")
private String data;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public DMP getDmp() {
return dmp;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public DescriptionTemplate getDatasetprofile() {
return datasetprofile;
}
public void setDatasetprofile(DescriptionTemplate datasetprofile) {
this.datasetprofile = datasetprofile;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
@Override
public void update(DMPDatasetProfile entity) {
this.dmp = entity.getDmp();
this.datasetprofile = entity.getDatasetprofile();
this.data = entity.getData();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DMPDatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
}

View File

@ -100,6 +100,9 @@ public class Dataset implements DataEntity<Dataset, UUID> {
@JoinColumn(name = "\"DMP\"", nullable = false) @JoinColumn(name = "\"DMP\"", nullable = false)
private DMP dmp; private DMP dmp;
@Column(name = "\"DmpSectionIndex\"")
private Integer dmpSectionIndex;
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@ -110,7 +113,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL) //@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"Profile\"") @JoinColumn(name = "\"Profile\"")
private DatasetProfile profile; private DescriptionTemplate profile;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml") @Column(name = "\"Reference\"", columnDefinition = "xml")
@ -232,6 +235,12 @@ public class Dataset implements DataEntity<Dataset, UUID> {
this.dmp = dmp; this.dmp = dmp;
} }
public Integer getDmpSectionIndex() {
return dmpSectionIndex;
}
public void setDmpSectionIndex(Integer dmpSectionIndex) {
this.dmpSectionIndex = dmpSectionIndex;
}
public String getUri() { public String getUri() {
return uri; return uri;
@ -249,10 +258,10 @@ public class Dataset implements DataEntity<Dataset, UUID> {
} }
public DatasetProfile getProfile() { public DescriptionTemplate getProfile() {
return profile; return profile;
} }
public void setProfile(DatasetProfile profile) { public void setProfile(DescriptionTemplate profile) {
this.profile = profile; this.profile = profile;
} }
@ -328,6 +337,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
this.setRegistries(entity.getRegistries()); this.setRegistries(entity.getRegistries());
this.setDmp(entity.getDmp()); this.setDmp(entity.getDmp());
this.setDmpSectionIndex(entity.getDmpSectionIndex());
this.setStatus(entity.getStatus()); this.setStatus(entity.getStatus());
this.setProfile(entity.getProfile()); this.setProfile(entity.getProfile());
this.setModified(new Date()); this.setModified(new Date());

View File

@ -14,8 +14,8 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"DatasetProfile\"") @Table(name = "\"DescriptionTemplate\"")
public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{ public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>{
public enum Status { public enum Status {
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99); SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
@ -79,19 +79,21 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
@Column(name = "\"Version\"", nullable = false) @Column(name = "\"Version\"", nullable = false)
private Short version; private Short version;
@ManyToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPDatasetProfile\"", private Set<DMP> dmps;
joinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")}
)
private List<DMP> dmps;
@Column(name = "\"Language\"", nullable = false) @Column(name = "\"Language\"", nullable = false)
private String language; private String language;
@OneToMany(mappedBy = "datasetProfile", fetch = FetchType.LAZY) @OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Type\"", nullable = false)
private DescriptionTemplateType type;
@OneToMany(mappedBy = "descriptionTemplate", fetch = FetchType.LAZY)
private Set<UserDatasetProfile> users; private Set<UserDatasetProfile> users;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "datasetprofile")
private Set<DMPDatasetProfile> associatedDmps;
public String getDescription() { public String getDescription() {
return description; return description;
@ -156,26 +158,31 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
public String getLanguage() { public String getLanguage() {
return language; return language;
} }
public void setLanguage(String language) { public void setLanguage(String language) {
this.language = language; this.language = language;
} }
public DescriptionTemplateType getType() {
return type;
}
public void setType(DescriptionTemplateType type) {
this.type = type;
}
public Set<UserDatasetProfile> getUsers() { public Set<UserDatasetProfile> getUsers() {
return users; return users;
} }
public void setUsers(Set<UserDatasetProfile> users) { public void setUsers(Set<UserDatasetProfile> users) {
this.users = users; this.users = users;
} }
@Override @Override
public String toString() { public String toString() {
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + ", language=" + language + "]"; return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + ", language=" + language + ", type=" + type +"]";
} }
@Override @Override
public void update(DatasetProfile entity) { public void update(DescriptionTemplate entity) {
} }
@Override @Override
@ -184,7 +191,7 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
} }
@Override @Override
public DatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) { public DescriptionTemplate buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id")); this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this; return this;
} }

View File

@ -0,0 +1,89 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"DescriptionTemplateType\"")
public class DescriptionTemplateType implements DataEntity<DescriptionTemplateType, UUID> {
public enum Status {
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALIZED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Description Template Type Status");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Name\"", nullable = false)
private String name;
@Column(name = "\"Status\"", nullable = false)
private Short status;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
@Override
public void update(DescriptionTemplateType entity) {
this.name = entity.name;
this.status = entity.status;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DescriptionTemplateType buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(!base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
}

View File

@ -22,8 +22,8 @@ public class UserDatasetProfile implements DataEntity<UserDatasetProfile, UUID>
private UserInfo user; private UserInfo user;
@OneToOne(fetch = FetchType.LAZY) @OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"datasetProfile\"") @JoinColumn(name = "\"descriptionTemplate\"")
private DatasetProfile datasetProfile; private DescriptionTemplate descriptionTemplate;
@Column(name = "role") @Column(name = "role")
private Integer role; private Integer role;
@ -44,12 +44,12 @@ public class UserDatasetProfile implements DataEntity<UserDatasetProfile, UUID>
this.user = user; this.user = user;
} }
public DatasetProfile getDatasetProfile() { public DescriptionTemplate getDatasetProfile() {
return datasetProfile; return descriptionTemplate;
} }
public void setDatasetProfile(DatasetProfile datasetProfile) { public void setDatasetProfile(DescriptionTemplate descriptionTemplate) {
this.datasetProfile = datasetProfile; this.descriptionTemplate = descriptionTemplate;
} }
public Integer getRole() { public Integer getRole() {

View File

@ -0,0 +1,25 @@
package eu.eudat.data.query.items.dmpblueprint;
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class DataManagementPlanBlueprintTableRequest extends TableQuery<DataManagementPlanBlueprintCriteria, DMPProfile, UUID> {
@Override
public QueryableList<DMPProfile> applyCriteria() {
QueryableList<DMPProfile> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
return query;
}
@Override
public QueryableList<DMPProfile> applyPaging(QueryableList<DMPProfile> items) {
return PaginationService.applyPaging(items, this);
}
}

View File

@ -1,25 +1,24 @@
package eu.eudat.data.query.items.item.datasetprofile; package eu.eudat.data.query.items.item.datasetprofile;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria; import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.PaginationService; import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.Query;
import eu.eudat.data.query.definition.TableQuery; import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import java.util.UUID; import java.util.UUID;
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria,DatasetProfile, UUID> { public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
@Override @Override
public QueryableList<DatasetProfile> applyCriteria() { public QueryableList<DescriptionTemplate> applyCriteria() {
QueryableList<DatasetProfile> query = this.getQuery(); QueryableList<DescriptionTemplate> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
return query; return query;
} }
@Override @Override
public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) { public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
return PaginationService.applyPaging(items, this); return PaginationService.applyPaging(items, this);
} }
} }

View File

@ -1,15 +1,13 @@
package eu.eudat.data.query.items.item.datasetprofile; package eu.eudat.data.query.items.item.datasetprofile;
import eu.eudat.data.dao.criteria.DatasetProfileWizardCriteria; import eu.eudat.data.dao.criteria.DatasetProfileWizardCriteria;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.definition.Query; import eu.eudat.data.query.definition.Query;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import java.util.UUID; public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria, DescriptionTemplate> {
public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria,DatasetProfile> {
@Override @Override
public QueryableList<DatasetProfile> applyCriteria() { public QueryableList<DescriptionTemplate> applyCriteria() {
return null; return null;
} }
} }

View File

@ -1,23 +1,23 @@
package eu.eudat.data.query.items.table.datasetprofile; package eu.eudat.data.query.items.table.datasetprofile;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria; import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.definition.TableQuery; import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import java.util.UUID; import java.util.UUID;
public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DatasetProfile, UUID> { public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
@Override @Override
public QueryableList<DatasetProfile> applyCriteria() { public QueryableList<DescriptionTemplate> applyCriteria() {
QueryableList<DatasetProfile> query = this.getQuery(); QueryableList<DescriptionTemplate> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
return query; return query;
} }
@Override @Override
public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) { public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
return null; return null;
} }
} }

View File

@ -1,14 +1,18 @@
package eu.eudat.elastic.entities; package eu.eudat.elastic.entities;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class DatasetTempalate implements ElasticEntity<DatasetTempalate> { public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
private UUID id; private UUID id;
private String name; private String name;
private Map<String, Object> data;
public UUID getId() { public UUID getId() {
return id; return id;
@ -26,11 +30,25 @@ public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
this.name = name; this.name = name;
} }
public Map<String, Object> getData() {
return data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
@Override @Override
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException { public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
builder.startObject(); builder.startObject();
builder.field("id", this.id.toString()); builder.field("id", this.id.toString());
builder.field("name", this.name); builder.field("name", this.name);
if(this.data != null) {
builder.field("data", new ObjectMapper().writeValueAsString(this.data));
}
else{
builder.field("data", "");
}
builder.endObject(); builder.endObject();
return builder; return builder;
} }
@ -39,6 +57,12 @@ public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
public DatasetTempalate fromElasticEntity(Map<String, Object> fields) { public DatasetTempalate fromElasticEntity(Map<String, Object> fields) {
this.id = UUID.fromString((String) fields.get("id")); this.id = UUID.fromString((String) fields.get("id"));
this.name = (String) fields.get("name"); this.name = (String) fields.get("name");
try {
this.data = new ObjectMapper().readValue((String) fields.get("data"), new TypeReference<Map<String, Object>>() {});
}
catch (Exception e){
this.data = new HashMap<>();
}
return this; return this;
} }
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.UserDatasetProfile; import eu.eudat.data.entities.UserDatasetProfile;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
@ -16,7 +17,6 @@ import eu.eudat.models.data.admin.composite.DatasetProfile;
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
@ -32,7 +32,6 @@ import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
import static eu.eudat.types.Authorities.ADMIN; import static eu.eudat.types.Authorities.ADMIN;
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER; import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
@ -61,20 +60,21 @@ public class Admin extends BaseController {
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN ,DATASET_PROFILE_MANAGER}) Principal principal) { public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN ,DATASET_PROFILE_MANAGER}) Principal principal) {
//this.getLoggerService().info(principal, "Admin Added Dataset Profile"); //this.getLoggerService().info(principal, "Admin Added Dataset Profile");
DatasetProfile shortenProfile = profile.toShort(); DatasetProfile shortenProfile = profile.toShort();
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext()); DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
modelDefinition.setType(getApiContext().getOperationsContext().getDatabaseRepository().getDescriptionTemplateTypeDao().findFromName(profile.getType()));
modelDefinition.setGroupId(UUID.randomUUID()); modelDefinition.setGroupId(UUID.randomUUID());
modelDefinition.setVersion((short) 0); modelDefinition.setVersion((short) 0);
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition); DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
UserDatasetProfile userDatasetProfile = new UserDatasetProfile(); UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
userDatasetProfile.setDatasetProfile(datasetProfile); userDatasetProfile.setDatasetProfile(descriptionTemplate);
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
userDatasetProfile.setUser(userInfo); userDatasetProfile.setUser(userInfo);
userDatasetProfile.setRole(0); userDatasetProfile.setRole(0);
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile); getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile); datasetProfileManager.storeDatasetProfileUsers(descriptionTemplate, profile);
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricsManager.datasetTemplateStatus.get(datasetProfile.getStatus()) ); metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricsManager.datasetTemplateStatus.get(descriptionTemplate.getStatus()) );
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId()); return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
} }
@ -82,17 +82,17 @@ public class Admin extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) { public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
DatasetProfile shortenProfile = profile.toShort(); DatasetProfile shortenProfile = profile.toShort();
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext()); DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); DescriptionTemplate datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
datasetprofile.setDefinition(modelDefinition.getDefinition()); datasetprofile.setDefinition(modelDefinition.getDefinition());
Short oldStatus = datasetprofile.getStatus(); Short oldStatus = datasetprofile.getStatus();
datasetprofile.setStatus(modelDefinition.getStatus()); datasetprofile.setStatus(modelDefinition.getStatus());
datasetprofile.setLabel(modelDefinition.getLabel()); datasetprofile.setLabel(modelDefinition.getLabel());
datasetprofile.setDescription(modelDefinition.getDescription()); datasetprofile.setDescription(modelDefinition.getDescription());
datasetprofile.setLanguage(modelDefinition.getLanguage()); datasetprofile.setLanguage(modelDefinition.getLanguage());
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile); DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile); datasetProfileManager.storeDatasetProfileUsers(descriptionTemplate, profile);
if (datasetProfile.getStatus() == 1 && oldStatus == 0) { if (descriptionTemplate.getStatus() == 1 && oldStatus == 0) {
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricNames.ACTIVE); metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricNames.ACTIVE);
} }
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
@ -102,7 +102,7 @@ public class Admin extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/newVersion/{id}"}, produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/newVersion/{id}"}, produces = "application/json")
public ResponseEntity newVersionDatasetProfile(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception { public ResponseEntity newVersionDatasetProfile(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
try { try {
eu.eudat.data.entities.DatasetProfile modelDefinition = this.datasetProfileManager.createNewVersionDatasetProfile(id, profile); DescriptionTemplate modelDefinition = this.datasetProfileManager.createNewVersionDatasetProfile(id, profile);
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId()); return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
} catch (DatasetProfileNewVersionException exception) { } catch (DatasetProfileNewVersionException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
@ -125,7 +125,7 @@ public class Admin extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) { public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext()); DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(modelDefinition); eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(modelDefinition);
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile(); PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
pagedDatasetProfile.buildPagedDatasetProfile(datasetProfile); pagedDatasetProfile.buildPagedDatasetProfile(datasetProfile);
@ -145,7 +145,7 @@ public class Admin extends BaseController {
public @ResponseBody public @ResponseBody
ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) { ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
try { try {
eu.eudat.data.entities.DatasetProfile ret = AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id); DescriptionTemplate ret = AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.SUCCESS_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (DatasetProfileWithDatasetsExeption exception) { } catch (DatasetProfileWithDatasetsExeption exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage()));
@ -156,7 +156,7 @@ public class Admin extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json") @RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
public ResponseEntity getDatasetProfileXml(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws IllegalAccessException, IOException, InstantiationException { public ResponseEntity getDatasetProfileXml(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
if (contentType.equals("application/xml")) { if (contentType.equals("application/xml")) {
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); DescriptionTemplate profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(profile); eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(profile);
datasetProfile.setStatus(profile.getStatus()); datasetProfile.setStatus(profile.getStatus());
datasetProfile.setDescription(profile.getDescription()); datasetProfile.setDescription(profile.getDescription());
@ -173,12 +173,12 @@ public class Admin extends BaseController {
@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception { @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile datasetProfileModel = this.datasetProfileManager.createDatasetProfileFromXml(file); eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile datasetProfileModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename()); eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename());
eu.eudat.data.entities.DatasetProfile modelDefinition; DescriptionTemplate modelDefinition;
if (id == null) { if (id == null) {
modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext()); modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition); DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
UserDatasetProfile userDatasetProfile = new UserDatasetProfile(); UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
userDatasetProfile.setDatasetProfile(datasetProfile); userDatasetProfile.setDatasetProfile(descriptionTemplate);
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
userDatasetProfile.setUser(userInfo); userDatasetProfile.setUser(userInfo);
userDatasetProfile.setRole(0); userDatasetProfile.setRole(0);
@ -186,7 +186,7 @@ public class Admin extends BaseController {
} else { } else {
modelDefinition = datasetProfileManager.createNewVersionDatasetProfile(id, datasetProfileEntity); modelDefinition = datasetProfileManager.createNewVersionDatasetProfile(id, datasetProfileEntity);
} }
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>() return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>()
.status(ApiMessageCode.SUCCESS_MESSAGE).message("")); .status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
} }

View File

@ -2,6 +2,8 @@ package eu.eudat.controllers;
import eu.eudat.data.dao.criteria.RequestItem; import eu.eudat.data.dao.criteria.RequestItem;
import eu.eudat.data.entities.DMPProfile; import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest; import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
import eu.eudat.logic.managers.DataManagementProfileManager; import eu.eudat.logic.managers.DataManagementProfileManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.security.claims.ClaimedAuthorities;
@ -10,6 +12,7 @@ import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem; import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel; import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
@ -51,6 +54,14 @@ public class DMPProfileController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created")); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
} }
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/blueprint"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMPProfile>> createOrUpdateBlueprint(@RequestBody DataManagementPlanBlueprintListingModel dataManagementPlan, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
this.dataManagementProfileManager.createOrUpdateBlueprint(dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json") @RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
public @ResponseBody public @ResponseBody
ResponseEntity<ResponseItem<DataManagementPlanProfileListingModel>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException { ResponseEntity<ResponseItem<DataManagementPlanProfileListingModel>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
@ -58,6 +69,13 @@ public class DMPProfileController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanProfileListingModel)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanProfileListingModel));
} }
@RequestMapping(method = RequestMethod.GET, value = {"/getSingleBlueprint/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataManagementPlanBlueprintListingModel>> getSingleBlueprint(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanBlueprintListingModel));
}
@RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception { ResponseEntity<ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception {
@ -65,6 +83,13 @@ public class DMPProfileController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
} }
@RequestMapping(method = RequestMethod.POST, value = {"/getPagedBlueprint"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanBlueprintListingModel>>> getPagedBlueprint(@Valid @RequestBody DataManagementPlanBlueprintTableRequest dataManagementPlanBlueprintTableRequest, Principal principal) throws Exception {
DataTableData<DataManagementPlanBlueprintListingModel> dataTable = this.dataManagementProfileManager.getPagedBlueprint(dataManagementPlanBlueprintTableRequest, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanBlueprintListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json") @RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
public @ResponseBody public @ResponseBody
ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException, IOException { ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException, IOException {
@ -82,7 +107,7 @@ public class DMPProfileController extends BaseController {
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file); eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename()); DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename());
this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal); this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>() return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>()
.status(ApiMessageCode.SUCCESS_MESSAGE).message("")); .status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.data.dao.criteria.RequestItem; import eu.eudat.data.dao.criteria.RequestItem;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.managers.AdminManager; import eu.eudat.logic.managers.AdminManager;
import eu.eudat.logic.managers.DatasetProfileManager; import eu.eudat.logic.managers.DatasetProfileManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.security.claims.ClaimedAuthorities;
@ -56,7 +57,7 @@ public class DatasetProfileController extends BaseController {
@Transactional @Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN})Principal principal) { public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN})Principal principal) {
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(id); DescriptionTemplate profile = this.datasetProfileManager.clone(id);
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
datasetprofile.setLabel(profile.getLabel() + " new "); datasetprofile.setLabel(profile.getLabel() + " new ");
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
@ -64,8 +65,8 @@ public class DatasetProfileController extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody RequestItem<AutoCompleteLookupItem> lookupItem) throws XPathExpressionException { public ResponseEntity<Object> getDataForAutocomplete(@RequestBody RequestItem<AutoCompleteLookupItem> lookupItem) throws XPathExpressionException {
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID())); DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID()));
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = this.datasetProfileManager.queryForField(datasetProfile.getDefinition(), lookupItem.getCriteria().getFieldID()); eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = this.datasetProfileManager.queryForField(descriptionTemplate.getDefinition(), lookupItem.getCriteria().getFieldID());
AutoCompleteData data = (AutoCompleteData) modelfield.getData(); AutoCompleteData data = (AutoCompleteData) modelfield.getData();
List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike()); List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
return ResponseEntity.status(HttpStatus.OK).body(items); return ResponseEntity.status(HttpStatus.OK).body(items);

View File

@ -1,6 +1,7 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest; import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest; import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest; import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
@ -202,7 +203,7 @@ public class Datasets extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json") @RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json")
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getSingle(@PathVariable String id) { public ResponseEntity<ResponseItem<PagedDatasetProfile>> getSingle(@PathVariable String id) {
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); DescriptionTemplate profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile); eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile(); PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile); pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);

View File

@ -0,0 +1,94 @@
package eu.eudat.controllers;
import eu.eudat.exceptions.descriptiontemplate.DescriptionTemplatesWithTypeException;
import eu.eudat.logic.managers.DescriptionTemplateTypeManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.descriptiontemplatetype.DescriptionTemplateTypeModel;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
import eu.eudat.types.Authorities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
import java.util.UUID;
import static eu.eudat.types.Authorities.ADMIN;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/descriptionTemplateType/"})
public class DescriptionTemplateTypeController extends BaseController {
private DescriptionTemplateTypeManager descriptionTemplateTypeManager;
@Autowired
public DescriptionTemplateTypeController(ApiContext apiContext, DescriptionTemplateTypeManager descriptionTemplateTypeManager){
super(apiContext);
this.descriptionTemplateTypeManager = descriptionTemplateTypeManager;
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"create"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> create(@RequestBody DescriptionTemplateTypeModel type, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
try {
this.descriptionTemplateTypeManager.create(type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}
catch(DescriptionTemplatesWithTypeException e){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"update"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> update(@RequestBody DescriptionTemplateTypeModel type, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
try {
this.descriptionTemplateTypeManager.update(type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Updated"));
}
catch(DescriptionTemplatesWithTypeException e){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"get"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DescriptionTemplateTypeModel>>> get(@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
DataTableData<DescriptionTemplateTypeModel> dataTable = this.descriptionTemplateTypeManager.get();
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DescriptionTemplateTypeModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.GET, value = {"get/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> getSingle(@PathVariable(value = "id") UUID id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
try {
DescriptionTemplateTypeModel typeModel = this.descriptionTemplateTypeManager.getSingle(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.NO_MESSAGE).payload(typeModel));
}
catch(DescriptionTemplatesWithTypeException e){
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> delete(@PathVariable(value = "id") UUID id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
try{
this.descriptionTemplateTypeManager.delete(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted"));
}
catch(DescriptionTemplatesWithTypeException e){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.UNSUCCESS_DELETE).message(e.getMessage()));
}
}
}

View File

@ -1,8 +1,7 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.Funder; import eu.eudat.data.entities.Funder;
import eu.eudat.data.entities.Project; import eu.eudat.data.entities.Project;
import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.managers.DatasetManager;
@ -23,7 +22,6 @@ import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.UUID;
@RestController @RestController
@CrossOrigin @CrossOrigin
@ -88,7 +86,7 @@ public class QuickWizardController extends BaseController {
quickWizard.getDmp().setId(dmpEntity.getId()); quickWizard.getDmp().setId(dmpEntity.getId());
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) { for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
DataManagementPlan dmp = quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, principal); DataManagementPlan dmp = quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, principal);
DatasetProfile profile = quickWizard.getDmp().getDatasetProfile(); DescriptionTemplate profile = quickWizard.getDmp().getDatasetProfile();
DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, profile); DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, profile);
this.datasetManager.createOrUpdate(datasetWizardModel, principal); this.datasetManager.createOrUpdate(datasetWizardModel, principal);
} }
@ -100,7 +98,7 @@ public class QuickWizardController extends BaseController {
public @ResponseBody public @ResponseBody
ResponseEntity<ResponseItem<DatasetCreateWizardModel>> addDatasetWizard(@RequestBody DatasetCreateWizardModel datasetCreateWizardModel, Principal principal) throws Exception{ ResponseEntity<ResponseItem<DatasetCreateWizardModel>> addDatasetWizard(@RequestBody DatasetCreateWizardModel datasetCreateWizardModel, Principal principal) throws Exception{
for(DatasetDescriptionQuickWizardModel dataset : datasetCreateWizardModel.getDatasets().getDatasetsList()){ for(DatasetDescriptionQuickWizardModel dataset : datasetCreateWizardModel.getDatasets().getDatasetsList()){
DatasetProfile profile = new DatasetProfile(); DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getId()); profile.setId(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getId());
profile.setLabel(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getLabel()); profile.setLabel(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getLabel());
this.datasetManager.createOrUpdate(dataset.toDataModel(datasetCreateWizardModel.getDmpMeta().getDmp(), profile), principal); this.datasetManager.createOrUpdate(dataset.toDataModel(datasetCreateWizardModel.getDmpMeta().getDmp(), profile), principal);

View File

@ -0,0 +1,9 @@
package eu.eudat.exceptions.descriptiontemplate;
public class DescriptionTemplatesWithTypeException extends RuntimeException {
public DescriptionTemplatesWithTypeException(String message) {
super(message);
}
}

View File

@ -1,8 +1,8 @@
package eu.eudat.logic.builders.entity; package eu.eudat.logic.builders.entity;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.builders.Builder; import eu.eudat.logic.builders.Builder;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DatasetProfile;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
@ -11,7 +11,7 @@ import java.util.UUID;
/** /**
* Created by ikalyvas on 2/15/2018. * Created by ikalyvas on 2/15/2018.
*/ */
public class DatasetProfileBuilder extends Builder<DatasetProfile> { public class DatasetProfileBuilder extends Builder<DescriptionTemplate> {
private UUID id; private UUID id;
@ -77,17 +77,17 @@ public class DatasetProfileBuilder extends Builder<DatasetProfile> {
} }
@Override @Override
public DatasetProfile build() { public DescriptionTemplate build() {
DatasetProfile datasetProfile = new DatasetProfile(); DescriptionTemplate descriptionTemplate = new DescriptionTemplate();
datasetProfile.setCreated(created); descriptionTemplate.setCreated(created);
datasetProfile.setStatus(status); descriptionTemplate.setStatus(status);
datasetProfile.setId(id); descriptionTemplate.setId(id);
datasetProfile.setDataset(dataset); descriptionTemplate.setDataset(dataset);
datasetProfile.setDefinition(definition); descriptionTemplate.setDefinition(definition);
datasetProfile.setDescription(description); descriptionTemplate.setDescription(description);
datasetProfile.setModified(modified); descriptionTemplate.setModified(modified);
datasetProfile.setLabel(label); descriptionTemplate.setLabel(label);
datasetProfile.setLanguage(language); descriptionTemplate.setLanguage(language);
return datasetProfile; return descriptionTemplate;
} }
} }

View File

@ -2,6 +2,7 @@ package eu.eudat.logic.managers;
import eu.eudat.data.dao.entities.DatasetDao; import eu.eudat.data.dao.entities.DatasetDao;
import eu.eudat.data.dao.entities.DatasetProfileDao; import eu.eudat.data.dao.entities.DatasetProfileDao;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption; import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
import eu.eudat.logic.builders.entity.DatasetProfileBuilder; import eu.eudat.logic.builders.entity.DatasetProfileBuilder;
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel; import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel;
@ -17,7 +18,7 @@ import java.util.UUID;
public class AdminManager { public class AdminManager {
public static eu.eudat.data.entities.DatasetProfile generateViewStyleDefinition(DatasetProfile profile, ApiContext apiContext) { public static DescriptionTemplate generateViewStyleDefinition(DatasetProfile profile, ApiContext apiContext) {
ViewStyleModel viewStyleModel = new ViewStyleModel(); ViewStyleModel viewStyleModel = new ViewStyleModel();
viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section.class)); viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section.class));
viewStyleModel.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Page.class)); viewStyleModel.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Page.class));
@ -34,22 +35,22 @@ public class AdminManager {
profile.setLanguage("en"); profile.setLanguage("en");
} }
eu.eudat.data.entities.DatasetProfile datasetProfile = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel()) DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel())
.status(profile.getStatus()).created(new Date()).description(profile.getDescription()).language(profile.getLanguage()) .status(profile.getStatus()).created(new Date()).description(profile.getDescription()).language(profile.getLanguage())
.build(); .build();
if (datasetProfile.getGroupId() == null) { if (descriptionTemplate.getGroupId() == null) {
datasetProfile.setGroupId(UUID.randomUUID()); descriptionTemplate.setGroupId(UUID.randomUUID());
} }
if (datasetProfile.getVersion() == null) { if (descriptionTemplate.getVersion() == null) {
datasetProfile.setVersion((short)1); descriptionTemplate.setVersion((short)1);
} }
return datasetProfile; return descriptionTemplate;
} }
public static eu.eudat.models.data.admin.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) { public static eu.eudat.models.data.admin.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplate profile) {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition()); Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = viewStyleDoc.getDocumentElement(); Element root = viewStyleDoc.getDocumentElement();
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root); eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);
@ -60,12 +61,12 @@ public class AdminManager {
} }
public static eu.eudat.data.entities.DatasetProfile inactivate(DatasetProfileDao datasetProfileRepository, DatasetDao datasetDao, String id) { public static DescriptionTemplate inactivate(DatasetProfileDao datasetProfileRepository, DatasetDao datasetDao, String id) {
eu.eudat.data.dao.criteria.DatasetCriteria datasetsForThatDatasetProfile = new eu.eudat.data.dao.criteria.DatasetCriteria(); eu.eudat.data.dao.criteria.DatasetCriteria datasetsForThatDatasetProfile = new eu.eudat.data.dao.criteria.DatasetCriteria();
datasetsForThatDatasetProfile.setProfileDatasetId(UUID.fromString(id)); datasetsForThatDatasetProfile.setProfileDatasetId(UUID.fromString(id));
if (datasetDao.getWithCriteria(datasetsForThatDatasetProfile).count() == 0) { if (datasetDao.getWithCriteria(datasetsForThatDatasetProfile).count() == 0) {
eu.eudat.data.entities.DatasetProfile detasetProfile = datasetProfileRepository.find(UUID.fromString(id)); DescriptionTemplate detasetProfile = datasetProfileRepository.find(UUID.fromString(id));
detasetProfile.setStatus(eu.eudat.data.entities.DatasetProfile.Status.DELETED.getValue()); detasetProfile.setStatus(DescriptionTemplate.Status.DELETED.getValue());
detasetProfile = datasetProfileRepository.createOrUpdate(detasetProfile); detasetProfile = datasetProfileRepository.createOrUpdate(detasetProfile);
return detasetProfile; return detasetProfile;
} else { } else {

View File

@ -5,6 +5,7 @@ import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
import eu.eudat.configurations.dynamicgrant.entities.Property; import eu.eudat.configurations.dynamicgrant.entities.Property;
import eu.eudat.data.dao.criteria.*; import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.dao.entities.*; import eu.eudat.data.dao.entities.*;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.Organisation; import eu.eudat.data.entities.Organisation;
import eu.eudat.data.entities.Researcher; import eu.eudat.data.entities.Researcher;
import eu.eudat.data.entities.*; import eu.eudat.data.entities.*;
@ -25,7 +26,6 @@ import eu.eudat.elastic.entities.Tag;
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException; import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException; import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
import eu.eudat.exceptions.security.ForbiddenException; import eu.eudat.exceptions.security.ForbiddenException;
import eu.eudat.exceptions.security.NonValidTokenException;
import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.builders.entity.UserInfoBuilder; import eu.eudat.logic.builders.entity.UserInfoBuilder;
import eu.eudat.logic.mapper.elastic.DmpMapper; import eu.eudat.logic.mapper.elastic.DmpMapper;
@ -51,8 +51,8 @@ import eu.eudat.models.data.dmp.*;
import eu.eudat.models.data.doi.DepositRequest; import eu.eudat.models.data.doi.DepositRequest;
import eu.eudat.models.data.doi.Doi; import eu.eudat.models.data.doi.Doi;
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue; import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile; import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.*;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field; import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
import eu.eudat.models.data.funder.FunderDMPEditorModel; import eu.eudat.models.data.funder.FunderDMPEditorModel;
import eu.eudat.models.data.grant.GrantDMPEditorModel; import eu.eudat.models.data.grant.GrantDMPEditorModel;
import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpermodels.Tuple;
@ -65,7 +65,6 @@ import eu.eudat.models.data.userinfo.UserListingModel;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.types.Authorities; import eu.eudat.types.Authorities;
import eu.eudat.types.MetricNames; import eu.eudat.types.MetricNames;
import org.apache.commons.io.IOUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun; import org.apache.poi.xwpf.usermodel.XWPFRun;
@ -87,7 +86,6 @@ import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
import java.io.*; import java.io.*;
import java.math.BigInteger; import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
@ -408,7 +406,7 @@ public class DataManagementPlanManager {
datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue());
datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId()); datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId());
QueryableList<DatasetProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria()); QueryableList<DescriptionTemplate> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
DataTableData<DatasetProfileListingModel> data = new DataTableData<>(); DataTableData<DatasetProfileListingModel> data = new DataTableData<>();
@ -449,6 +447,7 @@ public class DataManagementPlanManager {
* Data Management * Data Management
* */ * */
@Transactional
public DMP createOrUpdate(DataManagementPlanEditorModel dataManagementPlan, Principal principal) throws Exception { public DMP createOrUpdate(DataManagementPlanEditorModel dataManagementPlan, Principal principal) throws Exception {
boolean setNotification = false; boolean setNotification = false;
if (dataManagementPlan.getId() != null) { if (dataManagementPlan.getId() != null) {
@ -465,7 +464,7 @@ public class DataManagementPlanManager {
} }
List<Dataset> datasetList = dmp1.getDataset().stream().filter(dataset -> dataset.getStatus() != 99).collect(Collectors.toList()); List<Dataset> datasetList = dmp1.getDataset().stream().filter(dataset -> dataset.getStatus() != 99).collect(Collectors.toList());
for (Dataset dataset : datasetList) { for (Dataset dataset : datasetList) {
if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> dataset.getProfile().getId().equals(associatedProfile.getId())).findAny().orElse(null) == null) if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> dataset.getProfile().getId().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null)
throw new Exception("Dataset Template for Dataset Description is missing from the DMP."); throw new Exception("Dataset Template for Dataset Description is missing from the DMP.");
} }
if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue())) if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
@ -521,9 +520,19 @@ public class DataManagementPlanManager {
assignFunderUserIfInternal(newDmp, user); assignFunderUserIfInternal(newDmp, user);
assignProjectUserIfInternal(newDmp, user); assignProjectUserIfInternal(newDmp, user);
if(newDmp.getId() != null){
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().createOrUpdate(dmpDatasetProfile);
}
}
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant()); apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp); newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().createOrUpdate(dmpDatasetProfile);
}
if (dataManagementPlan.getUsers() != null && !dataManagementPlan.getUsers().isEmpty()) { if (dataManagementPlan.getUsers() != null && !dataManagementPlan.getUsers().isEmpty()) {
clearUsers(newDmp); clearUsers(newDmp);
for (UserInfoListingModel userListing : dataManagementPlan.getUsers()) { for (UserInfoListingModel userListing : dataManagementPlan.getUsers()) {
@ -599,7 +608,7 @@ public class DataManagementPlanManager {
throw new Exception("Another user have already edit that DMP."); throw new Exception("Another user have already edit that DMP.");
} }
for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) { for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) {
if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> dataset.getProfile().getId().equals(associatedProfile.getId())).findAny().orElse(null) == null) if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> dataset.getProfile().getId().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null)
throw new Exception("Dataset Template for Dataset Description is missing from the DMP."); throw new Exception("Dataset Template for Dataset Description is missing from the DMP.");
} }
if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue())) if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
@ -1254,12 +1263,155 @@ public class DataManagementPlanManager {
// wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.HEADER1, BigInteger.ZERO); // wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
// // Space below Datasets. // // Space below Datasets.
// XWPFParagraph parBreakDatasets = document.createParagraph(); // XWPFParagraph parBreakDatasets = document.createParagraph();
DMPProfile dmpProfile = dmpEntity.getProfile();
DataManagementPlanBlueprintListingModel dmpBlueprintModel = new DataManagementPlanBlueprintListingModel();
dmpBlueprintModel.fromDataModel(dmpProfile);
DataManagementPlanBlueprint dmpBlueprint = dmpBlueprintModel.getDefinition();
for(Section section: dmpBlueprint.getSections()){
wordBuilder.addParagraphContent("Section " + section.getOrdinal(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
XWPFParagraph sectionInfoParagraph = document.createParagraph();
sectionInfoParagraph.setSpacingBetween(1.0);
XWPFRun runSectionTitle = sectionInfoParagraph.createRun();
runSectionTitle.setText("Title: ");
runSectionTitle.setColor("000000");
XWPFRun runSectionTitleText = sectionInfoParagraph.createRun();
runSectionTitleText.setText(section.getLabel());
runSectionTitleText.setColor("116a78");
XWPFParagraph sectionDescriptionParagraph = document.createParagraph();
XWPFRun runSectionDescription = sectionDescriptionParagraph.createRun();
runSectionDescription.setText("Description: ");
runSectionDescription.setColor("000000");
XWPFRun runSectionDescriptionText = sectionDescriptionParagraph.createRun();
runSectionDescriptionText.setText(section.getDescription());
runSectionDescriptionText.setColor("116a78");
wordBuilder.addParagraphContent("Section Fields", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
section.getFields().sort(Comparator.comparingInt(FieldModel::getOrdinal));
for(FieldModel field: section.getFields()){
if(field.getCategory() == FieldCategory.SYSTEM){
SystemField systemField = field.toSystemField();
XWPFParagraph systemFieldParagraph = document.createParagraph();
systemFieldParagraph.setSpacingBetween(1.0);
XWPFRun runSyStemFieldTitle = systemFieldParagraph.createRun();
runSyStemFieldTitle.setText("Title: ");
runSyStemFieldTitle.setColor("000000");
XWPFRun runSystemFieldTitleText = systemFieldParagraph.createRun();
runSystemFieldTitleText.setText(systemField.getLabel());
runSystemFieldTitleText.setColor("116a78");
if(systemField.getDescription() != null && !systemField.getDescription().isEmpty()){
XWPFParagraph systemFieldDescription = document.createParagraph();
systemFieldDescription.setSpacingBetween(1.0);
XWPFRun runSyStemFieldDescription = systemFieldDescription.createRun();
runSyStemFieldDescription.setText("Description: ");
runSyStemFieldDescription.setColor("000000");
XWPFRun runSystemFieldDescriptionText = systemFieldDescription.createRun();
runSystemFieldDescriptionText.setText(systemField.getDescription());
runSystemFieldDescriptionText.setColor("116a78");
}
XWPFParagraph systemFieldInput = document.createParagraph();
systemFieldInput.setSpacingBetween(1.0);
XWPFRun runInput = systemFieldInput.createRun();
runInput.setText("Input: ");
runInput.setColor("000000");
switch (systemField.getType()) {
case TEXT:
XWPFRun runTitle = systemFieldInput.createRun();
runTitle.setText(dmpEntity.getLabel());
runTitle.setColor("116a78");
break;
case HTML_TEXT:
XWPFRun runDescription = systemFieldInput.createRun();
runDescription.setText(dmpEntity.getDescription());
runDescription.setColor("116a78");
break;
case RESEARCHERS:
for(Researcher researcher: dmpEntity.getResearchers()){
XWPFRun runResearcher = systemFieldInput.createRun();
runResearcher.setText("" + researcher.getLabel());
runResearcher.setColor("116a78");
}
break;
case ORGANIZATIONS:
for(Organisation organisation: dmpEntity.getOrganisations()){
XWPFRun runOrganisation = systemFieldInput.createRun();
runOrganisation.setText("" + organisation.getLabel());
runOrganisation.setColor("116a78");
}
break;
case LANGUAGE:
XWPFRun runLanguage = systemFieldInput.createRun();
runLanguage.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("language").toString());
runLanguage.setColor("116a78");
break;
case CONTACT:
XWPFRun runContact = systemFieldInput.createRun();
runContact.setText(dmpEntity.getCreator().getName());
runContact.setColor("116a78");
break;
case FUNDER:
XWPFRun runFunder = systemFieldInput.createRun();
runFunder.setText(dmpEntity.getGrant().getFunder().getLabel());
runFunder.setColor("116a78");
break;
case GRANT:
XWPFRun runGrant = systemFieldInput.createRun();
runGrant.setText(dmpEntity.getGrant().getLabel());
runGrant.setColor("116a78");
break;
case PROJECT:
XWPFRun runProject = systemFieldInput.createRun();
runProject.setText(dmpEntity.getProject().getLabel());
runProject.setColor("116a78");
break;
case LICENSE:
XWPFRun runLicense = systemFieldInput.createRun();
runLicense.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("license").toString());
runLicense.setColor("116a78");
break;
case ACCESS_RIGHTS:
XWPFRun runAccessRights = systemFieldInput.createRun();
runAccessRights.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("visible").toString());
runAccessRights.setColor("116a78");
break;
}
document.createParagraph();
}
else if(field.getCategory() == FieldCategory.EXTRA){
ExtraField extraField = field.toExtraField();
XWPFParagraph extraFieldParagraph = document.createParagraph();
extraFieldParagraph.setSpacingBetween(1.0);
XWPFRun runExtraFieldLabel = extraFieldParagraph.createRun();
runExtraFieldLabel.setText(extraField.getLabel());
runExtraFieldLabel.setColor("116a78");
if(extraField.getDescription() != null && !extraField.getDescription().isEmpty()){
XWPFRun runExtraFieldDescription = extraFieldParagraph.createRun();
runExtraFieldDescription.setText(extraField.getDescription());
runExtraFieldDescription.setColor("116a78");
}
XWPFRun runExtraFieldInput = extraFieldParagraph.createRun();
runExtraFieldInput.setText(extraField.getLabel());
runExtraFieldInput.setColor("116a78");
}
}
if(!section.getDescriptionTemplates().isEmpty()){
wordBuilder.addParagraphContent("Section descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
wordBuilder.addParagraphContent("Description Templates", document, ParagraphStyle.HEADER4, BigInteger.ZERO, 0);
for(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate descriptionTemplate: section.getDescriptionTemplates()){
XWPFParagraph templateParagraph = document.createParagraph();
XWPFRun runTemplateLabel = templateParagraph.createRun();
runTemplateLabel.setText("" + descriptionTemplate.getLabel());
runTemplateLabel.setColor("116a78");
}
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue(); final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
final Boolean isPublic = dmpEntity.isPublic(); final Boolean isPublic = dmpEntity.isPublic();
dmpEntity.getDataset().stream() dmpEntity.getDataset().stream()
.filter(item -> item.getStatus() != Dataset.Status.CANCELED.getValue()) .filter(item -> item.getStatus() != Dataset.Status.CANCELED.getValue())
.filter(item -> item.getStatus() != Dataset.Status.DELETED.getValue()) .filter(item -> item.getStatus() != Dataset.Status.DELETED.getValue())
.filter(item -> !isPublic && !isFinalized || item.getStatus() == Dataset.Status.FINALISED.getValue()) .filter(item -> !isPublic && !isFinalized || item.getStatus() == Dataset.Status.FINALISED.getValue())
.filter(item -> item.getDmpSectionIndex().equals(section.getOrdinal() - 1))
.sorted(Comparator.comparing(Dataset::getCreated)) .sorted(Comparator.comparing(Dataset::getCreated))
.forEach(datasetEntity -> { .forEach(datasetEntity -> {
Map<String, Object> properties = new HashMap<>(); Map<String, Object> properties = new HashMap<>();
@ -1274,6 +1426,18 @@ public class DataManagementPlanManager {
properties = jObject.toMap();*/ properties = jObject.toMap();*/
} }
// Dataset Description custom style.
XWPFParagraph datasetDescriptionParagraph = document.createParagraph();
datasetDescriptionParagraph.setStyle("Heading4");
datasetDescriptionParagraph.setSpacingBetween(1.5);
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
datasetDescriptionRun.setText("Dataset Description");
//datasetDescriptionRun.setColor("2E75B6");
//datasetDescriptionRun.setBold(true);
datasetDescriptionRun.setFontSize(15);
// Custom style for the Dataset title. // Custom style for the Dataset title.
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO); //wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
XWPFParagraph datasetLabelParagraph = document.createParagraph(); XWPFParagraph datasetLabelParagraph = document.createParagraph();
@ -1303,8 +1467,6 @@ public class DataManagementPlanManager {
//runDatasetTemplate.setBold(true); //runDatasetTemplate.setBold(true);
//runDatasetTemplate.setFontSize(12); //runDatasetTemplate.setFontSize(12);
document.createParagraph();
// /*XWPFParagraph externalReferencesParagraph = document.createParagraph(); // /*XWPFParagraph externalReferencesParagraph = document.createParagraph();
// externalReferencesParagraph.setStyle("Heading3"); // externalReferencesParagraph.setStyle("Heading3");
// XWPFRun externalReferencesRun = externalReferencesParagraph.createRun(); // XWPFRun externalReferencesRun = externalReferencesParagraph.createRun();
@ -1340,17 +1502,17 @@ public class DataManagementPlanManager {
// }*/ // }*/
// //
// //
wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
// Dataset Description custom style. XWPFParagraph datasetDescParagraph = document.createParagraph();
XWPFParagraph datasetDescriptionParagraph = document.createParagraph(); XWPFRun runDatasetDescription1 = datasetDescParagraph.createRun();
datasetDescriptionParagraph.setStyle("Heading4"); runDatasetDescription1.setText("Description: ");
datasetDescriptionParagraph.setSpacingBetween(1.5); runDatasetDescription1.setColor("000000");
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun(); XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
datasetDescriptionRun.setText("Dataset Description"); runDatasetDescription.setText(datasetEntity.getProfile().getLabel());
//datasetDescriptionRun.setColor("2E75B6"); runDatasetDescription.setColor("116a78");
//datasetDescriptionRun.setBold(true); //wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
datasetDescriptionRun.setFontSize(15);
document.createParagraph();
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity); PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
visibilityRuleService.setProperties(properties); visibilityRuleService.setProperties(properties);
@ -1364,6 +1526,8 @@ public class DataManagementPlanManager {
XWPFParagraph parBreakDataset = document.createParagraph(); XWPFParagraph parBreakDataset = document.createParagraph();
parBreakDataset.setPageBreak(true); parBreakDataset.setPageBreak(true);
}); });
}
}
// // Removes the top empty headings. // // Removes the top empty headings.
// for (int i = 0; i < 6; i++) { // for (int i = 0; i < 6; i++) {
@ -1603,19 +1767,20 @@ public class DataManagementPlanManager {
Element profiles = xmlDoc.createElement("profiles"); Element profiles = xmlDoc.createElement("profiles");
// Get DatasetProfiles from DMP to add to XML. // Get DatasetProfiles from DMP to add to XML.
for (DatasetProfile datasetProfile : dmp.getAssociatedDmps()) { for (DMPDatasetProfile dmpDescriptionProfile : dmp.getAssociatedDmps()) {
DescriptionTemplate descriptionTemplate = dmpDescriptionProfile.getDatasetprofile();
Element profile = xmlDoc.createElement("profile"); Element profile = xmlDoc.createElement("profile");
Element profileId = xmlDoc.createElement("profileId"); Element profileId = xmlDoc.createElement("profileId");
profileId.setTextContent(datasetProfile.getId().toString()); profileId.setTextContent(descriptionTemplate.getId().toString());
profile.appendChild(profileId); profile.appendChild(profileId);
Element profileGroupId = xmlDoc.createElement("profileGroupId"); Element profileGroupId = xmlDoc.createElement("profileGroupId");
profileGroupId.setTextContent(datasetProfile.getGroupId().toString()); profileGroupId.setTextContent(descriptionTemplate.getGroupId().toString());
profile.appendChild(profileGroupId); profile.appendChild(profileGroupId);
Element profileLabel = xmlDoc.createElement("profileLabel"); Element profileLabel = xmlDoc.createElement("profileLabel");
profileLabel.setTextContent(datasetProfile.getLabel()); profileLabel.setTextContent(descriptionTemplate.getLabel());
profile.appendChild(profileLabel); profile.appendChild(profileLabel);
Element profileVersion = xmlDoc.createElement("profileVersion"); Element profileVersion = xmlDoc.createElement("profileVersion");
profileVersion.setTextContent(String.valueOf(datasetProfile.getVersion())); profileVersion.setTextContent(String.valueOf(descriptionTemplate.getVersion()));
profile.appendChild(profileVersion); profile.appendChild(profileVersion);
profiles.appendChild(profile); profiles.appendChild(profile);
} }
@ -1755,7 +1920,7 @@ public class DataManagementPlanManager {
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>(); List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
if (profiles != null && profiles.length > 0) { if (profiles != null && profiles.length > 0) {
for (String profile : profiles) { for (String profile : profiles) {
DatasetProfile exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(profile)); DescriptionTemplate exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(profile));
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile); AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
associatedProfiles.add(associatedProfile); associatedProfiles.add(associatedProfile);
} }
@ -1763,7 +1928,7 @@ public class DataManagementPlanManager {
for (AssociatedProfileImportModels a : dataManagementPlans.get(0).getProfilesImportModels()) { for (AssociatedProfileImportModels a : dataManagementPlans.get(0).getProfilesImportModels()) {
try { try {
DatasetProfile exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(a.getId()); DescriptionTemplate exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(a.getId());
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile); AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
associatedProfiles.add(associatedProfile); associatedProfiles.add(associatedProfile);
} catch (Exception ignored) { } catch (Exception ignored) {
@ -1843,7 +2008,7 @@ public class DataManagementPlanManager {
try { try {
dataset.setProfile(databaseRepository.getDatasetProfileDao().find(das.getProfile())); dataset.setProfile(databaseRepository.getDatasetProfileDao().find(das.getProfile()));
} catch (Exception ignored) { } catch (Exception ignored) {
dataset.setProfile(databaseRepository.getDatasetProfileDao().find(associatedProfiles.get(0).getId())); dataset.setProfile(databaseRepository.getDatasetProfileDao().find(associatedProfiles.get(0).getDescriptionTemplateId()));
} }
dataset.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels())); dataset.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels()));
dataset.setStatus((short) 0); dataset.setStatus((short) 0);

View File

@ -5,6 +5,7 @@ import com.jayway.jsonpath.JsonPath;
import eu.eudat.data.dao.criteria.RequestItem; import eu.eudat.data.dao.criteria.RequestItem;
import eu.eudat.data.dao.entities.DMPProfileDao; import eu.eudat.data.dao.entities.DMPProfileDao;
import eu.eudat.data.entities.DMPProfile; import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest; import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest; import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
@ -17,6 +18,7 @@ import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field;
import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem; import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel; import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
@ -78,6 +80,20 @@ public class DataManagementProfileManager {
return dataTable; return dataTable;
} }
public DataTableData<DataManagementPlanBlueprintListingModel> getPagedBlueprint(DataManagementPlanBlueprintTableRequest dataManagementPlanBlueprintTableRequest, Principal principal) throws Exception {
QueryableList<DMPProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().getWithCriteriaBlueprint(dataManagementPlanBlueprintTableRequest.getCriteria());
QueryableList<DMPProfile> pagedItems = PaginationManager.applyPaging(items, dataManagementPlanBlueprintTableRequest);
DataTableData<DataManagementPlanBlueprintListingModel> dataTable = new DataTableData<>();
CompletableFuture itemsFuture = pagedItems
.selectAsync(item -> new DataManagementPlanBlueprintListingModel().fromDataModel(item)).whenComplete((resultList, throwable) -> dataTable.setData(resultList));
CompletableFuture countFuture = items.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
CompletableFuture.allOf(itemsFuture, countFuture).join();
return dataTable;
}
public DataManagementPlanProfileListingModel getSingle(String id, Principal principal) throws InstantiationException, IllegalAccessException { public DataManagementPlanProfileListingModel getSingle(String id, Principal principal) throws InstantiationException, IllegalAccessException {
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id)); DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = new DataManagementPlanProfileListingModel(); DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = new DataManagementPlanProfileListingModel();
@ -85,6 +101,13 @@ public class DataManagementProfileManager {
return dataManagementPlanProfileListingModel; return dataManagementPlanProfileListingModel;
} }
public DataManagementPlanBlueprintListingModel getSingleBlueprint(String id, Principal principal) throws InstantiationException, IllegalAccessException {
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = new DataManagementPlanBlueprintListingModel();
dataManagementPlanBlueprintListingModel.fromDataModel(dmpProfile);
return dataManagementPlanBlueprintListingModel;
}
public List<DataManagementPlanProfileListingModel> getWithCriteria(DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException { public List<DataManagementPlanProfileListingModel> getWithCriteria(DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException {
QueryableList<DMPProfile> items = databaseRepository.getDmpProfileDao().getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria()); QueryableList<DMPProfile> items = databaseRepository.getDmpProfileDao().getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria());
List<DataManagementPlanProfileListingModel> datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item)); List<DataManagementPlanProfileListingModel> datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item));
@ -96,6 +119,11 @@ public class DataManagementProfileManager {
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile); apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
} }
public void createOrUpdateBlueprint(DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel, Principal principal) throws Exception {
DMPProfile dmpProfile = dataManagementPlanBlueprintListingModel.toDataModel();
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
}
public ResponseEntity<byte[]> getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException { public ResponseEntity<byte[]> getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
FileEnvelope envelope = getXmlDocument(dmpProfile, label); FileEnvelope envelope = getXmlDocument(dmpProfile, label);
InputStream resource = new FileInputStream(envelope.getFile()); InputStream resource = new FileInputStream(envelope.getFile());

View File

@ -292,7 +292,7 @@ public class DatasetManager {
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity)); dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
dataset.fromDataModel(datasetEntity); dataset.fromDataModel(datasetEntity);
// Creates the Criteria to get all version of DatasetProfile in question. // Creates the Criteria to get all version of DescriptionTemplate in question.
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria(); DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
UUID profileId = datasetEntity.getProfile().getGroupId(); UUID profileId = datasetEntity.getProfile().getGroupId();
List<UUID> uuidList = new LinkedList<>(); List<UUID> uuidList = new LinkedList<>();
@ -300,13 +300,13 @@ public class DatasetManager {
profileCriteria.setGroupIds(uuidList); profileCriteria.setGroupIds(uuidList);
profileCriteria.setAllVersions(true); profileCriteria.setAllVersions(true);
List<eu.eudat.data.entities.DatasetProfile> profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria) List<DescriptionTemplate> profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria)
.orderBy(((builder, root) -> builder.desc(root.get("version")))) .orderBy(((builder, root) -> builder.desc(root.get("version"))))
.toList(); .toList();
List<DatasetProfile> profileVersionsIncluded = new LinkedList<>(); List<DescriptionTemplate> profileVersionsIncluded = new LinkedList<>();
// Iterate through the versions and remove those that are not included in the DMP of the dataset in question. // Iterate through the versions and remove those that are not included in the DMP of the dataset in question.
for (DatasetProfile version : profileVersions) { for (DescriptionTemplate version : profileVersions) {
for (AssociatedProfile p : dataset.getDmp().getProfiles()) { for (AssociatedProfile p : dataset.getDmp().getProfiles()) {
if (version.getId().toString().equals(p.getId().toString())) { if (version.getId().toString().equals(p.getId().toString())) {
profileVersionsIncluded.add(version); profileVersionsIncluded.add(version);
@ -315,14 +315,14 @@ public class DatasetManager {
} }
// Sort the list with the included Versions. // Sort the list with the included Versions.
Stream<DatasetProfile> sorted = profileVersionsIncluded.stream().sorted(Comparator.comparing(DatasetProfile::getVersion).reversed()); Stream<DescriptionTemplate> sorted = profileVersionsIncluded.stream().sorted(Comparator.comparing(DescriptionTemplate::getVersion).reversed());
// Make the Stream into List and get the first item. // Make the Stream into List and get the first item.
List<DatasetProfile> profiles = sorted.collect(Collectors.toList()); List<DescriptionTemplate> profiles = sorted.collect(Collectors.toList());
if (profiles.isEmpty()) if (profiles.isEmpty())
throw new NoSuchElementException("No profiles found for the specific Dataset"); throw new NoSuchElementException("No profiles found for the specific Dataset");
DatasetProfile profile = profiles.get(0); DescriptionTemplate profile = profiles.get(0);
// Check if the dataset is on the latest Version. // Check if the dataset is on the latest Version.
boolean latestVersion = profile.getVersion().toString().equals(datasetEntity.getProfile().getVersion().toString()); boolean latestVersion = profile.getVersion().toString().equals(datasetEntity.getProfile().getVersion().toString());
@ -717,7 +717,7 @@ public class DatasetManager {
public String checkDatasetValidation(Dataset dataset) throws Exception { public String checkDatasetValidation(Dataset dataset) throws Exception {
List<String> datasetProfileValidators = new LinkedList<>(); List<String> datasetProfileValidators = new LinkedList<>();
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(dataset.getProfile().getId()); DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(dataset.getProfile().getId());
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder(); DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes())); Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes()));
@ -975,9 +975,9 @@ public class DatasetManager {
// Checks if XML datasetProfileId GroupId matches the one selected. // Checks if XML datasetProfileId GroupId matches the one selected.
try { try {
eu.eudat.data.entities.DatasetProfile importDatasetProfile = databaseRepository.getDatasetProfileDao().find(UUID.fromString(importModel.getDatasetProfileId())); DescriptionTemplate importDescriptionTemplate = databaseRepository.getDatasetProfileDao().find(UUID.fromString(importModel.getDatasetProfileId()));
eu.eudat.data.entities.DatasetProfile latestVersionDatasetProfile = databaseRepository.getDatasetProfileDao().find(UUID.fromString(datasetProfileId)); DescriptionTemplate latestVersionDescriptionTemplate = databaseRepository.getDatasetProfileDao().find(UUID.fromString(datasetProfileId));
if (latestVersionDatasetProfile.getGroupId() != importDatasetProfile.getGroupId()) { if (latestVersionDescriptionTemplate.getGroupId() != importDescriptionTemplate.getGroupId()) {
throw new Exception(); throw new Exception();
} }
} catch (Exception e) { } catch (Exception e) {
@ -1010,7 +1010,7 @@ public class DatasetManager {
entity.setStatus((short) 0); entity.setStatus((short) 0);
entity.setCreated(new Date()); entity.setCreated(new Date());
entity.setModified(new Date()); entity.setModified(new Date());
DatasetProfile profile = new DatasetProfile(); DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(UUID.fromString(datasetProfileId)); profile.setId(UUID.fromString(datasetProfileId));
entity.setProfile(profile); entity.setProfile(profile);
@ -1037,7 +1037,7 @@ public class DatasetManager {
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity)); dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
dataset.fromDataModel(datasetEntity); dataset.fromDataModel(datasetEntity);
// Creates the Criteria to get all version of DatasetProfile in question. // Creates the Criteria to get all version of DescriptionTemplate in question.
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria(); DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
UUID profileId = datasetEntity.getProfile().getGroupId(); UUID profileId = datasetEntity.getProfile().getGroupId();
List<UUID> uuidList = new LinkedList<>(); List<UUID> uuidList = new LinkedList<>();
@ -1045,7 +1045,7 @@ public class DatasetManager {
profileCriteria.setGroupIds(uuidList); profileCriteria.setGroupIds(uuidList);
// Gets the latest version of the datasetProfile. // Gets the latest version of the datasetProfile.
eu.eudat.data.entities.DatasetProfile item = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria).getSingle(); DescriptionTemplate item = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria).getSingle();
// Sets the latest version of dataet Profile to the Dataset in question. // Sets the latest version of dataet Profile to the Dataset in question.
dataset.setDatasetProfileDefinition(getLatestDatasetProfile(datasetEntity, item)); dataset.setDatasetProfileDefinition(getLatestDatasetProfile(datasetEntity, item));
@ -1071,7 +1071,7 @@ public class DatasetManager {
return dataset; return dataset;
} }
public PagedDatasetProfile getLatestDatasetProfile(Dataset datasetEntity, DatasetProfile profile) { public PagedDatasetProfile getLatestDatasetProfile(Dataset datasetEntity, DescriptionTemplate profile) {
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile); eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
datasetprofile.setStatus(datasetEntity.getStatus()); datasetprofile.setStatus(datasetEntity.getStatus());
if (datasetEntity.getProperties() != null) { if (datasetEntity.getProperties() != null) {
@ -1088,7 +1088,7 @@ public class DatasetManager {
datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue()); datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue());
datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId()); datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId());
QueryableList<DatasetProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria()); QueryableList<DescriptionTemplate> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
DataTableData<DatasetProfileListingModel> data = new DataTableData<>(); DataTableData<DatasetProfileListingModel> data = new DataTableData<>();
@ -1183,10 +1183,10 @@ public class DatasetManager {
DatasetListingModel listingModel = new DatasetListingModel().fromDataModel(item); DatasetListingModel listingModel = new DatasetListingModel().fromDataModel(item);
/*DatasetProfileCriteria criteria = new DatasetProfileCriteria(); /*DatasetProfileCriteria criteria = new DatasetProfileCriteria();
criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId())); criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId()));
List<DatasetProfile> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList(); List<DescriptionTemplate> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
boolean islast = false; boolean islast = false;
if (!profiles.isEmpty()) { if (!profiles.isEmpty()) {
profiles = profiles.stream().sorted(Comparator.comparing(DatasetProfile::getVersion)).collect(Collectors.toList()); profiles = profiles.stream().sorted(Comparator.comparing(DescriptionTemplate::getVersion)).collect(Collectors.toList());
islast = profiles.get(0).getId().equals(item.getProfile().getId()); islast = profiles.get(0).getId().equals(item.getProfile().getId());
} }
listingModel.setProfileLatestVersion(islast);*/ listingModel.setProfileLatestVersion(islast);*/

View File

@ -3,7 +3,7 @@ package eu.eudat.logic.managers;
import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria; import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.UserDatasetProfile; import eu.eudat.data.entities.UserDatasetProfile;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest; import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
@ -82,11 +82,12 @@ public class DatasetProfileManager {
@Transactional @Transactional
public eu.eudat.models.data.admin.composite.DatasetProfile getDatasetProfile(String id) { public eu.eudat.models.data.admin.composite.DatasetProfile getDatasetProfile(String id) {
eu.eudat.data.entities.DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
datasetprofile.setLabel(profile.getLabel()); datasetprofile.setLabel(profile.getLabel());
datasetprofile.setStatus(profile.getStatus()); datasetprofile.setStatus(profile.getStatus());
datasetprofile.setDescription(profile.getDescription()); datasetprofile.setDescription(profile.getDescription());
datasetprofile.setType(profile.getType().getName());
datasetprofile.setLanguage(profile.getLanguage()); datasetprofile.setLanguage(profile.getLanguage());
datasetprofile.setUsers(new ArrayList<>()); datasetprofile.setUsers(new ArrayList<>());
retrieveUsers(profile, datasetprofile); retrieveUsers(profile, datasetprofile);
@ -94,35 +95,35 @@ public class DatasetProfileManager {
} }
public List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException { public List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException {
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(datasetProfileAutocompleteRequest.getCriteria()); QueryableList<DescriptionTemplate> items = databaseRepository.getDatasetProfileDao().getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
QueryableList<DatasetProfile> pagedItems = datasetProfileAutocompleteRequest.applyPaging(items); QueryableList<DescriptionTemplate> pagedItems = datasetProfileAutocompleteRequest.applyPaging(items);
List<DatasetProfileAutocompleteItem> datasetProfiles = pagedItems.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item)); List<DatasetProfileAutocompleteItem> datasetProfiles = pagedItems.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item));
return datasetProfiles; return datasetProfiles;
} }
public DatasetProfile clone(String id) { public DescriptionTemplate clone(String id) {
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile); apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile);
profile.setId(null); profile.setId(null);
return profile; return profile;
} }
public DataTableData<DatasetProfileListingModel> getPaged(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) throws Exception { public DataTableData<DatasetProfileListingModel> getPaged(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) throws Exception {
QueryableList<DatasetProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria()); QueryableList<DescriptionTemplate> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
QueryableList<DatasetProfile> authItems = null; QueryableList<DescriptionTemplate> authItems = null;
if (principal.getAuthz().contains(Authorities.ADMIN)) { if (principal.getAuthz().contains(Authorities.ADMIN)) {
authItems = items; authItems = items;
} else if (principal.getAuthz().contains(Authorities.DATASET_PROFILE_MANAGER)) { } else if (principal.getAuthz().contains(Authorities.DATASET_PROFILE_MANAGER)) {
List<Integer> roles = Arrays.asList(0, 1); List<Integer> roles = Arrays.asList(0, 1);
authItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getAuthenticated(items, principal.getId(), roles); authItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getAuthenticated(items, principal.getId(), roles);
} }
QueryableList<DatasetProfile> pagedItems = PaginationManager.applyPaging(authItems, datasetProfileTableRequestItem); QueryableList<DescriptionTemplate> pagedItems = PaginationManager.applyPaging(authItems, datasetProfileTableRequestItem);
List<DatasetProfileListingModel> datasetProfiles = pagedItems.select(item -> new DatasetProfileListingModel().fromDataModel(item)); List<DatasetProfileListingModel> datasetProfiles = pagedItems.select(item -> new DatasetProfileListingModel().fromDataModel(item));
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build(); return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build();
} }
public List<DatasetProfileListingModel> getAll(DatasetProfileTableRequestItem tableRequestItem) throws IllegalAccessException, InstantiationException { public List<DatasetProfileListingModel> getAll(DatasetProfileTableRequestItem tableRequestItem) throws IllegalAccessException, InstantiationException {
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(tableRequestItem.getCriteria()); QueryableList<DescriptionTemplate> items = databaseRepository.getDatasetProfileDao().getWithCriteria(tableRequestItem.getCriteria());
List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
return datasetProfiles; return datasetProfiles;
@ -276,36 +277,36 @@ public class DatasetProfileManager {
return convFile; return convFile;
} }
public eu.eudat.data.entities.DatasetProfile createNewVersionDatasetProfile(String id, eu.eudat.models.data.admin.composite.DatasetProfile profile) throws Exception { public DescriptionTemplate createNewVersionDatasetProfile(String id, eu.eudat.models.data.admin.composite.DatasetProfile profile) throws Exception {
// Getting the DatasetProfile which we will create its new version. // Getting the DescriptionTemplate which we will create its new version.
eu.eudat.data.entities.DatasetProfile oldDatasetProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); DescriptionTemplate oldDescriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
// Getting the DatasetProfile with the latest Version. // Getting the DescriptionTemplate with the latest Version.
DatasetProfileCriteria criteria = new DatasetProfileCriteria(); DatasetProfileCriteria criteria = new DatasetProfileCriteria();
LinkedList<UUID> list = new LinkedList<>(); LinkedList<UUID> list = new LinkedList<>();
list.push(oldDatasetProfile.getGroupId()); list.push(oldDescriptionTemplate.getGroupId());
criteria.setGroupIds(list); criteria.setGroupIds(list);
criteria.setAllVersions(false); criteria.setAllVersions(false);
QueryableList<DatasetProfile> datasetProfileQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria); QueryableList<DescriptionTemplate> datasetProfileQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria);
eu.eudat.data.entities.DatasetProfile latestVersionDatasetProfile = datasetProfileQueryableList.getSingle(); DescriptionTemplate latestVersionDescriptionTemplate = datasetProfileQueryableList.getSingle();
if (latestVersionDatasetProfile.getVersion().equals(oldDatasetProfile.getVersion())){ if (latestVersionDescriptionTemplate.getVersion().equals(oldDescriptionTemplate.getVersion())){
eu.eudat.models.data.admin.composite.DatasetProfile sortedProfile = profile.toShort(); eu.eudat.models.data.admin.composite.DatasetProfile sortedProfile = profile.toShort();
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(sortedProfile, apiContext); DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(sortedProfile, apiContext);
// modelDefinition.setLabel(oldDatasetProfile.getLabel()); // modelDefinition.setLabel(oldDescriptionTemplate.getLabel());
modelDefinition.setVersion((short) (oldDatasetProfile.getVersion() + 1)); modelDefinition.setVersion((short) (oldDescriptionTemplate.getVersion() + 1));
modelDefinition.setGroupId(oldDatasetProfile.getGroupId()); modelDefinition.setGroupId(oldDescriptionTemplate.getGroupId());
// modelDefinition.setLanguage(oldDatasetProfile.getLanguage()); // modelDefinition.setLanguage(oldDescriptionTemplate.getLanguage());
apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition); apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
eu.eudat.data.entities.DatasetProfile datasetProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition); DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
this.storeDatasetProfileUsers(datasetProfile, profile); this.storeDatasetProfileUsers(descriptionTemplate, profile);
return modelDefinition; return modelDefinition;
} else { } else {
throw new DatasetProfileNewVersionException("Version to update not the latest."); throw new DatasetProfileNewVersionException("Version to update not the latest.");
} }
} }
public void storeDatasetProfileUsers(DatasetProfile entity, eu.eudat.models.data.admin.composite.DatasetProfile model) { public void storeDatasetProfileUsers(DescriptionTemplate entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
if (model.getUsers() != null && !model.getUsers().isEmpty()) { if (model.getUsers() != null && !model.getUsers().isEmpty()) {
if (entity.getUsers() == null) { if (entity.getUsers() == null) {
entity.setUsers(new HashSet<>()); entity.setUsers(new HashSet<>());
@ -340,7 +341,7 @@ public class DatasetProfileManager {
} }
@Transactional @Transactional
public void retrieveUsers(DatasetProfile entity, eu.eudat.models.data.admin.composite.DatasetProfile model) { public void retrieveUsers(DescriptionTemplate entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
if (entity.getUsers() != null && !entity.getUsers().isEmpty()) { if (entity.getUsers() != null && !entity.getUsers().isEmpty()) {
model.setUsers(entity.getUsers().stream().filter(userDatasetProfile -> userDatasetProfile.getRole() < 2).map(userDatasetProfile -> { model.setUsers(entity.getUsers().stream().filter(userDatasetProfile -> userDatasetProfile.getRole() < 2).map(userDatasetProfile -> {
UserInfoListingModel userInfoListingModel = new UserInfoListingModel(); UserInfoListingModel userInfoListingModel = new UserInfoListingModel();
@ -381,10 +382,10 @@ public class DatasetProfileManager {
} }
public void addSemanticsInDatasetProfiles() throws XPathExpressionException { public void addSemanticsInDatasetProfiles() throws XPathExpressionException {
List<DatasetProfile> ids = this.databaseRepository.getDatasetProfileDao().getAllIds(); List<DescriptionTemplate> ids = this.databaseRepository.getDatasetProfileDao().getAllIds();
for(DatasetProfile dp: ids){ for(DescriptionTemplate dp: ids){
DatasetProfile datasetProfile = this.databaseRepository.getDatasetProfileDao().find(dp.getId()); DescriptionTemplate descriptionTemplate = this.databaseRepository.getDatasetProfileDao().find(dp.getId());
Document document = XmlBuilder.fromXml(datasetProfile.getDefinition()); Document document = XmlBuilder.fromXml(descriptionTemplate.getDefinition());
XPathFactory xpathFactory = XPathFactory.newInstance(); XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath(); XPath xpath = xpathFactory.newXPath();
XPathExpression expr = xpath.compile("//rdaCommonStandard"); XPathExpression expr = xpath.compile("//rdaCommonStandard");
@ -402,15 +403,15 @@ public class DatasetProfileManager {
fieldParent.insertBefore(schematics, rdaPropertyNode); fieldParent.insertBefore(schematics, rdaPropertyNode);
fieldParent.removeChild(rdaPropertyNode); fieldParent.removeChild(rdaPropertyNode);
} }
this.updateDatasetProfileXml(document, datasetProfile); this.updateDatasetProfileXml(document, descriptionTemplate);
} }
} }
public void addRdaInSemanticsInDatasetProfiles() throws XPathExpressionException { public void addRdaInSemanticsInDatasetProfiles() throws XPathExpressionException {
List<DatasetProfile> ids = this.databaseRepository.getDatasetProfileDao().getAllIds(); List<DescriptionTemplate> ids = this.databaseRepository.getDatasetProfileDao().getAllIds();
for(DatasetProfile dp: ids){ for(DescriptionTemplate dp: ids){
DatasetProfile datasetProfile = this.databaseRepository.getDatasetProfileDao().find(dp.getId()); DescriptionTemplate descriptionTemplate = this.databaseRepository.getDatasetProfileDao().find(dp.getId());
Document document = XmlBuilder.fromXml(datasetProfile.getDefinition()); Document document = XmlBuilder.fromXml(descriptionTemplate.getDefinition());
XPathFactory xpathFactory = XPathFactory.newInstance(); XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath(); XPath xpath = xpathFactory.newXPath();
XPathExpression expr = xpath.compile("//schematic"); XPathExpression expr = xpath.compile("//schematic");
@ -422,11 +423,11 @@ public class DatasetProfileManager {
schematicNode.setTextContent("rda." + schematicRda); schematicNode.setTextContent("rda." + schematicRda);
} }
} }
this.updateDatasetProfileXml(document, datasetProfile); this.updateDatasetProfileXml(document, descriptionTemplate);
} }
} }
private void updateDatasetProfileXml(Document document, DatasetProfile datasetProfile) { private void updateDatasetProfileXml(Document document, DescriptionTemplate descriptionTemplate) {
try { try {
DOMSource domSource = new DOMSource(document); DOMSource domSource = new DOMSource(document);
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
@ -437,8 +438,8 @@ public class DatasetProfileManager {
transformer.transform(domSource, result); transformer.transform(domSource, result);
String newDefinition = writer.toString(); String newDefinition = writer.toString();
if(newDefinition != null){ if(newDefinition != null){
datasetProfile.setDefinition(newDefinition); descriptionTemplate.setDefinition(newDefinition);
this.databaseRepository.getDatasetProfileDao().createOrUpdate(datasetProfile); this.databaseRepository.getDatasetProfileDao().createOrUpdate(descriptionTemplate);
} }
} }
catch(TransformerException ex) { catch(TransformerException ex) {

View File

@ -5,7 +5,7 @@ import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.dao.entities.DatasetProfileDao; import eu.eudat.data.dao.entities.DatasetProfileDao;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest; import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest; import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
@ -40,12 +40,12 @@ public class DatasetWizardManager {
return new LinkedList<>(); return new LinkedList<>();
} }
DatasetProfileCriteria criteria = new DatasetProfileCriteria(); DatasetProfileCriteria criteria = new DatasetProfileCriteria();
criteria.setIds(dataManagementPlan.getProfiles().stream().map(AssociatedProfile::getId).collect(Collectors.toList())); criteria.setIds(dataManagementPlan.getProfiles().stream().map(AssociatedProfile::getDescriptionTemplateId).collect(Collectors.toList()));
List<DatasetProfile> datasetProfiles = profileDao.getWithCriteria(criteria).toList(); List<DescriptionTemplate> descriptionTemplates = profileDao.getWithCriteria(criteria).toList();
criteria.setIds(null); criteria.setIds(null);
criteria.setGroupIds(datasetProfiles.stream().map(DatasetProfile::getGroupId).collect(Collectors.toList())); criteria.setGroupIds(descriptionTemplates.stream().map(DescriptionTemplate::getGroupId).collect(Collectors.toList()));
datasetProfiles = profileDao.getWithCriteria(criteria).toList(); descriptionTemplates = profileDao.getWithCriteria(criteria).toList();
List<AssociatedProfile> profiles = datasetProfiles.stream().map(profile -> new AssociatedProfile().fromData(profile)).collect(Collectors.toList()); List<AssociatedProfile> profiles = descriptionTemplates.stream().map(profile -> new AssociatedProfile().fromData(profile)).collect(Collectors.toList());
return profiles; return profiles;
} }

View File

@ -0,0 +1,84 @@
package eu.eudat.logic.managers;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.exceptions.descriptiontemplate.DescriptionTemplatesWithTypeException;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.descriptiontemplatetype.DescriptionTemplateTypeModel;
import eu.eudat.models.data.helpers.common.DataTableData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Component
public class DescriptionTemplateTypeManager {
private static final Logger logger = LoggerFactory.getLogger(DescriptionTemplateTypeManager.class);
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
@Autowired
public DescriptionTemplateTypeManager(ApiContext apiContext, DatabaseRepository databaseRepository) {
this.apiContext = apiContext;
this.databaseRepository = databaseRepository;
}
public DataTableData<DescriptionTemplateTypeModel> get() {
List<DescriptionTemplateType> types = this.databaseRepository.getDescriptionTemplateTypeDao().asQueryable().toList();
List<DescriptionTemplateTypeModel> typesModelList = types.stream().map(type -> new DescriptionTemplateTypeModel().fromDataModel(type)).collect(Collectors.toList());
DataTableData<DescriptionTemplateTypeModel> dataTableData = new DataTableData<>();
dataTableData.setData(typesModelList);
dataTableData.setTotalCount((long) typesModelList.size());
return dataTableData;
}
public DescriptionTemplateTypeModel getSingle(UUID id) throws Exception {
DescriptionTemplateType type = this.databaseRepository.getDescriptionTemplateTypeDao().find(id);
if (type != null) {
return new DescriptionTemplateTypeModel().fromDataModel(type);
}
else {
throw new DescriptionTemplatesWithTypeException("No description template type found with this id");
}
}
public void create(DescriptionTemplateTypeModel type) throws Exception {
DescriptionTemplateType existed = this.databaseRepository.getDescriptionTemplateTypeDao().findFromName(type.getName());
if (existed == null) {
this.databaseRepository.getDescriptionTemplateTypeDao().createOrUpdate(type.toDataModel());
}
else {
throw new DescriptionTemplatesWithTypeException("There is already a description template type with that name.");
}
}
public void update(DescriptionTemplateTypeModel type) throws Exception {
DescriptionTemplateType existed = this.databaseRepository.getDescriptionTemplateTypeDao().findFromName(type.getName());
if (existed != null) {
this.databaseRepository.getDescriptionTemplateTypeDao().createOrUpdate(type.toDataModel());
}
else {
throw new DescriptionTemplatesWithTypeException("No description template type found.");
}
}
public void delete(UUID id) throws DescriptionTemplatesWithTypeException {
DescriptionTemplateType type = this.databaseRepository.getDescriptionTemplateTypeDao().find(id);
if (type != null) {
Long descriptionsWithType = this.databaseRepository.getDatasetProfileDao().countWithType(type);
if(descriptionsWithType == 0) {
type.setStatus(DescriptionTemplateType.Status.DELETED.getValue());
this.databaseRepository.getDescriptionTemplateTypeDao().createOrUpdate(type);
}
else{
throw new DescriptionTemplatesWithTypeException("This type can not deleted, because Descriptions are associated with it");
}
}
}
}

View File

@ -1,7 +1,7 @@
package eu.eudat.logic.managers; package eu.eudat.logic.managers;
import eu.eudat.data.dao.criteria.*; import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.types.MetricNames; import eu.eudat.types.MetricNames;
import io.micrometer.prometheus.PrometheusMeterRegistry; import io.micrometer.prometheus.PrometheusMeterRegistry;
@ -33,8 +33,8 @@ public class MetricsManager {
private final Map<String, Gauge> gauges; private final Map<String, Gauge> gauges;
public static final Map<Short, String> datasetTemplateStatus = Stream.of(new Object[][] { public static final Map<Short, String> datasetTemplateStatus = Stream.of(new Object[][] {
{ DatasetProfile.Status.SAVED.getValue(), MetricNames.DRAFT }, { DescriptionTemplate.Status.SAVED.getValue(), MetricNames.DRAFT },
{ DatasetProfile.Status.FINALIZED.getValue(), MetricNames.ACTIVE }, { DescriptionTemplate.Status.FINALIZED.getValue(), MetricNames.ACTIVE },
}).collect(Collectors.toMap(data -> (Short) data[0], data -> (String) data[1])); }).collect(Collectors.toMap(data -> (Short) data[0], data -> (String) data[1]));
public void increaseValue(String name, int amount, String label) { public void increaseValue(String name, int amount, String label) {
@ -406,9 +406,9 @@ public class MetricsManager {
criteria.setStatus(1); criteria.setStatus(1);
criteria.setAllVersions(false); criteria.setAllVersions(false);
if (countNexus) criteria.setPeriodStart(getNexusDate()); if (countNexus) criteria.setPeriodStart(getNexusDate());
List<DatasetProfile> datasetProfiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList(); List<DescriptionTemplate> descriptionTemplates = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList();
DatasetCriteria datasetCriteria = new DatasetCriteria(); DatasetCriteria datasetCriteria = new DatasetCriteria();
datasetCriteria.setDatasetTemplates(datasetProfiles.stream().map(DatasetProfile::getId).collect(Collectors.toList())); datasetCriteria.setDatasetTemplates(descriptionTemplates.stream().map(DescriptionTemplate::getId).collect(Collectors.toList()));
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getProfile().getId()).stream().distinct().count(); return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getProfile().getId()).stream().distinct().count();
} }

View File

@ -2,7 +2,7 @@ package eu.eudat.logic.managers;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.mapper.prefilling.PrefillingMapper; import eu.eudat.logic.mapper.prefilling.PrefillingMapper;
import eu.eudat.logic.proxy.config.ExternalUrlCriteria; import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
@ -61,8 +61,8 @@ public class PrefillingManager {
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId); PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet(); PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId); Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId);
DatasetProfile datasetProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId); DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
return PrefillingMapper.mapPrefilledEntityToDatasetWizard(prefillingEntity, prefillingGet, prefillingConfig.getType(), datasetProfile, datasetManager, licenseManager); return PrefillingMapper.mapPrefilledEntityToDatasetWizard(prefillingEntity, prefillingGet, prefillingConfig.getType(), descriptionTemplate, datasetManager, licenseManager);
} }
public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> data, String configId, UUID profileId) throws Exception { public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> data, String configId, UUID profileId) throws Exception {

View File

@ -3,13 +3,8 @@ package eu.eudat.logic.managers;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria; import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.entities.UserInfoDao; import eu.eudat.data.dao.entities.UserInfoDao;
import eu.eudat.data.entities.Credential; import eu.eudat.data.entities.*;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.entities.UserRole;
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem; import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
import eu.eudat.exceptions.security.ExpiredTokenException;
import eu.eudat.exceptions.security.NonValidTokenException;
import eu.eudat.exceptions.security.NullEmailException; import eu.eudat.exceptions.security.NullEmailException;
import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.builders.entity.UserRoleBuilder; import eu.eudat.logic.builders.entity.UserRoleBuilder;
@ -72,7 +67,7 @@ public class UserManager {
this.environment = environment; this.environment = environment;
} }
public eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) { public eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplate profile) {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition()); Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = (Element) viewStyleDoc.getDocumentElement(); Element root = (Element) viewStyleDoc.getDocumentElement();
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root); eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);

View File

@ -1,14 +1,26 @@
package eu.eudat.logic.mapper.elastic; package eu.eudat.logic.mapper.elastic;
import eu.eudat.data.entities.DatasetProfile; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.DMPDatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.elastic.entities.DatasetTempalate; import eu.eudat.elastic.entities.DatasetTempalate;
import java.util.HashMap;
import java.util.Map;
public class DatasetTemplateMapper { public class DatasetTemplateMapper {
public static DatasetTempalate toElastic(DatasetProfile profile) { public static DatasetTempalate toElastic(DMPDatasetProfile profile) {
DatasetTempalate elastic = new DatasetTempalate(); DatasetTempalate elastic = new DatasetTempalate();
elastic.setId(profile.getId()); elastic.setId(profile.getDatasetprofile().getId());
elastic.setName(profile.getLabel()); elastic.setName(profile.getDatasetprofile().getLabel());
try {
elastic.setData(new ObjectMapper().readValue(profile.getData(), new TypeReference<Map<String, Object>>() {}));
}
catch (Exception e){
elastic.setData(new HashMap<>());
}
return elastic; return elastic;
} }
} }

View File

@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.elastic.entities.Tag; import eu.eudat.elastic.entities.Tag;
import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.managers.DatasetProfileManager; import eu.eudat.logic.managers.DatasetProfileManager;
@ -40,7 +40,7 @@ public class PrefillingMapper {
private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
public static DatasetWizardModel mapPrefilledEntityToDatasetWizard(Map<String, Object> prefilledEntity, PrefillingGet prefillingGet, String type, public static DatasetWizardModel mapPrefilledEntityToDatasetWizard(Map<String, Object> prefilledEntity, PrefillingGet prefillingGet, String type,
DatasetProfile profile, DatasetManager datasetManager, LicenseManager licenseManager) throws Exception { DescriptionTemplate profile, DatasetManager datasetManager, LicenseManager licenseManager) throws Exception {
DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile)); datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
Dataset dataset = new Dataset(); Dataset dataset = new Dataset();

View File

@ -14,6 +14,8 @@ public interface DatabaseRepository {
DMPDao getDmpDao(); DMPDao getDmpDao();
DmpDatasetProfileDao getDmpDatasetProfileDao();
OrganisationDao getOrganisationDao(); OrganisationDao getOrganisationDao();
GrantDao getGrantDao(); GrantDao getGrantDao();
@ -62,5 +64,7 @@ public interface DatabaseRepository {
EntityDoiDao getEntityDoiDao(); EntityDoiDao getEntityDoiDao();
DescriptionTemplateTypeDao getDescriptionTemplateTypeDao();
<T> void detachEntity(T entity); <T> void detachEntity(T entity);
} }

View File

@ -16,6 +16,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
private DatasetDao datasetDao; private DatasetDao datasetDao;
private DatasetProfileDao datasetProfileDao; private DatasetProfileDao datasetProfileDao;
private DMPDao dmpDao; private DMPDao dmpDao;
private DmpDatasetProfileDao dmpDatasetProfileDao;
private OrganisationDao organisationDao; private OrganisationDao organisationDao;
private GrantDao GrantDao; private GrantDao GrantDao;
private RegistryDao registryDao; private RegistryDao registryDao;
@ -40,6 +41,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
private NotificationDao notificationDao; private NotificationDao notificationDao;
private FileUploadDao fileUploadDao; private FileUploadDao fileUploadDao;
private EntityDoiDao entityDoiDao; private EntityDoiDao entityDoiDao;
private DescriptionTemplateTypeDao descriptionTemplateTypeDao;
private EntityManager entityManager; private EntityManager entityManager;
@ -63,6 +65,11 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
this.dmpDao = dmpDao; this.dmpDao = dmpDao;
} }
@Autowired
private void setDmpDatasetProfileDao(DmpDatasetProfileDao dmpDatasetProfileDao) {
this.dmpDatasetProfileDao = dmpDatasetProfileDao;
}
@Autowired @Autowired
private void setOrganisationDao(OrganisationDao organisationDao) { private void setOrganisationDao(OrganisationDao organisationDao) {
this.organisationDao = organisationDao; this.organisationDao = organisationDao;
@ -113,6 +120,11 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
return dmpDao; return dmpDao;
} }
@Override
public DmpDatasetProfileDao getDmpDatasetProfileDao() {
return dmpDatasetProfileDao;
}
@Override @Override
public OrganisationDao getOrganisationDao() { public OrganisationDao getOrganisationDao() {
return organisationDao; return organisationDao;
@ -328,6 +340,16 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
this.entityDoiDao = entityDoiDao; this.entityDoiDao = entityDoiDao;
} }
@Override
public DescriptionTemplateTypeDao getDescriptionTemplateTypeDao() {
return descriptionTemplateTypeDao;
}
@Autowired
public void setDescriptionTemplateTypeDao(DescriptionTemplateTypeDao descriptionTemplateTypeDao) {
this.descriptionTemplateTypeDao = descriptionTemplateTypeDao;
}
public <T> void detachEntity(T entity) { public <T> void detachEntity(T entity) {
this.entityManager.detach(entity); this.entityManager.detach(entity);
} }

View File

@ -1,6 +1,8 @@
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel; package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
import eu.eudat.data.entities.DescriptionTemplate;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -45,7 +47,7 @@ public class DatasetProfile {
public eu.eudat.models.data.admin.composite.DatasetProfile toAdminCompositeModel(String label){ public eu.eudat.models.data.admin.composite.DatasetProfile toAdminCompositeModel(String label){
eu.eudat.models.data.admin.composite.DatasetProfile newDatasetEntityProfile = new eu.eudat.models.data.admin.composite.DatasetProfile(); eu.eudat.models.data.admin.composite.DatasetProfile newDatasetEntityProfile = new eu.eudat.models.data.admin.composite.DatasetProfile();
newDatasetEntityProfile.setLabel(label); newDatasetEntityProfile.setLabel(label);
newDatasetEntityProfile.setStatus(eu.eudat.data.entities.DatasetProfile.Status.SAVED.getValue()); newDatasetEntityProfile.setStatus(DescriptionTemplate.Status.SAVED.getValue());
newDatasetEntityProfile.setDescription(description); newDatasetEntityProfile.setDescription(description);
newDatasetEntityProfile.setLanguage(language); newDatasetEntityProfile.setLanguage(language);
List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>(); List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>();

View File

@ -13,6 +13,7 @@ import java.util.List;
public class DatasetProfile { public class DatasetProfile {
private String label; private String label;
private String description; private String description;
private String type;
private List<Page> pages; private List<Page> pages;
private List<Section> sections; private List<Section> sections;
private Short status; private Short status;
@ -35,6 +36,13 @@ public class DatasetProfile {
this.description = description; this.description = description;
} }
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<Page> getPages() { public List<Page> getPages() {
return pages; return pages;
} }
@ -80,6 +88,7 @@ public class DatasetProfile {
DatasetProfile shortProfile = new DatasetProfile(); DatasetProfile shortProfile = new DatasetProfile();
shortProfile.setLabel(this.label); shortProfile.setLabel(this.label);
shortProfile.setDescription(this.description); shortProfile.setDescription(this.description);
shortProfile.setType(this.type);
List<Section> shortSection = new LinkedList<>(); List<Section> shortSection = new LinkedList<>();
for (Section toshortSection : this.getSections()) { for (Section toshortSection : this.getSections()) {
shortSection.add(toshortSection.toShort()); shortSection.add(toshortSection.toShort());

View File

@ -1,12 +1,12 @@
package eu.eudat.models.data.datasetprofile; package eu.eudat.models.data.datasetprofile;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import java.util.UUID; import java.util.UUID;
public class DatasetProfileAutocompleteItem implements DataModel<DatasetProfile, DatasetProfileAutocompleteItem> { public class DatasetProfileAutocompleteItem implements DataModel<DescriptionTemplate, DatasetProfileAutocompleteItem> {
private UUID id; private UUID id;
private String label; private String label;
@ -34,7 +34,7 @@ public class DatasetProfileAutocompleteItem implements DataModel<DatasetProfile,
} }
@Override @Override
public DatasetProfileAutocompleteItem fromDataModel(DatasetProfile entity) { public DatasetProfileAutocompleteItem fromDataModel(DescriptionTemplate entity) {
this.id = entity.getId(); this.id = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
this.description = entity.getDescription(); this.description = entity.getDescription();
@ -42,8 +42,8 @@ public class DatasetProfileAutocompleteItem implements DataModel<DatasetProfile,
} }
@Override @Override
public DatasetProfile toDataModel() { public DescriptionTemplate toDataModel() {
DatasetProfile profile = new DatasetProfile(); DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(this.id); profile.setId(this.id);
return profile; return profile;
} }

View File

@ -1,12 +1,12 @@
package eu.eudat.models.data.datasetprofile; package eu.eudat.models.data.datasetprofile;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
public class DatasetProfileListingModel implements DataModel<DatasetProfile, DatasetProfileListingModel> { public class DatasetProfileListingModel implements DataModel<DescriptionTemplate, DatasetProfileListingModel> {
private UUID id; private UUID id;
private String label; private String label;
@ -66,7 +66,7 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile, Dat
public void setGroupId(UUID groupId) { this.groupId = groupId; } public void setGroupId(UUID groupId) { this.groupId = groupId; }
@Override @Override
public DatasetProfileListingModel fromDataModel(DatasetProfile entity) { public DatasetProfileListingModel fromDataModel(DescriptionTemplate entity) {
this.id = entity.getId(); this.id = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
this.status = entity.getStatus(); this.status = entity.getStatus();
@ -79,8 +79,8 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile, Dat
} }
@Override @Override
public DatasetProfile toDataModel() { public DescriptionTemplate toDataModel() {
DatasetProfile profile = new DatasetProfile(); DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(this.id); profile.setId(this.id);
return profile; return profile;
} }

View File

@ -1,11 +1,11 @@
package eu.eudat.models.data.datasetprofile; package eu.eudat.models.data.datasetprofile;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import java.util.UUID; import java.util.UUID;
public class DatasetProfileOverviewModel implements DataModel<DatasetProfile, DatasetProfileOverviewModel> { public class DatasetProfileOverviewModel implements DataModel<DescriptionTemplate, DatasetProfileOverviewModel> {
private UUID id; private UUID id;
private String label; private String label;
@ -24,15 +24,15 @@ public class DatasetProfileOverviewModel implements DataModel<DatasetProfile, Da
} }
@Override @Override
public DatasetProfileOverviewModel fromDataModel(DatasetProfile entity) { public DatasetProfileOverviewModel fromDataModel(DescriptionTemplate entity) {
this.id = entity.getId(); this.id = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
return this; return this;
} }
@Override @Override
public DatasetProfile toDataModel() { public DescriptionTemplate toDataModel() {
DatasetProfile entity = new DatasetProfile(); DescriptionTemplate entity = new DescriptionTemplate();
entity.setId(this.getId()); entity.setId(this.getId());
entity.setLabel(this.getLabel()); entity.setLabel(this.getLabel());
return entity; return entity;

View File

@ -26,6 +26,7 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
private short status; private short status;
private Date created; private Date created;
private DataManagementPlan dmp; private DataManagementPlan dmp;
private Integer dmpSectionIndex;
private PagedDatasetProfile datasetProfileDefinition; private PagedDatasetProfile datasetProfileDefinition;
private List<Registry> registries; private List<Registry> registries;
private List<Service> services; private List<Service> services;
@ -92,6 +93,13 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
this.dmp = dmp; this.dmp = dmp;
} }
public Integer getDmpSectionIndex() {
return dmpSectionIndex;
}
public void setDmpSectionIndex(Integer dmpSectionIndex) {
this.dmpSectionIndex = dmpSectionIndex;
}
public PagedDatasetProfile getDatasetProfileDefinition() { public PagedDatasetProfile getDatasetProfileDefinition() {
return datasetProfileDefinition; return datasetProfileDefinition;
} }
@ -179,6 +187,7 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>(); this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
this.created = entity.getCreated(); this.created = entity.getCreated();
this.dmp = new DataManagementPlan().fromDataModelNoDatasets(entity.getDmp()); this.dmp = new DataManagementPlan().fromDataModelNoDatasets(entity.getDmp());
this.dmpSectionIndex = entity.getDmpSectionIndex();
this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> { this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset()); ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset());
if (item.getData() != null) { if (item.getData() != null) {
@ -202,6 +211,7 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
this.profile = new DatasetProfileOverviewModel(); this.profile = new DatasetProfileOverviewModel();
this.profile = this.profile.fromDataModel(entity.getProfile()); this.profile = this.profile.fromDataModel(entity.getProfile());
this.uri = entity.getUri(); this.uri = entity.getUri();
this.dmpSectionIndex = entity.getDmpSectionIndex();
this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>(); this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> { this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
DataRepository dataRepository = new DataRepository().fromDataModel(item.getDataRepository()); DataRepository dataRepository = new DataRepository().fromDataModel(item.getDataRepository());
@ -241,10 +251,11 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
DMP dmp = new DMP(); DMP dmp = new DMP();
dmp.setId(this.dmp.getId()); dmp.setId(this.dmp.getId());
entity.setDmp(dmp); entity.setDmp(dmp);
entity.setDmpSectionIndex(this.dmpSectionIndex);
entity.setDescription(this.description); entity.setDescription(this.description);
entity.setCreated(this.created != null ? this.created : new Date()); entity.setCreated(this.created != null ? this.created : new Date());
entity.setModified(new Date()); entity.setModified(new Date());
DatasetProfile profile = new DatasetProfile(); DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(this.profile.getId()); profile.setId(this.profile.getId());
entity.setProfile(profile); entity.setProfile(profile);
if (this.registries != null && !this.registries.isEmpty()) { if (this.registries != null && !this.registries.isEmpty()) {

View File

@ -0,0 +1,56 @@
package eu.eudat.models.data.descriptiontemplatetype;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.models.DataModel;
import java.util.UUID;
public class DescriptionTemplateTypeModel implements DataModel<DescriptionTemplateType, DescriptionTemplateTypeModel> {
private UUID id;
private String name;
private short status;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public short getStatus() {
return status;
}
public void setStatus(short status) {
this.status = status;
}
@Override
public DescriptionTemplateTypeModel fromDataModel(DescriptionTemplateType entity) {
this.id = entity.getId();
this.name = entity.getName();
this.status = entity.getStatus();
return this;
}
@Override
public DescriptionTemplateType toDataModel() throws Exception {
DescriptionTemplateType descriptionTemplateType = new DescriptionTemplateType();
descriptionTemplateType.setId(this.id);
descriptionTemplateType.setName(this.name);
descriptionTemplateType.setStatus(this.status);
return descriptionTemplateType;
}
@Override
public String getHint() {
return null;
}
}

View File

@ -1,16 +1,19 @@
package eu.eudat.models.data.dmp; package eu.eudat.models.data.dmp;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.utilities.interfaces.XmlSerializable; import eu.eudat.logic.utilities.interfaces.XmlSerializable;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class AssociatedProfile implements XmlSerializable<AssociatedProfile> { public class AssociatedProfile implements XmlSerializable<AssociatedProfile> {
private UUID id; private UUID id;
private UUID descriptionTemplateId;
private String label; private String label;
private Map<String, Object> data;
public UUID getId() { public UUID getId() {
return id; return id;
@ -20,6 +23,14 @@ public class AssociatedProfile implements XmlSerializable<AssociatedProfile> {
this.id = id; this.id = id;
} }
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
}
public String getLabel() { public String getLabel() {
return label; return label;
} }
@ -28,30 +39,38 @@ public class AssociatedProfile implements XmlSerializable<AssociatedProfile> {
this.label = label; this.label = label;
} }
public Map<String, Object> getData() {
return data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
@Override @Override
public Element toXml(Document doc) { public Element toXml(Document doc) {
Element profile = doc.createElement("profile"); Element profile = doc.createElement("profile");
profile.setAttribute("profileId", this.id.toString()); profile.setAttribute("profileId", this.descriptionTemplateId.toString());
profile.setAttribute("label", this.label); profile.setAttribute("label", this.label);
return profile; return profile;
} }
@Override @Override
public AssociatedProfile fromXml(Element item) { public AssociatedProfile fromXml(Element item) {
this.id = UUID.fromString(item.getAttribute("profileId")); this.descriptionTemplateId = UUID.fromString(item.getAttribute("profileId"));
this.label = item.getAttribute("label"); this.label = item.getAttribute("label");
return this; return this;
} }
public DatasetProfile toData() { public DescriptionTemplate toData() {
DatasetProfile profile = new DatasetProfile(); DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(this.id); profile.setId(this.descriptionTemplateId);
profile.setLabel(this.label); profile.setLabel(this.label);
return profile; return profile;
} }
public AssociatedProfile fromData(DatasetProfile entity) { public AssociatedProfile fromData(DescriptionTemplate entity) {
this.id = entity.getId(); this.descriptionTemplateId = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
return this; return this;
} }

View File

@ -1,5 +1,7 @@
package eu.eudat.models.data.dmp; package eu.eudat.models.data.dmp;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.*; import eu.eudat.data.entities.*;
import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
@ -9,7 +11,6 @@ import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile; import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
import eu.eudat.models.data.funder.Funder; import eu.eudat.models.data.funder.Funder;
import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.listingmodels.DatasetListingModel;
import eu.eudat.models.data.listingmodels.UserInfoListingModel; import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.grant.Grant; import eu.eudat.models.data.grant.Grant;
import eu.eudat.models.data.project.Project; import eu.eudat.models.data.project.Project;
@ -259,8 +260,15 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) { if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
this.profiles = new LinkedList<>(); this.profiles = new LinkedList<>();
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) { for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile); AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
associatedProfile.setId(dmpDescriptionProfile.getId());
try {
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
}
catch (Exception e) {
associatedProfile.setData(null);
}
this.profiles.add(associatedProfile); this.profiles.add(associatedProfile);
} }
} }
@ -321,11 +329,16 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
dataManagementPlanEntity.setProject(this.project.toDataModel()); dataManagementPlanEntity.setProject(this.project.toDataModel());
} }
if (this.profiles != null) { if (this.profiles != null) {
Set<DatasetProfile> datasetProfiles = new HashSet<>(); Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
for (AssociatedProfile profile : this.profiles) { for (AssociatedProfile profile : this.profiles) {
datasetProfiles.add(profile.toData()); DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
dmpDatasetProfile.setId(profile.getId());
dmpDatasetProfile.setDmp(dataManagementPlanEntity);
dmpDatasetProfile.setDatasetprofile(profile.toData());
dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
dmpDatasetProfiles.add(dmpDatasetProfile);
} }
dataManagementPlanEntity.setAssociatedDmps(datasetProfiles); dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles);
} }
dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null); dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID()); dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
@ -366,8 +379,15 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) { if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
this.profiles = new LinkedList<>(); this.profiles = new LinkedList<>();
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) { for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile); AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
associatedProfile.setId(dmpDescriptionProfile.getId());
try {
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
}
catch (Exception e) {
associatedProfile.setData(null);
}
this.profiles.add(associatedProfile); this.profiles.add(associatedProfile);
} }
} }

View File

@ -1,5 +1,7 @@
package eu.eudat.models.data.dmp; package eu.eudat.models.data.dmp;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.*; import eu.eudat.data.entities.*;
import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
@ -8,7 +10,6 @@ import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile; import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
import eu.eudat.models.data.funder.FunderDMPEditorModel; import eu.eudat.models.data.funder.FunderDMPEditorModel;
import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.listingmodels.DatasetListingModel;
import eu.eudat.models.data.listingmodels.UserInfoListingModel; import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.grant.GrantDMPEditorModel; import eu.eudat.models.data.grant.GrantDMPEditorModel;
import eu.eudat.models.data.project.ProjectDMPEditorModel; import eu.eudat.models.data.project.ProjectDMPEditorModel;
@ -250,8 +251,14 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) { if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
this.profiles = new LinkedList<>(); this.profiles = new LinkedList<>();
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) { for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile); AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
try {
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
}
catch (Exception e) {
associatedProfile.setData(null);
}
this.profiles.add(associatedProfile); this.profiles.add(associatedProfile);
} }
} }
@ -359,11 +366,16 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
} }
dataManagementPlanEntity.setDescription(this.description); dataManagementPlanEntity.setDescription(this.description);
if (this.profiles != null) { if (this.profiles != null) {
Set<DatasetProfile> datasetProfiles = new HashSet<>(); Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
for (AssociatedProfile profile : this.profiles) { for (AssociatedProfile profile : this.profiles) {
datasetProfiles.add(profile.toData()); DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
dmpDatasetProfile.setId(profile.getId());
dmpDatasetProfile.setDmp(dataManagementPlanEntity);
dmpDatasetProfile.setDatasetprofile(profile.toData());
dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
dmpDatasetProfiles.add(dmpDatasetProfile);
} }
dataManagementPlanEntity.setAssociatedDmps(datasetProfiles); dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles);
} }
dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null); dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID()); dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());

View File

@ -1,5 +1,6 @@
package eu.eudat.models.data.dmp; package eu.eudat.models.data.dmp;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.*; import eu.eudat.data.entities.*;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.dataset.Dataset; import eu.eudat.models.data.dataset.Dataset;
@ -260,8 +261,18 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
} }
entity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null); entity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
if (this.profiles != null) if (this.profiles != null) {
entity.setAssociatedDmps(this.profiles.stream().map(x -> x.toData()).collect(Collectors.toSet())); Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
for (AssociatedProfile profile : this.profiles) {
DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
dmpDatasetProfile.setId(profile.getId());
dmpDatasetProfile.setDmp(entity);
dmpDatasetProfile.setDatasetprofile(profile.toData());
dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
dmpDatasetProfiles.add(dmpDatasetProfile);
}
entity.setAssociatedDmps(dmpDatasetProfiles);
}
return entity; return entity;
} }

View File

@ -0,0 +1,50 @@
package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.LinkedList;
import java.util.List;
public class DataManagementPlanBlueprint implements XmlSerializable<DataManagementPlanBlueprint> {
private List<Section> sections;
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("root");
Element sections = doc.createElement("sections");
for (Section section : this.sections) {
sections.appendChild(section.toXml(doc));
}
root.appendChild(sections);
return root;
}
@Override
public DataManagementPlanBlueprint fromXml(Element item) {
this.sections = new LinkedList<>();
Element sections = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "sections");
if (sections != null) {
NodeList sectionElements = sections.getChildNodes();
for (int temp = 0; temp < sectionElements.getLength(); temp++) {
Node sectionElement = sectionElements.item(temp);
if (sectionElement.getNodeType() == Node.ELEMENT_NODE) {
this.sections.add(new Section().fromXml((Element) sectionElement));
}
}
}
return this;
}
}

View File

@ -0,0 +1,72 @@
package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition;
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.UUID;
public class DescriptionTemplate implements XmlSerializable<DescriptionTemplate> {
private UUID id;
private UUID descriptionTemplateId;
private String label;
private Integer minMultiplicity;
private Integer maxMultiplicity;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Integer getMinMultiplicity() {
return minMultiplicity;
}
public void setMinMultiplicity(Integer minMultiplicity) {
this.minMultiplicity = minMultiplicity;
}
public Integer getMaxMultiplicity() {
return maxMultiplicity;
}
public void setMaxMultiplicity(Integer maxMultiplicity) {
this.maxMultiplicity = maxMultiplicity;
}
@Override
public Element toXml(Document doc) {
Element rootElement = doc.createElement("descriptionTemplate");
rootElement.setAttribute("id", this.getId().toString());
rootElement.setAttribute("descriptionTemplateId", this.getDescriptionTemplateId().toString());
rootElement.setAttribute("label", this.label);
rootElement.setAttribute("minMultiplicity", String.valueOf(this.minMultiplicity));
rootElement.setAttribute("maxMultiplicity", String.valueOf(this.maxMultiplicity));
return rootElement;
}
@Override
public DescriptionTemplate fromXml(Element item) {
this.id = UUID.fromString(item.getAttribute("id"));
this.descriptionTemplateId = UUID.fromString(item.getAttribute("descriptionTemplateId"));
this.label = item.getAttribute("label");
this.minMultiplicity = Integer.valueOf(item.getAttribute("minMultiplicity"));
this.maxMultiplicity = Integer.valueOf(item.getAttribute("maxMultiplicity"));
return this;
}
}

View File

@ -0,0 +1,93 @@
package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition;
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.ExtraFieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.UUID;
public class ExtraField implements XmlSerializable<ExtraField> {
private UUID id;
private String label;
private String description;
private String placeholder;
private ExtraFieldType type;
private Boolean required;
private Integer ordinal;
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 String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPlaceholder() {
return placeholder;
}
public void setPlaceholder(String placeholder) {
this.placeholder = placeholder;
}
public ExtraFieldType getType() {
return type;
}
public void setType(ExtraFieldType type) {
this.type = type;
}
public Boolean getRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
public Integer getOrdinal() {
return ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
@Override
public Element toXml(Document doc) {
Element rootElement = doc.createElement("extraField");
rootElement.setAttribute("id", this.getId().toString());
rootElement.setAttribute("label", this.label);
rootElement.setAttribute("description", this.description);
rootElement.setAttribute("placeholder", this.placeholder);
rootElement.setAttribute("type", String.valueOf(this.type.getValue()));
rootElement.setAttribute("required", String.valueOf(this.required));
rootElement.setAttribute("ordinal", String.valueOf(this.ordinal));
return rootElement;
}
@Override
public ExtraField fromXml(Element item) {
this.id = UUID.fromString(item.getAttribute("id"));
this.label = item.getAttribute("label");
this.description = item.getAttribute("description");
this.placeholder = item.getAttribute("placeholder");
this.type = ExtraFieldType.fromInteger(Integer.parseInt(item.getAttribute("type")));
this.required = Boolean.parseBoolean(item.getAttribute("required"));
this.ordinal = Integer.valueOf(item.getAttribute("ordinal"));
return this;
}
}

View File

@ -0,0 +1,127 @@
package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.ExtraFieldType;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType;
import java.util.UUID;
public class FieldModel {
private UUID id;
private FieldCategory category;
private Integer type;
private String label;
private String placeholder;
private String description;
private Integer ordinal;
private boolean required;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public FieldCategory getCategory() {
return category;
}
public void setCategory(FieldCategory category) {
this.category = category;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getPlaceholder() {
return placeholder;
}
public void setPlaceholder(String placeholder) {
this.placeholder = placeholder;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getOrdinal() {
return ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public boolean isRequired() {
return required;
}
public void setRequired(boolean required) {
this.required = required;
}
public SystemField toSystemField(){
SystemField systemField = new SystemField();
if (this.category == FieldCategory.SYSTEM) {
systemField.setId(this.id);
systemField.setType(SystemFieldType.fromInteger(this.type));
systemField.setLabel(this.label);
systemField.setPlaceholder(this.placeholder);
systemField.setDescription(this.description);
systemField.setOrdinal(this.ordinal);
systemField.setRequired(this.required);
}
return systemField;
}
public FieldModel fromSystemField(SystemField systemField){
this.setId(systemField.getId());
this.setCategory(FieldCategory.SYSTEM);
this.setType(systemField.getType().getType());
this.setLabel(systemField.getLabel());
this.setPlaceholder(systemField.getPlaceholder());
this.setDescription(systemField.getDescription());
this.setOrdinal(systemField.getOrdinal());
this.setRequired(systemField.isRequired());
return this;
}
public ExtraField toExtraField(){
ExtraField extraField = new ExtraField();
if (this.category == FieldCategory.EXTRA) {
extraField.setId(this.id);
extraField.setType(ExtraFieldType.fromInteger(this.type));
extraField.setLabel(this.label);
extraField.setPlaceholder(this.placeholder);
extraField.setDescription(this.description);
extraField.setOrdinal(this.ordinal);
extraField.setRequired(this.required);
}
return extraField;
}
public FieldModel fromExtraField(ExtraField extraField){
this.setId(extraField.getId());
this.setCategory(FieldCategory.EXTRA);
this.setType(extraField.getType().getValue());
this.setLabel(extraField.getLabel());
this.setPlaceholder(extraField.getPlaceholder());
this.setDescription(extraField.getDescription());
this.setOrdinal(extraField.getOrdinal());
this.setRequired(extraField.getRequired());
return this;
}
}

View File

@ -0,0 +1,149 @@
package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
public class Section implements XmlSerializable<Section> {
private UUID id;
private String label;
private String description;
private Integer ordinal;
private List<FieldModel> fields;
private Boolean hasTemplates;
private List<DescriptionTemplate> descriptionTemplates;
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 String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getOrdinal() {
return ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public List<FieldModel> getFields() {
return fields;
}
public void setFields(List<FieldModel> fields) {
this.fields = fields;
}
public Boolean getHasTemplates() {
return hasTemplates;
}
public void setHasTemplates(Boolean hasTemplates) {
this.hasTemplates = hasTemplates;
}
public List<DescriptionTemplate> getDescriptionTemplates() {
return descriptionTemplates;
}
public void setDescriptionTemplates(List<DescriptionTemplate> descriptionTemplates) {
this.descriptionTemplates = descriptionTemplates;
}
@Override
public Element toXml(Document doc) {
Element rootElement = doc.createElement("section");
rootElement.setAttribute("id", this.getId().toString());
rootElement.setAttribute("label", this.label);
rootElement.setAttribute("description", this.description);
rootElement.setAttribute("ordinal", String.valueOf(this.ordinal));
rootElement.setAttribute("hasTemplates", String.valueOf(this.hasTemplates));
List<FieldModel> temp = this.fields.stream().filter(f -> f.getCategory().equals(FieldCategory.SYSTEM)).collect(Collectors.toList());
List<SystemField> systemFieldsList = temp.stream().map(FieldModel::toSystemField).collect(Collectors.toList());
Element systemFields = doc.createElement("systemFields");
for (SystemField systemField : systemFieldsList) {
systemFields.appendChild(systemField.toXml(doc));
}
rootElement.appendChild(systemFields);
Element descriptionTemplates = doc.createElement("descriptionTemplates");
for (DescriptionTemplate descriptionTemplate : this.descriptionTemplates) {
descriptionTemplates.appendChild(descriptionTemplate.toXml(doc));
}
rootElement.appendChild(descriptionTemplates);
temp = this.fields.stream().filter(f -> f.getCategory().equals(FieldCategory.EXTRA)).collect(Collectors.toList());
List<ExtraField> extraFieldList = temp.stream().map(FieldModel::toExtraField).collect(Collectors.toList());
Element extraFields = doc.createElement("extraFields");
for (ExtraField extraField : extraFieldList) {
extraFields.appendChild(extraField.toXml(doc));
}
rootElement.appendChild(extraFields);
return rootElement;
}
@Override
public Section fromXml(Element item) {
this.id = UUID.fromString(item.getAttribute("id"));
this.label = item.getAttribute("label");
this.description = item.getAttribute("description");
this.ordinal = Integer.valueOf(item.getAttribute("ordinal"));
this.hasTemplates = Boolean.valueOf(item.getAttribute("hasTemplates"));
this.fields = new LinkedList<>();
Element systemFields = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "systemFields");
if (systemFields != null) {
NodeList systemFieldElements = systemFields.getChildNodes();
for (int temp = 0; temp < systemFieldElements.getLength(); temp++) {
Node systemFieldElement = systemFieldElements.item(temp);
if (systemFieldElement.getNodeType() == Node.ELEMENT_NODE) {
SystemField systemField = new SystemField().fromXml((Element) systemFieldElement);
this.fields.add(new FieldModel().fromSystemField(systemField));
}
}
}
this.descriptionTemplates = new LinkedList<>();
Element descriptionTemplates = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "descriptionTemplates");
if (descriptionTemplates != null) {
NodeList descriptionTemplateElements = descriptionTemplates.getChildNodes();
for (int temp = 0; temp < descriptionTemplateElements.getLength(); temp++) {
Node descriptionTemplateElement = descriptionTemplateElements.item(temp);
if (descriptionTemplateElement.getNodeType() == Node.ELEMENT_NODE) {
this.descriptionTemplates.add(new DescriptionTemplate().fromXml((Element) descriptionTemplateElement));
}
}
}
Element extraFields = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "extraFields");
if (extraFields != null) {
NodeList extraFieldElements = extraFields.getChildNodes();
for (int temp = 0; temp < extraFieldElements.getLength(); temp++) {
Node extraFieldElement = extraFieldElements.item(temp);
if (extraFieldElement.getNodeType() == Node.ELEMENT_NODE) {
ExtraField extraField = new ExtraField().fromXml((Element) extraFieldElement);
this.fields.add(new FieldModel().fromExtraField(extraField));
}
}
}
return this;
}
}

View File

@ -0,0 +1,94 @@
package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition;
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.UUID;
public class SystemField implements XmlSerializable<SystemField> {
private UUID id;
private SystemFieldType type;
private String label;
private String placeholder;
private String description;
private boolean required;
private Integer ordinal;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public SystemFieldType getType() {
return type;
}
public void setType(SystemFieldType type) {
this.type = type;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getPlaceholder() {
return placeholder;
}
public void setPlaceholder(String placeholder) {
this.placeholder = placeholder;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isRequired() {
return required;
}
public void setRequired(boolean required) {
this.required = required;
}
public Integer getOrdinal() {
return ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
@Override
public Element toXml(Document doc) {
Element rootElement = doc.createElement("systemField");
rootElement.setAttribute("id", this.getId().toString());
rootElement.setAttribute("type", String.valueOf(this.type.getType()));
rootElement.setAttribute("label", this.label);
rootElement.setAttribute("placeholder", this.placeholder);
rootElement.setAttribute("description", this.description);
rootElement.setAttribute("required", String.valueOf(this.required));
rootElement.setAttribute("ordinal", String.valueOf(this.ordinal));
return rootElement;
}
@Override
public SystemField fromXml(Element item) {
this.id = UUID.fromString(item.getAttribute("id"));
this.type = SystemFieldType.fromInteger(Integer.parseInt(item.getAttribute("type")));
this.label = item.getAttribute("label");
this.placeholder = item.getAttribute("placeholder");
this.description = item.getAttribute("description");
this.required = Boolean.parseBoolean(item.getAttribute("required"));
this.ordinal = Integer.valueOf(item.getAttribute("ordinal"));
return this;
}
}

View File

@ -0,0 +1,30 @@
package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types;
public enum ExtraFieldType {
TEXT(0), RICH_TEXT(1), DATE(2), NUMBER(3);
private Integer value;
private ExtraFieldType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static ExtraFieldType fromInteger(Integer value) {
switch (value) {
case 0:
return TEXT;
case 1:
return RICH_TEXT;
case 2:
return DATE;
case 3:
return NUMBER;
default:
throw new RuntimeException("Unsupported ExtraFieldType Type");
}
}
}

View File

@ -0,0 +1,27 @@
package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types;
public enum FieldCategory {
SYSTEM(0),
EXTRA(1);
private Integer value;
private FieldCategory(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static FieldCategory fromInteger(Integer value) {
switch (value) {
case 0:
return SYSTEM;
case 1:
return EXTRA;
default:
throw new RuntimeException("Unsupported FieldCategory Type");
}
}
}

View File

@ -0,0 +1,55 @@
package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types;
public enum SystemFieldType {
TEXT(0),
HTML_TEXT(1),
RESEARCHERS(2),
ORGANIZATIONS(3),
LANGUAGE(4),
CONTACT(5),
FUNDER(6),
GRANT(7),
PROJECT(8),
LICENSE(9),
ACCESS_RIGHTS(10);
private int type;
SystemFieldType(int type) {
this.type = type;
}
public int getType() {
return type;
}
public static SystemFieldType fromInteger(int type) {
switch (type) {
case 0:
return TEXT;
case 1:
return HTML_TEXT;
case 2:
return RESEARCHERS;
case 3:
return ORGANIZATIONS;
case 4:
return LANGUAGE;
case 5:
return CONTACT;
case 6:
return FUNDER;
case 7:
return GRANT;
case 8:
return PROJECT;
case 9:
return LICENSE;
case 10:
return ACCESS_RIGHTS;
default:
throw new RuntimeException("Unsupported System Field Type");
}
}
}

View File

@ -0,0 +1,93 @@
package eu.eudat.models.data.listingmodels;
import eu.eudat.data.entities.DMPProfile;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint;
import org.w3c.dom.Document;
import java.util.Date;
import java.util.UUID;
public class DataManagementPlanBlueprintListingModel implements DataModel<DMPProfile, DataManagementPlanBlueprintListingModel> {
private UUID id;
private String label;
private DataManagementPlanBlueprint definition;
private int status;
private Date created = null;
private Date modified = new Date();
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 DataManagementPlanBlueprint getDefinition() {
return definition;
}
public void setDefinition(DataManagementPlanBlueprint definition) {
this.definition = definition;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
@Override
public DataManagementPlanBlueprintListingModel fromDataModel(DMPProfile entity) {
this.id = entity.getId();
this.created = entity.getCreated();
this.definition = new DataManagementPlanBlueprint().fromXml(XmlBuilder.fromXml(entity.getDefinition()).getDocumentElement());
this.modified = entity.getModified();
this.label = entity.getLabel();
this.status = entity.getStatus();
return this;
}
@Override
public DMPProfile toDataModel() throws Exception {
Document document = XmlBuilder.getDocument();
document.appendChild(this.definition.toXml(document));
DMPProfile dmpProfile = new DMPProfile();
dmpProfile.setCreated(this.created == null ? new Date() : this.created);
dmpProfile.setDefinition(XmlBuilder.generateXml(document));
dmpProfile.setId(this.id);
dmpProfile.setLabel(this.label);
dmpProfile.setStatus(this.status);
dmpProfile.setModified(this.modified == null ? new Date() : this.modified);
return dmpProfile;
}
@Override
public String getHint() {
return null;
}
}

View File

@ -1,8 +1,11 @@
package eu.eudat.models.data.listingmodels; package eu.eudat.models.data.listingmodels;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.DMPDatasetProfile;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.dataset.DatasetOverviewModel; import eu.eudat.models.data.dataset.DatasetOverviewModel;
import eu.eudat.models.data.dmp.AssociatedProfile; import eu.eudat.models.data.dmp.AssociatedProfile;
@ -11,10 +14,7 @@ import eu.eudat.models.data.dmp.Researcher;
import eu.eudat.models.data.doi.Doi; import eu.eudat.models.data.doi.Doi;
import eu.eudat.models.data.grant.GrantOverviewModel; import eu.eudat.models.data.grant.GrantOverviewModel;
import java.util.Date; import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManagementPlanOverviewModel> { public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManagementPlanOverviewModel> {
@ -205,8 +205,14 @@ public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManag
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) { if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
this.associatedProfiles = new LinkedList<>(); this.associatedProfiles = new LinkedList<>();
for (DatasetProfile datasetProfile : entity.getAssociatedDmps()) { for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile); AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
try {
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
}
catch (Exception e) {
associatedProfile.setData(null);
}
this.associatedProfiles.add(associatedProfile); this.associatedProfiles.add(associatedProfile);
} }
} }

View File

@ -1,15 +1,13 @@
package eu.eudat.models.data.quickwizard; package eu.eudat.models.data.quickwizard;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
import eu.eudat.models.data.dmp.DataManagementPlan; import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.data.entities.Dataset;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import java.util.Date; import java.util.Date;
import java.util.UUID;
public class DatasetDescriptionQuickWizardModel extends PagedDatasetProfile { public class DatasetDescriptionQuickWizardModel extends PagedDatasetProfile {
@ -24,7 +22,7 @@ public class DatasetDescriptionQuickWizardModel extends PagedDatasetProfile {
} }
public DatasetWizardModel toDataModel(DataManagementPlan dmp, DatasetProfile profile){ public DatasetWizardModel toDataModel(DataManagementPlan dmp, DescriptionTemplate profile){
DatasetWizardModel newDataset = new DatasetWizardModel(); DatasetWizardModel newDataset = new DatasetWizardModel();
newDataset.setLabel(datasetLabel); newDataset.setLabel(datasetLabel);
newDataset.setCreated(new Date()); newDataset.setCreated(new Date());

View File

@ -1,5 +1,6 @@
package eu.eudat.models.data.quickwizard; package eu.eudat.models.data.quickwizard;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.Grant; import eu.eudat.data.entities.Grant;
import eu.eudat.data.entities.Project; import eu.eudat.data.entities.Project;
import eu.eudat.models.data.dmp.AssociatedProfile; import eu.eudat.models.data.dmp.AssociatedProfile;
@ -107,12 +108,12 @@ public class DmpQuickWizardModel {
} }
public eu.eudat.data.entities.DatasetProfile getDatasetProfile() { public DescriptionTemplate getDatasetProfile() {
eu.eudat.data.entities.DatasetProfile datasetProfile = new eu.eudat.data.entities.DatasetProfile(); DescriptionTemplate descriptionTemplate = new DescriptionTemplate();
datasetProfile.setDefinition(this.datasetProfile.getLabel()); descriptionTemplate.setDefinition(this.datasetProfile.getLabel());
datasetProfile.setLabel(this.datasetProfile.getLabel()); descriptionTemplate.setLabel(this.datasetProfile.getLabel());
datasetProfile.setId(this.datasetProfile.getId()); descriptionTemplate.setId(this.datasetProfile.getDescriptionTemplateId());
return datasetProfile; return descriptionTemplate;
} }

View File

@ -2,8 +2,8 @@ package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.DatasetProfile;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.elastic.criteria.DatasetCriteria; import eu.eudat.elastic.criteria.DatasetCriteria;
import eu.eudat.elastic.entities.Tag; import eu.eudat.elastic.entities.Tag;
import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.managers.DatasetManager;
@ -280,12 +280,12 @@ public class DatasetRDAMapper {
} }
public eu.eudat.data.entities.Dataset toEntity(Dataset rda, DatasetProfile defaultProfile) { public eu.eudat.data.entities.Dataset toEntity(Dataset rda, DescriptionTemplate defaultProfile) {
eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset(); eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset();
entity.setLabel(rda.getTitle()); entity.setLabel(rda.getTitle());
entity.setDescription(rda.getDescription()); entity.setDescription(rda.getDescription());
try { try {
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString())); DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString()));
entity.setProfile(profile); entity.setProfile(profile);
}catch(Exception e) { }catch(Exception e) {
logger.warn(e.getMessage(), e); logger.warn(e.getMessage(), e);

View File

@ -124,16 +124,15 @@ public class DmpRDAMapper {
entity.setDois(new HashSet<>()); entity.setDois(new HashSet<>());
} }
} }
if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty()) { if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty() && entity.getId() != null) {
entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).filter(Objects::nonNull).collect(Collectors.toSet())); entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(x -> this.getProfile(x, entity.getId())).filter(Objects::nonNull).collect(Collectors.toSet()));
} }
if (entity.getAssociatedDmps() == null) { if (entity.getAssociatedDmps() == null) {
entity.setAssociatedDmps(new HashSet<>()); entity.setAssociatedDmps(new HashSet<>());
} }
if (profiles != null) { if (profiles != null && entity.getId() != null) {
for (String profile : profiles) { for (String profile : profiles) {
DatasetProfile exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(profile)); entity.getAssociatedDmps().add(this.getProfile(profile, entity.getId()));
entity.getAssociatedDmps().add(exProfile);
} }
} }
if (rda.getContributor() != null && !rda.getContributor().isEmpty() && rda.getContributor().get(0).getContributorId() != null) { if (rda.getContributor() != null && !rda.getContributor().isEmpty() && rda.getContributor().get(0).getContributorId() != null) {
@ -142,7 +141,7 @@ public class DmpRDAMapper {
entity.setCreated(rda.getCreated()); entity.setCreated(rda.getCreated());
entity.setModified(rda.getModified()); entity.setModified(rda.getModified());
entity.setDescription(rda.getDescription()); entity.setDescription(rda.getDescription());
DatasetProfile defaultProfile = ((DatasetProfile)entity.getAssociatedDmps().toArray()[0]); DescriptionTemplate defaultProfile = ((DescriptionTemplate)entity.getAssociatedDmps().toArray()[0]);
entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, defaultProfile)).collect(Collectors.toSet())); entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, defaultProfile)).collect(Collectors.toSet()));
if (rda.getProject().size() > 0) { if (rda.getProject().size() > 0) {
Map<String, Object> result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext); Map<String, Object> result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext);
@ -158,7 +157,10 @@ public class DmpRDAMapper {
return entity; return entity;
} }
private DatasetProfile getProfile(String id) { private DMPDatasetProfile getProfile(String descriptionTemplateId, UUID dmpId) {
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().asQueryable().where(((builder, root) -> builder.equal(root.get("id"), UUID.fromString(id)))).getSingleOrDefault(); return apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().asQueryable().where(((builder, root) -> builder.and(
builder.equal(root.get("datasetprofile"), UUID.fromString(descriptionTemplateId)),
builder.equal(root.get("dmp"), dmpId))
)).getSingleOrDefault();
} }
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.publicapi.managers; package eu.eudat.publicapi.managers;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.definition.helpers.ColumnOrderings; import eu.eudat.data.query.definition.helpers.ColumnOrderings;
import eu.eudat.elastic.criteria.DatasetCriteria; import eu.eudat.elastic.criteria.DatasetCriteria;
import eu.eudat.elastic.repository.DatasetRepository; import eu.eudat.elastic.repository.DatasetRepository;
@ -139,10 +140,10 @@ public class DatasetPublicManager {
DatasetPublicListingModel listingPublicModel = new DatasetPublicListingModel().fromDataModel(item); DatasetPublicListingModel listingPublicModel = new DatasetPublicListingModel().fromDataModel(item);
/*DatasetProfileCriteria criteria = new DatasetProfileCriteria(); /*DatasetProfileCriteria criteria = new DatasetProfileCriteria();
criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId())); criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId()));
List<DatasetProfile> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList(); List<DescriptionTemplate> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
boolean islast = false; boolean islast = false;
if (!profiles.isEmpty()) { if (!profiles.isEmpty()) {
profiles = profiles.stream().sorted(Comparator.comparing(DatasetProfile::getVersion)).collect(Collectors.toList()); profiles = profiles.stream().sorted(Comparator.comparing(DescriptionTemplate::getVersion)).collect(Collectors.toList());
islast = profiles.get(0).getId().equals(item.getProfile().getId()); islast = profiles.get(0).getId().equals(item.getProfile().getId());
} }
listingModel.setProfileLatestVersion(islast);*/ listingModel.setProfileLatestVersion(islast);*/
@ -162,7 +163,7 @@ public class DatasetPublicManager {
return pagedDatasetProfile; return pagedDatasetProfile;
} }
private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) { private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplate profile) {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition()); Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = (Element) viewStyleDoc.getDocumentElement(); Element root = (Element) viewStyleDoc.getDocumentElement();
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root); eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);

View File

@ -1,15 +1,18 @@
package eu.eudat.publicapi.models.associatedprofile; package eu.eudat.publicapi.models.associatedprofile;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.utilities.interfaces.XmlSerializable; import eu.eudat.logic.utilities.interfaces.XmlSerializable;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class AssociatedProfilePublicModel implements XmlSerializable<AssociatedProfilePublicModel> { public class AssociatedProfilePublicModel implements XmlSerializable<AssociatedProfilePublicModel> {
private UUID id; private UUID id;
private UUID descriptionTemplateId;
private String label; private String label;
private Map<String, Object> data;
public UUID getId() { public UUID getId() {
return id; return id;
@ -19,6 +22,14 @@ public class AssociatedProfilePublicModel implements XmlSerializable<AssociatedP
this.id = id; this.id = id;
} }
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
}
public String getLabel() { public String getLabel() {
return label; return label;
} }
@ -27,6 +38,14 @@ public class AssociatedProfilePublicModel implements XmlSerializable<AssociatedP
this.label = label; this.label = label;
} }
public Map<String, Object> getData() {
return data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
@Override @Override
public Element toXml(Document doc) { public Element toXml(Document doc) {
Element profile = doc.createElement("profile"); Element profile = doc.createElement("profile");
@ -37,20 +56,20 @@ public class AssociatedProfilePublicModel implements XmlSerializable<AssociatedP
@Override @Override
public AssociatedProfilePublicModel fromXml(Element item) { public AssociatedProfilePublicModel fromXml(Element item) {
this.id = UUID.fromString(item.getAttribute("profileId")); this.descriptionTemplateId = UUID.fromString(item.getAttribute("profileId"));
this.label = item.getAttribute("label"); this.label = item.getAttribute("label");
return this; return this;
} }
public DatasetProfile toData() { public DescriptionTemplate toData() {
DatasetProfile profile = new DatasetProfile(); DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(this.id); profile.setId(this.descriptionTemplateId);
profile.setLabel(this.label); profile.setLabel(this.label);
return profile; return profile;
} }
public AssociatedProfilePublicModel fromData(DatasetProfile entity) { public AssociatedProfilePublicModel fromData(DescriptionTemplate entity) {
this.id = entity.getId(); this.descriptionTemplateId = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
return this; return this;
} }

View File

@ -1,11 +1,11 @@
package eu.eudat.publicapi.models.datasetprofile; package eu.eudat.publicapi.models.datasetprofile;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import java.util.UUID; import java.util.UUID;
public class DatasetProfilePublicModel implements DataModel<DatasetProfile, DatasetProfilePublicModel> { public class DatasetProfilePublicModel implements DataModel<DescriptionTemplate, DatasetProfilePublicModel> {
private UUID id; private UUID id;
private String label; private String label;
@ -24,15 +24,15 @@ public class DatasetProfilePublicModel implements DataModel<DatasetProfile, Data
} }
@Override @Override
public DatasetProfilePublicModel fromDataModel(DatasetProfile entity) { public DatasetProfilePublicModel fromDataModel(DescriptionTemplate entity) {
this.id = entity.getId(); this.id = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
return this; return this;
} }
@Override @Override
public DatasetProfile toDataModel() { public DescriptionTemplate toDataModel() {
DatasetProfile entity = new DatasetProfile(); DescriptionTemplate entity = new DescriptionTemplate();
entity.setId(this.getId()); entity.setId(this.getId());
entity.setLabel(this.getLabel()); entity.setLabel(this.getLabel());
return entity; return entity;

View File

@ -1,10 +1,14 @@
package eu.eudat.publicapi.models.overviewmodels; package eu.eudat.publicapi.models.overviewmodels;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.DMPDatasetProfile;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.publicapi.models.associatedprofile.AssociatedProfilePublicModel; import eu.eudat.publicapi.models.associatedprofile.AssociatedProfilePublicModel;
import eu.eudat.publicapi.models.doi.DoiPublicModel; import eu.eudat.publicapi.models.doi.DoiPublicModel;
@ -193,8 +197,15 @@ public class DataManagementPlanPublicModel implements DataModel<DMP, DataManagem
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) { if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
this.associatedProfiles = new LinkedList<>(); this.associatedProfiles = new LinkedList<>();
for (DatasetProfile datasetProfile : entity.getAssociatedDmps()) { for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
AssociatedProfilePublicModel associatedProfile = new AssociatedProfilePublicModel().fromData(datasetProfile); AssociatedProfilePublicModel associatedProfile = new AssociatedProfilePublicModel().fromData(dmpDescriptionProfile.getDatasetprofile());
associatedProfile.setId(dmpDescriptionProfile.getId());
try {
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
}
catch (Exception e) {
associatedProfile.setData(null);
}
this.associatedProfiles.add(associatedProfile); this.associatedProfiles.add(associatedProfile);
} }
} }
@ -217,7 +228,7 @@ public class DataManagementPlanPublicModel implements DataModel<DMP, DataManagem
return pagedDatasetProfile; return pagedDatasetProfile;
} }
private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) { private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplate profile) {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition()); Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = (Element) viewStyleDoc.getDocumentElement(); Element root = (Element) viewStyleDoc.getDocumentElement();
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root); eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);

View File

@ -232,7 +232,7 @@ public class DatasetPublicModel implements DataModel<Dataset, DatasetPublicModel
entity.setDescription(this.description); entity.setDescription(this.description);
entity.setCreated(this.createdAt != null ? this.createdAt : new Date()); entity.setCreated(this.createdAt != null ? this.createdAt : new Date());
entity.setModified(new Date()); entity.setModified(new Date());
DatasetProfile profile = new DatasetProfile(); DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(this.profile.getId()); profile.setId(this.profile.getId());
entity.setProfile(profile); entity.setProfile(profile);
if (this.registries != null && !this.registries.isEmpty()) { if (this.registries != null && !this.registries.isEmpty()) {

View File

@ -17,7 +17,9 @@ INSERT INTO public."DoiFunder"(name, doi) VALUES ('Wellcome Trust', '10.13039/10
UPDATE public."DMP" UPDATE public."DMP"
SET "extraProperties"='{"language": "en"}'; SET "extraProperties"='{"language": "en"}';
UPDATE public."DatasetProfile" UPDATE public."DescriptionTemplate"
SET "Language"='en'; SET "Language"='en';
INSERT INTO public."DescriptionTemplateType"("ID", "Name", "Status") VALUES (uuid_generate_v4(), 'Dataset', 1);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.007', '2020-10-27 13:40:00.000000+03', now(), 'Add userstatus on UserInfo table'); INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.007', '2020-10-27 13:40:00.000000+03', now(), 'Add userstatus on UserInfo table');

View File

@ -129,7 +129,8 @@ COMMENT ON COLUMN public."DMP"."AssociatedDmps" IS 'More data about the DMP as d
CREATE TABLE public."DMPDatasetProfile" ( CREATE TABLE public."DMPDatasetProfile" (
"ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL, "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
dmp uuid NOT NULL, dmp uuid NOT NULL,
datasetprofile uuid NOT NULL datasetprofile uuid NOT NULL,
"data" text
); );
@ -235,6 +236,7 @@ CREATE TABLE public."Dataset" (
"ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL, "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL, "Label" character varying(250) NOT NULL,
"DMP" uuid, "DMP" uuid,
"DmpSectionIndex" integer,
"Uri" character varying(250), "Uri" character varying(250),
"Properties" text, "Properties" text,
"Profile" uuid, "Profile" uuid,
@ -302,10 +304,23 @@ CREATE TABLE public."DatasetExternalDataset" (
ALTER TABLE public."DatasetExternalDataset" OWNER TO :POSTGRES_USER; ALTER TABLE public."DatasetExternalDataset" OWNER TO :POSTGRES_USER;
-- --
-- Name: DatasetProfile; Type: TABLE; Schema: public; Owner: :POSTGRES_USER -- Name: DescriptionTemplateType; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
-- --
CREATE TABLE public."DatasetProfile" ( CREATE TABLE public."DescriptionTemplateType" (
"ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
"Name" character varying(250) NOT NULL,
"Status" smallint DEFAULT 0 NOT NULL
);
ALTER TABLE public."DescriptionTemplateType" OWNER TO :POSTGRES_USER;
--
-- Name: DescriptionTemplate; Type: TABLE; Schema: public; Owner: :POSTGRES_USER
--
CREATE TABLE public."DescriptionTemplate" (
"ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL, "ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL, "Label" character varying(250) NOT NULL,
"Definition" xml NOT NULL, "Definition" xml NOT NULL,
@ -315,17 +330,18 @@ CREATE TABLE public."DatasetProfile" (
"Description" text NOT NULL, "Description" text NOT NULL,
"GroupId" uuid NOT NULL, "GroupId" uuid NOT NULL,
"Version" integer DEFAULT 0 NOT NULL, "Version" integer DEFAULT 0 NOT NULL,
"Language" character varying NOT NULL "Language" character varying NOT NULL,
"Type" uuid NOT NULL
); );
ALTER TABLE public."DatasetProfile" OWNER TO :POSTGRES_USER; ALTER TABLE public."DescriptionTemplate" OWNER TO :POSTGRES_USER;
-- --
-- Name: TABLE "DatasetProfile"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER -- Name: TABLE "DescriptionTemplate"; Type: COMMENT; Schema: public; Owner: :POSTGRES_USER
-- --
COMMENT ON TABLE public."DatasetProfile" IS 'Profiles for dmp datasets'; COMMENT ON TABLE public."DescriptionTemplate" IS 'Profiles for dmp descriptions';
-- --
@ -1020,11 +1036,19 @@ ALTER TABLE ONLY public."DatasetProfileViewstyle"
-- --
-- Name: DatasetProfile DatasetProfile_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER -- Name: DescriptionTemplateType DescriptionTemplateType_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
-- --
ALTER TABLE ONLY public."DatasetProfile" ALTER TABLE ONLY public."DescriptionTemplateType"
ADD CONSTRAINT "DatasetProfile_pkey" PRIMARY KEY ("ID"); ADD CONSTRAINT "DescriptionTemplateType_pkey" PRIMARY KEY ("ID");
--
-- Name: DescriptionTemplate DescriptionTemplate_pkey; Type: CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--
ALTER TABLE ONLY public."DescriptionTemplate"
ADD CONSTRAINT "DescriptionTemplate_pkey" PRIMARY KEY ("ID");
-- --
@ -1260,7 +1284,7 @@ ALTER TABLE ONLY public."DMP"
-- --
ALTER TABLE ONLY public."DMPDatasetProfile" ALTER TABLE ONLY public."DMPDatasetProfile"
ADD CONSTRAINT "DMPDatasetProfile_datasetprofile_fkey" FOREIGN KEY (datasetprofile) REFERENCES public."DatasetProfile"("ID"); ADD CONSTRAINT "DMPDatasetProfile_datasetprofile_fkey" FOREIGN KEY (datasetprofile) REFERENCES public."DescriptionTemplate"("ID");
-- --
@ -1340,7 +1364,7 @@ ALTER TABLE ONLY public."DatasetDataRepository"
-- --
ALTER TABLE ONLY public."Dataset" ALTER TABLE ONLY public."Dataset"
ADD CONSTRAINT "DatasetDatasetProfileReference" FOREIGN KEY ("Profile") REFERENCES public."DatasetProfile"("ID"); ADD CONSTRAINT "DatasetDatasetProfileReference" FOREIGN KEY ("Profile") REFERENCES public."DescriptionTemplate"("ID");
-- --
@ -1375,6 +1399,14 @@ ALTER TABLE ONLY public."DatasetService"
ADD CONSTRAINT "DatasetServiceServiceReference" FOREIGN KEY ("Service") REFERENCES public."Service"("ID"); ADD CONSTRAINT "DatasetServiceServiceReference" FOREIGN KEY ("Service") REFERENCES public."Service"("ID");
--
-- Name: DescriptionTemplate DescriptionTemplateTypeReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
--
ALTER TABLE ONLY public."DescriptionTemplate"
ADD CONSTRAINT "DescriptionTemplateTypeReference" FOREIGN KEY ("Type") REFERENCES public."DescriptionTemplateType"("ID");
-- --
-- Name: Lock LockUserReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER -- Name: Lock LockUserReference; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER
-- --
@ -1395,7 +1427,7 @@ ALTER TABLE ONLY public."Notification"
-- --
ALTER TABLE ONLY public."UserDatasetProfile" ALTER TABLE ONLY public."UserDatasetProfile"
ADD CONSTRAINT "UserDatasetProfile_datasetProfile_fkey" FOREIGN KEY ("datasetProfile") REFERENCES public."DatasetProfile" ("ID"); ADD CONSTRAINT "UserDatasetProfile_datasetProfile_fkey" FOREIGN KEY ("datasetProfile") REFERENCES public."DescriptionTemplate" ("ID");
-- --
-- Name: UserDatasetProfile UserDatasetProfile_user_key; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER -- Name: UserDatasetProfile UserDatasetProfile_user_key; Type: FK CONSTRAINT; Schema: public; Owner: :POSTGRES_USER

View File

@ -0,0 +1,20 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.00.013';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."DescriptionTemplateType"
(
"ID" uuid NOT NULL,
"Name" character varying(250) NOT NULL,
"Status" smallint DEFAULT 0 NOT NULL,
CONSTRAINT "DescriptionTemplateType_pkey" PRIMARY KEY ("ID")
);
/*ALTER TABLE public."DescriptionTemplateType" OWNER TO :POSTGRES_USER;*/
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.013', '2023-06-21 12:00:00.000000+02', now(), 'Add Description Template Type table.');
END$$;

View File

@ -0,0 +1,29 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.00.014';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
ALTER TABLE public."DatasetProfile"
RENAME TO "DescriptionTemplate";
ALTER TABLE public."DescriptionTemplate"
ADD COLUMN "Type" uuid;
INSERT INTO public."DescriptionTemplateType" ("ID", "Name", "Status")
VALUES ('709a8400-10ca-11ee-be56-0242ac120002', 'Dataset', 1);
UPDATE public."DescriptionTemplate" SET ("Type") = '709a8400-10ca-11ee-be56-0242ac120002';
ALTER TABLE public."DescriptionTemplate"
ALTER COLUMN "Type" SET NOT NULL;
ALTER TABLE ONLY public."DescriptionTemplate"
ADD CONSTRAINT "DescriptionTemplate_type_fkey" FOREIGN KEY ("Type") REFERENCES public."DescriptionTemplateType"("ID");
ALTER TABLE "UserDatasetProfile"
RENAME COLUMN "datasetProfile" TO "descriptionTemplate";
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.014', '2023-06-21 12:00:00.000000+02', now(), 'Rename DatasetProfile Table to DescriptionTemplate and add column Type referencing the DescriptionTemplateType.');
END$$;

View File

@ -0,0 +1,15 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.00.015';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
ALTER TABLE public."Dataset"
ADD COLUMN "DmpSectionIndex" integer;
ALTER TABLE public."DMPDatasetProfile"
ADD COLUMN "data" text;
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.015', '2023-09-01 12:00:00.000000+02', now(), 'Add column DmpSectionIndex to Dataset table and data to DMPDatasetProfile.');
END$$;

View File

@ -0,0 +1,20 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.00.016';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
INSERT INTO public."DMPProfile" VALUES ('1374c46d-55b5-472a-8e10-c6ee8c0b5f7f', 'Dmp Default Blueprint', '<root><sections><section id="f94e50e0-cb97-4c65-8b88-e5db6badd41d" label="Main Info" description="A DMP in Argos consists of key information about research, such as purpose, objectives and researchers involved, but also about documentation of research datasets that highlight the steps followed and the means used across data management activities." ordinal="1" hasTemplates="false"><systemFields><systemField id="e62c3fa2-4cbe-41bf-a00e-ad722c7c7da1" type="0" label="Title of DMP" placeholder="Title of DMP" description="" required="true" ordinal="1"></systemField><systemField id="eed2871d-5201-401e-8453-87afbeac77e3" type="1" label="Description" placeholder="Fill with description" description="Briefly describe the context and purpose of the DMP" required="true" ordinal="2"></systemField><systemField id="41a0b1db-b186-467d-8edf-7d3b2456f95e" type="2" label="Researchers" placeholder="Select researchers" description="Add here the names of people that have produced, processed, analysed the data described in the DMP." required="false" ordinal="3"></systemField><systemField id="0f0afb55-a11b-41db-a4d0-67ebb74d8685" type="3" label="Organizations" placeholder="Select organization" description="Add here the names of the organizations contributing to the creation and revision of the DMPs" required="false" ordinal="4"></systemField><systemField id="db493026-3130-4730-9b93-da6b77d2eea4" type="4" label="Language" placeholder="Language" description="Select the language of your DMP" required="true" ordinal="5"></systemField><systemField id="22deb104-1c46-4ea8-8261-8fdc9500dca2" type="5" label="Contact" placeholder="Contact" description="" required="true" ordinal="6"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="3c2608e5-9320-4d94-9ed7-1eab9500d84b" label="Funding" description="Add here information about the scope, funding, actors of your DMP and decide on access and re-use issues for the DMP output that you are creating." ordinal="2" hasTemplates="false"><systemFields><systemField id="527af8fe-27b0-4715-9e1e-35a2fce834a1" type="6" label="Funding organizations" placeholder="Funder" description="Select a funder of your research or add new" required="true" ordinal="1"></systemField><systemField id="4d12904e-2501-4d57-8d2b-1ac795c297e7" type="7" label="Grants" placeholder="Grant" description="Find the grant of your research or add new" required="true" ordinal="2"></systemField><systemField id="82f235c8-98fc-48d1-8245-36ab08f01036" type="8" label="Project" placeholder="Project" description="Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted." required="false" ordinal="3"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="2a77e1f6-9989-4aeb-acd9-48e911a92abd" label="License" description="Each DMP can contain specific license informatation over how much open and available it is, that way you can determine who can see your dataset and for how long that data will be private." ordinal="3" hasTemplates="false"><systemFields><systemField id="75c31705-6731-45dd-9853-75c5d0627439" type="9" label="License" placeholder="License" description="Assign a license to your DMP by selecting the most appropriate from the list." required="false" ordinal="1"></systemField><systemField id="990df932-eae6-44ca-85da-5378b010f439" type="10" label="Access Rights" placeholder="Access Rights" description="Choose how the DMP is displayed after is published on Zenodo. By choosing Open Access, the DMP will be open on Zenodo after the Publication Date. By choosing Restricted Access, the DMP will be restricted after the publication is made." required="false" ordinal="2"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="0db7845b-0e7c-41df-8d91-cbca97995fd5" label="Dataset Info" description="Datasets are documented following pre-defined templates which set the content of dataset descriptions. In Argos, a DMP can contain as many dataset descriptions as the datasets it documents." ordinal="4" hasTemplates="true"><systemFields></systemFields><descriptionTemplates></descriptionTemplates></section></sections></root>',1, now(),now());
UPDATE public."DMP" SET ("Profile") = '1374c46d-55b5-472a-8e10-c6ee8c0b5f7f' WHERE "Profile" IS NULL;
UPDATE public."Dataset" SET ("DmpSectionIndex") = '3' WHERE "DmpSectionIndex" IS NULL;
UPDATE public."DMPDatasetProfile" SET ("data") = '{"dmpSectionIndex":[3]}' WHERE "data" IS NULL;
ALTER TABLE public."Dataset"
ALTER COLUMN "DmpSectionIndex" SET NOT NULL;
ALTER TABLE public."DMPDatasetProfile"
ALTER COLUMN "data" SET NOT NULL;
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.016', '2023-09-12 12:00:00.000000+02', now(), 'Insert default blueprint, update profile of existing dmps and update DmpSectionIndex for each dataset.');
END$$;

View File

@ -47,7 +47,7 @@ const appRoutes: Routes = [
loadChildren: () => import('./ui/dataset/dataset.module').then(m => m.DatasetModule), loadChildren: () => import('./ui/dataset/dataset.module').then(m => m.DatasetModule),
data: { data: {
breadcrumb: true, breadcrumb: true,
title: 'GENERAL.TITLES.DATASETS' title: 'GENERAL.TITLES.DESCRIPTIONS'
} }
}, },
{ {
@ -80,7 +80,7 @@ const appRoutes: Routes = [
loadChildren: () => import('./ui/admin/dmp-profile/dmp-profile.module').then(m => m.DmpProfileModule), loadChildren: () => import('./ui/admin/dmp-profile/dmp-profile.module').then(m => m.DmpProfileModule),
data: { data: {
breadcrumb: true, breadcrumb: true,
title: 'GENERAL.TITLES.DMP-PROFILES' title: 'GENERAL.TITLES.DMP-BLUEPRINTS'
} }
}, },
{ {
@ -99,6 +99,14 @@ const appRoutes: Routes = [
title: 'GENERAL.TITLES.DATASET-PROFILES' title: 'GENERAL.TITLES.DATASET-PROFILES'
} }
}, },
{
path: 'description-types',
loadChildren: () => import('./ui/admin/description-types/description-types.module').then(m => m.DescriptionTypesModule),
data: {
breadcrumb: true,
title: 'GENERAL.TITLES.DESCRIPTION-TYPES'
}
},
{ {
path: 'contact-support', path: 'contact-support',
loadChildren: () => import('./ui/contact/contact.module').then(m => m.ContactModule), loadChildren: () => import('./ui/contact/contact.module').then(m => m.ContactModule),

View File

@ -0,0 +1,5 @@
export enum DescriptionTemplateTypeStatus {
Draft = 0,
Finalized = 1,
Deleted = 99
}

View File

@ -52,6 +52,7 @@ import { FaqService } from './services/faq/faq.service';
import { GlossaryService } from './services/glossary/glossary.service'; import { GlossaryService } from './services/glossary/glossary.service';
import { TermsOfServiceService } from './services/terms-of-service/terms-of-service.service'; import { TermsOfServiceService } from './services/terms-of-service/terms-of-service.service';
import { UnlinkAccountEmailConfirmationService } from './services/unlink-account-email-confirmation/unlink-account-email-confirmation.service'; import { UnlinkAccountEmailConfirmationService } from './services/unlink-account-email-confirmation/unlink-account-email-confirmation.service';
import { DescriptionTemplateTypeService } from './services/description-template-type/description-template-type.service';
// //
// //
// This is shared module that provides all the services. Its imported only once on the AppModule. // This is shared module that provides all the services. Its imported only once on the AppModule.
@ -132,7 +133,8 @@ export class CoreServiceModule {
multi: true multi: true
}, },
LanguageInfoService, LanguageInfoService,
PrefillingService PrefillingService,
DescriptionTemplateTypeService
], ],
}; };
} }

View File

@ -9,6 +9,7 @@ import { JsonParserPipe } from './pipes/json-parser.pipe';
import { DateTimeCultureFormatPipe } from './pipes/date-time-culture-format.pipe'; import { DateTimeCultureFormatPipe } from './pipes/date-time-culture-format.pipe';
import {FieldValuePipe} from "@app/core/pipes/field-value.pipe"; import {FieldValuePipe} from "@app/core/pipes/field-value.pipe";
import {ColumnClassPipe} from "@app/core/pipes/column-class.pipe"; import {ColumnClassPipe} from "@app/core/pipes/column-class.pipe";
import { DatasetInSectioPipe } from './pipes/dataset-in-section.pipe';
// //
// //
@ -25,7 +26,8 @@ import {ColumnClassPipe} from "@app/core/pipes/column-class.pipe";
DateTimeCultureFormatPipe, DateTimeCultureFormatPipe,
JsonParserPipe, JsonParserPipe,
FieldValuePipe, FieldValuePipe,
ColumnClassPipe ColumnClassPipe,
DatasetInSectioPipe
], ],
exports: [ exports: [
NgForLimitPipe, NgForLimitPipe,
@ -35,7 +37,8 @@ import {ColumnClassPipe} from "@app/core/pipes/column-class.pipe";
DateTimeCultureFormatPipe, DateTimeCultureFormatPipe,
JsonParserPipe, JsonParserPipe,
FieldValuePipe, FieldValuePipe,
ColumnClassPipe ColumnClassPipe,
DatasetInSectioPipe
], ],
providers: [ providers: [
EnumUtils, EnumUtils,
@ -47,7 +50,8 @@ import {ColumnClassPipe} from "@app/core/pipes/column-class.pipe";
DateTimeCultureFormatPipe, DateTimeCultureFormatPipe,
JsonParserPipe, JsonParserPipe,
FieldValuePipe, FieldValuePipe,
ColumnClassPipe ColumnClassPipe,
DatasetInSectioPipe
] ]
}) })
export class FormattingModule { } export class FormattingModule { }

View File

@ -3,6 +3,7 @@ import { UserInfoListingModel } from "../../user/user-info-listing";
export interface DatasetProfile { export interface DatasetProfile {
label: string; label: string;
type: string;
sections: Section[]; sections: Section[];
pages: Page[]; pages: Page[];
status: number; status: number;

View File

@ -14,6 +14,7 @@ export interface DatasetWizardModel {
description?: String; description?: String;
status?: number; status?: number;
dmp?: DmpModel; dmp?: DmpModel;
dmpSectionIndex?: number;
datasetProfileDefinition?: DatasetProfileDefinitionModel; datasetProfileDefinition?: DatasetProfileDefinitionModel;
registries?: RegistryModel[]; registries?: RegistryModel[];
services?: ServiceModel[]; services?: ServiceModel[];

View File

@ -0,0 +1,5 @@
export interface DescriptionTemplateType {
id: string;
name: string;
status: number;
}

View File

@ -0,0 +1,10 @@
import { DmpBlueprintDefinition } from "./dmp-blueprint";
export interface DmpBlueprintListing {
id: string;
label: string;
definition: DmpBlueprintDefinition;
status: number;
created: Date;
modified: Date;
}

View File

@ -0,0 +1,68 @@
export interface DmpBlueprint {
id: string;
label: string;
definition: DmpBlueprintDefinition;
status: number;
created: Date;
modified: Date;
description: string;
}
export interface DmpBlueprintDefinition {
sections: SectionDmpBlueprint[];
}
export interface SectionDmpBlueprint {
id: string;
label: string;
description: string;
ordinal: number;
fields: FieldInSection[];
hasTemplates: boolean;
descriptionTemplates?: DescriptionTemplatesInSection[];
}
export interface FieldInSection {
id: string;
category: FieldCategory;
type: number;
label: string;
placeholder: string;
description: string;
required: boolean;
ordinal: number;
}
export enum FieldCategory {
SYSTEM = 0,
EXTRA = 1
}
export enum SystemFieldType {
TEXT = 0,
HTML_TEXT = 1,
RESEARCHERS= 2,
ORGANIZATIONS = 3,
LANGUAGE = 4,
CONTACT = 5,
FUNDER = 6,
GRANT = 7,
PROJECT = 8,
LICENSE = 9,
ACCESS_RIGHTS = 10
}
export interface DescriptionTemplatesInSection {
id: string;
descriptionTemplateId: string;
label: string;
minMultiplicity: number;
maxMultiplicity: number;
}
export enum ExtraFieldType {
TEXT = 0,
RICH_TEXT = 1,
DATE = 2,
NUMBER = 3
}

View File

@ -0,0 +1,28 @@
import { FormGroup, FormBuilder } from "@angular/forms";
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
import { ValidationContext } from "@common/forms/validation/validation-context";
export class DmpDatasetProfileSectionsFormModel {
public dmpSectionIndex: number[] = [];
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
fromModel(item: any): DmpDatasetProfileSectionsFormModel {
this.dmpSectionIndex = item.dmpSectionIndex;
return this;
}
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
if (context == null) { context = this.createValidationContext(); }
const formGroup = new FormBuilder().group({
language: [{ value: this.dmpSectionIndex, disabled: disabled }, context.getValidation('dmpSectionIndex').validators],
});
return formGroup;
}
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'dmpSectionIndex', validators: [BackendErrorValidator(this.validationErrorModel, 'dmpSectionIndex')] });
return baseContext;
}
}

View File

@ -0,0 +1,8 @@
import { DmpDatasetProfileSectionsFormModel } from "./dmp-dataset-profile-sections-form.model";
export interface DmpDatasetProfile {
id: string;
descriptionTemplateId: string;
label: string;
data: DmpDatasetProfileSectionsFormModel;
}

View File

@ -1,17 +1,15 @@
import { Status } from "../../common/enum/status"; import { DmpProfileDefinition } from "../dmp-profile/dmp-profile";
import { DmpProfile, DmpProfileDefinition } from "../dmp-profile/dmp-profile";
import { OrganizationModel } from "../organisation/organization"; import { OrganizationModel } from "../organisation/organization";
import { GrantListingModel } from "../grant/grant-listing"; import { GrantListingModel } from "../grant/grant-listing";
import { ResearcherModel } from "../researcher/researcher"; import { ResearcherModel } from "../researcher/researcher";
import { UserModel } from "../user/user"; import { UserModel } from "../user/user";
import { DmpDynamicField } from "./dmp-dynamic-field"; import { DmpDynamicField } from "./dmp-dynamic-field";
import { UserInfoListingModel } from "../user/user-info-listing"; import { UserInfoListingModel } from "../user/user-info-listing";
import { DatasetModel } from "../dataset/dataset";
import { ProjectModel } from "../project/project"; import { ProjectModel } from "../project/project";
import { FunderModel } from "../funder/funder"; import { FunderModel } from "../funder/funder";
import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { DmpStatus } from '@app/core/common/enum/dmp-status';
import { ExtraPropertiesFormModel } from '@app/ui/dmp/editor/general-tab/extra-properties-form.model';
import { DatasetWizardModel } from '../dataset/dataset-wizard'; import { DatasetWizardModel } from '../dataset/dataset-wizard';
import { DmpDatasetProfile } from "./dmp-dataset-profile/dmp-dataset-profile";
export interface DmpModel { export interface DmpModel {
id: string; id: string;
@ -27,7 +25,7 @@ export interface DmpModel {
funder: FunderModel; funder: FunderModel;
datasets: DatasetWizardModel[]; datasets: DatasetWizardModel[];
datasetsToBeFinalized: string[]; datasetsToBeFinalized: string[];
profiles: DmpProfile[]; profiles: DmpDatasetProfile[];
organisations: OrganizationModel[]; organisations: OrganizationModel[];
researchers: ResearcherModel[]; researchers: ResearcherModel[];
associatedUsers: UserModel[]; associatedUsers: UserModel[];

View File

@ -0,0 +1,18 @@
import { Pipe, PipeTransform } from "@angular/core";
import { FormGroup } from "@angular/forms";
@Pipe({
name: 'datasetInSection'
})
export class DatasetInSectioPipe implements PipeTransform{
transform(datasets: FormGroup[], args: string): FormGroup[] {
let values = [];
for(var dataset of datasets){
if(dataset.get('dmpSectionIndex').value == args){
values.push(dataset);
}
}
return values;
}
}

View File

@ -0,0 +1,5 @@
import { BaseCriteria } from "../base-criteria";
export class DmpBlueprintCriteria extends BaseCriteria {
}

View File

@ -0,0 +1,38 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ConfigurationService } from '../configuration/configuration.service';
import { BaseHttpService } from '../http/base-http.service';
import { Observable } from 'rxjs';
import { DataTableData } from '@app/core/model/data-table/data-table-data';
import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type';
@Injectable()
export class DescriptionTemplateTypeService {
private actionUrl: string;
private headers = new HttpHeaders();
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'descriptionTemplateType/';
}
getTypes(): Observable<DataTableData<DescriptionTemplateType>> {
return this.http.get<DataTableData<DescriptionTemplateType>>(this.actionUrl + 'get', { headers: this.headers });
}
getSingle(id: string): Observable<DescriptionTemplateType> {
return this.http.get<DescriptionTemplateType>(this.actionUrl + 'get/' + id, { headers: this.headers });
}
createType(type: DescriptionTemplateType): Observable<DescriptionTemplateType> {
return this.http.post<DescriptionTemplateType>(this.actionUrl + 'create', type, { headers: this.headers });
}
updateType(type: DescriptionTemplateType): Observable<DescriptionTemplateType> {
return this.http.post<DescriptionTemplateType>(this.actionUrl + 'update', type, { headers: this.headers });
}
deleteType(id: string): Observable<DescriptionTemplateType> {
return this.http.delete<DescriptionTemplateType>(this.actionUrl + 'delete/' + id, { headers: this.headers });
}
}

Some files were not shown because too many files have changed in this diff Show More