Merge branch 'Development'
This commit is contained in:
commit
e8aef281d4
|
@ -48,3 +48,4 @@ bin/
|
||||||
*.classpath
|
*.classpath
|
||||||
openDMP/dmp-backend/uploads/
|
openDMP/dmp-backend/uploads/
|
||||||
openDMP/dmp-backend/tmp/
|
openDMP/dmp-backend/tmp/
|
||||||
|
dmp-frontend/.angular/
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
|
|
||||||
|
public class DataManagementPlanBlueprintCriteria extends Criteria<DMPProfile> {
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
import eu.eudat.data.entities.Grant;
|
import eu.eudat.data.entities.Grant;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -10,6 +11,7 @@ import java.util.UUID;
|
||||||
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
private Date periodEnd;
|
private Date periodEnd;
|
||||||
|
private DMPProfile profile;
|
||||||
private List<eu.eudat.data.entities.Grant> grants;
|
private List<eu.eudat.data.entities.Grant> grants;
|
||||||
private boolean allVersions;
|
private boolean allVersions;
|
||||||
private List<UUID> groupIds;
|
private List<UUID> groupIds;
|
||||||
|
@ -37,6 +39,13 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||||
this.periodEnd = periodEnd;
|
this.periodEnd = periodEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DMPProfile getProfile() {
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
public void setProfile(DMPProfile profile) {
|
||||||
|
this.profile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Grant> getGrants() {
|
public List<Grant> getGrants() {
|
||||||
return grants;
|
return grants;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
|
@ -42,6 +42,8 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||||
if (criteria.getPeriodStart() != null)
|
if (criteria.getPeriodStart() != null)
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||||
|
if (criteria.getProfile() != null)
|
||||||
|
query.where((builder, root) -> builder.equal(root.get("profile"), criteria.getProfile()));
|
||||||
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
||||||
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
||||||
if (!criteria.getAllVersions())
|
if (!criteria.getAllVersions())
|
||||||
|
@ -75,7 +77,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
||||||
}
|
}
|
||||||
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
|
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
|
||||||
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
|
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("datasetprofile").get("id").in(criteria.getDatasetTemplates()));
|
||||||
}
|
}
|
||||||
if (criteria.getGrantStatus() != null) {
|
if (criteria.getGrantStatus() != null) {
|
||||||
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
|
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,20 @@ 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() + "%"));
|
||||||
|
if (criteria.getStatus() != null) {
|
||||||
|
if (criteria.getStatus() == DMPProfile.Status.FINALIZED.getValue()) {
|
||||||
|
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.FINALIZED.getValue()));
|
||||||
|
} else if (criteria.getStatus() == DMPProfile.Status.SAVED.getValue()) {
|
||||||
|
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.SAVED.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
}
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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.and(builder.equal(root.get("name"), name), builder.notEqual(root.get("status"), DescriptionTemplateType.Status.DELETED.getValue()))).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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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> {
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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());
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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() {
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
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() + "%"));
|
||||||
|
if (this.getCriteria().getStatus() != null)
|
||||||
|
query.where((builder, root) -> builder.equal(root.get("status"), this.getCriteria().getStatus()));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryableList<DMPProfile> applyPaging(QueryableList<DMPProfile> items) {
|
||||||
|
return PaginationService.applyPaging(items, this);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,9 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
if (this.group != null) {
|
if (this.group != null) {
|
||||||
builder.field("group", this.group.toString());
|
builder.field("group", this.group.toString());
|
||||||
}
|
}
|
||||||
builder.field("grant", this.grant.toString());
|
if (this.grant != null) {
|
||||||
|
builder.field("grant", this.grant.toString());
|
||||||
|
}
|
||||||
if (collaborators != null) {
|
if (collaborators != null) {
|
||||||
builder.startArray("collaborators");
|
builder.startArray("collaborators");
|
||||||
this.collaborators.forEach(x -> {
|
this.collaborators.forEach(x -> {
|
||||||
|
@ -300,7 +302,9 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
this.status = Short.valueOf((String) fields.get("status"));
|
this.status = Short.valueOf((String) fields.get("status"));
|
||||||
this.dmp = UUID.fromString((String) fields.get("dmp"));
|
this.dmp = UUID.fromString((String) fields.get("dmp"));
|
||||||
this.group = UUID.fromString((String) fields.get("group"));
|
this.group = UUID.fromString((String) fields.get("group"));
|
||||||
this.grant = UUID.fromString((String) fields.get("grant"));
|
if (fields.get("grant") != null) {
|
||||||
|
this.grant = UUID.fromString((String) fields.get("grant"));
|
||||||
|
}
|
||||||
if (fields.get("created") != null)
|
if (fields.get("created") != null)
|
||||||
this.created = Date.from(Instant.parse((String) fields.get("created")));
|
this.created = Date.from(Instant.parse((String) fields.get("created")));
|
||||||
if (fields.get("modified") != null)
|
if (fields.get("modified") != null)
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,7 +323,9 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
if (fields.get(MapKey.DATASETS.getName()) != null) {
|
if (fields.get(MapKey.DATASETS.getName()) != null) {
|
||||||
this.datasets = ((List<HashMap<String, Object>>) fields.get(MapKey.DATASETS.getName())).stream().map(map -> new Dataset().fromElasticEntity(map)).collect(Collectors.toList());
|
this.datasets = ((List<HashMap<String, Object>>) fields.get(MapKey.DATASETS.getName())).stream().map(map -> new Dataset().fromElasticEntity(map)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
this.grant = UUID.fromString((String) fields.get(MapKey.GRANT.getName()));
|
if (fields.containsKey(MapKey.GRANT.getName()) && fields.get(MapKey.GRANT.getName()) != null) {
|
||||||
|
this.grant = UUID.fromString((String) fields.get(MapKey.GRANT.getName()));
|
||||||
|
}
|
||||||
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
|
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
|
||||||
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
|
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.tags"}, null)));
|
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.tags"}, null)).setSize(this.environment.getProperty("elasticsearch.innerHitsSize", Integer.class)));
|
||||||
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset())*/.fetchSource("datasets.tags", null);
|
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset())*/.fetchSource("datasets.tags", null);
|
||||||
/*if (criteria.getSize() > 0) {
|
/*if (criteria.getSize() > 0) {
|
||||||
searchSourceBuilder.size(criteria.getSize());
|
searchSourceBuilder.size(criteria.getSize());
|
||||||
|
@ -206,7 +206,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.None).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.id"}, null)));
|
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.None).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.id"}, null)).setSize(this.environment.getProperty("elasticsearch.innerHitsSize", Integer.class)));
|
||||||
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset()).size(criteria.getSize())*/.fetchSource("datasets.id", null);
|
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset()).size(criteria.getSize())*/.fetchSource("datasets.id", null);
|
||||||
sortBuilders.forEach(searchSourceBuilder::sort);
|
sortBuilders.forEach(searchSourceBuilder::sort);
|
||||||
searchRequest.source(searchSourceBuilder);
|
searchRequest.source(searchSourceBuilder);
|
||||||
|
@ -261,6 +261,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getDatasetTemplates() != null && criteria.getDatasetTemplates().size() > 0) {
|
if (criteria.getDatasetTemplates() != null && criteria.getDatasetTemplates().size() > 0) {
|
||||||
|
criteria.setDatasetTemplates(criteria.getDatasetTemplates().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.template", criteria.getDatasetTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.template", criteria.getDatasetTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,14 +270,17 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getDmps() != null && criteria.getDmps().size() > 0) {
|
if (criteria.getDmps() != null && criteria.getDmps().size() > 0) {
|
||||||
|
criteria.setDmps(criteria.getDmps().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.dmp", criteria.getDmps().stream().map(UUID::toString).collect(Collectors.toList())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.dmp", criteria.getDmps().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getGroupIds() != null && criteria.getGroupIds().size() > 0) {
|
if (criteria.getGroupIds() != null && criteria.getGroupIds().size() > 0) {
|
||||||
|
criteria.setGroupIds(criteria.getGroupIds().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.group", criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.group", criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getGrants() != null && criteria.getGrants().size() > 0) {
|
if (criteria.getGrants() != null && criteria.getGrants().size() > 0) {
|
||||||
|
criteria.setGrants(criteria.getGrants().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.grant", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.grant", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,6 +289,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
||||||
|
criteria.setCollaborators(criteria.getCollaborators().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.collaborators.id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.collaborators.id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,10 +300,12 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getOrganiztions() != null && criteria.getOrganiztions().size() > 0) {
|
if (criteria.getOrganiztions() != null && criteria.getOrganiztions().size() > 0) {
|
||||||
|
criteria.setOrganiztions(criteria.getOrganiztions().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.organizations.id", criteria.getOrganiztions()));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.organizations.id", criteria.getOrganiztions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getTags() != null && criteria.getTags().size() > 0) {
|
if (criteria.getTags() != null && criteria.getTags().size() > 0) {
|
||||||
|
criteria.setTags(criteria.getTags().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.tags.name", criteria.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.tags.name", criteria.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
<artifactId>repositorydepositbase</artifactId>
|
<artifactId>repositorydepositbase</artifactId>
|
||||||
<version>1.0.3</version>
|
<version>1.0.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +46,10 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||||
|
|
||||||
|
|
|
@ -22,22 +22,15 @@ public class AboutController {
|
||||||
|
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
private MaterialManager materialManager;
|
private MaterialManager materialManager;
|
||||||
private final MetricsManager metricsManager;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public AboutController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
public AboutController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.materialManager = materialManager;
|
this.materialManager = materialManager;
|
||||||
this.metricsManager = metricsManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||||
public ResponseEntity<byte[]> getAbout(@PathVariable(name = "lang") String lang) throws IOException {
|
public ResponseEntity<byte[]> getAbout(@PathVariable(name = "lang") String lang) throws IOException {
|
||||||
// long files = 0;
|
|
||||||
// try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("about.path"))))) {
|
|
||||||
// files = paths.count();
|
|
||||||
// }
|
|
||||||
// metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
|
||||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("about.path"))))) {
|
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("about.path"))))) {
|
||||||
return this.materialManager.getResponseEntity(lang, paths);
|
return this.materialManager.getResponseEntity(lang, paths);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -58,41 +57,42 @@ public class Admin extends BaseController {
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
|
||||||
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) throws Exception {
|
||||||
//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());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@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) throws Exception {
|
||||||
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()));
|
||||||
|
@ -124,8 +124,8 @@ 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) throws Exception {
|
||||||
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,11 +156,12 @@ 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());
|
||||||
datasetProfile.setLanguage(profile.getLanguage());
|
datasetProfile.setLanguage(profile.getLanguage());
|
||||||
|
datasetProfile.setType(profile.getType().getName());
|
||||||
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||||
|
@ -173,12 +174,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 +187,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(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,10 @@ 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.exceptions.dmpblueprint.DmpBlueprintUsedException;
|
||||||
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;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
@ -10,6 +13,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;
|
||||||
|
@ -26,6 +30,7 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static eu.eudat.types.Authorities.ADMIN;
|
import static eu.eudat.types.Authorities.ADMIN;
|
||||||
|
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/21/2018.
|
* Created by ikalyvas on 3/21/2018.
|
||||||
|
@ -51,6 +56,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 +71,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) {
|
||||||
|
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,24 +85,51 @@ 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public ResponseEntity<ResponseItem<DataManagementPlanBlueprintListingModel>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||||
|
DataManagementPlanBlueprintListingModel dmpBlueprint = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
|
||||||
|
dmpBlueprint.setLabel(dmpBlueprint.getLabel() + " new ");
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().payload(dmpBlueprint));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<Void>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||||
|
try {
|
||||||
|
this.dataManagementProfileManager.inactivate(id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
|
} catch (DmpBlueprintUsedException exception) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@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 IOException {
|
||||||
if (contentType.equals("application/xml")) {
|
if (contentType.equals("application/xml")) {
|
||||||
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id, principal);
|
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
|
||||||
return this.dataManagementProfileManager.getDocument(dataManagementPlanProfileListingModel,dataManagementPlanProfileListingModel.getLabel());
|
return this.dataManagementProfileManager.getDocument(dataManagementPlanBlueprintListingModel);
|
||||||
}else {
|
}else {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||||
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||||
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException,IOException,Exception{
|
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||||
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
|
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint dmpBlueprintModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
|
||||||
DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename());
|
DataManagementPlanBlueprintListingModel dmpBlueprint = dmpBlueprintModel.toDmpProfileCompositeModel(file.getOriginalFilename());
|
||||||
this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal);
|
this.dataManagementProfileManager.createOrUpdateBlueprint(dmpBlueprint, 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(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ public class DMPs extends BaseController {
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<UUID>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
ResponseEntity<ResponseItem<UUID>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||||
UUID cloneId = this.dataManagementPlanManager.clone(dataManagementPlan, principal);
|
UUID cloneId = this.dataManagementPlanManager.clone(id, dataManagementPlan, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(cloneId));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(cloneId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -8,6 +9,7 @@ import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||||
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
||||||
|
import eu.eudat.models.data.helpers.common.AutoCompleteOptionsLookupItem;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.properties.PropertiesModel;
|
import eu.eudat.models.data.properties.PropertiesModel;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
|
@ -55,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));
|
||||||
|
@ -63,11 +65,19 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocompleteOptions"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public ResponseEntity<Object> getDataForAutocompleteOptions(@RequestBody RequestItem<AutoCompleteOptionsLookupItem> lookupItem) {
|
||||||
|
AutoCompleteData data = new AutoCompleteData();
|
||||||
|
data.setAutoCompleteSingleDataList(lookupItem.getCriteria().getAutoCompleteSingleDataList());
|
||||||
|
List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(items);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.logic.managers.DatasetProfileManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
|
import eu.eudat.models.data.datasetprofile.DatasetProfileWithPrefillingPropertyModel;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -42,5 +43,12 @@ public class DatasetProfiles extends BaseController {
|
||||||
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
|
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getAllWithPrefilling"}, produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>> getAllWithPrefilling(@RequestBody DatasetProfileTableRequestItem tableRequestItem) {
|
||||||
|
List<DatasetProfileWithPrefillingPropertyModel> datasetProfileTableData = this.datasetProfileManager.getAllWithPrefilling(tableRequestItem);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -256,7 +257,8 @@ public class Datasets extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DatasetWizardModel>> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) throws Exception {
|
ResponseEntity<ResponseItem<DatasetWizardModel>> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) throws Exception {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel().fromDataModel(this.datasetManager.createOrUpdate(profile, principal));
|
DatasetWizardModel dataset = new DatasetWizardModel().fromDataModel(this.datasetManager.createOrUpdate(profile, principal));
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dataset));
|
dataset.setTags(profile.getTags());
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dataset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
|
@ -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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,16 +32,16 @@ public class EmailMergeConfirmation {
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/{emailToken}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/{emailToken}"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem> emailConfirmation(@PathVariable(value = "emailToken") String token) {
|
ResponseEntity<ResponseItem<String>> emailConfirmation(@PathVariable(value = "emailToken") String token) {
|
||||||
try {
|
try {
|
||||||
this.emailConfirmationManager.confirmEmail(token);
|
String emailToBeMerged = this.emailConfirmationManager.confirmEmail(token);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().payload(emailToBeMerged).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
} catch
|
} catch
|
||||||
(HasConfirmedEmailException | TokenExpiredException ex) {
|
(HasConfirmedEmailException | TokenExpiredException ex) {
|
||||||
if (ex instanceof TokenExpiredException) {
|
if (ex instanceof TokenExpiredException) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.NO_MESSAGE));
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem().status(ApiMessageCode.WARN_MESSAGE));
|
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem<String>().status(ApiMessageCode.WARN_MESSAGE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,22 +21,15 @@ public class FaqController {
|
||||||
|
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
private MaterialManager materialManager;
|
private MaterialManager materialManager;
|
||||||
private final MetricsManager metricsManager;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public FaqController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
public FaqController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.materialManager = materialManager;
|
this.materialManager = materialManager;
|
||||||
this.metricsManager = metricsManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||||
public ResponseEntity<byte[]> getFaq(@PathVariable(name = "lang") String lang) throws IOException {
|
public ResponseEntity<byte[]> getFaq(@PathVariable(name = "lang") String lang) throws IOException {
|
||||||
// long files = 0;
|
|
||||||
// try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("faq.path"))))) {
|
|
||||||
// files = paths.count();
|
|
||||||
// }
|
|
||||||
// metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
|
||||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("faq.path"))))) {
|
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("faq.path"))))) {
|
||||||
return this.materialManager.getResponseEntity(lang, paths);
|
return this.materialManager.getResponseEntity(lang, paths);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,22 +21,15 @@ public class GlossaryController {
|
||||||
|
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
private MaterialManager materialManager;
|
private MaterialManager materialManager;
|
||||||
private final MetricsManager metricsManager;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public GlossaryController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
public GlossaryController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.materialManager = materialManager;
|
this.materialManager = materialManager;
|
||||||
this.metricsManager = metricsManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||||
public ResponseEntity<byte[]> getGlossary(@PathVariable(name = "lang") String lang) throws IOException {
|
public ResponseEntity<byte[]> getGlossary(@PathVariable(name = "lang") String lang) throws IOException {
|
||||||
// long files = 0;
|
|
||||||
// try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("glossary.path"))))) {
|
|
||||||
// files = paths.count();
|
|
||||||
// }
|
|
||||||
// metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
|
||||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("glossary.path"))))) {
|
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("glossary.path"))))) {
|
||||||
return this.materialManager.getResponseEntity(lang, paths);
|
return this.materialManager.getResponseEntity(lang, paths);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -26,8 +27,8 @@ public class Prefillings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/prefilling/list"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/prefilling/list"}, produces = "application/json")
|
||||||
public ResponseEntity<ResponseItem<List<Prefilling>>> getPrefillingList(@RequestParam String like, @RequestParam String configId) {
|
public ResponseEntity<ResponseItem<List<Prefilling>>> getPrefillingList(@RequestParam String like) {
|
||||||
List<Prefilling> prefillingList = prefillingManager.getPrefillings(like, configId);
|
List<Prefilling> prefillingList = prefillingManager.getPrefillings(like);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Prefilling>>().payload(prefillingList).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Prefilling>>().payload(prefillingList).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,4 +37,10 @@ public class Prefillings {
|
||||||
DatasetWizardModel datasetWizardModel = prefillingManager.getPrefilledDataset(id, configId, profileId);
|
DatasetWizardModel datasetWizardModel = prefillingManager.getPrefilledDataset(id, configId, profileId);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().payload(datasetWizardModel).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().payload(datasetWizardModel).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/prefilling/generateUsingData"}, produces = "application/json")
|
||||||
|
public ResponseEntity<ResponseItem<DatasetWizardModel>> getPrefillingDataset(@RequestBody Map<String, Object> data, @RequestParam String configId, @RequestParam UUID profileId) throws Exception {
|
||||||
|
DatasetWizardModel datasetWizardModel = prefillingManager.getPrefilledDatasetUsingData(data, configId, profileId);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().payload(datasetWizardModel).status(ApiMessageCode.NO_MESSAGE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -48,9 +46,9 @@ public class QuickWizardController extends BaseController {
|
||||||
Funder funderEntity;
|
Funder funderEntity;
|
||||||
//Create Funder
|
//Create Funder
|
||||||
if (quickWizard.getFunder() == null) {
|
if (quickWizard.getFunder() == null) {
|
||||||
throw new Exception("Funder is a mandatory entity");
|
funderEntity = null;
|
||||||
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
|
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
|
||||||
throw new Exception("Funder is a mandatory entity");
|
funderEntity = null;
|
||||||
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
|
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
|
||||||
funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder(), principal);
|
funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder(), principal);
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,9 +58,9 @@ public class QuickWizardController extends BaseController {
|
||||||
eu.eudat.data.entities.Grant grantEntity;
|
eu.eudat.data.entities.Grant grantEntity;
|
||||||
//Create Grant
|
//Create Grant
|
||||||
if (quickWizard.getGrant() == null) {
|
if (quickWizard.getGrant() == null) {
|
||||||
throw new Exception("Grant is a mandatory entity");
|
grantEntity = null;
|
||||||
} else if (quickWizard.getGrant().getExistGrant() == null && quickWizard.getGrant().getLabel() == null) {
|
} else if (quickWizard.getGrant().getExistGrant() == null && quickWizard.getGrant().getLabel() == null) {
|
||||||
throw new Exception("Grant is a mandatory entity");
|
grantEntity = null;
|
||||||
} else if (quickWizard.getGrant().getExistGrant() == null) {
|
} else if (quickWizard.getGrant().getExistGrant() == null) {
|
||||||
grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant(), principal);
|
grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant(), principal);
|
||||||
} else {
|
} else {
|
||||||
|
@ -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);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.sam
|
||||||
import eu.eudat.logic.security.validators.configurableProvider.Saml2SSOUtils;
|
import eu.eudat.logic.security.validators.configurableProvider.Saml2SSOUtils;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
|
import eu.eudat.models.data.saml2.AuthnRequestModel;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
@ -56,14 +57,14 @@ public class Saml2MetadataController extends BaseController {
|
||||||
}
|
}
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"authnRequest/{configurableProviderId}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"authnRequest/{configurableProviderId}"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<String>> getAuthnRequest(@PathVariable String configurableProviderId) {
|
ResponseEntity getAuthnRequest(@PathVariable String configurableProviderId) {
|
||||||
Saml2ConfigurableProvider saml2ConfigurableProvider = (Saml2ConfigurableProvider) this.configLoader.getConfigurableProviders().getProviders().stream()
|
Saml2ConfigurableProvider saml2ConfigurableProvider = (Saml2ConfigurableProvider) this.configLoader.getConfigurableProviders().getProviders().stream()
|
||||||
.filter(prov -> prov.getConfigurableLoginId().equals(configurableProviderId))
|
.filter(prov -> prov.getConfigurableLoginId().equals(configurableProviderId))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
if (saml2ConfigurableProvider != null) {
|
if (saml2ConfigurableProvider != null) {
|
||||||
try {
|
try {
|
||||||
String authnRequestXml = Saml2SSOUtils.getAuthnRequest(saml2ConfigurableProvider);
|
AuthnRequestModel authnRequest = Saml2SSOUtils.getAuthnRequest(saml2ConfigurableProvider);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(authnRequestXml));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<AuthnRequestModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(authnRequest));
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create authentication request."));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create authentication request."));
|
||||||
|
|
|
@ -21,22 +21,15 @@ public class TermsOfServiceController {
|
||||||
|
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
private MaterialManager materialManager;
|
private MaterialManager materialManager;
|
||||||
private final MetricsManager metricsManager;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public TermsOfServiceController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
public TermsOfServiceController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.materialManager = materialManager;
|
this.materialManager = materialManager;
|
||||||
this.metricsManager = metricsManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||||
public ResponseEntity<byte[]> getTermsOfService(@PathVariable(name = "lang") String lang) throws IOException {
|
public ResponseEntity<byte[]> getTermsOfService(@PathVariable(name = "lang") String lang) throws IOException {
|
||||||
// long files = 0;
|
|
||||||
// try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("termsofservice.path"))))) {
|
|
||||||
// files = paths.count();
|
|
||||||
// }
|
|
||||||
// metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
|
||||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("termsofservice.path"))))) {
|
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("termsofservice.path"))))) {
|
||||||
return this.materialManager.getResponseEntity(lang, paths);
|
return this.materialManager.getResponseEntity(lang, paths);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,22 +34,15 @@ public class UserGuideController {
|
||||||
|
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
private MaterialManager materialManager;
|
private MaterialManager materialManager;
|
||||||
private final MetricsManager metricsManager;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UserGuideController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
public UserGuideController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.materialManager = materialManager;
|
this.materialManager = materialManager;
|
||||||
this.metricsManager = metricsManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||||
public ResponseEntity<byte[]> getUserGuide(@PathVariable(name = "lang") String lang) throws IOException {
|
public ResponseEntity<byte[]> getUserGuide(@PathVariable(name = "lang") String lang) throws IOException {
|
||||||
long files = 0;
|
|
||||||
try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
|
|
||||||
files = paths.count();
|
|
||||||
}
|
|
||||||
metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
|
||||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
|
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
|
||||||
return this.materialManager.getResponseEntity(lang, paths);
|
return this.materialManager.getResponseEntity(lang, paths);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.criteria;
|
||||||
public class RecentActivityCriteria {
|
public class RecentActivityCriteria {
|
||||||
private String like;
|
private String like;
|
||||||
private String order;
|
private String order;
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
public String getLike() {
|
public String getLike() {
|
||||||
return like;
|
return like;
|
||||||
|
@ -19,4 +20,12 @@ public class RecentActivityCriteria {
|
||||||
public void setOrder(String order) {
|
public void setOrder(String order) {
|
||||||
this.order = order;
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package eu.eudat.exceptions.descriptiontemplate;
|
||||||
|
|
||||||
|
public class DescriptionTemplatesWithTypeException extends RuntimeException {
|
||||||
|
|
||||||
|
public DescriptionTemplatesWithTypeException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package eu.eudat.exceptions.dmpblueprint;
|
||||||
|
|
||||||
|
public class DmpBlueprintUsedException extends RuntimeException {
|
||||||
|
public DmpBlueprintUsedException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpBlueprintUsedException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpBlueprintUsedException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpBlueprintUsedException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
package eu.eudat.logic.builders.entity;
|
package eu.eudat.logic.builders.entity;
|
||||||
|
|
||||||
|
import eu.eudat.data.entities.DescriptionTemplate;
|
||||||
|
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||||
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,12 +12,14 @@ 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;
|
||||||
|
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
|
private DescriptionTemplateType type;
|
||||||
|
|
||||||
private Set<Dataset> dataset;
|
private Set<Dataset> dataset;
|
||||||
|
|
||||||
private String definition;
|
private String definition;
|
||||||
|
@ -41,6 +44,11 @@ public class DatasetProfileBuilder extends Builder<DatasetProfile> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DatasetProfileBuilder type(DescriptionTemplateType type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DatasetProfileBuilder dataset(Set<Dataset> dataset) {
|
public DatasetProfileBuilder dataset(Set<Dataset> dataset) {
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
return this;
|
return this;
|
||||||
|
@ -77,17 +85,18 @@ 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;
|
descriptionTemplate.setType(type);
|
||||||
|
return descriptionTemplate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ 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.data.entities.DescriptionTemplateType;
|
||||||
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,8 +19,9 @@ 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) throws Exception {
|
||||||
ViewStyleModel viewStyleModel = new ViewStyleModel();
|
ViewStyleModel viewStyleModel = new ViewStyleModel();
|
||||||
|
viewStyleModel.setEnablePrefilling(profile.isEnablePrefilling());
|
||||||
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));
|
||||||
Document viewStyleDoc = XmlBuilder.getDocument();
|
Document viewStyleDoc = XmlBuilder.getDocument();
|
||||||
|
@ -34,22 +37,31 @@ 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())
|
DescriptionTemplateType type;
|
||||||
|
try {
|
||||||
|
type = apiContext.getOperationsContext().getDatabaseRepository().getDescriptionTemplateTypeDao().findFromName(profile.getType());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new Exception("Description template type '" + profile.getType() + "' could not be found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
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())
|
||||||
|
.type(type)
|
||||||
.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 +72,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 {
|
||||||
|
|
|
@ -91,7 +91,9 @@ public class DashBoardManager {
|
||||||
for (DMP dmp : dmps) {
|
for (DMP dmp : dmps) {
|
||||||
numberOfDatasets = numberOfDatasets + dmp.getDataset().stream()
|
numberOfDatasets = numberOfDatasets + dmp.getDataset().stream()
|
||||||
.filter(item -> item.getStatus() == Dataset.Status.FINALISED.getValue()).count();
|
.filter(item -> item.getStatus() == Dataset.Status.FINALISED.getValue()).count();
|
||||||
grants.add(dmp.getGrant());
|
if (dmp.getGrant() != null) {
|
||||||
|
grants.add(dmp.getGrant());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
statistics.setTotalDataManagementPlanCount((long) dmps.size());
|
statistics.setTotalDataManagementPlanCount((long) dmps.size());
|
||||||
|
@ -221,11 +223,17 @@ public class DashBoardManager {
|
||||||
}
|
}
|
||||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||||
datasetCriteria.setLike(tableRequest.getCriteria().getLike());
|
datasetCriteria.setLike(tableRequest.getCriteria().getLike());
|
||||||
|
if(tableRequest.getCriteria().getStatus() != null) {
|
||||||
|
datasetCriteria.setStatus(tableRequest.getCriteria().getStatus());
|
||||||
|
}
|
||||||
datasetCriteria.setAllVersions(false);
|
datasetCriteria.setAllVersions(false);
|
||||||
datasetCriteria.setIsPublic(!isAuthenticated);
|
datasetCriteria.setIsPublic(!isAuthenticated);
|
||||||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||||
dataManagementPlanCriteria.setAllVersions(false);
|
dataManagementPlanCriteria.setAllVersions(false);
|
||||||
dataManagementPlanCriteria.setLike(tableRequest.getCriteria().getLike());
|
dataManagementPlanCriteria.setLike(tableRequest.getCriteria().getLike());
|
||||||
|
if(tableRequest.getCriteria().getStatus() != null) {
|
||||||
|
dataManagementPlanCriteria.setStatus(tableRequest.getCriteria().getStatus());
|
||||||
|
}
|
||||||
dataManagementPlanCriteria.setIsPublic(!isAuthenticated);
|
dataManagementPlanCriteria.setIsPublic(!isAuthenticated);
|
||||||
dataManagementPlanCriteria.setOnlyPublic(!isAuthenticated);
|
dataManagementPlanCriteria.setOnlyPublic(!isAuthenticated);
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,21 +2,29 @@ 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.DataManagementPlanCriteria;
|
||||||
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.DatasetDao;
|
||||||
|
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
||||||
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.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.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
|
||||||
|
import eu.eudat.exceptions.dmpblueprint.DmpBlueprintUsedException;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpProfile;
|
import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpBlueprint;
|
||||||
import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpProfile;
|
import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpBlueprint;
|
||||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DmpProfileExternalAutoComplete;
|
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.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType;
|
||||||
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 +86,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 +107,45 @@ public class DataManagementProfileManager {
|
||||||
return dataManagementPlanProfileListingModel;
|
return dataManagementPlanProfileListingModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DataManagementPlanBlueprintListingModel getSingleBlueprint(String id, Principal principal) {
|
||||||
|
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
|
||||||
|
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = new DataManagementPlanBlueprintListingModel();
|
||||||
|
dataManagementPlanBlueprintListingModel.fromDataModel(dmpProfile);
|
||||||
|
return dataManagementPlanBlueprintListingModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fieldInBlueprint(String id, SystemFieldType type, Principal principal) {
|
||||||
|
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
|
||||||
|
return this.fieldInBlueprint(dmpProfile, type, principal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fieldInBlueprint(DMPProfile dmpProfile, SystemFieldType type, Principal principal) {
|
||||||
|
DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel();
|
||||||
|
dmpBlueprint.fromDataModel(dmpProfile);
|
||||||
|
for(Section section: dmpBlueprint.getDefinition().getSections()){
|
||||||
|
for(FieldModel field: section.getFields()){
|
||||||
|
if(field.getCategory().equals(FieldCategory.SYSTEM)){
|
||||||
|
SystemField systemField = field.toSystemField();
|
||||||
|
if(systemField.getType().equals(type)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> sectionIndexesForDescriptionTemplate(DMPProfile dmpProfile, UUID descriptionTemplateId) {
|
||||||
|
DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel();
|
||||||
|
dmpBlueprint.fromDataModel(dmpProfile);
|
||||||
|
List<Integer> sectionIndexes = new ArrayList<>();
|
||||||
|
for(int i = 0; i < dmpBlueprint.getDefinition().getSections().size(); i++) {
|
||||||
|
Section section = dmpBlueprint.getDefinition().getSections().get(i);
|
||||||
|
if(section.getHasTemplates() && section.getDescriptionTemplates().stream().anyMatch(x -> x.getDescriptionTemplateId().equals(descriptionTemplateId))) sectionIndexes.add(i);
|
||||||
|
}
|
||||||
|
return sectionIndexes;
|
||||||
|
}
|
||||||
|
|
||||||
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,8 +157,25 @@ public class DataManagementProfileManager {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<byte[]> getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
|
public void createOrUpdateBlueprint(DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel, Principal principal) throws Exception {
|
||||||
FileEnvelope envelope = getXmlDocument(dmpProfile, label);
|
DMPProfile dmpProfile = dataManagementPlanBlueprintListingModel.toDataModel();
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inactivate(String id) {
|
||||||
|
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
|
||||||
|
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||||
|
dataManagementPlanCriteria.setProfile(dmpProfile);
|
||||||
|
if (dmpProfile.getStatus() == DMPProfile.Status.SAVED.getValue() || databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).count() == 0) {
|
||||||
|
dmpProfile.setStatus(DMPProfile.Status.DELETED.getValue());
|
||||||
|
databaseRepository.getDmpProfileDao().createOrUpdate(dmpProfile);
|
||||||
|
} else {
|
||||||
|
throw new DmpBlueprintUsedException("This blueprint can not deleted, because DMPs are associated with it");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<byte[]> getDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException {
|
||||||
|
FileEnvelope envelope = getXmlDocument(dmpProfile);
|
||||||
InputStream resource = new FileInputStream(envelope.getFile());
|
InputStream resource = new FileInputStream(envelope.getFile());
|
||||||
logger.info("Mime Type of " + envelope.getFilename() + " is " +
|
logger.info("Mime Type of " + envelope.getFilename() + " is " +
|
||||||
new MimetypesFileTypeMap().getContentType(envelope.getFile()));
|
new MimetypesFileTypeMap().getContentType(envelope.getFile()));
|
||||||
|
@ -116,18 +194,18 @@ public class DataManagementProfileManager {
|
||||||
HttpStatus.OK);
|
HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileEnvelope getXmlDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws InstantiationException, IllegalAccessException, IOException {
|
public FileEnvelope getXmlDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException {
|
||||||
ExportXmlBuilderDmpProfile xmlBuilder = new ExportXmlBuilderDmpProfile();
|
ExportXmlBuilderDmpBlueprint xmlBuilder = new ExportXmlBuilderDmpBlueprint();
|
||||||
File file = xmlBuilder.build(dmpProfile, environment);
|
File file = xmlBuilder.build(dmpProfile, environment);
|
||||||
FileEnvelope fileEnvelope = new FileEnvelope();
|
FileEnvelope fileEnvelope = new FileEnvelope();
|
||||||
fileEnvelope.setFile(file);
|
fileEnvelope.setFile(file);
|
||||||
fileEnvelope.setFilename(label);
|
fileEnvelope.setFilename(dmpProfile.getLabel());
|
||||||
return fileEnvelope;
|
return fileEnvelope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile createDmpProfileFromXml(MultipartFile multiPartFile) {
|
public eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint createDmpProfileFromXml(MultipartFile multiPartFile) {
|
||||||
ImportXmlBuilderDmpProfile xmlBuilder = new ImportXmlBuilderDmpProfile();
|
ImportXmlBuilderDmpBlueprint xmlBuilder = new ImportXmlBuilderDmpBlueprint();
|
||||||
try {
|
try {
|
||||||
return xmlBuilder.build(convert(multiPartFile));
|
return xmlBuilder.build(convert(multiPartFile));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -289,6 +289,45 @@ public class DatasetManager {
|
||||||
.stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
|
.stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
|
||||||
.collect(Collectors.toList()).size() == 0 && !datasetEntity.getDmp().isPublic())
|
.collect(Collectors.toList()).size() == 0 && !datasetEntity.getDmp().isPublic())
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
||||||
|
dataset.fromDataModel(datasetEntity);
|
||||||
|
|
||||||
|
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
||||||
|
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
||||||
|
UUID profileId = datasetEntity.getProfile().getGroupId();
|
||||||
|
List<UUID> uuidList = new LinkedList<>();
|
||||||
|
uuidList.add(profileId);
|
||||||
|
profileCriteria.setGroupIds(uuidList);
|
||||||
|
profileCriteria.setAllVersions(true);
|
||||||
|
|
||||||
|
List<DescriptionTemplate> profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria)
|
||||||
|
.orderBy(((builder, root) -> builder.desc(root.get("version"))))
|
||||||
|
.toList();
|
||||||
|
List<DescriptionTemplate> profileVersionsIncluded = new LinkedList<>();
|
||||||
|
|
||||||
|
// Iterate through the versions and remove those that are not included in the DMP of the dataset in question.
|
||||||
|
for (DescriptionTemplate version : profileVersions) {
|
||||||
|
for (AssociatedProfile p : dataset.getDmp().getProfiles()) {
|
||||||
|
if (version.getId().toString().equals(p.getDescriptionTemplateId().toString())) {
|
||||||
|
profileVersionsIncluded.add(version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort the list with the included Versions.
|
||||||
|
Stream<DescriptionTemplate> sorted = profileVersionsIncluded.stream().sorted(Comparator.comparing(DescriptionTemplate::getVersion).reversed());
|
||||||
|
|
||||||
|
// Make the Stream into List and get the first item.
|
||||||
|
List<DescriptionTemplate> profiles = sorted.collect(Collectors.toList());
|
||||||
|
if (profiles.isEmpty())
|
||||||
|
throw new NoSuchElementException("No profiles found for the specific Dataset");
|
||||||
|
|
||||||
|
DescriptionTemplate profile = profiles.get(0);
|
||||||
|
|
||||||
|
// Check if the dataset is on the latest Version.
|
||||||
|
boolean latestVersion = profile.getVersion().toString().equals(datasetEntity.getProfile().getVersion().toString());
|
||||||
|
dataset.setIsProfileLatestVersion(latestVersion);
|
||||||
|
|
||||||
eu.eudat.elastic.entities.Dataset datasetElastic;
|
eu.eudat.elastic.entities.Dataset datasetElastic;
|
||||||
try {
|
try {
|
||||||
datasetElastic = datasetRepository.exists() ?
|
datasetElastic = datasetRepository.exists() ?
|
||||||
|
@ -297,45 +336,6 @@ public class DatasetManager {
|
||||||
logger.warn(ex.getMessage());
|
logger.warn(ex.getMessage());
|
||||||
datasetElastic = null;
|
datasetElastic = null;
|
||||||
}
|
}
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
|
||||||
dataset.fromDataModel(datasetEntity);
|
|
||||||
|
|
||||||
// Creates the Criteria to get all version of DatasetProfile in question.
|
|
||||||
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
|
||||||
UUID profileId = datasetEntity.getProfile().getGroupId();
|
|
||||||
List<UUID> uuidList = new LinkedList<>();
|
|
||||||
uuidList.add(profileId);
|
|
||||||
profileCriteria.setGroupIds(uuidList);
|
|
||||||
profileCriteria.setAllVersions(true);
|
|
||||||
|
|
||||||
List<eu.eudat.data.entities.DatasetProfile> profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria)
|
|
||||||
.orderBy(((builder, root) -> builder.desc(root.get("version"))))
|
|
||||||
.toList();
|
|
||||||
List<DatasetProfile> profileVersionsIncluded = new LinkedList<>();
|
|
||||||
|
|
||||||
// Iterate through the versions and remove those that are not included in the DMP of the dataset in question.
|
|
||||||
for (DatasetProfile version : profileVersions) {
|
|
||||||
for (AssociatedProfile p : dataset.getDmp().getProfiles()) {
|
|
||||||
if (version.getId().toString().equals(p.getId().toString())) {
|
|
||||||
profileVersionsIncluded.add(version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort the list with the included Versions.
|
|
||||||
Stream<DatasetProfile> sorted = profileVersionsIncluded.stream().sorted(Comparator.comparing(DatasetProfile::getVersion).reversed());
|
|
||||||
|
|
||||||
// Make the Stream into List and get the first item.
|
|
||||||
List<DatasetProfile> profiles = sorted.collect(Collectors.toList());
|
|
||||||
if (profiles.isEmpty())
|
|
||||||
throw new NoSuchElementException("No profiles found for the specific Dataset");
|
|
||||||
|
|
||||||
DatasetProfile profile = profiles.get(0);
|
|
||||||
|
|
||||||
// Check if the dataset is on the latest Version.
|
|
||||||
boolean latestVersion = profile.getVersion().toString().equals(datasetEntity.getProfile().getVersion().toString());
|
|
||||||
dataset.setIsProfileLatestVersion(latestVersion);
|
|
||||||
|
|
||||||
if (datasetElastic != null && datasetElastic.getTags() != null && !datasetElastic.getTags().isEmpty()) {
|
if (datasetElastic != null && datasetElastic.getTags() != null && !datasetElastic.getTags().isEmpty()) {
|
||||||
dataset.setTags(datasetElastic.getTags());
|
dataset.setTags(datasetElastic.getTags());
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private XWPFDocument getWordDocument(ConfigLoader configLoader, eu.eudat.data.entities.Dataset datasetEntity, VisibilityRuleService visibilityRuleService, Principal principal) throws IOException {
|
private XWPFDocument getWordDocument(ConfigLoader configLoader, eu.eudat.data.entities.Dataset datasetEntity, VisibilityRuleService visibilityRuleService, Principal principal) throws IOException {
|
||||||
WordBuilder wordBuilder = new WordBuilder(this.environment);
|
WordBuilder wordBuilder = new WordBuilder(this.environment, configLoader);
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
XWPFDocument document = configLoader.getDatasetDocument();
|
XWPFDocument document = configLoader.getDatasetDocument();
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private XWPFDocument getLightWordDocument(ConfigLoader configLoader, DatasetWizardModel dataset, VisibilityRuleService visibilityRuleService) throws IOException {
|
private XWPFDocument getLightWordDocument(ConfigLoader configLoader, DatasetWizardModel dataset, VisibilityRuleService visibilityRuleService) throws IOException {
|
||||||
WordBuilder wordBuilder = new WordBuilder(this.environment);
|
WordBuilder wordBuilder = new WordBuilder(this.environment, configLoader);
|
||||||
XWPFDocument document = configLoader.getDocument();
|
XWPFDocument document = configLoader.getDocument();
|
||||||
|
|
||||||
// Space below Dataset title.
|
// Space below Dataset title.
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -1034,18 +1034,10 @@ public class DatasetManager {
|
||||||
public DatasetWizardModel datasetUpdateProfile(String id) {
|
public DatasetWizardModel datasetUpdateProfile(String id) {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
eu.eudat.elastic.entities.Dataset datasetElastic;
|
|
||||||
try {
|
|
||||||
datasetElastic = datasetRepository.exists() ?
|
|
||||||
datasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.warn(ex.getMessage());
|
|
||||||
datasetElastic = null;
|
|
||||||
}
|
|
||||||
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<>();
|
||||||
|
@ -1053,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));
|
||||||
|
@ -1062,6 +1054,14 @@ public class DatasetManager {
|
||||||
// Now at latest version.
|
// Now at latest version.
|
||||||
dataset.setIsProfileLatestVersion(true);
|
dataset.setIsProfileLatestVersion(true);
|
||||||
|
|
||||||
|
eu.eudat.elastic.entities.Dataset datasetElastic;
|
||||||
|
try {
|
||||||
|
datasetElastic = datasetRepository.exists() ?
|
||||||
|
datasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.warn(ex.getMessage());
|
||||||
|
datasetElastic = null;
|
||||||
|
}
|
||||||
if (datasetElastic != null && datasetElastic.getTags() != null && !datasetElastic.getTags().isEmpty()) {
|
if (datasetElastic != null && datasetElastic.getTags() != null && !datasetElastic.getTags().isEmpty()) {
|
||||||
dataset.setTags(datasetElastic.getTags());
|
dataset.setTags(datasetElastic.getTags());
|
||||||
}
|
}
|
||||||
|
@ -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<>();
|
||||||
|
@ -1143,19 +1143,21 @@ public class DatasetManager {
|
||||||
if (!tagNodes.isEmpty()) {
|
if (!tagNodes.isEmpty()) {
|
||||||
tagNodes.forEach(node -> {
|
tagNodes.forEach(node -> {
|
||||||
JsonNode value = node.get("value");
|
JsonNode value = node.get("value");
|
||||||
if (!value.toString().equals("\"\"") && !value.toString().equals("null") && value.toString().startsWith("[")) {
|
if (!value.toString().equals("\"\"") && !value.toString().equals("null")) {
|
||||||
String stringValue = value.toString().replaceAll("=", ":");
|
if (value.toString().startsWith("[")) {
|
||||||
JSONArray values = new JSONArray(stringValue);
|
String stringValue = value.toString().replaceAll("=", ":");
|
||||||
values.iterator().forEachRemaining(element -> {
|
JSONArray values = new JSONArray(stringValue);
|
||||||
Map<String, Object> data = ((JSONObject) element).toMap();
|
values.iterator().forEachRemaining(element -> {
|
||||||
this.addTag(tags, wizardModel.getTags(), data.get("id").toString(), data.get("name").toString());
|
Map<String, Object> data = ((JSONObject) element).toMap();
|
||||||
});
|
this.addTag(tags, wizardModel.getTags(), data.get("id").toString(), data.get("name").toString());
|
||||||
} else {
|
});
|
||||||
List<String> values = Arrays.asList(value.textValue().split(", "));
|
} else {
|
||||||
List<Tag> tagValues = values.stream().map(stringValue -> new Tag(stringValue, stringValue)).collect(Collectors.toList());
|
List<String> values = Arrays.asList(value.textValue().split(", "));
|
||||||
tagValues.iterator().forEachRemaining(tag -> {
|
List<Tag> tagValues = values.stream().map(stringValue -> new Tag(stringValue, stringValue)).collect(Collectors.toList());
|
||||||
this.addTag(tags, wizardModel.getTags(), tag.getId(), tag.getName());
|
tagValues.iterator().forEachRemaining(tag -> {
|
||||||
});
|
this.addTag(tags, wizardModel.getTags(), tag.getId(), tag.getName());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1181,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);*/
|
||||||
|
|
|
@ -1,26 +1,28 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
|
||||||
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;
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||||
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
|
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
|
||||||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
||||||
import eu.eudat.logic.proxy.config.Semantic;
|
import eu.eudat.logic.proxy.config.*;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
|
import eu.eudat.logic.proxy.config.entities.GeneralUrls;
|
||||||
|
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
||||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
|
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
|
||||||
|
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||||
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
|
import eu.eudat.models.data.datasetprofile.DatasetProfileWithPrefillingPropertyModel;
|
||||||
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field;
|
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
|
@ -34,10 +36,11 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -54,6 +57,8 @@ import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
import javax.xml.xpath.*;
|
import javax.xml.xpath.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -64,29 +69,30 @@ public class DatasetProfileManager {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DatasetProfileManager.class);
|
private static final Logger logger = LoggerFactory.getLogger(DatasetProfileManager.class);
|
||||||
private static final List<String> cache = new ArrayList<>();
|
private static final List<String> cache = new ArrayList<>();
|
||||||
|
|
||||||
private ApiContext apiContext;
|
private final ApiContext apiContext;
|
||||||
private DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
private Environment environment;
|
private final Environment environment;
|
||||||
private ConfigLoader configLoader;
|
private final ConfigLoader configLoader;
|
||||||
|
|
||||||
private final MetricsManager metricsManager;
|
private final MetricsManager metricsManager;
|
||||||
|
private final RemoteFetcher remoteFetcher;
|
||||||
@Autowired
|
@Autowired
|
||||||
public DatasetProfileManager(ApiContext apiContext, Environment environment, ConfigLoader configLoader, MetricsManager metricsManager) {
|
public DatasetProfileManager(ApiContext apiContext, Environment environment, ConfigLoader configLoader, MetricsManager metricsManager, RemoteFetcher remoteFetcher) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
this.metricsManager = metricsManager;
|
this.metricsManager = metricsManager;
|
||||||
|
this.remoteFetcher = remoteFetcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,40 +100,55 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<DatasetProfileWithPrefillingPropertyModel> getAllWithPrefilling(DatasetProfileTableRequestItem tableRequestItem) {
|
||||||
|
List<DatasetProfileWithPrefillingPropertyModel> datasetProfiles = new ArrayList<>();
|
||||||
|
if (!tableRequestItem.getCriteria().getIds().isEmpty()) {
|
||||||
|
tableRequestItem.getCriteria().getIds().forEach(id -> {
|
||||||
|
DatasetProfile datasetProfile = this.getDatasetProfile(id.toString());
|
||||||
|
DatasetProfileWithPrefillingPropertyModel profileModel = new DatasetProfileWithPrefillingPropertyModel();
|
||||||
|
profileModel.setId(id);
|
||||||
|
profileModel.setLabel(datasetProfile.getLabel());
|
||||||
|
profileModel.setEnablePrefilling(datasetProfile.isEnablePrefilling());
|
||||||
|
datasetProfiles.add(profileModel);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return datasetProfiles;
|
||||||
|
}
|
||||||
|
|
||||||
public eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field queryForField(String xml, String fieldId) throws XPathExpressionException {
|
public eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field queryForField(String xml, String fieldId) throws XPathExpressionException {
|
||||||
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field field = new Field();
|
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field field = new Field();
|
||||||
Document document = XmlBuilder.fromXml(xml);
|
Document document = XmlBuilder.fromXml(xml);
|
||||||
|
@ -140,10 +161,10 @@ public class DatasetProfileManager {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ExternalAutocompleteFieldModel> getAutocomplete(AutoCompleteData data, String like) {
|
public List<ExternalAutocompleteFieldModel> getAutocomplete(AutoCompleteData data, String like) {
|
||||||
List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
|
/*List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
|
||||||
SimpleClientHttpRequestFactory simpleFactory = new SimpleClientHttpRequestFactory();
|
SimpleClientHttpRequestFactory simpleFactory = new SimpleClientHttpRequestFactory();
|
||||||
|
|
||||||
RestTemplate restTemplate = new RestTemplate(simpleFactory);
|
RestTemplate restTemplate = new RestTemplate(simpleFactory);
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
DocumentContext jsonContext = null;
|
DocumentContext jsonContext = null;
|
||||||
|
@ -162,7 +183,7 @@ public class DatasetProfileManager {
|
||||||
if (url.contains("zenodo")) {
|
if (url.contains("zenodo")) {
|
||||||
url = url.replace("?", "/?");
|
url = url.replace("?", "/?");
|
||||||
}
|
}
|
||||||
|
|
||||||
url = url.replace("{like}", like.equals("") ? "*" : like);
|
url = url.replace("{like}", like.equals("") ? "*" : like);
|
||||||
url = url.replace("%20", " ");
|
url = url.replace("%20", " ");
|
||||||
url = url.replace("%22", "\"");
|
url = url.replace("%22", "\"");
|
||||||
|
@ -178,7 +199,7 @@ public class DatasetProfileManager {
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
entity = new HttpEntity<>("parameters", headers);
|
entity = new HttpEntity<>("parameters", headers);
|
||||||
|
|
||||||
|
|
||||||
response = restTemplate.exchange(url, HttpMethod.GET, entity, Object.class);
|
response = restTemplate.exchange(url, HttpMethod.GET, entity, Object.class);
|
||||||
jsonContext = JsonPath.parse(response.getBody());
|
jsonContext = JsonPath.parse(response.getBody());
|
||||||
jsonItems = jsonContext.read(singleData.getOptionsRoot() + "['" + singleData.getAutoCompleteOptions().getLabel() + "','" + singleData.getAutoCompleteOptions().getValue() + "','" + singleData.getAutoCompleteOptions().getSource() + "','" + "uri" + "']");
|
jsonItems = jsonContext.read(singleData.getOptionsRoot() + "['" + singleData.getAutoCompleteOptions().getLabel() + "','" + singleData.getAutoCompleteOptions().getValue() + "','" + singleData.getAutoCompleteOptions().getSource() + "','" + "uri" + "']");
|
||||||
|
@ -204,8 +225,72 @@ public class DatasetProfileManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.stream().sorted(Comparator.comparing(ExternalAutocompleteFieldModel::getLabel)).collect(Collectors.toList());
|
return result.stream().sorted(Comparator.comparing(ExternalAutocompleteFieldModel::getLabel)).collect(Collectors.toList());
|
||||||
|
*/
|
||||||
//return result;
|
List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
|
||||||
|
ExternalUrlCriteria urlCriteria = new ExternalUrlCriteria();
|
||||||
|
GeneralUrls genericUrls = new GeneralUrls();
|
||||||
|
int ordinal = 1;
|
||||||
|
List<Map<String, String>> rawResults = new ArrayList<>();
|
||||||
|
genericUrls.setFetchMode(FetchStrategy.FIRST);
|
||||||
|
urlCriteria.setLike(like);
|
||||||
|
for (AutoCompleteData.AutoCompleteSingleData singleData : data.getAutoCompleteSingleDataList()) {
|
||||||
|
UrlConfiguration urlConfiguration = new UrlConfiguration();
|
||||||
|
try {
|
||||||
|
URI uri;
|
||||||
|
if (singleData.getUrl().contains("?")) {
|
||||||
|
uri = new URI(singleData.getUrl().substring(0, singleData.getUrl().lastIndexOf("?")));
|
||||||
|
} else {
|
||||||
|
uri = new URI(singleData.getUrl());
|
||||||
|
}
|
||||||
|
String source = singleData.getAutoCompleteOptions().getSource();
|
||||||
|
source = source != null && !source.isEmpty() ? source : uri.getHost();
|
||||||
|
String uriString = singleData.getAutoCompleteOptions().getUri();
|
||||||
|
uriString = uriString != null && !uriString.isEmpty() ? uriString : "uri";
|
||||||
|
String parsedUrl = singleData.getUrl();
|
||||||
|
parsedUrl = parsedUrl.replace("%20", " ");
|
||||||
|
parsedUrl = parsedUrl.replace("%22", "\"");
|
||||||
|
while (parsedUrl.contains("&")) {
|
||||||
|
parsedUrl = parsedUrl.replace("&", "&");
|
||||||
|
}
|
||||||
|
urlConfiguration.setUrl(parsedUrl);
|
||||||
|
urlConfiguration.setOrdinal(ordinal);
|
||||||
|
urlConfiguration.setType("External");
|
||||||
|
urlConfiguration.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
urlConfiguration.setFirstpage("1");
|
||||||
|
urlConfiguration.setRequestType(singleData.getMethod() != null ? singleData.getMethod() : "GET");
|
||||||
|
DataUrlConfiguration dataUrlConfiguration = new DataUrlConfiguration();
|
||||||
|
dataUrlConfiguration.setPath(singleData.getOptionsRoot());
|
||||||
|
DataFieldsUrlConfiguration fieldsUrlConfiguration = new DataFieldsUrlConfiguration();
|
||||||
|
fieldsUrlConfiguration.setId(singleData.getAutoCompleteOptions().getValue());
|
||||||
|
fieldsUrlConfiguration.setName(singleData.getAutoCompleteOptions().getLabel());
|
||||||
|
fieldsUrlConfiguration.setSource(singleData.getAutoCompleteOptions().getSource().isEmpty()? null : singleData.getAutoCompleteOptions().getSource());
|
||||||
|
fieldsUrlConfiguration.setUri(uriString);
|
||||||
|
dataUrlConfiguration.setFieldsUrlConfiguration(fieldsUrlConfiguration);
|
||||||
|
urlConfiguration.setKey(source);
|
||||||
|
urlConfiguration.setLabel(source);
|
||||||
|
urlConfiguration.setData(dataUrlConfiguration);
|
||||||
|
if (singleData.getHasAuth()) {
|
||||||
|
AuthenticationConfiguration authenticationConfiguration = new AuthenticationConfiguration();
|
||||||
|
authenticationConfiguration.setAuthUrl(singleData.getAuth().getUrl());
|
||||||
|
authenticationConfiguration.setAuthMethod(singleData.getAuth().getMethod());
|
||||||
|
authenticationConfiguration.setAuthTokenPath(singleData.getAuth().getPath());
|
||||||
|
authenticationConfiguration.setAuthRequestBody(singleData.getAuth().getBody());
|
||||||
|
authenticationConfiguration.setType(singleData.getAuth().getType());
|
||||||
|
urlConfiguration.setAuth(authenticationConfiguration);
|
||||||
|
}
|
||||||
|
genericUrls.getUrls().add(urlConfiguration);
|
||||||
|
List<Map<String, String>> singleResults = this.remoteFetcher.getExternalGeneric(urlCriteria, genericUrls);
|
||||||
|
if (!singleResults.isEmpty() && !singleResults.get(0).containsKey("source") && !singleData.getAutoCompleteOptions().getSource().isEmpty()) {
|
||||||
|
singleResults.forEach(singleResult -> singleResult.put("source", singleData.getAutoCompleteOptions().getSource()));
|
||||||
|
}
|
||||||
|
rawResults.addAll(singleResults);
|
||||||
|
genericUrls.getUrls().clear();
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rawResults.forEach(item -> result.add(new ExternalAutocompleteFieldModel(parseItem(item.get("pid")), parseItem(item.get("name")), parseItem(item.get("source")), parseItem(item.get("uri")))));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String parseItem(Object item) {
|
private static String parseItem(Object item) {
|
||||||
|
@ -276,36 +361,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 +425,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 +466,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 +487,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 +507,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 +522,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) {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,18 +31,24 @@ public class DepositManager {
|
||||||
public List<RepositoryConfig> getAvailableRepos() {
|
public List<RepositoryConfig> getAvailableRepos() {
|
||||||
List<RepositoryConfig> reposConfigModel = new ArrayList<>();
|
List<RepositoryConfig> reposConfigModel = new ArrayList<>();
|
||||||
for (RepositoryDeposit r: this.repositories) {
|
for (RepositoryDeposit r: this.repositories) {
|
||||||
RepositoryConfig repoModel = new RepositoryConfig();
|
List<RepositoryDepositConfiguration> repoConf = r.getConfiguration();
|
||||||
RepositoryDepositConfiguration repoConf = r.getConfiguration();
|
|
||||||
if(repoConf != null) {
|
if(repoConf != null) {
|
||||||
reposConfigModel.add(repoModel.toModel(repoConf));
|
for(RepositoryDepositConfiguration cf: repoConf){
|
||||||
|
RepositoryConfig repoModel = new RepositoryConfig();
|
||||||
|
reposConfigModel.add(repoModel.toModel(cf));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return reposConfigModel;
|
return reposConfigModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String authenticate(String id, String code) {
|
public String authenticate(String id, String code) {
|
||||||
Optional<RepositoryDeposit> repo = repositories.stream().filter(x -> x.getConfiguration().getRepositoryId().equals(id)).findFirst();
|
for(RepositoryDeposit r: this.repositories){
|
||||||
return repo.map(repositoryDeposit -> repositoryDeposit.authenticate(code)).orElse(null);
|
if(r.getConfiguration().stream().anyMatch(x -> x.getRepositoryId().equals(id))){
|
||||||
|
return r.authenticate(id, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Doi deposit(DepositRequest depositRequest, Principal principal) throws Exception {
|
public Doi deposit(DepositRequest depositRequest, Principal principal) throws Exception {
|
||||||
|
@ -50,9 +56,12 @@ public class DepositManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRepositoryLogo(String repositoryId){
|
public String getRepositoryLogo(String repositoryId){
|
||||||
Optional<RepositoryDeposit> repo = repositories.stream().filter(x -> x.getConfiguration().getRepositoryId().equals(repositoryId)).findFirst();
|
for(RepositoryDeposit r: this.repositories){
|
||||||
return repo.map(repositoryDeposit ->
|
Optional<RepositoryDepositConfiguration> cf = r.getConfiguration().stream().filter(x -> x.getRepositoryId().equals(repositoryId)).findFirst();
|
||||||
(repositoryDeposit.getConfiguration().isHasLogo()) ? repositoryDeposit.getLogo() : null
|
if(cf.isPresent()){
|
||||||
).orElse(null);
|
return cf.get().isHasLogo() ? r.getLogo(repositoryId) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,6 +48,9 @@ public class EmailConfirmationManager {
|
||||||
// Checks if mail is used by another user. If it is, merges the new the old.
|
// Checks if mail is used by another user. If it is, merges the new the old.
|
||||||
Long existingUsers = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).count();
|
Long existingUsers = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).count();
|
||||||
if (existingUsers > 0) {
|
if (existingUsers > 0) {
|
||||||
|
Credential credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userInfo"), user)).getSingle();
|
||||||
|
credential.setEmail(loginConfirmationEmail.getEmail());
|
||||||
|
databaseRepository.getCredentialDao().createOrUpdate(credential);
|
||||||
UserInfo oldUser = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).getSingle();
|
UserInfo oldUser = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).getSingle();
|
||||||
mergeNewUserToOld(user, oldUser);
|
mergeNewUserToOld(user, oldUser);
|
||||||
expireUserToken(user);
|
expireUserToken(user);
|
||||||
|
@ -57,6 +60,12 @@ public class EmailConfirmationManager {
|
||||||
|
|
||||||
user.setEmail(loginConfirmationEmail.getEmail());
|
user.setEmail(loginConfirmationEmail.getEmail());
|
||||||
databaseRepository.getUserInfoDao().createOrUpdate(user);
|
databaseRepository.getUserInfoDao().createOrUpdate(user);
|
||||||
|
Credential credential = databaseRepository.getCredentialDao().asQueryable()
|
||||||
|
.where((builder, root) -> builder.equal(root.get("userInfo"), user)).getSingle();
|
||||||
|
if(credential.getEmail() == null){
|
||||||
|
credential.setEmail(user.getEmail());
|
||||||
|
databaseRepository.getCredentialDao().createOrUpdate(credential);
|
||||||
|
}
|
||||||
databaseRepository.getLoginConfirmationEmailDao().createOrUpdate(loginConfirmationEmail);
|
databaseRepository.getLoginConfirmationEmailDao().createOrUpdate(loginConfirmationEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,7 @@ public class GrantManager {
|
||||||
|
|
||||||
grants.add(grant);
|
grants.add(grant);
|
||||||
}
|
}
|
||||||
|
grants = grants.stream().filter(grant -> grant.getLabel() != null).collect(Collectors.toList());
|
||||||
grants.sort(Comparator.comparing(Grant::getLabel));
|
grants.sort(Comparator.comparing(Grant::getLabel));
|
||||||
grants = grants.stream().filter(listHelper.distinctByKey(Grant::getLabel)).collect(Collectors.toList());
|
grants = grants.stream().filter(listHelper.distinctByKey(Grant::getLabel)).collect(Collectors.toList());
|
||||||
return grants;
|
return grants;
|
||||||
|
|
|
@ -5,6 +5,10 @@ import eu.eudat.data.entities.EmailConfirmation;
|
||||||
import eu.eudat.data.entities.UserDMP;
|
import eu.eudat.data.entities.UserDMP;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.data.entities.UserToken;
|
import eu.eudat.data.entities.UserToken;
|
||||||
|
import eu.eudat.elastic.criteria.DmpCriteria;
|
||||||
|
import eu.eudat.elastic.entities.Collaborator;
|
||||||
|
import eu.eudat.elastic.entities.Dmp;
|
||||||
|
import eu.eudat.elastic.repository.DmpRepository;
|
||||||
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
|
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
|
||||||
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
|
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
@ -25,21 +29,25 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class MergeEmailConfirmationManager {
|
public class MergeEmailConfirmationManager {
|
||||||
private static Logger logger = LoggerFactory.getLogger(MergeEmailConfirmationManager.class);
|
private static Logger logger = LoggerFactory.getLogger(MergeEmailConfirmationManager.class);
|
||||||
private ApiContext apiContext;
|
private ApiContext apiContext;
|
||||||
private DatabaseRepository databaseRepository;
|
private DatabaseRepository databaseRepository;
|
||||||
|
private DmpRepository dmpRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public MergeEmailConfirmationManager(ApiContext apiContext) {
|
public MergeEmailConfirmationManager(ApiContext apiContext) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||||
|
this.dmpRepository = apiContext.getOperationsContext().getElasticRepository().getDmpRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException {
|
public String confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException {
|
||||||
EmailConfirmation loginConfirmationEmail = apiContext.getOperationsContext()
|
EmailConfirmation loginConfirmationEmail = apiContext.getOperationsContext()
|
||||||
.getDatabaseRepository().getLoginConfirmationEmailDao().asQueryable()
|
.getDatabaseRepository().getLoginConfirmationEmailDao().asQueryable()
|
||||||
.where((builder, root) -> builder.equal(root.get("token"), UUID.fromString(token))).getSingle();
|
.where((builder, root) -> builder.equal(root.get("token"), UUID.fromString(token))).getSingle();
|
||||||
|
@ -49,7 +57,7 @@ public class MergeEmailConfirmationManager {
|
||||||
|
|
||||||
UserInfo userToBeMerged = databaseRepository.getUserInfoDao().asQueryable()
|
UserInfo userToBeMerged = databaseRepository.getUserInfoDao().asQueryable()
|
||||||
.where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle();
|
.where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle();
|
||||||
|
String userToBeMergedEmail = userToBeMerged.getEmail();
|
||||||
try {
|
try {
|
||||||
Map<String, Object> map = new ObjectMapper().readValue(loginConfirmationEmail.getData(), HashMap.class);
|
Map<String, Object> map = new ObjectMapper().readValue(loginConfirmationEmail.getData(), HashMap.class);
|
||||||
UUID otherUserId = UUID.fromString((String) map.get("userId"));
|
UUID otherUserId = UUID.fromString((String) map.get("userId"));
|
||||||
|
@ -64,6 +72,8 @@ public class MergeEmailConfirmationManager {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return userToBeMergedEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendConfirmationEmail(String email, Principal principal, UUID userId, Integer provider) throws HasConfirmedEmailException {
|
public void sendConfirmationEmail(String email, Principal principal, UUID userId, Integer provider) throws HasConfirmedEmailException {
|
||||||
|
@ -91,6 +101,38 @@ public class MergeEmailConfirmationManager {
|
||||||
userDmp.setUser(newUser);
|
userDmp.setUser(newUser);
|
||||||
databaseRepository.getUserDmpDao().createOrUpdate(userDmp);
|
databaseRepository.getUserDmpDao().createOrUpdate(userDmp);
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
DmpCriteria dmpCriteria = new DmpCriteria();
|
||||||
|
dmpCriteria.setCollaborators(Collections.singletonList(oldUser.getId()));
|
||||||
|
List<Dmp> elasticDmpsIds = dmpRepository.query(dmpCriteria);
|
||||||
|
for(Dmp dmpId: elasticDmpsIds){
|
||||||
|
Dmp dmp = dmpRepository.findDocument(dmpId.getId().toString());
|
||||||
|
if(dmp.getDatasets() != null) {
|
||||||
|
dmp.getDatasets().forEach(dataset -> {
|
||||||
|
if(dataset.getCollaborators() != null) {
|
||||||
|
for (Collaborator collaborator : dataset.getCollaborators()) {
|
||||||
|
if (collaborator.getId().equals(oldUser.getId().toString())) {
|
||||||
|
collaborator.setId(newUser.getId().toString());
|
||||||
|
collaborator.setName(newUser.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(dmp.getCollaborators() != null) {
|
||||||
|
for (Collaborator collaborator : dmp.getCollaborators()) {
|
||||||
|
if (collaborator.getId().equals(oldUser.getId().toString())) {
|
||||||
|
collaborator.setId(newUser.getId().toString());
|
||||||
|
collaborator.setName(newUser.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dmpRepository.createOrUpdate(dmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e){
|
||||||
|
logger.warn("Warning: Could not fetch dmps from elastic.", e);
|
||||||
|
}
|
||||||
oldUser.setUserStatus((short)1);
|
oldUser.setUserStatus((short)1);
|
||||||
oldUser.setEmail(null);
|
oldUser.setEmail(null);
|
||||||
List<Credential> credentials = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userInfo"), oldUser)).toList();
|
List<Credential> credentials = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userInfo"), oldUser)).toList();
|
||||||
|
|
|
@ -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) {
|
||||||
|
@ -180,6 +180,8 @@ public class MetricsManager {
|
||||||
try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
|
try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
|
||||||
long files = paths.count();
|
long files = paths.count();
|
||||||
calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Could not calculate languages.");
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateValue(MetricNames.INSTALLATIONS, 1, null);
|
calculateValue(MetricNames.INSTALLATIONS, 1, null);
|
||||||
|
@ -404,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,20 +60,20 @@ public class NotificationManager {
|
||||||
case DMP_MODIFIED:
|
case DMP_MODIFIED:
|
||||||
case DATASET_MODIFIED:
|
case DATASET_MODIFIED:
|
||||||
subjectTemplate = this.environment.getProperty("notification.modified.subject");
|
subjectTemplate = this.environment.getProperty("notification.modified.subject");
|
||||||
contentTemplate = mailService.getMailTemplateContent("classpath:templates/notifications/modifiedNotification.html");
|
contentTemplate = mailService.getMailTemplateContent(this.environment.getProperty("notification.modified.template"));
|
||||||
break;
|
break;
|
||||||
case DMP_PUBLISH:
|
case DMP_PUBLISH:
|
||||||
subjectTemplate = this.environment.getProperty("notification.publish.subject");
|
subjectTemplate = this.environment.getProperty("notification.publish.subject");
|
||||||
contentTemplate = mailService.getMailTemplateContent("classpath:templates/notifications/publishNotification.html");
|
contentTemplate = mailService.getMailTemplateContent(this.environment.getProperty("notification.publish.template"));
|
||||||
break;
|
break;
|
||||||
case DMP_FINALISED:
|
case DMP_FINALISED:
|
||||||
subjectTemplate = this.environment.getProperty("notification.finalised.subject");
|
subjectTemplate = this.environment.getProperty("notification.finalised.subject");
|
||||||
contentTemplate = mailService.getMailTemplateContent("classpath:templates/notifications/finalisedNotification.html");
|
contentTemplate = mailService.getMailTemplateContent(this.environment.getProperty("notification.finalised.template"));
|
||||||
break;
|
break;
|
||||||
case DMP_MODIFIED_FINALISED:
|
case DMP_MODIFIED_FINALISED:
|
||||||
case DATASET_MODIFIED_FINALISED:
|
case DATASET_MODIFIED_FINALISED:
|
||||||
subjectTemplate = this.environment.getProperty("notification.modifiedFinalised.subject");
|
subjectTemplate = this.environment.getProperty("notification.modifiedFinalised.subject");
|
||||||
contentTemplate = mailService.getMailTemplateContent("classpath:templates/notifications/modifiedFinalisedNotification.html");
|
contentTemplate = mailService.getMailTemplateContent(this.environment.getProperty("notification.modified_finalised.template"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -11,10 +12,7 @@ import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.prefilling.Prefilling;
|
import eu.eudat.models.data.prefilling.Prefilling;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.*;
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@ -29,30 +27,51 @@ public class PrefillingManager {
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
private final DatasetManager datasetManager;
|
private final DatasetManager datasetManager;
|
||||||
private final LicenseManager licenseManager;
|
private final LicenseManager licenseManager;
|
||||||
|
private final PrefillingMapper prefillingMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public PrefillingManager(ApiContext apiContext, ConfigLoader configLoader, DatasetManager datasetManager, LicenseManager licenseManager) {
|
public PrefillingManager(ApiContext apiContext, ConfigLoader configLoader, DatasetManager datasetManager, LicenseManager licenseManager, PrefillingMapper prefillingMapper) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
this.objectMapper = new ObjectMapper();
|
this.prefillingMapper = prefillingMapper;
|
||||||
|
this.objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
this.datasetManager = datasetManager;
|
this.datasetManager = datasetManager;
|
||||||
this.licenseManager = licenseManager;
|
this.licenseManager = licenseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Prefilling> getPrefillings(String like, String configId) {
|
public List<Prefilling> getPrefillings(String like) {
|
||||||
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
|
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria();
|
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria();
|
||||||
externalUrlCriteria.setLike(like);
|
externalUrlCriteria.setLike(like);
|
||||||
List<Map<String, String>> map = apiContext.getOperationsContext().getRemoteFetcher().getExternalGeneric(externalUrlCriteria, prefillingConfig.getPrefillingSearch());
|
List<Prefilling> prefillings = new ArrayList<>();
|
||||||
return map.stream().map(submap -> objectMapper.convertValue(submap, Prefilling.class)).collect(Collectors.toList());
|
List<Map<String, String>> map;
|
||||||
|
Map<String, PrefillingConfig> prefillingConfigs = configLoader.getExternalUrls().getPrefillings();
|
||||||
|
for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) {
|
||||||
|
map = apiContext.getOperationsContext().getRemoteFetcher().getExternalGeneric(externalUrlCriteria, prefillingConfig.getPrefillingSearch());
|
||||||
|
prefillings.addAll(map.stream().map(submap -> objectMapper.convertValue(submap, Prefilling.class)).collect(Collectors.toList()));
|
||||||
|
if (prefillingConfig.getPrefillingSearch().getUrlConfig().isDataInListing()) {
|
||||||
|
List<Map<String, Object>> mapData = apiContext.getOperationsContext().getRemoteFetcher().getExternalGenericWithData(externalUrlCriteria, prefillingConfig.getPrefillingSearch());
|
||||||
|
for (int i = 0; i < mapData.size(); i++) {
|
||||||
|
prefillings.get(i).setData(mapData.get(i));
|
||||||
|
}
|
||||||
|
prefillings = prefillings.stream().filter(prefilling -> prefilling.getData() != null).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return prefillings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetWizardModel getPrefilledDataset(String prefillId, String configId, UUID profileId) throws Exception {
|
public DatasetWizardModel getPrefilledDataset(String prefillId, String configId, UUID profileId) throws Exception {
|
||||||
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 {
|
||||||
|
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
|
||||||
|
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
||||||
|
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
||||||
|
return prefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), descriptionTemplate, datasetManager, licenseManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> getSingle(String url, String id) {
|
private Map<String, Object> getSingle(String url, String id) {
|
||||||
|
|
|
@ -72,20 +72,7 @@ public class UnlinkEmailConfirmationManager {
|
||||||
Credential credential = databaseRepository.getCredentialDao().asQueryable()
|
Credential credential = databaseRepository.getCredentialDao().asQueryable()
|
||||||
.where((builder, root) -> builder.and(builder.equal(root.get("email"), emailTobeUnlinked), builder.equal(root.get("provider"), provider))).getSingle();
|
.where((builder, root) -> builder.and(builder.equal(root.get("email"), emailTobeUnlinked), builder.equal(root.get("provider"), provider))).getSingle();
|
||||||
if(credential != null) {
|
if(credential != null) {
|
||||||
UserInfo userTobeUnlinked = databaseRepository.getUserInfoDao().asQueryable()
|
databaseRepository.getCredentialDao().delete(credential);
|
||||||
.where((builder, root) -> builder.and(builder.equal(root.get("userStatus"), 1), builder.equal(root.get("name"), credential.getPublicValue()))).getSingle();
|
|
||||||
userTobeUnlinked.setEmail(emailTobeUnlinked);
|
|
||||||
userTobeUnlinked.setUserStatus((short) 0);
|
|
||||||
databaseRepository.getUserInfoDao().createOrUpdate(userTobeUnlinked);
|
|
||||||
|
|
||||||
credential.setUserInfo(userTobeUnlinked);
|
|
||||||
databaseRepository.getCredentialDao().createOrUpdate(credential);
|
|
||||||
|
|
||||||
UserToken userToken = this.apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserTokenBuilder.class)
|
|
||||||
.token(UUID.randomUUID()).user(userTobeUnlinked)
|
|
||||||
.expiresAt(Timestamp.valueOf(LocalDateTime.now().plusDays(10))).issuedAt(new Date())
|
|
||||||
.build();
|
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getUserTokenDao().createOrUpdate(userToken);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -50,7 +50,9 @@ public class DatasetMapper {
|
||||||
elastic.setStatus(dataset.getStatus());
|
elastic.setStatus(dataset.getStatus());
|
||||||
elastic.setDmp(dataset.getDmp().getId());
|
elastic.setDmp(dataset.getDmp().getId());
|
||||||
elastic.setGroup(dataset.getDmp().getGroupId());
|
elastic.setGroup(dataset.getDmp().getGroupId());
|
||||||
elastic.setGrant(dataset.getDmp().getGrant().getId());
|
if (dataset.getDmp().getGrant() != null) {
|
||||||
|
elastic.setGrant(dataset.getDmp().getGrant().getId());
|
||||||
|
}
|
||||||
elastic.setCreated(dataset.getCreated());
|
elastic.setCreated(dataset.getCreated());
|
||||||
elastic.setModified(dataset.getModified());
|
elastic.setModified(dataset.getModified());
|
||||||
elastic.setFinalizedAt(dataset.getFinalizedAt());
|
elastic.setFinalizedAt(dataset.getFinalizedAt());
|
||||||
|
@ -74,7 +76,9 @@ public class DatasetMapper {
|
||||||
elastic.setOrganizations(dataset.getDmp().getOrganisations().stream().map(OrganizationMapper::toElastic).collect(Collectors.toList()));
|
elastic.setOrganizations(dataset.getDmp().getOrganisations().stream().map(OrganizationMapper::toElastic).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
elastic.setPublic(dataset.getDmp().isPublic());
|
elastic.setPublic(dataset.getDmp().isPublic());
|
||||||
elastic.setGrantStatus(dataset.getDmp().getGrant().getStatus());
|
if (dataset.getDmp().getGrant() != null) {
|
||||||
|
elastic.setGrantStatus(dataset.getDmp().getGrant().getStatus());
|
||||||
|
}
|
||||||
elastic.setFormData(datasetManager.getWordDocumentText(dataset));
|
elastic.setFormData(datasetManager.getWordDocumentText(dataset));
|
||||||
|
|
||||||
return elastic;
|
return elastic;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,9 @@ public class DmpMapper {
|
||||||
elastic.setCollaborators(dmp.getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser(), user.getRole())).collect(Collectors.toList()));
|
elastic.setCollaborators(dmp.getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser(), user.getRole())).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
elastic.setDescription(dmp.getDescription());
|
elastic.setDescription(dmp.getDescription());
|
||||||
elastic.setGrant(dmp.getGrant().getId());
|
if (dmp.getGrant() != null) {
|
||||||
|
elastic.setGrant(dmp.getGrant().getId());
|
||||||
|
}
|
||||||
elastic.setLabel(dmp.getLabel());
|
elastic.setLabel(dmp.getLabel());
|
||||||
elastic.setPublic(dmp.isPublic());
|
elastic.setPublic(dmp.isPublic());
|
||||||
elastic.setStatus(dmp.getStatus());
|
elastic.setStatus(dmp.getStatus());
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -25,6 +25,10 @@ import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||||
import eu.eudat.models.data.license.LicenseModel;
|
import eu.eudat.models.data.license.LicenseModel;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -33,11 +37,19 @@ import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class PrefillingMapper {
|
public class PrefillingMapper {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PrefillingMapper.class);
|
||||||
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);
|
||||||
|
private final DatasetProfileManager datasetProfileManager;
|
||||||
|
|
||||||
public static DatasetWizardModel mapPrefilledEntityToDatasetWizard(Map<String, Object> prefilledEntity, PrefillingGet prefillingGet, String type,
|
@Autowired
|
||||||
DatasetProfile profile, DatasetManager datasetManager, LicenseManager licenseManager) throws Exception {
|
public PrefillingMapper(DatasetProfileManager datasetProfileManager) {
|
||||||
|
this.datasetProfileManager = datasetProfileManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetWizardModel mapPrefilledEntityToDatasetWizard(Map<String, Object> prefilledEntity, PrefillingGet prefillingGet, String type,
|
||||||
|
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();
|
||||||
|
@ -54,7 +66,17 @@ public class PrefillingMapper {
|
||||||
sourceValue = ((Map)sourceValue).get(sourceKey);
|
sourceValue = ((Map)sourceValue).get(sourceKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setValue(prefillingMapping, mapper.writeValueAsString(sourceValue), datasetWizardModel, parentNode, properties, type, licenseManager);
|
try {
|
||||||
|
setValue(prefillingMapping, mapper.writeValueAsString(sourceValue), datasetWizardModel, parentNode, properties, type, licenseManager);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
if (prefillingMapping.getSemanticTarget() != null && !prefillingMapping.getSemanticTarget().isEmpty()) {
|
||||||
|
logger.warn("Couldn't map " + prefillingMapping.getSemanticTarget());
|
||||||
|
}
|
||||||
|
else if (prefillingMapping.getTarget() != null && !prefillingMapping.getTarget().isEmpty()) {
|
||||||
|
logger.warn("Couldn't map " + prefillingMapping.getTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (PrefillingFixedMapping fixedMapping: prefillingGet.getFixedMappings()) {
|
for (PrefillingFixedMapping fixedMapping: prefillingGet.getFixedMappings()) {
|
||||||
setValue(fixedMapping, fixedMapping.getValue(), datasetWizardModel, parentNode, properties, type, licenseManager);
|
setValue(fixedMapping, fixedMapping.getValue(), datasetWizardModel, parentNode, properties, type, licenseManager);
|
||||||
|
@ -64,7 +86,7 @@ public class PrefillingMapper {
|
||||||
return datasetWizardModel;
|
return datasetWizardModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setValue(PrefillingMapping prefillingMapping, String value, DatasetWizardModel datasetWizardModel, JsonNode parentNode, Map<String, Object> properties, String type, LicenseManager licenseManager) throws InvocationTargetException, IllegalAccessException, JsonProcessingException {
|
private void setValue(PrefillingMapping prefillingMapping, String value, DatasetWizardModel datasetWizardModel, JsonNode parentNode, Map<String, Object> properties, String type, LicenseManager licenseManager) throws InvocationTargetException, IllegalAccessException, JsonProcessingException {
|
||||||
String trimRegex = prefillingMapping.getTrimRegex() != null ? prefillingMapping.getTrimRegex() : "";
|
String trimRegex = prefillingMapping.getTrimRegex() != null ? prefillingMapping.getTrimRegex() : "";
|
||||||
if (!value.startsWith("\"") && !value.startsWith("[") && !value.equals("null")) {
|
if (!value.startsWith("\"") && !value.startsWith("[") && !value.equals("null")) {
|
||||||
value = "\"" + value + "\"";
|
value = "\"" + value + "\"";
|
||||||
|
@ -104,7 +126,11 @@ public class PrefillingMapper {
|
||||||
//GK: Tags Special logic
|
//GK: Tags Special logic
|
||||||
if (parsedValue != null && !parsedValue.equals("null") && prefillingMapping.getTarget().equals("tags")) {
|
if (parsedValue != null && !parsedValue.equals("null") && prefillingMapping.getTarget().equals("tags")) {
|
||||||
parsedValue = mapper.valueToTree(parseTags(parsedValue)).toString();
|
parsedValue = mapper.valueToTree(parseTags(parsedValue)).toString();
|
||||||
} else {
|
}
|
||||||
|
else if(!parsedValues.isEmpty() && prefillingMapping.getTarget().equals("tags")) {
|
||||||
|
parsedValue = mapper.valueToTree(parseTags(String.join(", ", parsedValues))).toString();
|
||||||
|
}
|
||||||
|
else {
|
||||||
parsedValue = mapper.valueToTree(parsedValue).toString();
|
parsedValue = mapper.valueToTree(parsedValue).toString();
|
||||||
}
|
}
|
||||||
setterMethod.invoke(datasetWizardModel, mapper.readValue(parsedValue, params[0]));
|
setterMethod.invoke(datasetWizardModel, mapper.readValue(parsedValue, params[0]));
|
||||||
|
@ -112,11 +138,11 @@ public class PrefillingMapper {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<JsonNode> nodes = JsonSearcher.findNodes(parentNode, "schematics", "rda." + prefillingMapping.getMaDmpTarget());
|
List<JsonNode> nodes = JsonSearcher.findNodes(parentNode, "schematics", prefillingMapping.getSemanticTarget());
|
||||||
|
|
||||||
// zenodo prefilling customizations
|
// zenodo prefilling customizations
|
||||||
if(type.equals("zenodo")){
|
if(type.equals("zenodo")){
|
||||||
if(prefillingMapping.getMaDmpTarget().equals("dataset.distribution.data_access")){
|
if(prefillingMapping.getSemanticTarget().equals("rda.dataset.distribution.data_access")){
|
||||||
if(parsedValue != null && parsedValue.equals("open")){
|
if(parsedValue != null && parsedValue.equals("open")){
|
||||||
List<JsonNode> issuedNodes = JsonSearcher.findNodes(parentNode, "schematics", "rda.dataset.issued");
|
List<JsonNode> issuedNodes = JsonSearcher.findNodes(parentNode, "schematics", "rda.dataset.issued");
|
||||||
if(!issuedNodes.isEmpty()){
|
if(!issuedNodes.isEmpty()){
|
||||||
|
@ -131,7 +157,7 @@ public class PrefillingMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefillingMapping.getMaDmpTarget().equals("dataset.distribution.available_until") && parsedValue != null && !parsedValue.equals("null")) {
|
if (prefillingMapping.getSemanticTarget().equals("rda.dataset.distribution.available_until") && parsedValue != null && !parsedValue.equals("null")) {
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
|
||||||
LocalDate date = LocalDate.parse(parsedValue, formatter);
|
LocalDate date = LocalDate.parse(parsedValue, formatter);
|
||||||
date = date.plusYears(20);
|
date = date.plusYears(20);
|
||||||
|
@ -152,7 +178,12 @@ public class PrefillingMapper {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TAGS:
|
case TAGS:
|
||||||
properties.put(id, mapper.valueToTree(parseTags(parsedValue)).toString());
|
if(parsedValues.isEmpty()) {
|
||||||
|
properties.put(id, mapper.valueToTree(parseTags(parsedValue)).toString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
properties.put(id, mapper.valueToTree(parseTags(String.join(", ", parsedValues))).toString());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DATASET_IDENTIFIER:
|
case DATASET_IDENTIFIER:
|
||||||
JSONObject datasetID = new JSONObject();
|
JSONObject datasetID = new JSONObject();
|
||||||
|
@ -194,7 +225,7 @@ public class PrefillingMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object parseComboBoxValues(JsonNode node, List<String> parsedValues) throws JsonProcessingException {
|
private Object parseComboBoxValues(JsonNode node, List<String> parsedValues) throws JsonProcessingException {
|
||||||
List<Object> normalizedValues = new ArrayList<>();
|
List<Object> normalizedValues = new ArrayList<>();
|
||||||
boolean isMultiSelect;
|
boolean isMultiSelect;
|
||||||
String type = node.isArray() ? node.get(0).get("data").get("type").asText() : node.get("data").get("type").asText();
|
String type = node.isArray() ? node.get(0).get("data").get("type").asText() : node.get("data").get("type").asText();
|
||||||
|
@ -203,7 +234,13 @@ public class PrefillingMapper {
|
||||||
AutoCompleteData autoCompleteData = mapper.treeToValue(dataNode, AutoCompleteData.class);
|
AutoCompleteData autoCompleteData = mapper.treeToValue(dataNode, AutoCompleteData.class);
|
||||||
isMultiSelect = autoCompleteData.getMultiAutoComplete();
|
isMultiSelect = autoCompleteData.getMultiAutoComplete();
|
||||||
for (String format : parsedValues) {
|
for (String format : parsedValues) {
|
||||||
List<ExternalAutocompleteFieldModel> result = DatasetProfileManager.getAutocomplete(autoCompleteData, format);
|
List<ExternalAutocompleteFieldModel> result = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
result = datasetProfileManager.getAutocomplete(autoCompleteData, format);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
result = result.stream().filter(StreamDistinctBy.distinctByKey(ExternalAutocompleteFieldModel::getId)).collect(Collectors.toList());
|
result = result.stream().filter(StreamDistinctBy.distinctByKey(ExternalAutocompleteFieldModel::getId)).collect(Collectors.toList());
|
||||||
if(!result.isEmpty()){
|
if(!result.isEmpty()){
|
||||||
List<String> tempValues = new LinkedList<>();
|
List<String> tempValues = new LinkedList<>();
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package eu.eudat.logic.proxy.config;
|
||||||
|
|
||||||
|
public enum AuthType {
|
||||||
|
;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
AuthType(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AuthType fromName(String name) {
|
||||||
|
for (AuthType authType : AuthType.values()) {
|
||||||
|
if (authType.getName().equals(name)) {
|
||||||
|
return authType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("AuthType [" + name + "] is not supported");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package eu.eudat.logic.proxy.config;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
|
||||||
|
public class AuthenticationConfiguration {
|
||||||
|
|
||||||
|
private String authUrl;
|
||||||
|
private String authMethod = "GET";
|
||||||
|
private String authTokenPath;
|
||||||
|
private String authRequestBody;
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public String getAuthUrl() {
|
||||||
|
return authUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authUrl")
|
||||||
|
public void setAuthUrl(String authUrl) {
|
||||||
|
this.authUrl = authUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthMethod() {
|
||||||
|
return authMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authUrlMethod")
|
||||||
|
public void setAuthMethod(String authMethod) {
|
||||||
|
this.authMethod = authMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthTokenPath() {
|
||||||
|
return authTokenPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authTokenJpath")
|
||||||
|
public void setAuthTokenPath(String authTokenPath) {
|
||||||
|
this.authTokenPath = authTokenPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthRequestBody() {
|
||||||
|
return authRequestBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authUrlBody")
|
||||||
|
public void setAuthRequestBody(String authRequestBody) {
|
||||||
|
this.authRequestBody = authRequestBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authType")
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ public class UrlConfiguration {
|
||||||
private String label;
|
private String label;
|
||||||
private Integer ordinal;
|
private Integer ordinal;
|
||||||
private String url;
|
private String url;
|
||||||
|
private boolean dataInListing;
|
||||||
private DataUrlConfiguration data;
|
private DataUrlConfiguration data;
|
||||||
private String type;
|
private String type;
|
||||||
private String paginationPath;
|
private String paginationPath;
|
||||||
|
@ -20,6 +21,7 @@ public class UrlConfiguration {
|
||||||
private String requestType = "GET";
|
private String requestType = "GET";
|
||||||
private String requestBody = "";
|
private String requestBody = "";
|
||||||
private String filterType = "remote";
|
private String filterType = "remote";
|
||||||
|
private AuthenticationConfiguration auth;
|
||||||
|
|
||||||
private List<QueryConfig> queries;
|
private List<QueryConfig> queries;
|
||||||
|
|
||||||
|
@ -47,6 +49,14 @@ public class UrlConfiguration {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDataInListing() {
|
||||||
|
return dataInListing;
|
||||||
|
}
|
||||||
|
@XmlElement(name = "dataInListing")
|
||||||
|
public void setDataInListing(boolean dataInListing) {
|
||||||
|
this.dataInListing = dataInListing;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getOrdinal() {
|
public Integer getOrdinal() {
|
||||||
return ordinal;
|
return ordinal;
|
||||||
}
|
}
|
||||||
|
@ -134,4 +144,13 @@ public class UrlConfiguration {
|
||||||
public void setQueries(List<QueryConfig> queries) {
|
public void setQueries(List<QueryConfig> queries) {
|
||||||
this.queries = queries;
|
this.queries = queries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AuthenticationConfiguration getAuth() {
|
||||||
|
return auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name="authentication")
|
||||||
|
public void setAuth(AuthenticationConfiguration auth) {
|
||||||
|
this.auth = auth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.proxy.config.configloaders;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrls;
|
import eu.eudat.logic.proxy.config.ExternalUrls;
|
||||||
import eu.eudat.logic.proxy.config.Semantic;
|
import eu.eudat.logic.proxy.config.Semantic;
|
||||||
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders;
|
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders;
|
||||||
|
import eu.eudat.models.data.pid.PidLinks;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -14,5 +15,6 @@ public interface ConfigLoader {
|
||||||
XWPFDocument getDocument();
|
XWPFDocument getDocument();
|
||||||
XWPFDocument getDatasetDocument();
|
XWPFDocument getDatasetDocument();
|
||||||
ConfigurableProviders getConfigurableProviders();
|
ConfigurableProviders getConfigurableProviders();
|
||||||
|
PidLinks getPidLinks();
|
||||||
Map<String, String> getKeyToSourceMap();
|
Map<String, String> getKeyToSourceMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrls;
|
import eu.eudat.logic.proxy.config.ExternalUrls;
|
||||||
import eu.eudat.logic.proxy.config.Semantic;
|
import eu.eudat.logic.proxy.config.Semantic;
|
||||||
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders;
|
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders;
|
||||||
|
import eu.eudat.models.data.pid.PidLinks;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -41,6 +42,7 @@ public class DefaultConfigLoader implements ConfigLoader {
|
||||||
private XWPFDocument document;
|
private XWPFDocument document;
|
||||||
private XWPFDocument datasetDocument;
|
private XWPFDocument datasetDocument;
|
||||||
private ConfigurableProviders configurableProviders;
|
private ConfigurableProviders configurableProviders;
|
||||||
|
private PidLinks pidLinks;
|
||||||
private Map<String, String> keyToSourceMap;
|
private Map<String, String> keyToSourceMap;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -134,6 +136,25 @@ public class DefaultConfigLoader implements ConfigLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setPidLinks() {
|
||||||
|
String filePath = environment.getProperty("configuration.pid_links");
|
||||||
|
logger.info("Loaded also config file: " + filePath);
|
||||||
|
InputStream is = null;
|
||||||
|
try {
|
||||||
|
is = getStreamFromPath(filePath);
|
||||||
|
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
this.pidLinks = mapper.readValue(is, PidLinks.class);
|
||||||
|
} catch (IOException | NullPointerException e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (is != null) is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.warn("Warning: Could not close a stream after reading from file: " + filePath, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setKeyToSourceMap() {
|
private void setKeyToSourceMap() {
|
||||||
String filePath = this.environment.getProperty("configuration.externalUrls");
|
String filePath = this.environment.getProperty("configuration.externalUrls");
|
||||||
logger.info("Loaded also config file: " + filePath);
|
logger.info("Loaded also config file: " + filePath);
|
||||||
|
@ -192,6 +213,14 @@ public class DefaultConfigLoader implements ConfigLoader {
|
||||||
return configurableProviders;
|
return configurableProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PidLinks getPidLinks() {
|
||||||
|
if (pidLinks == null) {
|
||||||
|
pidLinks = new PidLinks();
|
||||||
|
this.setPidLinks();
|
||||||
|
}
|
||||||
|
return pidLinks;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, String> getKeyToSourceMap() {
|
public Map<String, String> getKeyToSourceMap() {
|
||||||
if (keyToSourceMap == null) {
|
if (keyToSourceMap == null) {
|
||||||
keyToSourceMap = new HashMap<>();
|
keyToSourceMap = new HashMap<>();
|
||||||
|
|
|
@ -7,7 +7,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
public class DefaultPrefillingMapping implements PrefillingMapping{
|
public class DefaultPrefillingMapping implements PrefillingMapping{
|
||||||
private String source;
|
private String source;
|
||||||
private String target;
|
private String target;
|
||||||
private String maDmpTarget;
|
private String semanticTarget;
|
||||||
private String subSource;
|
private String subSource;
|
||||||
private String trimRegex;
|
private String trimRegex;
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ public class DefaultPrefillingMapping implements PrefillingMapping{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMaDmpTarget() {
|
public String getSemanticTarget() {
|
||||||
return maDmpTarget;
|
return semanticTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute(name = "maDmpTarget")
|
@XmlAttribute(name = "semanticTarget")
|
||||||
public void setMaDmpTarget(String maDmpTarget) {
|
public void setSemanticTarget(String semanticTarget) {
|
||||||
this.maDmpTarget = maDmpTarget;
|
this.semanticTarget = semanticTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSubSource() {
|
public String getSubSource() {
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package eu.eudat.logic.proxy.config.entities;
|
||||||
|
|
||||||
|
import eu.eudat.logic.proxy.config.FetchStrategy;
|
||||||
|
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GeneralUrls extends GenericUrls{
|
||||||
|
|
||||||
|
List<UrlConfiguration> urls;
|
||||||
|
FetchStrategy fetchMode;
|
||||||
|
|
||||||
|
public GeneralUrls() {
|
||||||
|
this.urls = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UrlConfiguration> getUrls() {
|
||||||
|
return urls;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FetchStrategy getFetchMode() {
|
||||||
|
return fetchMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFetchMode(FetchStrategy fetchMode) {
|
||||||
|
this.fetchMode = fetchMode;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
@XmlRootElement(name = "fixedMapping")
|
@XmlRootElement(name = "fixedMapping")
|
||||||
public class PrefillingFixedMapping implements PrefillingMapping{
|
public class PrefillingFixedMapping implements PrefillingMapping{
|
||||||
private String target;
|
private String target;
|
||||||
private String maDmpTarget;
|
private String semanticTarget;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public String getTarget() {
|
public String getTarget() {
|
||||||
|
@ -18,13 +18,13 @@ public class PrefillingFixedMapping implements PrefillingMapping{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMaDmpTarget() {
|
public String getSemanticTarget() {
|
||||||
return maDmpTarget;
|
return semanticTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute(name = "maDmpTarget")
|
@XmlAttribute(name = "semanticTarget")
|
||||||
public void setMaDmpTarget(String maDmpTarget) {
|
public void setSemanticTarget(String semanticTarget) {
|
||||||
this.maDmpTarget = maDmpTarget;
|
this.semanticTarget = semanticTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,9 +7,9 @@ public interface PrefillingMapping {
|
||||||
|
|
||||||
void setTarget(String target);
|
void setTarget(String target);
|
||||||
|
|
||||||
String getMaDmpTarget();
|
String getSemanticTarget();
|
||||||
|
|
||||||
void setMaDmpTarget(String maDmpTarget);
|
void setSemanticTarget(String semanticTarget);
|
||||||
|
|
||||||
String getSubSource();
|
String getSubSource();
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,14 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||||
|
import org.springframework.http.codec.json.Jackson2JsonDecoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import reactor.netty.http.client.HttpClient;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
@ -33,10 +38,16 @@ public class RemoteFetcher {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
|
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
|
||||||
|
|
||||||
private ConfigLoader configLoader;
|
private ConfigLoader configLoader;
|
||||||
|
private final WebClient client;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public RemoteFetcher(ConfigLoader configLoader) {
|
public RemoteFetcher(ConfigLoader configLoader) {
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
|
this.client = WebClient.builder().codecs(clientCodecConfigurer -> {
|
||||||
|
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
|
||||||
|
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
|
||||||
|
}
|
||||||
|
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(value = "repositories", keyGenerator = "externalUrlsKeyGenerator")
|
@Cacheable(value = "repositories", keyGenerator = "externalUrlsKeyGenerator")
|
||||||
|
@ -179,6 +190,10 @@ public class RemoteFetcher {
|
||||||
return getAll(urlConfigurations, fetchStrategy, externalUrlCriteria);
|
return getAll(urlConfigurations, fetchStrategy, externalUrlCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> getExternalGenericWithData(ExternalUrlCriteria externalUrlCriteria, GenericUrls genericUrls) {
|
||||||
|
List<UrlConfiguration> urlConfigurations = genericUrls.getUrls();
|
||||||
|
return getAllWithData(urlConfigurations, externalUrlCriteria);
|
||||||
|
}
|
||||||
|
|
||||||
private List<Map<String, String>> getAll(List<UrlConfiguration> urlConfigs, FetchStrategy fetchStrategy, ExternalUrlCriteria externalUrlCriteria) {
|
private List<Map<String, String>> getAll(List<UrlConfiguration> urlConfigs, FetchStrategy fetchStrategy, ExternalUrlCriteria externalUrlCriteria) {
|
||||||
|
|
||||||
|
@ -194,7 +209,11 @@ public class RemoteFetcher {
|
||||||
ifFunderQueryExist(urlConfiguration, externalUrlCriteria);
|
ifFunderQueryExist(urlConfiguration, externalUrlCriteria);
|
||||||
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
||||||
try {
|
try {
|
||||||
results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalUrlCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries()));
|
String auth = null;
|
||||||
|
if (urlConfiguration.getAuth() != null) {
|
||||||
|
auth = this.getAuthentication(urlConfiguration.getAuth());
|
||||||
|
}
|
||||||
|
results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalUrlCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries(), auth));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getLocalizedMessage(), e);
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -213,6 +232,42 @@ public class RemoteFetcher {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAuthentication(AuthenticationConfiguration authenticationConfiguration) {
|
||||||
|
HttpMethod method = HttpMethod.valueOf(authenticationConfiguration.getAuthMethod());
|
||||||
|
Map<String, Object> reponse = this.client.method(method).uri(authenticationConfiguration.getAuthUrl())
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.bodyValue(this.parseBodyString(authenticationConfiguration.getAuthRequestBody()))
|
||||||
|
.exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
|
||||||
|
})).block();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return authenticationConfiguration.getType() + " " + reponse.get(authenticationConfiguration.getAuthTokenPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Map<String, Object>> getAllWithData(List<UrlConfiguration> urlConfigs, ExternalUrlCriteria externalUrlCriteria) {
|
||||||
|
|
||||||
|
List<Map<String, Object>> results = new LinkedList<>();
|
||||||
|
|
||||||
|
if (urlConfigs == null || urlConfigs.isEmpty()) {
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
|
||||||
|
urlConfigs.forEach(urlConfiguration -> {
|
||||||
|
ifFunderQueryExist(urlConfiguration, externalUrlCriteria);
|
||||||
|
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
||||||
|
try {
|
||||||
|
results.addAll(getAllResultsFromUrlWithData(urlConfiguration.getUrl(), urlConfiguration.getData(), externalUrlCriteria, urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getQueries()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void ifFunderQueryExist(UrlConfiguration urlConfiguration, ExternalUrlCriteria externalUrlCriteria) {
|
private void ifFunderQueryExist(UrlConfiguration urlConfiguration, ExternalUrlCriteria externalUrlCriteria) {
|
||||||
if (urlConfiguration.getFunderQuery() != null) {
|
if (urlConfiguration.getFunderQuery() != null) {
|
||||||
if (externalUrlCriteria.getFunderId() != null && !urlConfiguration.getFunderQuery().startsWith("dmp:")) {
|
if (externalUrlCriteria.getFunderId() != null && !urlConfiguration.getFunderQuery().startsWith("dmp:")) {
|
||||||
|
@ -246,7 +301,7 @@ public class RemoteFetcher {
|
||||||
protected String replaceCriteriaOnUrl(String path, ExternalUrlCriteria externalUrlCriteria, String firstPage, List<QueryConfig> queries) {
|
protected String replaceCriteriaOnUrl(String path, ExternalUrlCriteria externalUrlCriteria, String firstPage, List<QueryConfig> queries) {
|
||||||
String completedPath = path;
|
String completedPath = path;
|
||||||
if (externalUrlCriteria.getLike() != null) {
|
if (externalUrlCriteria.getLike() != null) {
|
||||||
if ((path.contains("openaire") || path.contains("orcid") || path.contains("ror")) && externalUrlCriteria.getLike().equals("")) {
|
if ((path.contains("openaire") || path.contains("orcid") || path.contains("ror") || path.contains("fairsharing")) && externalUrlCriteria.getLike().equals("")) {
|
||||||
completedPath = completedPath.replaceAll("\\{like}", "*");
|
completedPath = completedPath.replaceAll("\\{like}", "*");
|
||||||
completedPath = completedPath.replaceAll("\\{query}", "*");
|
completedPath = completedPath.replaceAll("\\{query}", "*");
|
||||||
} else {
|
} else {
|
||||||
|
@ -271,6 +326,10 @@ public class RemoteFetcher {
|
||||||
*/
|
*/
|
||||||
completedPath = completedPath.replace("{funderId}", funderId);
|
completedPath = completedPath.replace("{funderId}", funderId);
|
||||||
}
|
}
|
||||||
|
else if(completedPath.contains("{funderId}")){
|
||||||
|
logger.warn("FunderId is null.");
|
||||||
|
completedPath = completedPath.replace("{funderId}", " ");
|
||||||
|
}
|
||||||
if (externalUrlCriteria.getPage() != null) {
|
if (externalUrlCriteria.getPage() != null) {
|
||||||
completedPath = completedPath.replace("{page}", externalUrlCriteria.getPage());
|
completedPath = completedPath.replace("{page}", externalUrlCriteria.getPage());
|
||||||
} else {
|
} else {
|
||||||
|
@ -298,49 +357,86 @@ public class RemoteFetcher {
|
||||||
return completedPath;
|
return completedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final DataUrlConfiguration jsonDataPath, final String jsonPaginationPath, ExternalUrlCriteria externalUrlCriteria, String tag, String key, String contentType, String firstPage, String requestBody, String requestType, String filterType, List<QueryConfig> queries) throws Exception {
|
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final DataUrlConfiguration jsonDataPath, final String jsonPaginationPath, ExternalUrlCriteria externalUrlCriteria, String tag, String key, String contentType, String firstPage, String requestBody, String requestType, String filterType, List<QueryConfig> queries, String auth) throws Exception {
|
||||||
Set<Integer> pages = new HashSet<>();
|
Set<Integer> pages = new HashSet<>();
|
||||||
|
|
||||||
String replacedPath = replaceCriteriaOnUrl(path, externalUrlCriteria, firstPage, queries);
|
String replacedPath = replaceCriteriaOnUrl(path, externalUrlCriteria, firstPage, queries);
|
||||||
String replacedBody = replaceCriteriaOnUrl(requestBody, externalUrlCriteria, firstPage, queries);
|
String replacedBody = replaceCriteriaOnUrl(requestBody, externalUrlCriteria, firstPage, queries);
|
||||||
|
|
||||||
Results results = getResultsFromUrl(replacedPath, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType);
|
Results results = getResultsFromUrl(replacedPath, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType, auth);
|
||||||
if(filterType != null && filterType.equals("local") && (externalUrlCriteria.getLike() != null && !externalUrlCriteria.getLike().isEmpty())){
|
if(results != null) {
|
||||||
results.setResults(results.getResults().stream()
|
if (filterType != null && filterType.equals("local") && (externalUrlCriteria.getLike() != null && !externalUrlCriteria.getLike().isEmpty())) {
|
||||||
.filter(r -> r.get("name").toLowerCase().contains(externalUrlCriteria.getLike().toLowerCase()))
|
results.setResults(results.getResults().stream()
|
||||||
.collect(Collectors.toList()));
|
.filter(r -> r.get("name").toLowerCase().contains(externalUrlCriteria.getLike().toLowerCase()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
if (fetchStrategy == FetchStrategy.FIRST)
|
||||||
|
return results.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
||||||
|
for (int i = 2; i <= results.getPagination().get("pages"); i++)
|
||||||
|
pages.add(i);
|
||||||
|
|
||||||
|
Long maxResults = configLoader.getExternalUrls().getMaxresults();
|
||||||
|
if ((maxResults > 0) && (results.getPagination().get("count") > maxResults))
|
||||||
|
throw new HugeResultSet("The submitted search query " + externalUrlCriteria.getLike() + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
|
||||||
|
|
||||||
|
Optional<Results> optionalResults = pages.parallelStream()
|
||||||
|
.map(page -> getResultsFromUrl(path + "&page=" + page, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType, auth))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.reduce((result1, result2) -> {
|
||||||
|
result1.getResults().addAll(result2.getResults());
|
||||||
|
return result1;
|
||||||
|
});
|
||||||
|
Results remainingResults = optionalResults.orElseGet(Results::new);
|
||||||
|
remainingResults.getResults().addAll(results.getResults());
|
||||||
|
|
||||||
|
return remainingResults.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
if (fetchStrategy == FetchStrategy.FIRST)
|
else {
|
||||||
return results == null ? new LinkedList<>() : results.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
return new LinkedList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (results != null && results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
private List<Map<String, Object>> getAllResultsFromUrlWithData(String path, final DataUrlConfiguration jsonDataPath, ExternalUrlCriteria externalUrlCriteria, String contentType, String firstPage, String requestBody, String requestType, List<QueryConfig> queries) {
|
||||||
for (int i = 2; i <= results.getPagination().get("pages"); i++)
|
|
||||||
pages.add(i);
|
|
||||||
|
|
||||||
Long maxResults = configLoader.getExternalUrls().getMaxresults();
|
String replacedPath = replaceCriteriaOnUrl(path, externalUrlCriteria, firstPage, queries);
|
||||||
if ((maxResults > 0 && results != null) && (results.getPagination().get("count") > maxResults))
|
String replacedBody = replaceCriteriaOnUrl(requestBody, externalUrlCriteria, firstPage, queries);
|
||||||
throw new HugeResultSet("The submitted search query " + externalUrlCriteria.getLike() + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
|
|
||||||
|
|
||||||
Optional<Results> optionalResults = pages.parallelStream()
|
try {
|
||||||
.map(page -> getResultsFromUrl(path + "&page=" + page, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType))
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
.filter(Objects::nonNull)
|
HttpHeaders headers = new HttpHeaders();
|
||||||
.reduce((result1, result2) -> {
|
HttpEntity<JsonNode> entity;
|
||||||
result1.getResults().addAll(result2.getResults());
|
ResponseEntity<String> response;
|
||||||
return result1;
|
if (contentType != null && !contentType.isEmpty()) {
|
||||||
});
|
headers.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
||||||
Results remainingResults = optionalResults.orElseGet(Results::new);
|
headers.setContentType(MediaType.valueOf(contentType));
|
||||||
remainingResults.getResults().addAll(results.getResults());
|
}
|
||||||
|
JsonNode jsonBody = new ObjectMapper().readTree(replacedBody);
|
||||||
|
entity = new HttpEntity<>(jsonBody, headers);
|
||||||
|
|
||||||
return remainingResults.getResults().stream().peek(x -> x.put("tag", tag)).collect(Collectors.toList());
|
response = restTemplate.exchange(replacedPath, HttpMethod.valueOf(requestType), entity, String.class);
|
||||||
|
if (response.getStatusCode() == HttpStatus.OK) {
|
||||||
|
if (response.getHeaders().get("Content-Type").get(0).contains("json")) {
|
||||||
|
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
||||||
|
return jsonContext.read(jsonDataPath.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
logger.error(exception.getMessage(), exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Results getResultsFromUrl(String urlString, DataUrlConfiguration jsonDataPath, String jsonPaginationPath, String contentType, String requestBody, String requestType) {
|
protected Results getResultsFromUrl(String urlString, DataUrlConfiguration jsonDataPath, String jsonPaginationPath, String contentType, String requestBody, String requestType, String auth) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
//RestTemplate restTemplate = new RestTemplate(new SimpleClientHttpRequestFactory());
|
||||||
HttpHeaders headers = new HttpHeaders();
|
//HttpHeaders headers = new HttpHeaders();
|
||||||
HttpEntity<JsonNode> entity;
|
//HttpEntity<JsonNode> entity;
|
||||||
ResponseEntity<String> response;
|
ResponseEntity<String> response;
|
||||||
/*
|
/*
|
||||||
* URL url = new URL(urlString.replaceAll(" ", "%20"));
|
* URL url = new URL(urlString.replaceAll(" ", "%20"));
|
||||||
|
@ -348,14 +444,27 @@ public class RemoteFetcher {
|
||||||
* HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
* HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
* con.setRequestMethod("GET");
|
* con.setRequestMethod("GET");
|
||||||
*/
|
*/
|
||||||
if (contentType != null && !contentType.isEmpty()) {
|
/* if (contentType != null && !contentType.isEmpty()) {
|
||||||
headers.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
headers.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
||||||
headers.setContentType(MediaType.valueOf(contentType));
|
headers.setContentType(MediaType.valueOf(contentType));
|
||||||
}
|
}
|
||||||
|
if (auth != null) {
|
||||||
|
headers.set("Authorization", auth);
|
||||||
|
}*/
|
||||||
JsonNode jsonBody = new ObjectMapper().readTree(requestBody);
|
JsonNode jsonBody = new ObjectMapper().readTree(requestBody);
|
||||||
entity = new HttpEntity<>(jsonBody, headers);
|
// entity = new HttpEntity<>(jsonBody, headers);
|
||||||
|
|
||||||
response = restTemplate.exchange(urlString, HttpMethod.resolve(requestType), entity, String.class);
|
|
||||||
|
response = this.client.method(HttpMethod.valueOf(requestType)).uri(urlString).headers(httpHeaders -> {
|
||||||
|
if (contentType != null && !contentType.isEmpty()) {
|
||||||
|
httpHeaders.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
||||||
|
httpHeaders.setContentType(MediaType.valueOf(contentType));
|
||||||
|
}
|
||||||
|
if (auth != null) {
|
||||||
|
httpHeaders.set("Authorization", auth);
|
||||||
|
}
|
||||||
|
}).bodyValue(jsonBody).retrieve().toEntity(String.class).block();
|
||||||
|
//response = restTemplate.exchange(urlString, HttpMethod.resolve(requestType), entity, String.class);
|
||||||
if (response.getStatusCode() == HttpStatus.OK) { // success
|
if (response.getStatusCode() == HttpStatus.OK) { // success
|
||||||
//do here all the parsing
|
//do here all the parsing
|
||||||
Results results = new Results();
|
Results results = new Results();
|
||||||
|
@ -363,7 +472,7 @@ public class RemoteFetcher {
|
||||||
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
||||||
|
|
||||||
if (jsonDataPath.getFieldsUrlConfiguration().getPath() != null) {
|
if (jsonDataPath.getFieldsUrlConfiguration().getPath() != null) {
|
||||||
results = RemoteFetcherUtils.getFromJsonWithRecursiveFetching(jsonContext, jsonDataPath, this, requestBody, requestType);
|
results = RemoteFetcherUtils.getFromJsonWithRecursiveFetching(jsonContext, jsonDataPath, this, requestBody, requestType, auth);
|
||||||
} else if (jsonDataPath.getFieldsUrlConfiguration().getFirstName() != null) {
|
} else if (jsonDataPath.getFieldsUrlConfiguration().getFirstName() != null) {
|
||||||
results = RemoteFetcherUtils.getFromJsonWithFirstAndLastName(jsonContext, jsonDataPath);
|
results = RemoteFetcherUtils.getFromJsonWithFirstAndLastName(jsonContext, jsonDataPath);
|
||||||
} else {
|
} else {
|
||||||
|
@ -485,8 +594,18 @@ public class RemoteFetcher {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String parseBodyString(String bodyString) {
|
||||||
|
String finalBodyString = bodyString;
|
||||||
|
if (bodyString.contains("{env:")) {
|
||||||
|
int index = bodyString.indexOf("{env: ");
|
||||||
|
while (index >= 0) {
|
||||||
|
int endIndex = bodyString.indexOf("}", index + 6);
|
||||||
|
String envName = bodyString.substring(index + 6, endIndex);
|
||||||
|
finalBodyString = finalBodyString.replace("{env: " + envName + "}", System.getenv(envName));
|
||||||
|
index = bodyString.indexOf("{env: ", index + 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return finalBodyString;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class RemoteFetcherUtils {
|
||||||
new HashMap<>(1, 1));
|
new HashMap<>(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Results getFromJsonWithRecursiveFetching(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath, RemoteFetcher remoteFetcher, String requestBody, String requestType) {
|
public static Results getFromJsonWithRecursiveFetching(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath, RemoteFetcher remoteFetcher, String requestBody, String requestType, String auth) {
|
||||||
Results results = new Results(parseData(jsonContext, jsonDataPath),
|
Results results = new Results(parseData(jsonContext, jsonDataPath),
|
||||||
new HashMap<>(1, 1));
|
new HashMap<>(1, 1));
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class RemoteFetcherUtils {
|
||||||
externalUrlCriteria.setPath(result.get("path"));
|
externalUrlCriteria.setPath(result.get("path"));
|
||||||
externalUrlCriteria.setHost(result.get("host"));
|
externalUrlCriteria.setHost(result.get("host"));
|
||||||
String replacedPath = remoteFetcher.replaceCriteriaOnUrl(jsonDataPath.getUrlConfiguration().getUrl(), externalUrlCriteria, jsonDataPath.getUrlConfiguration().getFirstpage(), jsonDataPath.getUrlConfiguration().getQueries());
|
String replacedPath = remoteFetcher.replaceCriteriaOnUrl(jsonDataPath.getUrlConfiguration().getUrl(), externalUrlCriteria, jsonDataPath.getUrlConfiguration().getFirstpage(), jsonDataPath.getUrlConfiguration().getQueries());
|
||||||
return remoteFetcher.getResultsFromUrl(replacedPath, jsonDataPath.getUrlConfiguration().getData(), jsonDataPath.getUrlConfiguration().getData().getPath(), jsonDataPath.getUrlConfiguration().getContentType(), requestBody, requestType);
|
return remoteFetcher.getResultsFromUrl(replacedPath, jsonDataPath.getUrlConfiguration().getData(), jsonDataPath.getUrlConfiguration().getData().getPath(), jsonDataPath.getUrlConfiguration().getContentType(), requestBody, requestType, auth);
|
||||||
}).filter(Objects::nonNull).map(results1 -> results1.getResults().get(0)).collect(Collectors.toList());
|
}).filter(Objects::nonNull).map(results1 -> results1.getResults().get(0)).collect(Collectors.toList());
|
||||||
return new Results(multiResults, new HashMap<>(1, 1));
|
return new Results(multiResults, new HashMap<>(1, 1));
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,13 @@ public class RemoteFetcherUtils {
|
||||||
Object pidObj = stringObjectMap.get(value.split("\\.")[0]);
|
Object pidObj = stringObjectMap.get(value.split("\\.")[0]);
|
||||||
if(pidObj != null){
|
if(pidObj != null){
|
||||||
if(pidObj instanceof Map){
|
if(pidObj instanceof Map){
|
||||||
pid = ((Map<String, String>) pidObj).get(value.split("\\.")[1]);
|
Object o = ((Map<String, Object>) pidObj).get(value.split("\\.")[1]);
|
||||||
|
if(o instanceof String){
|
||||||
|
pid = (String)o;
|
||||||
|
}
|
||||||
|
else if(o instanceof Integer){
|
||||||
|
pid = String.valueOf(o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(pidObj instanceof List){
|
else if(pidObj instanceof List){
|
||||||
Object o = ((List<Map<String,?>>) pidObj).get(0).get(value.split("\\.")[1]);
|
Object o = ((List<Map<String,?>>) pidObj).get(0).get(value.split("\\.")[1]);
|
||||||
|
@ -92,8 +98,22 @@ public class RemoteFetcherUtils {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
value = value.replace("'", "");
|
value = value.replace("'", "");
|
||||||
if (stringObjectMap.containsKey(value)) {
|
if (value.contains(".")) {
|
||||||
parsedData.get(parsedData.size() - 1).put(field.getName().equals("types") ? "tags" : value, normalizeValue(stringObjectMap.get(value), (field.getName().equals("types") || field.getName().equals("uri"))));
|
String[] parts = value.split("\\.");
|
||||||
|
Map<String, Object> tempMap = stringObjectMap;
|
||||||
|
for (int i = 0; i < parts.length; i++) {
|
||||||
|
if (tempMap.containsKey(parts[i])) {
|
||||||
|
if (i + 1 < parts.length) {
|
||||||
|
tempMap = (Map<String, Object>) tempMap.get(parts[i]);
|
||||||
|
} else {
|
||||||
|
parsedData.get(parsedData.size() - 1).put(field.getName().equals("types") ? "tags" : value, normalizeValue(tempMap.get(parts[i]), (field.getName().equals("types") || field.getName().equals("uri"))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (stringObjectMap.containsKey(value)) {
|
||||||
|
parsedData.get(parsedData.size() - 1).put(field.getName().equals("types") ? "tags" : value, normalizeValue(stringObjectMap.get(value), (field.getName().equals("types") || field.getName().equals("uri"))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +149,8 @@ public class RemoteFetcherUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (value instanceof Map) {
|
} else if (value instanceof Map) {
|
||||||
return ((Map<String, String>)value).get("content");
|
String key = ((Map<String, String>)value).containsKey("$") ? "$" : "content";
|
||||||
|
return ((Map<String, String>)value).get(key);
|
||||||
}
|
}
|
||||||
return value != null ? value.toString() : null;
|
return value != null ? value.toString() : null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,9 @@ public class DMPToDepositMapper {
|
||||||
deposit.setUsers(entity.getUsers().stream().map(DMPToDepositMapper::fromUserDMP).collect(Collectors.toSet()));
|
deposit.setUsers(entity.getUsers().stream().map(DMPToDepositMapper::fromUserDMP).collect(Collectors.toSet()));
|
||||||
deposit.setOrganisations(entity.getOrganisations().stream().map(DMPToDepositMapper::fromOrganisation).collect(Collectors.toSet()));
|
deposit.setOrganisations(entity.getOrganisations().stream().map(DMPToDepositMapper::fromOrganisation).collect(Collectors.toSet()));
|
||||||
deposit.setResearchers(entity.getResearchers().stream().map(DMPToDepositMapper::fromResearcher).collect(Collectors.toSet()));
|
deposit.setResearchers(entity.getResearchers().stream().map(DMPToDepositMapper::fromResearcher).collect(Collectors.toSet()));
|
||||||
deposit.setGrant(fromGrant(entity.getGrant()));
|
if (entity.getGrant() != null) {
|
||||||
|
deposit.setGrant(fromGrant(entity.getGrant()));
|
||||||
|
}
|
||||||
|
|
||||||
deposit.setPdfFile(pdfFile);
|
deposit.setPdfFile(pdfFile);
|
||||||
deposit.setRdaJsonFile(jsonFile);
|
deposit.setRdaJsonFile(jsonFile);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.security.validators.configurableProvider;
|
||||||
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.saml2.CertificateInfo;
|
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.saml2.CertificateInfo;
|
||||||
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.saml2.Saml2ConfigurableProvider;
|
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.saml2.Saml2ConfigurableProvider;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
|
import eu.eudat.models.data.saml2.AuthnRequestModel;
|
||||||
import jakarta.xml.soap.*;
|
import jakarta.xml.soap.*;
|
||||||
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
|
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
|
||||||
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
|
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
|
||||||
|
@ -34,7 +35,6 @@ import org.opensaml.core.xml.config.XMLObjectProviderRegistry;
|
||||||
import org.opensaml.core.xml.io.*;
|
import org.opensaml.core.xml.io.*;
|
||||||
import org.opensaml.core.xml.schema.*;
|
import org.opensaml.core.xml.schema.*;
|
||||||
import org.opensaml.saml.common.SAMLObject;
|
import org.opensaml.saml.common.SAMLObject;
|
||||||
import org.opensaml.saml.common.SAMLObjectContentReference;
|
|
||||||
import org.opensaml.saml.common.SAMLVersion;
|
import org.opensaml.saml.common.SAMLVersion;
|
||||||
import org.opensaml.saml.common.xml.SAMLConstants;
|
import org.opensaml.saml.common.xml.SAMLConstants;
|
||||||
import org.opensaml.saml.criterion.EntityRoleCriterion;
|
import org.opensaml.saml.criterion.EntityRoleCriterion;
|
||||||
|
@ -64,8 +64,6 @@ import org.opensaml.xmlsec.keyinfo.impl.X509KeyInfoGeneratorFactory;
|
||||||
import org.opensaml.xmlsec.signature.KeyInfo;
|
import org.opensaml.xmlsec.signature.KeyInfo;
|
||||||
import org.opensaml.xmlsec.signature.Signature;
|
import org.opensaml.xmlsec.signature.Signature;
|
||||||
import org.opensaml.xmlsec.signature.X509Data;
|
import org.opensaml.xmlsec.signature.X509Data;
|
||||||
import org.opensaml.xmlsec.signature.impl.SignatureBuilder;
|
|
||||||
import org.opensaml.xmlsec.signature.support.SignatureConstants;
|
|
||||||
import org.opensaml.xmlsec.signature.support.SignatureValidator;
|
import org.opensaml.xmlsec.signature.support.SignatureValidator;
|
||||||
import org.opensaml.xmlsec.signature.support.Signer;
|
import org.opensaml.xmlsec.signature.support.Signer;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -88,6 +86,7 @@ import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.*;
|
import java.security.*;
|
||||||
|
@ -794,47 +793,68 @@ public class Saml2SSOUtils {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAuthnRequest(Saml2ConfigurableProvider provider) throws Exception {
|
public static AuthnRequestModel getAuthnRequest(Saml2ConfigurableProvider provider) throws Exception {
|
||||||
|
|
||||||
AuthnRequest authnRequest = buildAuthnRequest(provider);
|
AuthnRequest authnRequest = buildAuthnRequest(provider);
|
||||||
|
String relayState = "spId=" + provider.getSpEntityId() + "&configurableLoginId=" + provider.getConfigurableLoginId();
|
||||||
|
|
||||||
String authnRequestXml = null;
|
String authnRequestXml = null;
|
||||||
DocumentBuilder builder;
|
String signatureBase64 = null;
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
|
||||||
try {
|
try {
|
||||||
Signature signature = (Signature) buildXMLObject(Signature.DEFAULT_ELEMENT_NAME);
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
if(provider.isAuthnRequestsSigned()){
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
|
||||||
Credential credential = getCredential(provider.getSigningCert());
|
|
||||||
signature.setSigningCredential(credential);
|
|
||||||
signature.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
|
|
||||||
signature.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
|
|
||||||
|
|
||||||
X509KeyInfoGeneratorFactory keyInfoGeneratorFactory = new X509KeyInfoGeneratorFactory();
|
|
||||||
keyInfoGeneratorFactory.setEmitEntityCertificate(true);
|
|
||||||
KeyInfoGenerator keyInfoGenerator = keyInfoGeneratorFactory.newInstance();
|
|
||||||
signature.setKeyInfo(keyInfoGenerator.generate(getCredential(provider.getSigningCert())));
|
|
||||||
|
|
||||||
authnRequest.setSignature(signature);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder = factory.newDocumentBuilder();
|
|
||||||
Document document = builder.newDocument();
|
Document document = builder.newDocument();
|
||||||
Marshaller out = registry.getMarshallerFactory().getMarshaller(authnRequest);
|
Marshaller out = registry.getMarshallerFactory().getMarshaller(authnRequest);
|
||||||
out.marshall(authnRequest, document);
|
out.marshall(authnRequest, document);
|
||||||
|
|
||||||
if(provider.isAuthnRequestsSigned()) {
|
|
||||||
Signer.signObject(signature);
|
|
||||||
}
|
|
||||||
|
|
||||||
authnRequestXml = XmlBuilder.generateXml(document);
|
authnRequestXml = XmlBuilder.generateXml(document);
|
||||||
|
|
||||||
|
if(provider.isAuthnRequestsSigned()) {
|
||||||
|
signatureBase64 = buildSignature(authnRequestXml, relayState, provider.getSigningCert());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (MarshallingException | ParserConfigurationException e) {
|
catch (MarshallingException | ParserConfigurationException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return authnRequestXml;
|
|
||||||
|
|
||||||
|
AuthnRequestModel authnRequestModel = new AuthnRequestModel();
|
||||||
|
authnRequestModel.setAuthnRequestXml(authnRequestXml);
|
||||||
|
authnRequestModel.setRelayState(relayState);
|
||||||
|
authnRequestModel.setAlgorithm("http://www.w3.org/2000/09/xmldsig#rsa-sha1");
|
||||||
|
authnRequestModel.setSignature(signatureBase64);
|
||||||
|
return authnRequestModel;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String buildSignature(String authnRequest, String relayState, CertificateInfo signingCertInfo) throws Exception{
|
||||||
|
|
||||||
|
KeyStore ks = (signingCertInfo.getKeyFormat().getType().equals("JKS")) ? KeyStore.getInstance("JKS") : KeyStore.getInstance("PKCS12");
|
||||||
|
String archivePassword = signingCertInfo.getKeystorePassword();
|
||||||
|
char[] pwdArray = (archivePassword != null) ? archivePassword.toCharArray() : "changeit".toCharArray();
|
||||||
|
ks.load(new FileInputStream(signingCertInfo.getKeystorePath()), pwdArray);
|
||||||
|
PrivateKey pk = (PrivateKey) ks.getKey(signingCertInfo.getAlias(), signingCertInfo.getPassword().toCharArray());
|
||||||
|
|
||||||
|
String signAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
|
||||||
|
String message = "SAMLRequest=" + URLEncoder.encode(authnRequest, "UTF-8")
|
||||||
|
+ "&RelayState=" + URLEncoder.encode(relayState, "UTF-8")
|
||||||
|
+ "&SigAlg=" + URLEncoder.encode(signAlgorithm, "UTF-8");
|
||||||
|
|
||||||
|
String signature = null;
|
||||||
|
try{
|
||||||
|
signature = new String(org.apache.commons.codec.binary.Base64.encodeBase64(sign(message, pk)), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
catch(InvalidKeyException | SignatureException | NoSuchAlgorithmException e){
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] sign(String message, PrivateKey key) throws InvalidKeyException, SignatureException, NoSuchAlgorithmException {
|
||||||
|
java.security.Signature instance = java.security.Signature.getInstance("SHA1withRSA");
|
||||||
|
instance.initSign(key);
|
||||||
|
instance.update(message.getBytes());
|
||||||
|
return instance.sign();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AuthnRequest buildAuthnRequest(Saml2ConfigurableProvider provider) throws Exception {
|
private static AuthnRequest buildAuthnRequest(Saml2ConfigurableProvider provider) throws Exception {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,14 @@ import eu.eudat.exceptions.security.NullEmailException;
|
||||||
import eu.eudat.logic.builders.entity.CredentialBuilder;
|
import eu.eudat.logic.builders.entity.CredentialBuilder;
|
||||||
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
||||||
import eu.eudat.logic.builders.entity.UserTokenBuilder;
|
import eu.eudat.logic.builders.entity.UserTokenBuilder;
|
||||||
|
import eu.eudat.logic.managers.MetricsManager;
|
||||||
import eu.eudat.logic.security.validators.TokenValidatorFactoryImpl;
|
import eu.eudat.logic.security.validators.TokenValidatorFactoryImpl;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.login.Credentials;
|
import eu.eudat.models.data.login.Credentials;
|
||||||
import eu.eudat.models.data.loginprovider.LoginProviderUser;
|
import eu.eudat.models.data.loginprovider.LoginProviderUser;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.Authorities;
|
import eu.eudat.types.Authorities;
|
||||||
|
import eu.eudat.types.MetricNames;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -30,10 +32,12 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
|
||||||
|
|
||||||
protected ApiContext apiContext;
|
protected ApiContext apiContext;
|
||||||
protected Environment environment;
|
protected Environment environment;
|
||||||
|
protected MetricsManager metricsManager;
|
||||||
|
|
||||||
public AbstractAuthenticationService(ApiContext apiContext, Environment environment) {
|
public AbstractAuthenticationService(ApiContext apiContext, Environment environment, MetricsManager metricsManager) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
|
this.metricsManager = metricsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Date addADay(Date date) {
|
protected Date addADay(Date date) {
|
||||||
|
@ -91,6 +95,7 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
|
||||||
if (credential == null && credentials.getUsername().equals(environment.getProperty("autouser.root.username"))) {
|
if (credential == null && credentials.getUsername().equals(environment.getProperty("autouser.root.username"))) {
|
||||||
try {
|
try {
|
||||||
credential = this.autoCreateUser(credentials.getUsername(), credentials.getSecret());
|
credential = this.autoCreateUser(credentials.getUsername(), credentials.getSecret());
|
||||||
|
metricsManager.increaseValue(MetricNames.USERS, 1, MetricNames.TOTAL);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
|
@ -162,7 +167,7 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
|
||||||
role.setRole(Authorities.USER.getValue());
|
role.setRole(Authorities.USER.getValue());
|
||||||
role.setUserInfo(userInfo);
|
role.setUserInfo(userInfo);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(role);
|
apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(role);
|
||||||
|
metricsManager.increaseValue(MetricNames.USERS, 1, MetricNames.TOTAL);
|
||||||
} else {
|
} else {
|
||||||
Map<String, Object> additionalInfo = userInfo.getAdditionalinfo() != null ?
|
Map<String, Object> additionalInfo = userInfo.getAdditionalinfo() != null ?
|
||||||
new JSONObject(userInfo.getAdditionalinfo()).toMap() : new HashMap<>();
|
new JSONObject(userInfo.getAdditionalinfo()).toMap() : new HashMap<>();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.data.entities.UserRole;
|
import eu.eudat.data.entities.UserRole;
|
||||||
import eu.eudat.data.entities.UserToken;
|
import eu.eudat.data.entities.UserToken;
|
||||||
import eu.eudat.logic.builders.model.models.PrincipalBuilder;
|
import eu.eudat.logic.builders.model.models.PrincipalBuilder;
|
||||||
|
import eu.eudat.logic.managers.MetricsManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.Authorities;
|
import eu.eudat.types.Authorities;
|
||||||
|
@ -19,8 +20,8 @@ import java.util.List;
|
||||||
@Service("nonVerifiedUserAuthenticationService")
|
@Service("nonVerifiedUserAuthenticationService")
|
||||||
public class NonVerifiedUserEmailAuthenticationService extends AbstractAuthenticationService {
|
public class NonVerifiedUserEmailAuthenticationService extends AbstractAuthenticationService {
|
||||||
|
|
||||||
public NonVerifiedUserEmailAuthenticationService(ApiContext apiContext, Environment environment) {
|
public NonVerifiedUserEmailAuthenticationService(ApiContext apiContext, Environment environment, MetricsManager metricsManager) {
|
||||||
super(apiContext, environment);
|
super(apiContext, environment, metricsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Principal Touch(UserToken token) {
|
public Principal Touch(UserToken token) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import eu.eudat.logic.builders.entity.CredentialBuilder;
|
||||||
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
||||||
import eu.eudat.logic.builders.entity.UserTokenBuilder;
|
import eu.eudat.logic.builders.entity.UserTokenBuilder;
|
||||||
import eu.eudat.logic.builders.model.models.PrincipalBuilder;
|
import eu.eudat.logic.builders.model.models.PrincipalBuilder;
|
||||||
|
import eu.eudat.logic.managers.MetricsManager;
|
||||||
import eu.eudat.logic.security.validators.TokenValidatorFactoryImpl;
|
import eu.eudat.logic.security.validators.TokenValidatorFactoryImpl;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.login.Credentials;
|
import eu.eudat.models.data.login.Credentials;
|
||||||
|
@ -27,8 +28,8 @@ import java.util.*;
|
||||||
@Service("verifiedUserAuthenticationService")
|
@Service("verifiedUserAuthenticationService")
|
||||||
public class VerifiedUserAuthenticationService extends AbstractAuthenticationService {
|
public class VerifiedUserAuthenticationService extends AbstractAuthenticationService {
|
||||||
|
|
||||||
public VerifiedUserAuthenticationService(ApiContext apiContext, Environment environment) {
|
public VerifiedUserAuthenticationService(ApiContext apiContext, Environment environment, MetricsManager metricsManager) {
|
||||||
super(apiContext, environment);
|
super(apiContext, environment, metricsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Principal Touch(UserToken token) {
|
public Principal Touch(UserToken token) {
|
||||||
|
|
|
@ -108,8 +108,11 @@ public class MailServiceImpl implements MailService {
|
||||||
lastIndex = content.indexOf("img src=\"", lastIndex);
|
lastIndex = content.indexOf("img src=\"", lastIndex);
|
||||||
|
|
||||||
if (lastIndex != -1) {
|
if (lastIndex != -1) {
|
||||||
imagePaths.add(content.substring(lastIndex + 9, content.indexOf("\"", lastIndex + 9)));
|
String imagePath = content.substring(lastIndex + 9, content.indexOf("\"", lastIndex + 9));
|
||||||
lastIndex ++;
|
if (!imagePath.contains("data:image/png;base64")) {
|
||||||
|
imagePaths.add(imagePath);
|
||||||
|
}
|
||||||
|
lastIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,14 @@ import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.Dataset;
|
import eu.eudat.data.entities.Dataset;
|
||||||
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.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
||||||
import eu.eudat.logic.utilities.interfaces.ApplierWithValue;
|
import eu.eudat.logic.utilities.interfaces.ApplierWithValue;
|
||||||
import eu.eudat.logic.utilities.json.JavaToJson;
|
import eu.eudat.logic.utilities.json.JavaToJson;
|
||||||
import eu.eudat.models.data.components.commons.datafield.*;
|
import eu.eudat.models.data.components.commons.datafield.*;
|
||||||
|
import eu.eudat.models.data.pid.PidLink;
|
||||||
|
import eu.eudat.models.data.pid.PidLinks;
|
||||||
import eu.eudat.models.data.user.components.datasetprofile.Field;
|
import eu.eudat.models.data.user.components.datasetprofile.Field;
|
||||||
import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
||||||
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
||||||
|
@ -21,6 +24,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
import org.apache.poi.xwpf.usermodel.*;
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
import org.apache.xmlbeans.XmlCursor;
|
import org.apache.xmlbeans.XmlCursor;
|
||||||
|
import org.apache.xmlbeans.XmlObject;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
@ -71,8 +75,9 @@ public class WordBuilder {
|
||||||
private Integer indent;
|
private Integer indent;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
private Integer imageCount;
|
private Integer imageCount;
|
||||||
|
private ConfigLoader configLoader;
|
||||||
|
|
||||||
public WordBuilder(Environment environment) {
|
public WordBuilder(Environment environment, ConfigLoader configLoader) {
|
||||||
this.cTAbstractNum = CTAbstractNum.Factory.newInstance();
|
this.cTAbstractNum = CTAbstractNum.Factory.newInstance();
|
||||||
this.cTAbstractNum.setAbstractNumId(BigInteger.valueOf(1));
|
this.cTAbstractNum.setAbstractNumId(BigInteger.valueOf(1));
|
||||||
this.indent = 0;
|
this.indent = 0;
|
||||||
|
@ -80,6 +85,7 @@ public class WordBuilder {
|
||||||
this.mapper = new ObjectMapper();
|
this.mapper = new ObjectMapper();
|
||||||
this.buildOptions(environment);
|
this.buildOptions(environment);
|
||||||
this.buildOptionsInTable(environment);
|
this.buildOptionsInTable(environment);
|
||||||
|
this.configLoader = configLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildOptionsInTable(Environment environment) {
|
private void buildOptionsInTable(Environment environment) {
|
||||||
|
@ -568,6 +574,37 @@ public class WordBuilder {
|
||||||
return hasValue;
|
return hasValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createHypeLink(XWPFDocument mainDocumentPart, String format, String pidType, String pid, boolean hasMultiplicityItems, boolean isMultiAutoComplete){
|
||||||
|
PidLink pidLink = this.configLoader.getPidLinks().getPidLinks().stream().filter(pl -> pl.getPid().equals(pidType)).findFirst().orElse(null);
|
||||||
|
if (pidLink != null) {
|
||||||
|
if (!hasMultiplicityItems) {
|
||||||
|
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
|
||||||
|
paragraph.setIndentFromLeft(400 * indent);
|
||||||
|
if (numId != null) {
|
||||||
|
paragraph.setNumID(numId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isMultiAutoComplete) {
|
||||||
|
XWPFRun r = mainDocumentPart.getLastParagraph().createRun();
|
||||||
|
r.setText("• ");
|
||||||
|
}
|
||||||
|
XWPFHyperlinkRun run = mainDocumentPart.getLastParagraph().createHyperlinkRun(pidLink.getLink().replace("{pid}", pid));
|
||||||
|
run.setText(format);
|
||||||
|
run.setUnderline(UnderlinePatterns.SINGLE);
|
||||||
|
run.setColor("0000FF");
|
||||||
|
run.setFontSize(11);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String newFormat = (isMultiAutoComplete) ? "• " + format : format;
|
||||||
|
if (hasMultiplicityItems) {
|
||||||
|
mainDocumentPart.getLastParagraph().createRun().setText(newFormat);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addParagraphContent(newFormat, mainDocumentPart, ParagraphStyle.TEXT, numId, indent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Boolean createFields(List<Field> fields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService, boolean hasMultiplicityItems) {
|
private Boolean createFields(List<Field> fields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService, boolean hasMultiplicityItems) {
|
||||||
if (createListing) this.addListing(mainDocumentPart, indent, false, false);
|
if (createListing) this.addListing(mainDocumentPart, indent, false, false);
|
||||||
boolean hasValue = false;
|
boolean hasValue = false;
|
||||||
|
@ -607,70 +644,126 @@ public class WordBuilder {
|
||||||
} else if (field.getViewStyle().getRenderStyle().equals("combobox") && field.getData() instanceof AutoCompleteData) {
|
} else if (field.getViewStyle().getRenderStyle().equals("combobox") && field.getData() instanceof AutoCompleteData) {
|
||||||
format = getCommaSeparatedFormatsFromJson(format, "label");
|
format = getCommaSeparatedFormatsFromJson(format, "label");
|
||||||
}
|
}
|
||||||
boolean isResearcher = field.getViewStyle().getRenderStyle().equals("researchers");
|
switch (field.getViewStyle().getRenderStyle()) {
|
||||||
if(format != null && !format.isEmpty()){
|
case "organizations":
|
||||||
Object hasMultiAutoComplete = mapper.convertValue(field.getData(), Map.class).get("multiAutoComplete");
|
case "externalDatasets":
|
||||||
boolean isMultiAutoComplete = hasMultiAutoComplete != null && (boolean)hasMultiAutoComplete;
|
case "publications":
|
||||||
boolean arrayStringFormat = format.charAt(0) == '[';
|
if(format != null && !format.isEmpty()){
|
||||||
if(arrayStringFormat || isMultiAutoComplete){
|
Object hasMultiAutoComplete = mapper.convertValue(field.getData(), Map.class).get("multiAutoComplete");
|
||||||
List<String> values = (arrayStringFormat) ? Arrays.asList(format.substring(1, format.length() - 1).split(",[ ]*")) : Arrays.asList(format.split(",[ ]*"));
|
boolean isMultiAutoComplete = hasMultiAutoComplete != null && (boolean)hasMultiAutoComplete;
|
||||||
if(values.size() > 1) {
|
if(!isMultiAutoComplete){
|
||||||
boolean orcidResearcher;
|
Map<String, String> value = mapper.readValue((String)field.getValue(), Map.class);
|
||||||
for (String val : values) {
|
|
||||||
orcidResearcher = false;
|
|
||||||
String orcId = null;
|
|
||||||
if(isResearcher && val.contains("orcid:")){
|
|
||||||
orcId = val.substring(val.indexOf(':') + 1, val.indexOf(')'));
|
|
||||||
val = val.substring(0, val.indexOf(':') + 1) + " ";
|
|
||||||
orcidResearcher = true;
|
|
||||||
}
|
|
||||||
format = "• " + val;
|
|
||||||
if(hasMultiplicityItems){
|
if(hasMultiplicityItems){
|
||||||
mainDocumentPart.getLastParagraph().createRun().setText(format);
|
createHypeLink(mainDocumentPart, format, value.get("pidTypeField"), value.get("pid"), true, false);
|
||||||
if(orcidResearcher){
|
|
||||||
XWPFHyperlinkRun run = mainDocumentPart.getLastParagraph().createHyperlinkRun("https://orcid.org/" + orcId);
|
|
||||||
run.setText(orcId);
|
|
||||||
run.setUnderline(UnderlinePatterns.SINGLE);
|
|
||||||
run.setColor("0000FF");
|
|
||||||
mainDocumentPart.getLastParagraph().createRun().setText(")");
|
|
||||||
}
|
|
||||||
hasMultiplicityItems = false;
|
hasMultiplicityItems = false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId, indent);
|
createHypeLink(mainDocumentPart, format, value.get("pidTypeField"), value.get("pid"), false, false);
|
||||||
if(orcidResearcher){
|
}
|
||||||
XWPFHyperlinkRun run = paragraph.createHyperlinkRun("https://orcid.org/" + orcId);
|
}
|
||||||
run.setText(orcId);
|
else{
|
||||||
run.setUnderline(UnderlinePatterns.SINGLE);
|
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
|
||||||
run.setColor("0000FF");
|
List<Map<String, Object>> values = new ArrayList<>();
|
||||||
paragraph.createRun().setText(")");
|
try {
|
||||||
}
|
values = Arrays.asList(mapper.readValue(field.getValue().toString(), HashMap[].class));
|
||||||
if (paragraph != null) {
|
}
|
||||||
// CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
catch (Exception e) {
|
||||||
// number.setVal(BigInteger.valueOf(indent));
|
Map <String, Object> map = new HashMap<>();
|
||||||
hasValue = true;
|
map.put("label", field.getValue());
|
||||||
|
values.add(map);
|
||||||
|
}
|
||||||
|
if (values.size() > 1) {
|
||||||
|
for (Map<String, Object> value : values) {
|
||||||
|
if(hasMultiplicityItems){
|
||||||
|
createHypeLink(mainDocumentPart, (String) value.get("name"), (String) value.get("pidTypeField"), (String) value.get("pid"), true, true);
|
||||||
|
hasMultiplicityItems = false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
createHypeLink(mainDocumentPart, (String) value.get("name"), (String) value.get("pidTypeField"), (String) value.get("pid"), false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
format = null;
|
else if(values.size() == 1){
|
||||||
|
if(hasMultiplicityItems){
|
||||||
|
createHypeLink(mainDocumentPart, format, (String) values.get(0).get("pidTypeField"), (String) values.get(0).get("pid"), true, false);
|
||||||
|
hasMultiplicityItems = false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
createHypeLink(mainDocumentPart, format, (String) values.get(0).get("pidTypeField"), (String) values.get(0).get("pid"), false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hasValue = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
boolean isResearcher = field.getViewStyle().getRenderStyle().equals("researchers");
|
||||||
|
if(format != null && !format.isEmpty()){
|
||||||
|
Object hasMultiAutoComplete = mapper.convertValue(field.getData(), Map.class).get("multiAutoComplete");
|
||||||
|
boolean isMultiAutoComplete = hasMultiAutoComplete != null && (boolean)hasMultiAutoComplete;
|
||||||
|
boolean arrayStringFormat = format.charAt(0) == '[';
|
||||||
|
if(arrayStringFormat || isMultiAutoComplete){
|
||||||
|
List<String> values = (arrayStringFormat) ? Arrays.asList(format.substring(1, format.length() - 1).split(",[ ]*")) : Arrays.asList(format.split(",[ ]*"));
|
||||||
|
if(values.size() > 1) {
|
||||||
|
boolean orcidResearcher;
|
||||||
|
for (String val : values) {
|
||||||
|
orcidResearcher = false;
|
||||||
|
String orcId = null;
|
||||||
|
if(isResearcher && val.contains("orcid:")){
|
||||||
|
orcId = val.substring(val.indexOf(':') + 1, val.indexOf(')'));
|
||||||
|
val = val.substring(0, val.indexOf(':') + 1) + " ";
|
||||||
|
orcidResearcher = true;
|
||||||
|
}
|
||||||
|
format = "• " + val;
|
||||||
|
if(hasMultiplicityItems){
|
||||||
|
mainDocumentPart.getLastParagraph().createRun().setText(format);
|
||||||
|
if(orcidResearcher){
|
||||||
|
XWPFHyperlinkRun run = mainDocumentPart.getLastParagraph().createHyperlinkRun("https://orcid.org/" + orcId);
|
||||||
|
run.setText(orcId);
|
||||||
|
run.setUnderline(UnderlinePatterns.SINGLE);
|
||||||
|
run.setColor("0000FF");
|
||||||
|
mainDocumentPart.getLastParagraph().createRun().setText(")");
|
||||||
|
}
|
||||||
|
hasMultiplicityItems = false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId, indent);
|
||||||
|
if(orcidResearcher){
|
||||||
|
XWPFHyperlinkRun run = paragraph.createHyperlinkRun("https://orcid.org/" + orcId);
|
||||||
|
run.setText(orcId);
|
||||||
|
run.setUnderline(UnderlinePatterns.SINGLE);
|
||||||
|
run.setColor("0000FF");
|
||||||
|
paragraph.createRun().setText(")");
|
||||||
|
}
|
||||||
|
if (paragraph != null) {
|
||||||
|
// CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||||
|
// number.setVal(BigInteger.valueOf(indent));
|
||||||
|
hasValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
format = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(values.size() == 1){
|
||||||
|
format = values.get(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(values.size() == 1){
|
if (format != null) {
|
||||||
format = values.get(0);
|
if (hasMultiplicityItems) {
|
||||||
|
mainDocumentPart.getLastParagraph().createRun().setText(format);
|
||||||
|
hasMultiplicityItems = false;
|
||||||
|
hasValue = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId, indent);
|
||||||
|
if (paragraph != null) {
|
||||||
|
// CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||||
|
// number.setVal(BigInteger.valueOf(indent));
|
||||||
|
hasValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
if(hasMultiplicityItems && format != null){
|
|
||||||
mainDocumentPart.getLastParagraph().createRun().setText(format);
|
|
||||||
hasMultiplicityItems = false;
|
|
||||||
hasValue = true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId, indent);
|
|
||||||
if (paragraph != null) {
|
|
||||||
// CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
|
||||||
// number.setVal(BigInteger.valueOf(indent));
|
|
||||||
hasValue = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -881,7 +974,7 @@ public class WordBuilder {
|
||||||
// logger.info("Reverting to custom parsing");
|
// logger.info("Reverting to custom parsing");
|
||||||
identifierData = customParse(field.getValue().toString());
|
identifierData = customParse(field.getValue().toString());
|
||||||
}
|
}
|
||||||
return "id: " + identifierData.get("identifier") + ", Validation Type: " + identifierData.get("type");
|
return "id: " + identifierData.get("identifier") + ", Type: " + identifierData.get("type");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -927,60 +1020,44 @@ public class WordBuilder {
|
||||||
int descrParPos = -1;
|
int descrParPos = -1;
|
||||||
XWPFParagraph descrPar = null;
|
XWPFParagraph descrPar = null;
|
||||||
for(XWPFParagraph p: document.getParagraphs()){
|
for(XWPFParagraph p: document.getParagraphs()){
|
||||||
List<XWPFRun> runs = p.getRuns();
|
|
||||||
if(runs != null){
|
|
||||||
for(XWPFRun r : runs){
|
|
||||||
String text = r.getText(0);
|
|
||||||
if(text != null){
|
|
||||||
if(text.contains("{ARGOS.DMP.TITLE}")) {
|
|
||||||
text = text.replace("{ARGOS.DMP.TITLE}", dmpEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
} else if(text.contains("{ARGOS.DMP.VERSION}")) {
|
|
||||||
text = text.replace("{ARGOS.DMP.VERSION}", "Version " + dmpEntity.getVersion());
|
|
||||||
r.setText(text, 0);
|
|
||||||
} else if(datasetEntity != null && text.contains("{ARGOS.DATASET.TITLE}")) {
|
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
// } else if(text.equals("Description") && ((!isDataset && (dmpEntity == null || dmpEntity.getDescription() != null)) || (isDataset && (datasetEntity == null || datasetEntity.getDescription() == null)))) {
|
|
||||||
// r.setText("", 0);
|
|
||||||
} else if((dmpEntity != null && text.contains("{ARGOS.DMP.DESCRIPTION}") && !isDataset) || (datasetEntity != null && text.contains("{ARGOS.DATASET.DESCRIPTION}") && isDataset)) {
|
|
||||||
descrParPos = parPos;
|
|
||||||
descrPar = p;
|
|
||||||
if(dmpEntity != null && !isDataset) {
|
|
||||||
text = text.replace("{ARGOS.DMP.DESCRIPTION}", "");
|
|
||||||
} else if(datasetEntity != null && isDataset) {
|
|
||||||
text = text.replace("{ARGOS.DATASET.DESCRIPTION}", "");
|
|
||||||
}
|
|
||||||
r.setText(text, 0);
|
|
||||||
} else if(text.equals("{ARGOS.DMP.RESEARCHERS}")) {
|
|
||||||
String researchersNames = "";
|
|
||||||
Set<Researcher> researchers = dmpEntity.getResearchers();
|
|
||||||
int i = 0;
|
|
||||||
for(Researcher researcher : researchers){
|
|
||||||
i++;
|
|
||||||
researchersNames += researcher.getLabel() + (i < researchers.size() ? ", " : "");
|
|
||||||
}
|
|
||||||
text = text.replace("{ARGOS.DMP.RESEARCHERS}", researchersNames);
|
|
||||||
r.setText(text, 0);
|
|
||||||
r.setFontSize(17);
|
|
||||||
} else if(text.equals("{ARGOS.DMP.ORGANIZATIONS}")) {
|
|
||||||
String organisationsNames = "";
|
|
||||||
Set<Organisation> organisations = dmpEntity.getOrganisations();
|
|
||||||
int i = 0;
|
|
||||||
for(Organisation organisation : organisations){
|
|
||||||
i++;
|
|
||||||
organisationsNames += organisation.getLabel() + (i < organisations.size() ? ", " : "");
|
|
||||||
}
|
|
||||||
text = text.replace("{ARGOS.DMP.ORGANIZATIONS}", organisationsNames);
|
|
||||||
r.setText(text, 0);
|
|
||||||
r.setFontSize(17);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parPos++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if( dmpEntity != null) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.TITLE}'", dmpEntity.getLabel());
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.VERSION}'", "Version " + dmpEntity.getVersion());
|
||||||
|
}
|
||||||
|
if( datasetEntity != null) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", datasetEntity.getLabel());
|
||||||
|
}
|
||||||
|
|
||||||
|
String researchersNames = "";
|
||||||
|
Set<Researcher> researchers = dmpEntity.getResearchers();
|
||||||
|
int i = 0;
|
||||||
|
for(Researcher researcher : researchers){
|
||||||
|
i++;
|
||||||
|
researchersNames += researcher.getLabel() + (i < researchers.size() ? ", " : "");
|
||||||
|
}
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.RESEARCHERS}'", researchersNames, 15);
|
||||||
|
|
||||||
|
String organisationsNames = "";
|
||||||
|
Set<Organisation> organisations = dmpEntity.getOrganisations();
|
||||||
|
i = 0;
|
||||||
|
for(Organisation organisation : organisations){
|
||||||
|
i++;
|
||||||
|
organisationsNames += organisation.getLabel() + (i < organisations.size() ? ", " : "");
|
||||||
|
}
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.ORGANIZATIONS}'", organisationsNames, 15);
|
||||||
|
|
||||||
|
if(this.textSegmentExists(p,"'{ARGOS.DMP.DESCRIPTION}'")) {
|
||||||
|
descrParPos = parPos;
|
||||||
|
descrPar = p;
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DESCRIPTION}'", "");
|
||||||
|
}
|
||||||
|
if(this.textSegmentExists(p,"'{ARGOS.DATASET.DESCRIPTION}'")) {
|
||||||
|
descrParPos = parPos;
|
||||||
|
descrPar = p;
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.DESCRIPTION}'", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
if((descrParPos != -1) && (dmpEntity!=null) && (dmpEntity.getDescription() != null) && !isDataset) {
|
if((descrParPos != -1) && (dmpEntity!=null) && (dmpEntity.getDescription() != null) && !isDataset) {
|
||||||
XmlCursor cursor = descrPar.getCTP().newCursor();
|
XmlCursor cursor = descrPar.getCTP().newCursor();
|
||||||
cursor.toNextSibling();
|
cursor.toNextSibling();
|
||||||
|
@ -1000,16 +1077,16 @@ public class WordBuilder {
|
||||||
XWPFTable tbl = document.getTables().get(0);
|
XWPFTable tbl = document.getTables().get(0);
|
||||||
Iterator<XWPFTableRow> it = tbl.getRows().iterator();
|
Iterator<XWPFTableRow> it = tbl.getRows().iterator();
|
||||||
it.next(); // skip first row
|
it.next(); // skip first row
|
||||||
if(it.hasNext()){
|
if(it.hasNext() && dmpEntity.getGrant() != null){
|
||||||
XWPFParagraph p = it.next().getCell(0).getParagraphs().get(0);
|
XWPFParagraph p = it.next().getCell(0).getParagraphs().get(0);
|
||||||
XWPFRun run = p.createRun();
|
XWPFRun run = p.createRun();
|
||||||
run.setText(dmpEntity.getGrant().getFunder().getLabel());
|
run.setText(dmpEntity.getGrant().getFunder().getLabel());
|
||||||
run.setFontSize(17);
|
run.setFontSize(15);
|
||||||
p.setAlignment(ParagraphAlignment.CENTER);
|
p.setAlignment(ParagraphAlignment.CENTER);
|
||||||
}
|
}
|
||||||
it = tbl.getRows().iterator();
|
it = tbl.getRows().iterator();
|
||||||
it.next();
|
it.next();
|
||||||
if(it.hasNext()){
|
if(it.hasNext() && dmpEntity.getGrant() != null){
|
||||||
XWPFParagraph p = it.next().getCell(1).getParagraphs().get(0);
|
XWPFParagraph p = it.next().getCell(1).getParagraphs().get(0);
|
||||||
XWPFRun run = p.createRun();
|
XWPFRun run = p.createRun();
|
||||||
String text = dmpEntity.getGrant().getLabel();
|
String text = dmpEntity.getGrant().getLabel();
|
||||||
|
@ -1019,7 +1096,7 @@ public class WordBuilder {
|
||||||
text += parts.length > 1 ? "/ No "+parts[parts.length - 1] : "";
|
text += parts.length > 1 ? "/ No "+parts[parts.length - 1] : "";
|
||||||
}
|
}
|
||||||
run.setText(text);
|
run.setText(text);
|
||||||
run.setFontSize(17);
|
run.setFontSize(15);
|
||||||
p.setAlignment(ParagraphAlignment.CENTER);
|
p.setAlignment(ParagraphAlignment.CENTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1027,43 +1104,165 @@ public class WordBuilder {
|
||||||
public void fillFooter(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document, boolean isDataset) {
|
public void fillFooter(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document, boolean isDataset) {
|
||||||
document.getFooterList().forEach(xwpfFooter -> {
|
document.getFooterList().forEach(xwpfFooter -> {
|
||||||
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
||||||
if(runs != null){
|
for(XWPFParagraph p : xwpfFooter.getParagraphs()){
|
||||||
for(XWPFRun r : runs){
|
if(p != null){
|
||||||
String text = r.getText(0);
|
if( dmpEntity != null) {
|
||||||
if(text != null){
|
this.replaceTextSegment(p, "'{ARGOS.DMP.TITLE}'", dmpEntity.getLabel());
|
||||||
if(text.contains("{ARGOS.DMP.TITLE}")){
|
|
||||||
text = text.replace("{ARGOS.DMP.TITLE}", dmpEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
|
||||||
if(text.contains("{ARGOS.DATASET.TITLE}") && datasetEntity != null){
|
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
|
||||||
if(text.contains("{ARGOS.DMP.LICENSE}")){
|
|
||||||
try{
|
|
||||||
Map<String, String> license = ((Map<String, String>) mapper.readValue(dmpEntity.getExtraProperties(), Map.class).get("license"));
|
|
||||||
text = text.replace("{ARGOS.DMP.LICENSE}", license.get("pid"));
|
|
||||||
}
|
|
||||||
catch (JsonProcessingException | NullPointerException e){
|
|
||||||
text = text.replace("{ARGOS.DMP.LICENSE}", "License: -");
|
|
||||||
}
|
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
|
||||||
if(text.contains("{ARGOS.DMP.DOI}")){
|
|
||||||
if(dmpEntity.getDois() != null && !dmpEntity.getDois().isEmpty())
|
|
||||||
text = text.replace("{ARGOS.DMP.DOI}", dmpEntity.getDois().iterator().next().getDoi());
|
|
||||||
else
|
|
||||||
text = text.replace("{ARGOS.DMP.DOI}", "-");
|
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
|
||||||
if(text.contains("{ARGOS.DMP.LAST_MODIFIED}")){
|
|
||||||
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
|
||||||
text = text.replace("{ARGOS.DMP.LAST_MODIFIED}", formatter.format(dmpEntity.getModified()));
|
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if( datasetEntity != null) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", datasetEntity.getLabel());
|
||||||
|
}
|
||||||
|
Map<String, String> license = null;
|
||||||
|
try {
|
||||||
|
license = ((Map<String, String>) mapper.readValue(dmpEntity.getExtraProperties(), Map.class).get("license"));
|
||||||
|
if (license != null && license.get("pid") != null) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", license.get("pid"));
|
||||||
|
} else {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", "License: -");
|
||||||
|
}
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", "License: -");
|
||||||
|
}
|
||||||
|
if(dmpEntity.getDois() != null && !dmpEntity.getDois().isEmpty()) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DOI}'", dmpEntity.getDois().iterator().next().getDoi());
|
||||||
|
} else {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DOI}'", "-");
|
||||||
|
}
|
||||||
|
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LAST_MODIFIED}'", formatter.format(dmpEntity.getModified()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean textSegmentExists(XWPFParagraph paragraph, String textToFind) {
|
||||||
|
TextSegment foundTextSegment = null;
|
||||||
|
PositionInParagraph startPos = new PositionInParagraph(0, 0, 0);
|
||||||
|
while((foundTextSegment = this.searchText(paragraph, textToFind, startPos)) != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceTextSegment(XWPFParagraph paragraph, String textToFind, String replacement) {
|
||||||
|
this.replaceTextSegment(paragraph, textToFind, replacement, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceTextSegment(XWPFParagraph paragraph, String textToFind, String replacement, Integer fontSize) {
|
||||||
|
TextSegment foundTextSegment = null;
|
||||||
|
PositionInParagraph startPos = new PositionInParagraph(0, 0, 0);
|
||||||
|
while((foundTextSegment = this.searchText(paragraph, textToFind, startPos)) != null) { // search all text segments having text to find
|
||||||
|
|
||||||
|
System.out.println(foundTextSegment.getBeginRun()+":"+foundTextSegment.getBeginText()+":"+foundTextSegment.getBeginChar());
|
||||||
|
System.out.println(foundTextSegment.getEndRun()+":"+foundTextSegment.getEndText()+":"+foundTextSegment.getEndChar());
|
||||||
|
|
||||||
|
// maybe there is text before textToFind in begin run
|
||||||
|
XWPFRun beginRun = paragraph.getRuns().get(foundTextSegment.getBeginRun());
|
||||||
|
String textInBeginRun = beginRun.getText(foundTextSegment.getBeginText());
|
||||||
|
String textBefore = textInBeginRun.substring(0, foundTextSegment.getBeginChar()); // we only need the text before
|
||||||
|
|
||||||
|
// maybe there is text after textToFind in end run
|
||||||
|
XWPFRun endRun = paragraph.getRuns().get(foundTextSegment.getEndRun());
|
||||||
|
String textInEndRun = endRun.getText(foundTextSegment.getEndText());
|
||||||
|
String textAfter = textInEndRun.substring(foundTextSegment.getEndChar() + 1); // we only need the text after
|
||||||
|
|
||||||
|
if (foundTextSegment.getEndRun() == foundTextSegment.getBeginRun()) {
|
||||||
|
textInBeginRun = textBefore + replacement + textAfter; // if we have only one run, we need the text before, then the replacement, then the text after in that run
|
||||||
|
} else {
|
||||||
|
textInBeginRun = textBefore + replacement; // else we need the text before followed by the replacement in begin run
|
||||||
|
endRun.setText(textAfter, foundTextSegment.getEndText()); // and the text after in end run
|
||||||
|
}
|
||||||
|
|
||||||
|
beginRun.setText(textInBeginRun, foundTextSegment.getBeginText());
|
||||||
|
if (fontSize != null) {
|
||||||
|
beginRun.setFontSize(fontSize);
|
||||||
|
}
|
||||||
|
// runs between begin run and end run needs to be removed
|
||||||
|
for (int runBetween = foundTextSegment.getEndRun() - 1; runBetween > foundTextSegment.getBeginRun(); runBetween--) {
|
||||||
|
paragraph.removeRun(runBetween); // remove not needed runs
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this methods parse the paragraph and search for the string searched.
|
||||||
|
* If it finds the string, it will return true and the position of the String
|
||||||
|
* will be saved in the parameter startPos.
|
||||||
|
*
|
||||||
|
* @param searched
|
||||||
|
* @param startPos
|
||||||
|
*/
|
||||||
|
private TextSegment searchText(XWPFParagraph paragraph, String searched, PositionInParagraph startPos) {
|
||||||
|
int startRun = startPos.getRun(),
|
||||||
|
startText = startPos.getText(),
|
||||||
|
startChar = startPos.getChar();
|
||||||
|
int beginRunPos = 0, candCharPos = 0;
|
||||||
|
boolean newList = false;
|
||||||
|
|
||||||
|
//CTR[] rArray = paragraph.getRArray(); //This does not contain all runs. It lacks hyperlink runs for ex.
|
||||||
|
java.util.List<XWPFRun> runs = paragraph.getRuns();
|
||||||
|
|
||||||
|
int beginTextPos = 0, beginCharPos = 0; //must be outside the for loop
|
||||||
|
|
||||||
|
//for (int runPos = startRun; runPos < rArray.length; runPos++) {
|
||||||
|
for (int runPos = startRun; runPos < runs.size(); runPos++) {
|
||||||
|
//int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos; //int beginTextPos = 0, beginCharPos = 0 must be outside the for loop
|
||||||
|
int textPos = 0, charPos;
|
||||||
|
//CTR ctRun = rArray[runPos];
|
||||||
|
CTR ctRun = runs.get(runPos).getCTR();
|
||||||
|
XmlCursor c = ctRun.newCursor();
|
||||||
|
c.selectPath("./*");
|
||||||
|
try {
|
||||||
|
while (c.toNextSelection()) {
|
||||||
|
XmlObject o = c.getObject();
|
||||||
|
if (o instanceof CTText) {
|
||||||
|
if (textPos >= startText) {
|
||||||
|
String candidate = ((CTText) o).getStringValue();
|
||||||
|
if (runPos == startRun) {
|
||||||
|
charPos = startChar;
|
||||||
|
} else {
|
||||||
|
charPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; charPos < candidate.length(); charPos++) {
|
||||||
|
if ((candidate.charAt(charPos) == searched.charAt(0)) && (candCharPos == 0)) {
|
||||||
|
beginTextPos = textPos;
|
||||||
|
beginCharPos = charPos;
|
||||||
|
beginRunPos = runPos;
|
||||||
|
newList = true;
|
||||||
|
}
|
||||||
|
if (candidate.charAt(charPos) == searched.charAt(candCharPos)) {
|
||||||
|
if (candCharPos + 1 < searched.length()) {
|
||||||
|
candCharPos++;
|
||||||
|
} else if (newList) {
|
||||||
|
TextSegment segment = new TextSegment();
|
||||||
|
segment.setBeginRun(beginRunPos);
|
||||||
|
segment.setBeginText(beginTextPos);
|
||||||
|
segment.setBeginChar(beginCharPos);
|
||||||
|
segment.setEndRun(runPos);
|
||||||
|
segment.setEndText(textPos);
|
||||||
|
segment.setEndChar(charPos);
|
||||||
|
return segment;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
candCharPos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textPos++;
|
||||||
|
} else if (o instanceof CTProofErr) {
|
||||||
|
c.removeXml();
|
||||||
|
} else if (o instanceof CTRPr) {
|
||||||
|
//do nothing
|
||||||
|
} else {
|
||||||
|
candCharPos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
c.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ public class ExportXmlBuilderDatasetProfile {
|
||||||
Element pages = (Element)xmlDoc.getFirstChild();
|
Element pages = (Element)xmlDoc.getFirstChild();
|
||||||
pages.setAttribute("description", datasetProfile.getDescription());
|
pages.setAttribute("description", datasetProfile.getDescription());
|
||||||
pages.setAttribute("language", datasetProfile.getLanguage());
|
pages.setAttribute("language", datasetProfile.getLanguage());
|
||||||
|
pages.setAttribute("type", datasetProfile.getType());
|
||||||
|
pages.setAttribute("enablePrefilling", String.valueOf(datasetProfile.isEnablePrefilling()));
|
||||||
String xml = XmlBuilder.generateXml(xmlDoc);
|
String xml = XmlBuilder.generateXml(xmlDoc);
|
||||||
writer.write(xml);
|
writer.write(xml);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -12,6 +14,8 @@ public class DatasetProfile {
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
private String language;
|
private String language;
|
||||||
|
private String type;
|
||||||
|
private boolean enablePrefilling;
|
||||||
|
|
||||||
private List<Page> page;
|
private List<Page> page;
|
||||||
|
|
||||||
|
@ -42,12 +46,32 @@ public class DatasetProfile {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "type")
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "enablePrefilling")
|
||||||
|
public boolean isEnablePrefilling() {
|
||||||
|
return enablePrefilling;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnablePrefilling(boolean enablePrefilling) {
|
||||||
|
this.enablePrefilling = enablePrefilling;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
newDatasetEntityProfile.setType(type);
|
||||||
|
newDatasetEntityProfile.setEnablePrefilling(enablePrefilling);
|
||||||
List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>();
|
List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>();
|
||||||
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionDatasetEntity = new LinkedList<>();
|
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionDatasetEntity = new LinkedList<>();
|
||||||
for (Page xmlPage: page) {
|
for (Page xmlPage: page) {
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
||||||
|
|
||||||
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
|
|
||||||
|
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint;
|
||||||
|
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section;
|
||||||
|
import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ExportXmlBuilderDmpBlueprint {
|
||||||
|
|
||||||
|
|
||||||
|
public File build(DataManagementPlanBlueprintListingModel dmpProfile, Environment environment) throws IOException {
|
||||||
|
|
||||||
|
File xmlFile = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".xml");
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true));
|
||||||
|
Document xmlDoc = XmlBuilder.getDocument();
|
||||||
|
Element root = xmlDoc.createElement("root");
|
||||||
|
Element definition = xmlDoc.createElement("definition");
|
||||||
|
// Element root = xmlDoc.createElement(dmpProfile.getLabel());
|
||||||
|
definition.appendChild(createDefinition(dmpProfile.getDefinition(), xmlDoc));
|
||||||
|
root.appendChild(definition);
|
||||||
|
xmlDoc.appendChild(root);
|
||||||
|
String xml = XmlBuilder.generateXml(xmlDoc);
|
||||||
|
writer.write(xml);
|
||||||
|
writer.close();
|
||||||
|
return xmlFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Element createDefinition(DataManagementPlanBlueprint dmpDefinition, Document doc) {
|
||||||
|
Element sections = doc.createElement("sections");
|
||||||
|
for (Section section : dmpDefinition.getSections()) {
|
||||||
|
sections.appendChild(section.toXml(doc));
|
||||||
|
}
|
||||||
|
return sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,56 +0,0 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
|
||||||
|
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
|
||||||
|
|
||||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
|
||||||
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ExportXmlBuilderDmpProfile {
|
|
||||||
|
|
||||||
|
|
||||||
public File build(DataManagementPlanProfileListingModel dmpProfile, Environment environment) throws IOException {
|
|
||||||
|
|
||||||
File xmlFile = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".xml");
|
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true));
|
|
||||||
Document xmlDoc = XmlBuilder.getDocument();
|
|
||||||
Element root = xmlDoc.createElement("root");
|
|
||||||
Element definition = xmlDoc.createElement("definition");
|
|
||||||
// Element root = xmlDoc.createElement(dmpProfile.getLabel());
|
|
||||||
definition.appendChild(createDefinition(dmpProfile.getDefinition(), xmlDoc));
|
|
||||||
root.appendChild(definition);
|
|
||||||
xmlDoc.appendChild(root);
|
|
||||||
String xml = XmlBuilder.generateXml(xmlDoc);
|
|
||||||
writer.write(xml);
|
|
||||||
writer.close();
|
|
||||||
return xmlFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Element createDefinition(DataManagementPlanProfile dmpDefinition, Document element) {
|
|
||||||
Element fields = element.createElement("fieldSets");
|
|
||||||
dmpDefinition.getFields().forEach(item -> {
|
|
||||||
Element field = element.createElement("field");
|
|
||||||
field.setAttribute("id", "" + item.getId());
|
|
||||||
field.setAttribute("type", "" + item.getType());
|
|
||||||
field.setAttribute("dataType", "" + item.getDataType());
|
|
||||||
field.setAttribute("required", "" + item.getRequired());
|
|
||||||
field.setAttribute("label", "" + item.getLabel());
|
|
||||||
if(item.getValue()!=null) {
|
|
||||||
Element value = element.createElement("value");
|
|
||||||
value.setAttribute("value", ""+item.getValue());
|
|
||||||
field.appendChild(value);
|
|
||||||
}
|
|
||||||
fields.appendChild(field);
|
|
||||||
});
|
|
||||||
return fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
||||||
|
|
||||||
import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile;
|
import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -10,16 +10,16 @@ import javax.xml.bind.Unmarshaller;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ImportXmlBuilderDmpProfile {
|
public class ImportXmlBuilderDmpBlueprint {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDmpProfile.class);
|
private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDmpBlueprint.class);
|
||||||
|
|
||||||
public DmpProfile build(File xmlFile) throws IOException {
|
public DmpBlueprint build(File xmlFile) throws IOException {
|
||||||
DmpProfile dmpProfile = new DmpProfile();
|
DmpBlueprint dmpProfile = new DmpBlueprint();
|
||||||
JAXBContext jaxbContext = null;
|
JAXBContext jaxbContext = null;
|
||||||
try {
|
try {
|
||||||
jaxbContext = JAXBContext.newInstance(DmpProfile.class);
|
jaxbContext = JAXBContext.newInstance(DmpBlueprint.class);
|
||||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||||
dmpProfile = (DmpProfile) unmarshaller.unmarshal(xmlFile);
|
dmpProfile = (DmpBlueprint) unmarshaller.unmarshal(xmlFile);
|
||||||
} catch (JAXBException e) {
|
} catch (JAXBException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
||||||
|
|
||||||
|
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "descriptionTemplate")
|
||||||
|
public class DescriptionTemplate {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String descriptionTemplateId;
|
||||||
|
private String label;
|
||||||
|
private Integer minMultiplicity;
|
||||||
|
private Integer maxMultiplicity;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "id")
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "descriptionTemplateId")
|
||||||
|
public String getDescriptionTemplateId() {
|
||||||
|
return descriptionTemplateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionTemplateId(String descriptionTemplateId) {
|
||||||
|
this.descriptionTemplateId = descriptionTemplateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "label")
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "minMultiplicity")
|
||||||
|
public Integer getMinMultiplicity() {
|
||||||
|
return minMultiplicity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinMultiplicity(Integer minMultiplicity) {
|
||||||
|
this.minMultiplicity = minMultiplicity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "maxMultiplicity")
|
||||||
|
public Integer getMaxMultiplicity() {
|
||||||
|
return maxMultiplicity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxMultiplicity(Integer maxMultiplicity) {
|
||||||
|
this.maxMultiplicity = maxMultiplicity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate toDmpBlueprintCompositeModel() {
|
||||||
|
eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate descriptionTemplate = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate();
|
||||||
|
descriptionTemplate.setId(UUID.fromString(this.id));
|
||||||
|
descriptionTemplate.setDescriptionTemplateId(UUID.fromString(this.descriptionTemplateId));
|
||||||
|
descriptionTemplate.setLabel(this.label);
|
||||||
|
descriptionTemplate.setMinMultiplicity(this.minMultiplicity);
|
||||||
|
descriptionTemplate.setMaxMultiplicity(this.maxMultiplicity);
|
||||||
|
return descriptionTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "descriptionTemplates")
|
||||||
|
public class DescriptionTemplates {
|
||||||
|
|
||||||
|
private List<DescriptionTemplate> descriptionTemplates;
|
||||||
|
|
||||||
|
@XmlElement(name = "descriptionTemplate")
|
||||||
|
public List<DescriptionTemplate> getDescriptionTemplates() {
|
||||||
|
return descriptionTemplates;
|
||||||
|
}
|
||||||
|
public void setDescriptionTemplates(List<DescriptionTemplate> descriptionTemplates) {
|
||||||
|
this.descriptionTemplates = descriptionTemplates;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue