remove old code

This commit is contained in:
Efstratios Giannopoulos 2024-02-01 17:29:04 +02:00
parent fde91b6677
commit 55fb0f3e00
48 changed files with 124 additions and 5825 deletions

View File

@ -18,7 +18,7 @@ import java.util.UUID;
@Entity
@Table(name = "\"Dmp\"")
public class DmpEntity extends TenantScopedBaseEntity implements DataEntity<DmpEntity, UUID> {
public class DmpEntity extends TenantScopedBaseEntity {
@Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@ -246,20 +246,4 @@ public class DmpEntity extends TenantScopedBaseEntity implements DataEntity<DmpE
public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
@Override
public void update(DmpEntity entity) {
}
@Override
public UUID getKeys() {
return null;
}
@Override
public DmpEntity buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
}

View File

@ -1,21 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
import eu.eudat.data.UserEntity;
import eu.eudat.queryable.QueryableList;
import java.util.List;
import java.util.UUID;
public interface DMPDao extends DatabaseAccessLayer<DmpEntity, UUID> {
QueryableList<DmpEntity> getWithCriteria(DataManagementPlanCriteria criteria);
QueryableList<DmpEntity> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserEntity userInfo);
QueryableList<DmpEntity> getAuthenticated(QueryableList<DmpEntity> query, UUID principalId, List<Integer> roles);
}

View File

@ -1,154 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.UserEntity;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import eu.eudat.types.grant.GrantStateType;
import jakarta.persistence.criteria.Join;
import jakarta.persistence.criteria.JoinType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.management.InvalidApplicationException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("dMPDao")
public class DMPDaoImpl extends DatabaseAccess<DmpEntity> implements DMPDao {
@Autowired
public DMPDaoImpl(DatabaseService<DmpEntity> databaseService) {
super(databaseService);
}
@Override
public QueryableList<DmpEntity> getWithCriteria(DataManagementPlanCriteria criteria) {
QueryableList<DmpEntity> query = getDatabaseService().getQueryable(DmpEntity.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%")));
if (criteria.getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
if (criteria.getPeriodStart() != null)
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()) //TODO
// query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
if (!criteria.getAllVersions())
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(
builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")),
builder1.notEqual(nestedRoot.get("isActive"), IsActive.Inactive.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), Integer.class)));
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
if (criteria.getStatus() != null) {
if (criteria.getStatus() == DmpStatus.Finalized.getValue().intValue()) {
query.where((builder, root) -> builder.equal(root.get("status"), DmpStatus.Finalized.getValue()));
} else if (criteria.getStatus() == DmpStatus.Draft.getValue().intValue()) {
query.where((builder, root) -> builder.equal(root.get("status"), DmpStatus.Draft.getValue()));
}
}
if (criteria.getIsPublic()) {
query.where(((builder, root) -> builder.equal(root.get("isPublic"), criteria.getIsPublic())));
}
/*if (criteria.getRole() != null) {
if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())) {
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.OWNER.getValue()));
} else if (criteria.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())) {
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.USER.getValue()));
}
}*/
if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) {
query.where((builder, root) -> root.join("organisations").get("reference").in(criteria.getOrganisations()));
}
if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty()) {
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()) {
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
}
if (criteria.getGrantStatus() != null) {
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
query.where((builder, root) -> builder.lessThan(root.get("grant").get("enddate"), new Date()));
if (criteria.getGrantStatus().equals(GrantStateType.ONGOING.getValue().shortValue()))
query.where((builder, root) ->
builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
, builder.isNull(root.get("grant").get("enddate"))));
}
if (criteria.hasDoi()) {
query.where((builder, root) -> builder.not(builder.isNull(root.join("dois").get("id"))));
}
query.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive));
return query;
}
public QueryableList<DmpEntity> getAuthenticated(QueryableList<DmpEntity> query, UUID principal, List<Integer> roles) {
if (roles != null && !roles.isEmpty()) {
query.where((builder, root) -> {
Join userJoin = root.join("users", JoinType.LEFT);
return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal), userJoin.get("role").in(roles));
});
} else {
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal));
}
return query;
}
@Override
@Transactional
public DmpEntity createOrUpdate(DmpEntity item) {
return this.getDatabaseService().createOrUpdate(item, DmpEntity.class);
}
@Override
public DmpEntity find(UUID id) throws InvalidApplicationException {
return getDatabaseService().getQueryable(DmpEntity.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
}
@Override
public QueryableList<DmpEntity> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardUserDmpCriteria, UserEntity userInfo) {
QueryableList<DmpEntity> query = getDatabaseService().getQueryable(DmpEntity.class).where((builder, root) -> builder.or(builder.equal(root.get("creator"), userInfo), builder.isMember(userInfo, root.get("users"))));
if (datasetWizardUserDmpCriteria.getLike() != null && !datasetWizardUserDmpCriteria.getLike().isEmpty()) {
query.where((builder, root) -> builder.like(root.get("label"), "%" + datasetWizardUserDmpCriteria.getLike() + "%"));
}
return query;
}
@Override
public void delete(DmpEntity item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DmpEntity> asQueryable() {
return this.getDatabaseService().getQueryable(DmpEntity.class);
}
@Async
@Override
public CompletableFuture<DmpEntity> createOrUpdateAsync(DmpEntity item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DmpEntity find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
}

View File

@ -13,7 +13,7 @@ import java.util.Collection;
* Created by ikalyvas on 3/21/2018.
*/
public class PaginationService {
public static <T extends DataEntity> QueryableList<T> applyPaging(QueryableList<T> items, TableQuery tableRequest) {
public static <T> QueryableList<T> applyPaging(QueryableList<T> items, TableQuery tableRequest) {
if (tableRequest.getOrderings() != null) applyOrder(items, tableRequest);
if (tableRequest.getLength() != null) items.take(tableRequest.getLength());
if (tableRequest.getOffset() != null) items.skip(tableRequest.getOffset());
@ -21,12 +21,12 @@ public class PaginationService {
items.withFields(Arrays.asList(tableRequest.getSelection().getFields()));
return items;
}
public static <T extends DataEntity> void applyOrder(QueryableList<T> items, TableQuery tableRequest) {
public static <T> void applyOrder(QueryableList<T> items, TableQuery tableRequest) {
applyOrder(items, tableRequest.getOrderings());
}
public static <T extends DataEntity> void applyOrder(QueryableList<T> items, ColumnOrderings columnOrderings) {
public static <T> void applyOrder(QueryableList<T> items, ColumnOrderings columnOrderings) {
for (Ordering ordering : columnOrderings.getFieldOrderings()) {
if (ordering.getOrderByType() == Ordering.OrderByType.ASC)
applyAscOrder(items, ordering);
@ -37,7 +37,7 @@ public class PaginationService {
return;
}
private static <T extends DataEntity> void applyAscOrder(QueryableList<T> items, Ordering ordering) {
private static <T> void applyAscOrder(QueryableList<T> items, Ordering ordering) {
if (ordering.getColumnType() == Ordering.ColumnType.COUNT) {
items.orderBy((builder, root) -> builder.asc(builder.size(root.<Collection>get(ordering.getFieldName()))));
} else if (ordering.getColumnType() == Ordering.ColumnType.JOIN_COLUMN) {
@ -48,7 +48,7 @@ public class PaginationService {
}
}
private static <T extends DataEntity> void applyDescOrder(QueryableList<T> items, Ordering ordering) {
private static <T> void applyDescOrder(QueryableList<T> items, Ordering ordering) {
if (ordering.getColumnType() == Ordering.ColumnType.COUNT) {
items.orderBy((builder, root) -> builder.desc(builder.size(root.<Collection>get(ordering.getFieldName()))));
} else if (ordering.getColumnType() == Ordering.ColumnType.JOIN_COLUMN) {

View File

@ -6,7 +6,7 @@ import eu.eudat.data.old.queryableentity.DataEntity;
/**
* Created by ikalyvas on 3/21/2018.
*/
public interface Collector<T extends DataEntity> {
public interface Collector<T> {
QueryableList<T> collect() throws Exception;
QueryableList<T> collect(QueryableList<T> repo) throws Exception;

View File

@ -7,7 +7,7 @@ import eu.eudat.data.old.queryableentity.DataEntity;
/**
* Created by ikalyvas on 3/21/2018.
*/
public interface CriteriaQuery<C extends Criteria<T>, T extends DataEntity> extends Collector<T> {
public interface CriteriaQuery<C extends Criteria<T>, T> extends Collector<T> {
QueryableList<T> applyCriteria();
}

View File

@ -7,7 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class Query<C extends Criteria<T>, T extends DataEntity> implements CriteriaQuery<C, T> {
public abstract class Query<C extends Criteria<T>, T> implements CriteriaQuery<C, T> {
private static final Logger logger = LoggerFactory.getLogger(Query.class);
private C criteria;
@ApiModelProperty(value = "query", name = "query", dataType = "String", hidden = true)

View File

@ -7,6 +7,6 @@ import eu.eudat.data.old.queryableentity.DataEntity;
/**
* Created by ikalyvas on 3/21/2018.
*/
public interface TableCriteriaQuery<C extends Criteria<T>, T extends DataEntity> extends CriteriaQuery<C, T> {
public interface TableCriteriaQuery<C extends Criteria<T>, T> extends CriteriaQuery<C, T> {
QueryableList<T> applyPaging(QueryableList<T> items) ;
}

View File

@ -9,7 +9,7 @@ import eu.eudat.data.old.queryableentity.DataEntity;
import io.swagger.annotations.ApiModelProperty;
public abstract class TableQuery<C extends Criteria<T>, T extends DataEntity<T, K>, K> extends Query<C, T> implements TableCriteriaQuery<C, T> {
public abstract class TableQuery<C extends Criteria<T>, T, K> extends Query<C, T> implements TableCriteriaQuery<C, T> {
private ColumnOrderings orderings;
@ApiModelProperty(hidden = true)
private SelectionFields selection;

View File

@ -1,17 +0,0 @@
package eu.eudat.data.query.items.item.dataset;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
import eu.eudat.data.query.definition.Query;
import eu.eudat.queryable.QueryableList;
public class DatasetWizardAutocompleteRequest extends Query<DatasetWizardUserDmpCriteria, DmpEntity> {
@Override
public QueryableList<DmpEntity> applyCriteria() {
QueryableList<DmpEntity> query = this.getQuery().where((builder, root) -> builder.or(builder.equal(root.get("creator"), this.getCriteria().getUserInfo()), builder.isMember(this.getCriteria().getUserInfo(), root.get("users"))));
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) {
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
}
return query;
}
}

View File

@ -1,41 +0,0 @@
package eu.eudat.data.query.items.table.dmp;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import java.util.Arrays;
import java.util.UUID;
public class DataManagementPlanTableRequest extends TableQuery<DataManagementPlanCriteria, DmpEntity, UUID> {
@Override
public QueryableList<DmpEntity> applyCriteria() {
QueryableList<DmpEntity> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd()));
if (this.getCriteria().getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart()));
// if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
// query.where(((builder, root) -> root.get("grant").in(this.getCriteria().getGrants()))); //TODO
if (!this.getCriteria().getAllVersions())
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
query.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive.getValue()));
return query;
}
@Override
public QueryableList<DmpEntity> applyPaging(QueryableList<DmpEntity> items) {
return PaginationService.applyPaging(items, this);
}
}

View File

@ -1,54 +0,0 @@
package eu.eudat.data.query.items.table.dmp;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.dao.criteria.DataManagementPlanPublicCriteria;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import eu.eudat.types.grant.GrantStateType;
import java.util.Arrays;
import java.util.Date;
import java.util.UUID;
public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManagementPlanPublicCriteria, DmpEntity, UUID> {
public QueryableList<DmpEntity> applyCriteria() {
QueryableList<DmpEntity> query = this.getQuery();
query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
query.where(((builder, root) -> root.get("grant").get("id").in(this.getCriteria().getGrants())));
if (this.getCriteria().getGrantStatus() != null) {
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.FINISHED.getValue()))
query.where((builder, root) -> builder.lessThan(root.get("grant").get("enddate"), new Date()));
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.ONGOING.getValue()))
query.where((builder, root) ->
builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
, builder.isNull(root.get("grant").get("enddate"))));
}
if (this.getCriteria().datasetProfile != null && !this.getCriteria().datasetProfile.isEmpty())
query.where((builder, root) -> root.join("associatedDmps").get("id").in(this.getCriteria().datasetProfile));
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty())
query.where(((builder, root) -> root.join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
if (!this.getCriteria().getAllVersions()) {
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("groupId"),
nestedRoot.get("groupId")), builder1.equal(nestedRoot.get("isPublic"), true)), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
}
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty()) {
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
}
return query;
}
@Override
public QueryableList<DmpEntity> applyPaging(QueryableList<DmpEntity> items) {
return PaginationService.applyPaging(items, this);
}
}

View File

@ -1,135 +0,0 @@
package eu.eudat.query;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import jakarta.persistence.criteria.Subquery;
import javax.management.InvalidApplicationException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class DMPQuery extends Query<DmpEntity, UUID> {
private UUID id;
private UUID groupId;
private String label;
private int version;
// private UserQueryOld userQuery;
private DatasetQuery datasetQuery;
private List<Integer> statuses;
private Date created;
private Date modified;
public DMPQuery(DatabaseAccessLayer<DmpEntity, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
public DMPQuery(DatabaseAccessLayer<DmpEntity, UUID> databaseAccessLayer, List<String> selectionFields) {
super(databaseAccessLayer, selectionFields);
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public List<Integer> getStatuses() {
return statuses;
}
public void setStatuses(List<Integer> statuses) {
statuses = statuses;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
// public UserQueryOld getUserQuery() {
// return userQuery;
// }
//
// public void setUserQuery(UserQueryOld userQuery) {
// this.userQuery = userQuery;
// }
public DatasetQuery getDatasetQuery() {
return datasetQuery;
}
public void setDatasetQuery(DatasetQuery datasetQuery) {
this.datasetQuery = datasetQuery;
}
public QueryableList<DmpEntity> getQuery() throws InvalidApplicationException {
QueryableList<DmpEntity> query = this.databaseAccessLayer.asQueryable();
if (this.id != null) {
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
}
// if (this.grantQuery != null) { //TODO
// Subquery<Grant> grantQuery = this.grantQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
// query.where((builder, root) -> root.get("grant").get("id").in(grantQuery));
// }
if (this.getStatuses() != null && !this.getStatuses().isEmpty()) {
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
}
// if (this.userQuery != null) {
// Subquery<UserEntity> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
// query.where((builder, root) -> root.get("creator").get("id").in(userInfoSubQuery));
// }
if(this.datasetQuery != null){
Subquery<DescriptionEntity> datasetSubQuery = this.datasetQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:id")));
query.where((builder, root) -> root.get("id").in(datasetSubQuery ));
}
if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) {
query.withFields(this.getSelectionFields());
}
return query;
}
}

View File

@ -18,7 +18,6 @@ public class DatasetQuery extends Query<DescriptionEntity, UUID> {
private UUID id;
private String label;
private DMPQuery dmpQuery;
public DatasetQuery(DatabaseAccessLayer<DescriptionEntity, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
@ -44,13 +43,6 @@ public class DatasetQuery extends Query<DescriptionEntity, UUID> {
this.label = label;
}
public DMPQuery getDmpQuery() {
return dmpQuery;
}
public void setDmpQuery(DMPQuery dmpQuery) {
this.dmpQuery = dmpQuery;
}
@Override
public QueryableList<DescriptionEntity> getQuery() throws InvalidApplicationException {
@ -58,10 +50,6 @@ public class DatasetQuery extends Query<DescriptionEntity, UUID> {
if (this.id != null) {
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
}
if (this.dmpQuery != null) {
Subquery<DmpEntity> dmpSubQuery = this.dmpQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("dmp").get("id").in(dmpSubQuery));
}
return query;
}
}

View File

@ -13,7 +13,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
public interface QueryableList<T extends DataEntity> {
public interface QueryableList<T> {
QueryableList<T> where(SinglePredicate<T> predicate);
<R> List<R> select(SelectPredicate<T, R> predicate) throws InvalidApplicationException;

View File

@ -1,9 +1,6 @@
package eu.eudat.controllers;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.validators.*;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
public abstract class BaseController {
@ -18,12 +15,4 @@ public abstract class BaseController {
this.apiContext = apiContext;
}
@InitBinder()
protected void initBinder(WebDataBinder binder) {
if (binder.getTarget() != null && DataManagementPlanTableRequestValidator.supportsType((binder.getTarget().getClass())))
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanTableRequestValidator", DataManagementPlanTableRequestValidator.class));
if (binder.getTarget() != null && DataManagementPlanNewVersionValidator.supportsType((binder.getTarget().getClass())))
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanNewVersionValidator", DataManagementPlanNewVersionValidator.class));
}
}

View File

@ -1,417 +0,0 @@
package eu.eudat.controllers;
import eu.eudat.authorization.Permission;
import eu.eudat.criteria.DMPCriteria;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.managers.DataManagementPlanManager;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.model.DmpUser;
import eu.eudat.model.file.FileEnvelope;
import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
import eu.eudat.models.data.listingmodels.VersionListingModel;
import eu.eudat.query.DMPQuery;
import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService;
import jakarta.activation.MimetypesFileTypeMap;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.management.InvalidApplicationException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import static org.springframework.http.MediaType.*;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/dmps/"})
public class DMPs extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(DMPs.class);
private Environment environment;
private DataManagementPlanManager dataManagementPlanManager;
private ConfigLoader configLoader;
private final AuthorizationService authorizationService;
@Autowired
public DMPs(ApiContext apiContext, Environment environment,
DataManagementPlanManager dataManagementPlanManager, ConfigLoader configLoader, AuthorizationService authorizationService) {
super(apiContext);
this.environment = environment;
this.dataManagementPlanManager = dataManagementPlanManager;
this.configLoader = configLoader;
this.authorizationService = authorizationService;
}
/*
* Data Retrieval
* */
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest,
@RequestParam String fieldsGroup) throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
DataTableData<DataManagementPlanListingModel> dataTable = this.dataManagementPlanManager.getPaged(dataManagementPlanTableRequest, fieldsGroup);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.GET, value = {"{id}"})
public @ResponseBody
ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType) throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
if (contentType.equals("application/xml") || contentType.equals("application/msword")) {
return this.dataManagementPlanManager.getDocument(id, contentType, this.configLoader);
} else {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, false, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/plain/{id}"})
public @ResponseBody
ResponseEntity getSingleNoDatasets(@PathVariable String id, @RequestHeader("Content-Type") String contentType) throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, false, false);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
// @RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDmps/paged"}, produces = "application/json")
// public @ResponseBody
// ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getUsingDatasetProfilesPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException {
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
//
// DataTableData<DatasetProfileListingModel> datasetProfileTableData = this.dataManagementPlanManager.getDatasetProfilesUsedByDMP(datasetProfileTableRequestItem);
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
// }
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSingle(@PathVariable String id) {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
try {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, false);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
} catch (Exception e) {
if (e instanceof UnauthorisedException) {
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
}
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"})
public @ResponseBody
ResponseEntity getSinglePublic(@PathVariable String id) throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
// try {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, true, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
// } catch (Exception ex) {
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
// }
}
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
public @ResponseBody
ResponseEntity<ResponseItem<DataManagementPlanOverviewModel>> getOverviewSinglePublic(@PathVariable String id) throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
// try {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
// } catch (Exception ex) {
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
// }
}
// @RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
// public @ResponseBody
// ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem) throws InstantiationException, IllegalAccessException {
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
//
// List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria());
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
// }
@RequestMapping(method = RequestMethod.GET, value = {"/versions/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<VersionListingModel>>> getVersions(@PathVariable(value= "id") String groupId, @RequestParam(value= "public") Boolean isPublic) throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
List<VersionListingModel> versions = this.dataManagementPlanManager.getAllVersions(groupId, isPublic);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<VersionListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(versions));
}
/*
* Data Export
* */
@RequestMapping(method = RequestMethod.GET, value = {"rda/{id}"})
public @ResponseBody
ResponseEntity getRDAJsonDocument(@PathVariable String id) {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
try {
FileEnvelope rdaJsonDocument = this.dataManagementPlanManager.getRDAJsonDocument(id);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(rdaJsonDocument.getFile().length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + rdaJsonDocument.getFilename());
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
InputStream resource = new FileInputStream(rdaJsonDocument.getFile());
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
resource.close();
Files.deleteIfExists(rdaJsonDocument.getFile().toPath());
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(new ResponseItem<>().message(e.getMessage()).status(ApiMessageCode.ERROR_MESSAGE));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
public @ResponseBody
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType) throws IllegalAccessException, IOException, InstantiationException, InterruptedException, InvalidApplicationException {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, configLoader);
String name = file.getFilename().substring(0, file.getFilename().length() - 5).replace(" ", "_").replace(",", "_");
File pdffile = null; //PDFUtils.convertToPDF(file, environment); //TODO
InputStream resource = new FileInputStream(pdffile);
logger.info("Mime Type of " + name + " is " +
new MimetypesFileTypeMap().getContentType(file.getFile()));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(pdffile.length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + name + ".pdf");
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
resource.close();
Files.deleteIfExists(file.getFile().toPath());
Files.deleteIfExists(pdffile.toPath());
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
/*
* Data Management
* */
@Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<eu.eudat.models.data.dmp.DataManagementPlan>> createOrUpdate(@RequestBody eu.eudat.models.data.dmp.DataManagementPlanEditorModel dataManagementPlanEditorModel) throws Exception {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
DmpEntity dmp = this.dataManagementPlanManager.createOrUpdate(dataManagementPlanEditorModel);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.dmp.DataManagementPlan>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(new eu.eudat.models.data.dmp.DataManagementPlan().fromDataModel(dmp)));
}
@Transactional
@RequestMapping(method = RequestMethod.POST, path = "full", consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<UUID>> createOrUpdateWithDatasets(@RequestBody eu.eudat.models.data.dmp.DataManagementPlanEditorModel dataManagementPlanEditorModel) throws Exception {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
DmpEntity dmp = this.dataManagementPlanManager.createOrUpdateWithDatasets(dataManagementPlanEditorModel);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dmp.getId()));
}
@RequestMapping(method = RequestMethod.POST, value = {"/new/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<UUID>> newVersion(@PathVariable UUID id, @Valid @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan) throws Exception {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try {
UUID result = this.dataManagementPlanManager.newVersion(id, dataManagementPlan);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE).payload(result));
} catch (DMPNewVersionException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<UUID>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<UUID>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan) throws Exception {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
UUID cloneId = this.dataManagementPlanManager.clone(id, dataManagementPlan);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(cloneId));
}
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DmpEntity>> delete(@PathVariable UUID id) {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try {
this.dataManagementPlanManager.delete(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Datamanagement Plan"));
} catch (DMPWithDatasetsDeleteException | IOException | InvalidApplicationException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
public ResponseEntity<ResponseItem> dmpUpload(@RequestParam("file") MultipartFile[] files, @RequestParam(name = "profiles", required = false)String[] profiles) throws Exception {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
if (files[0].getContentType().equals(APPLICATION_JSON.toString())) {
this.dataManagementPlanManager.createFromRDA(files, profiles);
} else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString()) || files[0].getContentType().equals(TEXT_XML.toString())) {
this.dataManagementPlanManager.createDmpFromXml(files, profiles);
} else {
return ResponseEntity.badRequest().body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message("File format is not supported"));
}
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List>()
.status(ApiMessageCode.SUCCESS_MESSAGE));
}
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"})
public ResponseEntity<ResponseItem<DmpEntity>> makePublic(@PathVariable String id) {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try {
this.dataManagementPlanManager.makePublic(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made public."));
} catch (Exception e) {
logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to make Data Management Plan public."));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/finalize/{id}"})
public ResponseEntity<ResponseItem<DmpEntity>> makeFinalize(@PathVariable String id, @RequestBody DatasetsToBeFinalized datasetsToBeFinalized) {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try {
this.dataManagementPlanManager.makeFinalize(UUID.fromString(id), datasetsToBeFinalized);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made finalized."));
} catch (Exception e) {
logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to finalize Data Management Plan."));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/unfinalize/{id}"})
public ResponseEntity<ResponseItem<DmpEntity>> undoFinalize(@PathVariable String id) {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try {
this.dataManagementPlanManager.undoFinalize(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made active."));
} catch (Exception e) {
logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to unfinalize the Data Management Plan."));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/updateusers/{id}"})
public ResponseEntity<ResponseItem<DmpEntity>> updateUsers(@PathVariable String id, @RequestBody List<DmpUser> users) {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try {
this.dataManagementPlanManager.updateUsers(UUID.fromString(id), users);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Updated Colaborators for Data Datamanagement Plan."));
} catch (Exception e) {
logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to update the users of Data Management Plan."));
}
}
/*
* Data Index
* */
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionEntity>> generateIndex() throws Exception {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
//this.dataManagementPlanManager.generateIndex(); //TODO
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
}
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionEntity>> clearIndex() throws Exception {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
//this.dataManagementPlanManager.clearIndex(); //TODO
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
}
/*
* Misc
* */
@RequestMapping(method = RequestMethod.POST, value = {"/test"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<Map>>> test(@RequestBody DMPCriteria criteria) throws Exception {
this.authorizationService.authorizeForce(Permission.AnonymousRole);
DatabaseRepository dbRepo = this.getApiContext().getOperationsContext().getDatabaseRepository();
DMPQuery query = criteria.buildQuery(dbRepo);
List<Map> models = query.getQuery().toListWithFields();
DataTableData<Map> dmp = new DataTableData<>();
dmp.setData(models);
dmp.setTotalCount(query.getQuery().count());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Map>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
/*@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPublicPaged(@RequestBody DataManagmentPlanPublicTableRequest dmpTableRequest,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal,
@RequestParam String fieldsGroup) throws Exception {
DataTableData<DataManagementPlanListingModel> dmp = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}*/
/*@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id) throws Exception {
this.dataManagementPlanManager.unlock(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
}*/
}

View File

@ -24,6 +24,7 @@ import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.query.DescriptionTemplateQuery;
import eu.eudat.query.DmpDescriptionTemplateQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.QueryFactory;
@ -145,7 +146,7 @@ public class FileController {
throw new NoSuchElementException("No dataset with id " + fileUpload.getEntityId() + " found. This dataset was related to the file with id " + id);
}
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
DmpEntity dmp = this.queryFactory.query(DmpQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId()).first();
if (!dmp.getAccessType().equals(DmpAccessType.Public)
//TODO

View File

@ -4,12 +4,9 @@ package eu.eudat.controllers;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.DmpEntity;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.managers.QuickWizardManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.quickwizard.DatasetCreateWizardModel;
import eu.eudat.models.data.quickwizard.DatasetDescriptionQuickWizardModel;
@ -86,17 +83,17 @@ public class QuickWizardController extends BaseController {
// }
//Create Dmp
DataManagementPlan dataManagementPlan = quickWizard.getDmp().toDataDmp(/*grantEntity,*/ userScope);
DmpEntity dmpEntity = this.quickWizardManager.createOrUpdate(dataManagementPlan/*, funderEntity*/);
//Create Datasets
quickWizard.getDmp().setId(dmpEntity.getId());
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
DataManagementPlan dmp = quickWizard.getDmp().toDataDmp(/*grantEntity , projectEntity, */ userScope);
DescriptionTemplateEntity profile = quickWizard.getDmp().getDatasetProfile();
DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, profile);
this.datasetManager.createOrUpdate(datasetWizardModel);
}
// DataManagementPlan dataManagementPlan = quickWizard.getDmp().toDataDmp(/*grantEntity,*/ userScope);
// DmpEntity dmpEntity = this.quickWizardManager.createOrUpdate(dataManagementPlan/*, funderEntity*/);
//
// //Create Datasets
// quickWizard.getDmp().setId(dmpEntity.getId());
// for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
// DataManagementPlan dmp = quickWizard.getDmp().toDataDmp(/*grantEntity , projectEntity, */ userScope);
// DescriptionTemplateEntity profile = quickWizard.getDmp().getDatasetProfile();
// DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, profile);
// this.datasetManager.createOrUpdate(datasetWizardModel);
// }
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<QuickWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}
@ -108,9 +105,9 @@ public class QuickWizardController extends BaseController {
for(DatasetDescriptionQuickWizardModel dataset : datasetCreateWizardModel.getDatasets().getDatasetsList()){
DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
profile.setId(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getId());
profile.setLabel(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getLabel());
this.datasetManager.createOrUpdate(dataset.toDataModel(datasetCreateWizardModel.getDmpMeta().getDmp(), profile));
// profile.setId(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getId());
// profile.setLabel(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getLabel());
this.datasetManager.createOrUpdate(dataset.toDataModel(profile));
}
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetCreateWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Dataset added!"));

View File

@ -1,141 +0,0 @@
package eu.eudat.criteria;
import eu.eudat.criteria.entities.Criteria;
import eu.eudat.criteria.entities.DateCriteria;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.query.DMPQuery;
import java.util.*;
public class DMPCriteria {
private Criteria<UUID> id;
private Criteria<UUID> groupId;
private Criteria<String> label;
private Criteria<Integer> version;
private DateCriteria created;
private DateCriteria modified;
private UserCriteria creator;
private DatasetCriteria dataset;
public Criteria<UUID> getId() {
return id;
}
public void setId(Criteria<UUID> id) {
this.id = id;
}
public void setId(String id) {
Criteria<UUID> criteria = new Criteria<>();
criteria.setAs(id);
this.id = criteria;
}
public Criteria<UUID> getGroupId() {
return groupId;
}
public void setGroupId(Criteria<UUID> groupId) {
this.groupId = groupId;
}
public void setGroupId(String groupId) {
Criteria<UUID> criteria = new Criteria<>();
criteria.setAs(groupId);
this.groupId = criteria;
}
public Criteria<String> getLabel() {
return label;
}
public void setLabel(Criteria<String> label) {
this.label = label;
}
public void setLabel(String label) {
Criteria<String> criteria = new Criteria<>();
criteria.setAs(label);
this.label = criteria;
}
public Criteria<Integer> getVersion() {
return version;
}
public void setVersion(Criteria<Integer> version) {
this.version = version;
}
public void setVersion(String version) {
Criteria<Integer> criteria = new Criteria<>();
criteria.setAs(version);
this.version = criteria;
}
public DateCriteria getCreated() {
return created;
}
public void setCreated(DateCriteria created) {
this.created = created;
}
public void setCreated(String created) {
DateCriteria criteria = new DateCriteria();
criteria.setAs(created);
this.created = criteria;
}
public DateCriteria getModified() {
return modified;
}
public void setModified(DateCriteria modified) {
this.modified = modified;
}
public void setModified(String modified) {
DateCriteria criteria = new DateCriteria();
criteria.setAs(modified);
this.modified = criteria;
}
public UserCriteria getCreator() {
return creator;
}
public void setCreator(UserCriteria creator) {
this.creator = creator;
}
public DatasetCriteria getDataset() {
return dataset;
}
public void setDataset(DatasetCriteria dataset) {
this.dataset = dataset;
}
protected List<String> buildFields(String path) {
Set<String> fields = new LinkedHashSet<>();
path = path != null && !path.isEmpty() ? path + "." : "";
if (this.id != null) fields.add(path + this.id.getAs());
if (this.label != null) fields.add(path + this.label.getAs());
// if (this.grant != null) fields.addAll(this.grant.buildFields(path + "grant"));
if (this.creator != null) fields.addAll(this.creator.buildFields(path + "creator"));
if (this.dataset != null) fields.addAll(this.dataset.buildFields(path + "dataset"));
if (!fields.contains(path + "id")) fields.add(path + "id");
return new LinkedList<>(fields);
}
public DMPQuery buildQuery(DatabaseRepository dao) {
List<String> fields = this.buildFields("");
DMPQuery dmpQuery = new DMPQuery(dao.getDmpDao(), fields);
if (this.id != null) dmpQuery.setId(this.id.getValue());
// if (this.grant != null) dmpQuery.setGrantQuery(this.grant.buildQuery(dao));
// if (this.creator != null) dmpQuery.setUserQuery(this.creator.buildQuery(dao));
if (this.dataset != null) dmpQuery.setDatasetQuery(this.dataset.buildQuery(dao));
return dmpQuery;
}
}

View File

@ -15,7 +15,6 @@ import java.util.*;
public class DatasetCriteria {
private Criteria<UUID> id;
private Criteria<String> label;
private DMPCriteria dmp;
public Criteria<UUID> getId() {
return id;
@ -49,20 +48,12 @@ public class DatasetCriteria {
}
}
public DMPCriteria getDmp() {
return dmp;
}
public void setDmp(DMPCriteria dmp) {
this.dmp = dmp;
}
protected List<String> buildFields(String path) {
Set<String> fields = new HashSet<>();
path = path != null && !path.isEmpty() ? path + "." : "";
if (this.id != null) fields.add(path + this.id.getAs());
if (this.label != null) fields.add(path + this.label.getAs());
if (this.dmp != null) fields.addAll(this.dmp.buildFields(path + "dmp"));
if (!fields.contains(path + "id")) fields.add(path + "id");
return new LinkedList<>(fields);
}
@ -71,7 +62,6 @@ public class DatasetCriteria {
List<String> fields = this.buildFields("");
DatasetQuery datasetQuery = new DatasetQuery(dao.getDatasetDao(), fields);
if (this.id != null) datasetQuery.setId(this.id.getValue());
if (this.dmp != null) datasetQuery.setDmpQuery(this.dmp.buildQuery(dao));
return datasetQuery;
}
}

View File

@ -41,6 +41,7 @@ import eu.eudat.models.data.listingmodels.DatasetListingModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.query.DescriptionTemplateQuery;
import eu.eudat.query.DmpDescriptionTemplateQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.DmpUserQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.types.MetricNames;
@ -288,7 +289,7 @@ public class DatasetManager {
DatasetWizardModel dataset = new DatasetWizardModel();
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
;
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
DmpEntity dmp = this.queryFactory.query(DmpQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId()).first();
if (
//TODO
// dmp.getUsers()
@ -314,11 +315,11 @@ public class DatasetManager {
// Iterate through the versions and remove those that are not included in the DMP of the dataset in question.
for (DescriptionTemplateEntity version : profileVersions) {
for (AssociatedProfile p : dataset.getDmp().getProfiles()) {
if (version.getId().toString().equals(p.getDescriptionTemplateId().toString())) {
profileVersionsIncluded.add(version);
}
}
// for (AssociatedProfile p : dataset.getDmp().getProfiles()) {
// if (version.getId().toString().equals(p.getDescriptionTemplateId().toString())) {
// profileVersionsIncluded.add(version);
// }
// }
}
// Sort the list with the included Versions.
@ -356,7 +357,7 @@ public class DatasetManager {
public DatasetWizardModel getSinglePublic(String id) throws Exception {
DatasetWizardModel dataset = new DatasetWizardModel();
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getId()).isActive(IsActive.Active).first().getDmpId());
DmpEntity dmp = this.queryFactory.query(DmpQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId()).first();
if (descriptionEntityEntity != null && descriptionEntityEntity.getStatus() == DescriptionStatus.Finalized && dmp.getStatus().getValue() == 1) {
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
dataset.fromDataModel(descriptionEntityEntity);
@ -371,7 +372,7 @@ public class DatasetManager {
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
throw new Exception("Dataset is deleted.");
}
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
DmpEntity dmp = this.queryFactory.query(DmpQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId()).first();
if (!isPublic && !this.userScope.isSet()) {
throw new UnauthorisedException();
} else
@ -412,7 +413,7 @@ public class DatasetManager {
DatasetWizardModel dataset = new DatasetWizardModel();
XWPFDocument document = configLoader.getDatasetDocument();
DmpEntity dmpEntity = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
DmpEntity dmpEntity = this.queryFactory.query(DmpQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId()).first();
if (!dmpEntity.getAccessType().equals(DmpAccessType.Public)
//TODO
// && dmpEntity.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())).collect(Collectors.toList()).size() == 0
@ -553,7 +554,7 @@ public class DatasetManager {
public FileEnvelope getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
DmpEntity dmp = this.queryFactory.query(DmpQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId()).first();
if (!dmp.getAccessType().equals(DmpAccessType.Public)
//TODO
// && dmp.getUsers()
@ -586,7 +587,7 @@ public class DatasetManager {
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
DatasetWizardModel dataset = new DatasetWizardModel();
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
DmpEntity dmp = this.queryFactory.query(DmpQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId()).first();
if (!dmp.getAccessType().equals(DmpAccessType.Public)
//TODO
// && dmp.getUsers()
@ -613,7 +614,7 @@ public class DatasetManager {
public DescriptionEntity createOrUpdate(DatasetWizardModel datasetWizardModel) throws Exception {
Boolean sendNotification = false;
DescriptionEntity tempDescriptionEntity = null;
DmpEntity dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId());
DmpEntity dmp = null; //apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId());
if (datasetWizardModel.getId() != null) {
tempDescriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId());
if (tempDescriptionEntity != null) {
@ -659,7 +660,7 @@ public class DatasetManager {
// descriptionEntity1.setDescriptionTemplateId(datasetWizardModel.getProfile().getId()); //TODO
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
DmpEntity dmp1 = databaseRepository.getDmpDao().find(dmpId);
DmpEntity dmp1 = this.queryFactory.query(DmpQuery.class).ids(dmpId).first();
// dmp1.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));//TODO
//updateTags(descriptionEntity1, datasetWizardModel.getTags()); //TODO
if (sendNotification) {
@ -1096,12 +1097,11 @@ public class DatasetManager {
public void generateIndex() throws InvalidApplicationException {
if (this.authorizationService.authorize(Permission.AdminRole)) {
this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().toList();
List<DescriptionEntity> descriptionEntityEntities = new ArrayList<>(this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().toList());
descriptionEntityEntities.forEach(datasetEntity -> {
try {
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(datasetEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
DmpEntity dmp = databaseRepository.getDmpDao().find(dmpId);
DmpEntity dmp = this.queryFactory.query(DmpQuery.class).ids(dmpId).first();
//dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList())); //TODO
// eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(datasetEntity.getId().toString()); //TODO
// updateTags(datasetEntity, dataset != null ? dataset.getTags() : null);

View File

@ -7,11 +7,8 @@ import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.UserEntity;
import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel;
import eu.eudat.queryable.QueryableList;
import gr.cite.tools.data.query.QueryFactory;
@ -23,13 +20,13 @@ import java.util.UUID;
public class DatasetWizardManager {
public static List<DataManagentPlanListingModel> getUserDmps(DMPDao dmpRepository, DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, UserScope userScope) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
UserEntity userInfo = new UserEntity();
userInfo.setId(userScope.getUserId());
QueryableList<DmpEntity> items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest.getCriteria(), userInfo);
List<DataManagentPlanListingModel> dataManagementPlans = items.select(item -> new DataManagentPlanListingModel().fromDataModel(item));
return dataManagementPlans;
}
// public static List<DataManagentPlanListingModel> getUserDmps(DMPDao dmpRepository, DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, UserScope userScope) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
// UserEntity userInfo = new UserEntity();
// userInfo.setId(userScope.getUserId());
// QueryableList<DmpEntity> items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest.getCriteria(), userInfo);
// List<DataManagentPlanListingModel> dataManagementPlans = items.select(item -> new DataManagentPlanListingModel().fromDataModel(item));
// return dataManagementPlans;
// }
// public static List<AssociatedProfile> getAvailableProfiles(DMPDao dmpRepository, DatasetProfileDao profileDao, DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
// DataManagementPlan dataManagementPlan = new DataManagementPlan().fromDataModel(dmpRepository.find(datasetProfileWizardAutocompleteRequest.getCriteria().getId()));
@ -46,14 +43,14 @@ public class DatasetWizardManager {
// return profiles;
// }
public void unlock(ApiContext apiContext, QueryFactory queryFactory, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
DmpEntity dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(descriptionEntity.getDescriptionTemplateId());
if(dmp.getStatus().equals(DmpStatus.Finalized)) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
descriptionEntity.setStatus(DescriptionStatus.Draft);
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
return;
}
// public void unlock(ApiContext apiContext, QueryFactory queryFactory, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
// DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
// DmpEntity dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(descriptionEntity.getDescriptionTemplateId());
// if(dmp.getStatus().equals(DmpStatus.Finalized)) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
// descriptionEntity.setStatus(DescriptionStatus.Draft);
// apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
// return;
// }
public void delete(ApiContext apiContext, UUID uuid) throws IOException, InvalidApplicationException {
DescriptionEntity oldDescriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);

View File

@ -210,7 +210,8 @@ public class MetricsManager {
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
criteria.setStatus(0);
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllFinalizedDMPs() throws InvalidApplicationException {
@ -221,7 +222,8 @@ public class MetricsManager {
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
criteria.setStatus(1);
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllPublishedDMPs() throws InvalidApplicationException {
@ -233,7 +235,8 @@ public class MetricsManager {
criteria.setIsPublic(true);
criteria.setOnlyPublic(true);
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllDoiedDMPs() throws InvalidApplicationException {
@ -244,7 +247,8 @@ public class MetricsManager {
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
criteria.setHasDoi(true);
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllDraftDMPsWithGrantId() throws InvalidApplicationException {
@ -255,7 +259,8 @@ public class MetricsManager {
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
criteria.setStatus(0);
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
return 0;
}
private long countAllFinalizedDMPsWithGrantId() throws InvalidApplicationException {
@ -266,7 +271,8 @@ public class MetricsManager {
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
criteria.setStatus(1);
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
return 0;
}
private long countAllPublishedDMPsWithGrantId() throws InvalidApplicationException {
@ -278,7 +284,8 @@ public class MetricsManager {
criteria.setIsPublic(true);
criteria.setOnlyPublic(true);
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
return 0;
}
private long countAllDoiedDMPsWithGrantId() throws InvalidApplicationException {
@ -289,7 +296,8 @@ public class MetricsManager {
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
criteria.setHasDoi(true);
if (countNexus) criteria.setPeriodStart(getNexusDate());
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
return 0;
}
private long countAllResearchers() throws InvalidApplicationException {

View File

@ -8,7 +8,6 @@ import eu.eudat.data.UserEntity;
import eu.eudat.data.old.*;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.query.QueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -55,32 +54,32 @@ public class QuickWizardManager {
// return databaseRepository.getProjectDao().createOrUpdate(projectEntity);
// }
public DmpEntity createOrUpdate(DataManagementPlan dataManagementPlan/*, Funder funderEntity*/) throws Exception {
DmpEntity newDmp = dataManagementPlan.toDataModel();
// if (funderEntity != null) {
// //TODO
// //newDmp.getGrant().setFunder(funderEntity);
// }
UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
createFunderIfItDoesntExist(newDmp, user);
createGrantIfItDoesntExist(newDmp, user);
//TODO
// if (newDmp.getProject() == null) {
// newDmp.setProject(new Project());
// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
// }
createProjectIfItDoesntExist(newDmp, user);
//TODO
//apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
DmpEntity dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
// if (dataManagementPlan.getAssociatedUsers().size() == 0)
// assignUser(newDmp, user, apiContext);
// this.updateIndex(dmpret);
return dmpret;
}
// public DmpEntity createOrUpdate(DataManagementPlan dataManagementPlan/*, Funder funderEntity*/) throws Exception {
// DmpEntity newDmp = dataManagementPlan.toDataModel();
//// if (funderEntity != null) {
//// //TODO
//// //newDmp.getGrant().setFunder(funderEntity);
//// }
// UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
// createFunderIfItDoesntExist(newDmp, user);
// createGrantIfItDoesntExist(newDmp, user);
// //TODO
//// if (newDmp.getProject() == null) {
//// newDmp.setProject(new Project());
//// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
//// }
// createProjectIfItDoesntExist(newDmp, user);
//
// //TODO
// //apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
// DmpEntity dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
//// if (dataManagementPlan.getAssociatedUsers().size() == 0)
//// assignUser(newDmp, user, apiContext);
//
//// this.updateIndex(dmpret);
//
// return dmpret;
// }
// private void updateIndex(DMP dmp) throws IOException, InvalidApplicationException {
// DmpMapper mapper = new DmpMapper(apiContext, datasetManager);

View File

@ -8,7 +8,6 @@ public interface DatabaseRepository {
DatasetDao getDatasetDao();
DMPDao getDmpDao();

View File

@ -11,8 +11,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
private DatasetDao datasetDao;
private DMPDao dmpDao;
private FileUploadDao fileUploadDao;
@ -25,10 +23,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
this.datasetDao = datasetDao;
}
@Autowired
private void setDmpDao(DMPDao dmpDao) {
this.dmpDao = dmpDao;
}
@Autowired
@ -37,11 +31,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
return datasetDao;
}
@Override
public DMPDao getDmpDao() {
return dmpDao;
}
@Autowired
public void setEntityManager(EntityManager entityManager) {

View File

@ -1,76 +0,0 @@
package eu.eudat.models.data.dashboard.recent.model;
import eu.eudat.data.DmpEntity;
import eu.eudat.models.data.urls.DatasetUrlListing;
import jakarta.transaction.Transactional;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class RecentDmpModel extends RecentActivityModel<DmpEntity, RecentDmpModel> {
private Map<String, Object> extraProperties;
private List<DatasetUrlListing> datasets;
private UUID groupId;
public Map<String, Object> getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(Map<String, Object> extraProperties) {
this.extraProperties = extraProperties;
}
public List<DatasetUrlListing> getDatasets() {
return datasets;
}
public void setDatasets(List<DatasetUrlListing> datasets) {
this.datasets = datasets;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
@Override
@Transactional
public RecentActivityModel fromEntity(DmpEntity entity) {
this.setType(RecentActivityType.DMP.getIndex());
this.setId(entity.getId().toString());
this.setTitle(entity.getLabel()); //TODO
// this.setCreated(entity.getCreated());
// this.setModified(entity.getModified());
// this.setStatus(entity.getStatus());
// this.setVersion(entity.getVersion());
// this.datasets = entity.getDataset().stream().map(dataset -> new DatasetUrlListing().fromDataModel(dataset)).collect(Collectors.toList());
// this.setFinalizedAt(entity.getFinalizedAt());
// if (entity.getGrant() != null) {
// this.setGrant(entity.getGrant().getLabel());
// }
// this.groupId = entity.getGroupId();
// this.setPublic(entity.isPublic());
// this.setPublishedAt(entity.getPublishedAt());
// this.setUsers(entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()));
return this;
}
@Override
public RecentDmpModel fromDataModel(DmpEntity entity) {
return (RecentDmpModel) this.fromEntity(entity);
}
@Override
public DmpEntity toDataModel() throws Exception {
return null;
}
@Override
public String getHint() {
return "recentDmpModel";
}
}

View File

@ -2,7 +2,6 @@ package eu.eudat.models.data.dataset;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.dmp.DataManagementPlan;
import java.util.Date;
import java.util.UUID;
@ -16,7 +15,6 @@ public class Dataset implements DataModel<DescriptionEntity, Dataset> {
private short status;
private String properties;
private Date created;
private DataManagementPlan dmp;
public UUID getId() {
return id;
@ -83,13 +81,13 @@ public class Dataset implements DataModel<DescriptionEntity, Dataset> {
this.description = description;
}
public DataManagementPlan getDmp() {
return dmp;
}
public void setDmp(DataManagementPlan dmp) {
this.dmp = dmp;
}
// public DataManagementPlan getDmp() {
// return dmp;
// }
//
// public void setDmp(DataManagementPlan dmp) {
// this.dmp = dmp;
// }
public Dataset fromDataModel(DescriptionEntity entity) {
//TODO

View File

@ -4,7 +4,6 @@ import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
import java.time.Instant;
import java.util.List;
@ -16,7 +15,7 @@ public class DatasetOverviewModel implements DataModel<DescriptionEntity, Datase
private String label;
private DescriptionStatus status;
private List<DmpUser> users;
private DataManagementPlanOverviewModel dmp;
// private DataManagementPlanOverviewModel dmp;
private String description;
private Boolean isPublic;
private Instant modified;
@ -51,13 +50,13 @@ public class DatasetOverviewModel implements DataModel<DescriptionEntity, Datase
this.users = users;
}
public DataManagementPlanOverviewModel getDmp() {
return dmp;
}
public void setDmp(DataManagementPlanOverviewModel dmp) {
this.dmp = dmp;
}
// public DataManagementPlanOverviewModel getDmp() {
// return dmp;
// }
//
// public void setDmp(DataManagementPlanOverviewModel dmp) {
// this.dmp = dmp;
// }
public String getDescription() {
return description;

View File

@ -1,44 +0,0 @@
package eu.eudat.models.data.datasetwizard;
import eu.eudat.data.DmpEntity;
import eu.eudat.models.DataModel;
public class DataManagentPlanListingModel implements DataModel<DmpEntity, DataManagentPlanListingModel> {
private String id;
private String label;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public DataManagentPlanListingModel fromDataModel(DmpEntity entity) {
this.id = entity.getId().toString();
this.label = entity.getLabel();
return this;
}
@Override
public DmpEntity toDataModel() {
return null;
}
@Override
public String getHint() {
return null;
}
}

View File

@ -3,7 +3,6 @@ package eu.eudat.models.data.datasetwizard;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import java.time.Instant;
@ -20,7 +19,7 @@ public class DatasetWizardModel implements DataModel<DescriptionEntity, DatasetW
private String description;
private DescriptionStatus status;
private Instant created;
private DataManagementPlan dmp;
// private DataManagementPlan dmp;
private Integer dmpSectionIndex;
private PagedDatasetProfile datasetProfileDefinition;
// private List<Tag> tags; //TODO
@ -76,12 +75,12 @@ public class DatasetWizardModel implements DataModel<DescriptionEntity, DatasetW
this.created = created;
}
public DataManagementPlan getDmp() {
return dmp;
}
public void setDmp(DataManagementPlan dmp) {
this.dmp = dmp;
}
// public DataManagementPlan getDmp() {
// return dmp;
// }
// public void setDmp(DataManagementPlan dmp) {
// this.dmp = dmp;
// }
public Integer getDmpSectionIndex() {
return dmpSectionIndex;

View File

@ -1,378 +0,0 @@
package eu.eudat.models.data.dmp;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.model.EntityDoi;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.helpermodels.Tuple;
import java.util.*;
public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPlan> {
private UUID id;
private String label;
private UUID groupId;
private Tuple<UUID, String> profile;
private int version;
private int status;
private boolean lockable;
private String description;
private List<DatasetWizardModel> datasets;
private List<AssociatedProfile> profiles;
private List<ExtraFieldModel> extraFields;
private Date modified;
private Date created;
private List<DynamicFieldWithValue> dynamicFields;
private Map<String, Object> properties;
private List<DmpUser> users;
private List<EntityDoi> dois;
private Boolean isPublic;
private Map<String, Object> extraProperties;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Tuple<UUID, String> getProfile() {
return profile;
}
public void setProfile(Tuple<UUID, String> profile) {
this.profile = profile;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public List<AssociatedProfile> getProfiles() {
return profiles;
}
public void setProfiles(List<AssociatedProfile> profiles) {
this.profiles = profiles;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<ExtraFieldModel> getExtraFields() {
return extraFields;
}
public void setExtraFields(List<ExtraFieldModel> extraFields) {
this.extraFields = extraFields;
}
public Map<String, Object> getProperties() {
return properties;
}
public void setProperties(Map<String, Object> properties) {
this.properties = properties;
}
public List<DynamicFieldWithValue> getDynamicFields() {
return dynamicFields;
}
public void setDynamicFields(List<DynamicFieldWithValue> dynamicFields) {
this.dynamicFields = dynamicFields;
}
public boolean getLockable() {
return lockable;
}
public void setLockable(boolean lockable) {
this.lockable = lockable;
}
public List<DatasetWizardModel> getDatasets() {
return datasets;
}
public void setDatasets(List<DatasetWizardModel> datasets) {
this.datasets = datasets;
}
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<DmpUser> users) {
this.users = users;
}
public List<EntityDoi> getDois() {
return dois;
}
public void setDois(List<EntityDoi> dois) {
this.dois = dois;
}
public Boolean getPublic() {
return isPublic;
}
public void setPublic(Boolean aPublic) {
isPublic = aPublic;
}
public Map<String, Object> getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(Map<String, Object> extraProperties) {
this.extraProperties = extraProperties;
}
@Override
public DataManagementPlan fromDataModel(DmpEntity entity) {
this.id = entity.getId();
//TODO
// this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
// this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
// this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
// this.version = entity.getVersion();
// this.groupId = this.groupId == null ? null : entity.getGroupId();
// this.label = entity.getLabel();
// this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
// if(entity.getGrant() != null) {
// this.grant = new Grant();
// this.grant.fromDataModel(entity.getGrant());
// }
// else {
// this.grant = null;
// }
// this.creator = new eu.eudat.models.data.userinfo.UserInfo();
// this.groupId = entity.getGroupId();
// this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
// if (this.properties != null) {
// this.extraFields = new ArrayList<>();
// this.properties.forEach((id, value) -> {
// if (value != null) {
// ExtraFieldModel extraField = new ExtraFieldModel();
// extraField.setId(id);
// extraField.setValue(value.toString());
// this.extraFields.add(extraField);
// }
// });
// }
// if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
// this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
//
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
// this.profiles = new LinkedList<>();
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
// associatedProfile.setId(dmpDescriptionProfile.getId());
// try {
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
// }
// catch (Exception e) {
// associatedProfile.setData(null);
// }
// this.profiles.add(associatedProfile);
// }
// }
// if (entity.getDataset() != null) {
// if (entity.isPublic()) {
// this.datasets = entity.getDataset().stream()
// .filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled) && !dataset.getStatus().equals(DescriptionStatus.Draft))
// .map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
// } else {
// this.datasets = entity.getDataset().stream()
// .filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Draft))
// .map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
// }
// }
// this.modified = entity.getModified();
// this.created = entity.getCreated();
// this.description = entity.getDescription();
// this.status = entity.getStatus();
// this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
// this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
// this.dois = entity.getDois() != null ? entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
//
// if (entity.getProject() != null) {
// this.project = new Project();
// this.project = new Project().fromDataModel(entity.getProject());
// }
//
// if (entity.getGrant() != null && entity.getGrant().getFunder() != null) {
// this.funder = new Funder();
// this.funder.fromDataModel(entity.getGrant().getFunder());
// }
// this.isPublic = entity.isPublic();
//
// this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
return this;
}
@Override
public DmpEntity toDataModel() throws Exception {
DmpEntity dataManagementPlanEntity = new DmpEntity(); //TODO
// if (this.profile != null) {
// DmpBlueprintEntity dmpBlueprint = new DmpBlueprintEntity();
// dmpBlueprint.setId(this.profile.getId());
// dataManagementPlanEntity.setProfile(dmpBlueprint);
// }
// dataManagementPlanEntity.setId(this.id);
// if (this.organisations != null && !this.organisations.isEmpty())
// dataManagementPlanEntity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
// if (this.researchers != null && !this.researchers.isEmpty())
// dataManagementPlanEntity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
// dataManagementPlanEntity.setVersion(this.version);
// dataManagementPlanEntity.setLabel(this.label);
// if (this.grant != null) dataManagementPlanEntity.setGrant(this.grant.toDataModel());
// dataManagementPlanEntity.setStatus((short) this.status);
// dataManagementPlanEntity.setDescription(this.description);
// if (this.project != null) {
// dataManagementPlanEntity.setProject(this.project.toDataModel());
// }
// if (this.profiles != null) {
// Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
// for (AssociatedProfile profile : this.profiles) {
// DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
// dmpDatasetProfile.setId(profile.getId());
// dmpDatasetProfile.setDmp(dataManagementPlanEntity);
// dmpDatasetProfile.setDatasetprofile(profile.toData());
// dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
// dmpDatasetProfiles.add(dmpDatasetProfile);
// }
// dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles);
// }
// if(this.extraFields != null) {
// this.properties = this.extraFields.stream().collect(Collectors.toMap(ExtraFieldModel::getId, ExtraFieldModel::getValue));
// }
// dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
// dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
// dataManagementPlanEntity.setModified(this.modified != null ? this.modified : new Date());
// dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
// if (this.dynamicFields != null)
// dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
//
// if (this.isPublic != null) {
// dataManagementPlanEntity.setPublic(this.isPublic);
// }
//
// dataManagementPlanEntity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
return dataManagementPlanEntity;
}
public DataManagementPlan fromDataModelNoDatasets(DmpEntity entity) {
this.id = entity.getId(); //TODO
// this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
// this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
// this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().filter(Objects::nonNull).map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
// this.version = entity.getVersion();
// this.label = entity.getLabel();
// this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
// this.creator = new eu.eudat.models.data.userinfo.UserInfo();
// this.groupId = entity.getGroupId();
// this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
// if (this.properties != null) {
// this.extraFields = new ArrayList<>();
// this.properties.forEach((id, value) -> {
// if (value != null) {
// ExtraFieldModel extraField = new ExtraFieldModel();
// extraField.setId(id);
// extraField.setValue(value.toString());
// this.extraFields.add(extraField);
// }
// });
// }
// if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
// this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
//
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
// this.profiles = new LinkedList<>();
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
// associatedProfile.setId(dmpDescriptionProfile.getId());
// try {
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
// }
// catch (Exception e) {
// associatedProfile.setData(null);
// }
// this.profiles.add(associatedProfile);
// }
// }
// this.modified = entity.getModified();
// this.created = entity.getCreated();
// this.description = entity.getDescription();
// this.status = entity.getStatus();
// this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
// this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
// this.dois = entity.getDois() != null ? entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
// if(entity.getGrant() != null) {
// this.grant = new Grant();
// this.grant.fromDataModel(entity.getGrant());
// }
// else {
// this.grant = null;
// }
//
// if (entity.getProject() != null) {
// this.project = new Project();
// this.project = new Project().fromDataModel(entity.getProject());
// }
// if (entity.getGrant() != null && entity.getGrant().getFunder() != null) {
// this.funder = new Funder();
// this.funder.fromDataModel(entity.getGrant().getFunder());
// }
// this.isPublic = entity.isPublic();
//
// this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
return this;
}
@Override
public String getHint() {
return "fullyDetailed";
}
}

View File

@ -1,343 +0,0 @@
package eu.eudat.models.data.dmp;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.project.ProjectDMPEditorModel;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataManagementPlanEditorModel> {
private UUID id;
private String label;
private UUID groupId;
private Tuple<UUID, String> profile;
private int version;
private int status;
private boolean lockable;
private String description;
private List<DatasetWizardModel> datasets;
private List<AssociatedProfile> profiles;
private List<ExtraFieldModel> extraFields;
private Date modified;
private Date created;
private List<DynamicFieldWithValue> dynamicFields;
private Map<String, Object> properties;
private List<DmpUser> users;
private List<UUID> datasetsToBeFinalized;
private ProjectDMPEditorModel project;
private Map<String, Object> extraProperties;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Tuple<UUID, String> getProfile() {
return profile;
}
public void setProfile(Tuple<UUID, String> profile) {
this.profile = profile;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public void setVersion(int version) {
this.version = version;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public List<AssociatedProfile> getProfiles() {
return profiles;
}
public void setProfiles(List<AssociatedProfile> profiles) {
this.profiles = profiles;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<ExtraFieldModel> getExtraFields() {
return extraFields;
}
public void setExtraFields(List<ExtraFieldModel> extraFields) {
this.extraFields = extraFields;
}
public Map<String, Object> getProperties() {
return properties;
}
public void setProperties(Map<String, Object> properties) {
this.properties = properties;
}
public List<DynamicFieldWithValue> getDynamicFields() {
return dynamicFields;
}
public void setDynamicFields(List<DynamicFieldWithValue> dynamicFields) {
this.dynamicFields = dynamicFields;
}
public boolean getLockable() {
return lockable;
}
public void setLockable(boolean lockable) {
this.lockable = lockable;
}
public List<DatasetWizardModel> getDatasets() {
return datasets;
}
public void setDatasets(List<DatasetWizardModel> datasets) {
this.datasets = datasets;
}
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<DmpUser> users) {
this.users = users;
}
public List<UUID> getDatasetsToBeFinalized() {
return datasetsToBeFinalized;
}
public void setDatasetsToBeFinalized(List<UUID> datasetsToBeFinalized) {
this.datasetsToBeFinalized = datasetsToBeFinalized;
}
public ProjectDMPEditorModel getProject() {
return project;
}
public void setProject(ProjectDMPEditorModel project) {
this.project = project;
}
public Map<String, Object> getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(Map<String, Object> extraProperties) {
this.extraProperties = extraProperties;
}
@Override
public DataManagementPlanEditorModel fromDataModel(DmpEntity entity) {
this.id = entity.getId();
// this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null; //TODO
// this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
// this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
// this.version = entity.getVersion();
// this.groupId = this.groupId == null ? null : entity.getGroupId();
// this.label = entity.getLabel();
// this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
// if (entity.getGrant() != null) {
// this.grant = new GrantDMPEditorModel();
// this.grant.getExistGrant().fromDataModel(entity.getGrant());
// this.grant.getExistGrant().setSource("");
// }
// this.creator = new eu.eudat.models.data.userinfo.UserInfo();
// this.groupId = entity.getGroupId();
// this.lockable = entity.getDataset().stream().findAny().isPresent();
// if (this.properties != null) {
// this.extraFields = new ArrayList<>();
// this.properties.forEach((id, value) -> {
// ExtraFieldModel extraField = new ExtraFieldModel();
// extraField.setId(id);
// extraField.setValue(value.toString());
// this.extraFields.add(extraField);
// });
// }
// if (entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
// this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
//
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
// this.profiles = new LinkedList<>();
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
// try {
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
// }
// catch (Exception e) {
// associatedProfile.setData(null);
// }
// this.profiles.add(associatedProfile);
// }
// }
// this.datasets = entity.getDataset().stream().map(item -> new DatasetWizardModel().fromDataModelNoDmp(item)).collect(Collectors.toList());
// this.modified = entity.getModified();
// this.created = entity.getCreated();
// this.description = entity.getDescription();
// this.status = entity.getStatus();
// this.project = new ProjectDMPEditorModel();
// this.project.getExistProject().fromDataModel(entity.getProject());
// this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
// this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
// if (entity.getGrant() != null) {
// this.funder = new FunderDMPEditorModel();
// this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
// }
// this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
return this;
}
@Override
public DmpEntity toDataModel() throws Exception {
DmpEntity dataManagementPlanEntity = new DmpEntity();//TODO
// if (this.profile != null) {
// DmpBlueprintEntity dmpBlueprint = new DmpBlueprintEntity();
// dmpBlueprint.setId(this.profile.getId());
// dataManagementPlanEntity.setProfile(dmpBlueprint);
// }
// dataManagementPlanEntity.setId(this.id);
// if (this.organisations != null && !this.organisations.isEmpty())
// dataManagementPlanEntity.setOrganisations(new HashSet<>(this.organisations.stream().map(Organisation::toDataModel).collect(Collectors.toList())));
// if (this.researchers != null && !this.researchers.isEmpty())
// dataManagementPlanEntity.setResearchers(new HashSet<>(this.researchers.stream().map(Researcher::toDataModel).collect(Collectors.toList())));
// dataManagementPlanEntity.setVersion(this.version);
// dataManagementPlanEntity.setLabel(this.label);
// if (this.grant != null) {
// if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
// dataManagementPlanEntity.setGrant(this.grant.getExistGrant().toDataModel());
// else if (this.grant.getLabel() != null) {
// Grant grant = new Grant();
// grant.setId(UUID.randomUUID());
// grant.setAbbreviation("");
// grant.setLabel(this.grant.getLabel());
// grant.setType(Grant.GrantType.INTERNAL.getValue());
// grant.setReference("dmp:" + (this.grant.getReference() != null ? this.grant.getReference() : grant.getId()));
// grant.setUri("");
// grant.setDefinition("");
// grant.setCreated(new Date());
// grant.setStatus(Grant.Status.ACTIVE.getValue());
// grant.setModified(new Date());
// grant.setDescription(this.grant.getDescription());
//
// dataManagementPlanEntity.setGrant(grant);
// }
// }
//
// if (this.funder != null) {
// if (this.funder.getLabel() != null) {
// Funder funder = new Funder();
// funder.setId(UUID.randomUUID());
// funder.setLabel(this.funder.getLabel());
// funder.setType(Funder.FunderType.INTERNAL.getValue());
// funder.setReference("dmp:" + (this.funder.getReference() != null ? this.funder.getReference() : funder.getId()));
// funder.setDefinition("");
// funder.setCreated(new Date());
// funder.setStatus(Funder.Status.ACTIVE.getValue());
// funder.setModified(new Date());
//
// dataManagementPlanEntity.getGrant().setFunder(funder);
// } else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null){
// dataManagementPlanEntity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
// dataManagementPlanEntity.getGrant().getFunder().setType(Funder.FunderType.EXTERNAL.getValue());
// }
// }
//
// if (this.project != null) {
// if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
// dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
// else if (this.project.getLabel() != null) {
// Project project = new Project();
// project.setId(UUID.randomUUID());
// project.setAbbreviation("");
// project.setLabel(this.project.getLabel());
// project.setType(Project.ProjectType.INTERNAL.getValue());
// project.setReference("dmp:" + (this.project.getReference() != null ? this.project.getReference() : project.getId()));
// project.setUri("");
// project.setDefinition("");
// project.setCreated(new Date());
// project.setStatus(Project.Status.ACTIVE.getValue());
// project.setModified(new Date());
// project.setDescription(this.project.getDescription());
//
// dataManagementPlanEntity.setProject(project);
// }
// }
//
// dataManagementPlanEntity.setStatus((short) this.status);
// if (this.status == (int) DMP.DMPStatus.FINALISED.getValue()) {
// dataManagementPlanEntity.setFinalizedAt(new Date());
// }
// dataManagementPlanEntity.setDescription(this.description);
// if (this.profiles != null) {
// Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
// for (AssociatedProfile profile : this.profiles) {
// DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
// dmpDatasetProfile.setId(profile.getId());
// dmpDatasetProfile.setDmp(dataManagementPlanEntity);
// dmpDatasetProfile.setDatasetprofile(profile.toData());
// dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
// dmpDatasetProfiles.add(dmpDatasetProfile);
// }
// dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles);
// }
// if(this.extraFields != null) {
// this.properties = new HashMap<>();
// this.extraFields.forEach((extraField) -> this.properties.put(extraField.getId(), extraField.getValue()));
// }
// dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
// dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
// dataManagementPlanEntity.setModified(this.modified != null ? this.modified : new Date());
// dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
// if (this.dynamicFields != null)
// dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
//
// dataManagementPlanEntity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
return dataManagementPlanEntity;
}
@Override
public String getHint() {
return "fullyDetailed";
}
}

View File

@ -1,222 +0,0 @@
package eu.eudat.models.data.dmp;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DmpEntity;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.dataset.Dataset;
import eu.eudat.models.data.project.ProjectDMPEditorModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Instant;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* Created by ikalyvas on 2/5/2018.
*/
public class DataManagementPlanNewVersionModel implements DataModel<DmpEntity, DataManagementPlanNewVersionModel> {
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanNewVersionModel.class);
private UUID id;
private String label;
private UUID groupId;
private int version;
private int status;
private String description;
private List<AssociatedProfile> profiles;
private List<Dataset> datasets;
private ProjectDMPEditorModel project;
private Map<String, Object> extraProperties;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<AssociatedProfile> getProfiles() {
return profiles;
}
public void setProfiles(List<AssociatedProfile> profiles) {
this.profiles = profiles;
}
public List<Dataset> getDatasets() {
return datasets;
}
public void setDatasets(List<Dataset> datasets) {
this.datasets = datasets;
}
public ProjectDMPEditorModel getProject() {
return project;
}
public void setProject(ProjectDMPEditorModel project) {
this.project = project;
}
public Map<String, Object> getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(Map<String, Object> extraProperties) {
this.extraProperties = extraProperties;
}
@Override
public DataManagementPlanNewVersionModel fromDataModel(DmpEntity entity) {
return null;
}
@Override
public DmpEntity toDataModel() throws Exception {
DmpEntity entity = new DmpEntity();
entity.setId(this.id);
// entity.setUsers(new HashSet<>(new ArrayList<>(this.associatedUsers)));
entity.setDescription(this.description);
entity.setStatus(DmpStatus.of((short)this.status));
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
entity.setCreatedAt(Instant.now());
entity.setUpdatedAt(Instant.now());
entity.setLabel(this.label);
List<DescriptionEntity> descriptionEntities = new LinkedList<>();//TODO
// if (this.datasets != null) {
// for (Dataset dataset : this.datasets) {
// DescriptionEntity entityDescriptionEntity = new DescriptionEntity();
// entityDescriptionEntity.setId(dataset.getId());
// descriptionEntities.add(entityDescriptionEntity);
// }
// entity.setDataset(new HashSet<>(descriptionEntities));
// }
// if (this.organisations != null && !this.organisations.isEmpty())
// entity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
// if (this.researchers != null && !this.researchers.isEmpty())
// entity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
// /*if (this.grant != null) {
// entity.setGrant(this.grant.toDataModel());
// }*/
//
// if (this.grant != null) {
// if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
// entity.setGrant(this.grant.getExistGrant().toDataModel());
// else if (this.grant.getLabel() != null) {
// Grant grant = new Grant();
// grant.setId(UUID.randomUUID());
// grant.setAbbreviation("");
// grant.setLabel(this.grant.getLabel());
// grant.setType(Grant.GrantType.INTERNAL.getValue());
// grant.setReference("dmp:" + (this.grant.getReference() != null ? this.grant.getReference() : grant.getId()));
// grant.setUri("");
// grant.setDefinition("");
// grant.setCreated(new Date());
// grant.setStatus(Grant.Status.ACTIVE.getValue());
// grant.setModified(new Date());
// grant.setDescription(this.grant.getDescription());
//
// entity.setGrant(grant);
// }
// }
//
// if (this.funder != null) {
// if (this.funder.getLabel() != null) {
// Funder funder = new Funder();
// funder.setId(UUID.randomUUID());
// funder.setLabel(this.funder.getLabel());
// funder.setType(Funder.FunderType.INTERNAL.getValue());
// funder.setReference("dmp:" + (this.funder.getReference() != null ? this.funder.getReference() : funder.getId()));
// funder.setDefinition("");
// funder.setCreated(new Date());
// funder.setStatus(Funder.Status.ACTIVE.getValue());
// funder.setModified(new Date());
//
// entity.getGrant().setFunder(funder);
// } else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null) {
// entity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
// entity.getGrant().getFunder().setType(Funder.FunderType.EXTERNAL.getValue());
// }
// }
// if (this.project != null) {
// if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
// entity.setProject(this.project.getExistProject().toDataModel());
// else if (this.project.getLabel() != null) {
// Project project = new Project();
// project.setId(UUID.randomUUID());
// project.setAbbreviation("");
// project.setLabel(this.project.getLabel());
// project.setType(Project.ProjectType.INTERNAL.getValue());
// project.setReference("dmp:" + (this.project.getReference() != null ? this.project.getReference() : project.getId()));
// project.setUri("");
// project.setDefinition("");
// project.setCreated(new Date());
// project.setStatus(Project.Status.ACTIVE.getValue());
// project.setModified(new Date());
// project.setDescription(this.project.getDescription());
//
// entity.setProject(project);
// }
// }
//
// entity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
// if (this.profiles != null) {
// Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
// for (AssociatedProfile profile : this.profiles) {
// DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
// dmpDatasetProfile.setId(null);
// dmpDatasetProfile.setDmp(entity);
// dmpDatasetProfile.setDatasetprofile(profile.toData());
// dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
// dmpDatasetProfiles.add(dmpDatasetProfile);
// }
// entity.setAssociatedDmps(dmpDatasetProfiles);
// }
return entity;
}
@Override
public String getHint() {
return null;
}
}

View File

@ -1,190 +0,0 @@
package eu.eudat.models.data.listingmodels;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.urls.DatasetUrlListing;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
public class DataManagementPlanListingModel implements DataModel<DmpEntity, DataManagementPlanListingModel> {
private String id;
private String label;
private String grant;
private Date creationTime;
private Date modifiedTime;
private int version;
private int status;
private UUID groupId;
private List<DatasetUrlListing> datasets;
private List<DmpUser> users;
private Date finalizedAt;
private Boolean isPublic;
private Date publishedAt;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getGrant() {
return grant;
}
public void setGrant(String grant) {
this.grant = grant;
}
public Date getCreationTime() {
return creationTime;
}
public void setCreationTime(Date creationTime) {
this.creationTime = creationTime;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public List<DatasetUrlListing> getDatasets() {
return datasets;
}
public void setDatasets(List<DatasetUrlListing> datasets) {
this.datasets = datasets;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<DmpUser> users) {
this.users = users;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public Boolean getPublic() {
return isPublic;
}
public void setPublic(Boolean aPublic) {
isPublic = aPublic;
}
public Date getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(Date publishedAt) {
this.publishedAt = publishedAt;
}
@Override
public DataManagementPlanListingModel fromDataModel(DmpEntity entity) {
this.id = entity.getId().toString();
this.label = entity.getLabel();
this.groupId = entity.getGroupId();
return this;
}
public DataManagementPlanListingModel fromDataModelAssociatedProfiles(DmpEntity entity) {
this.id = entity.getId().toString();
this.label = entity.getLabel();
this.groupId = entity.getGroupId();
this.creationTime = Date.from(entity.getCreatedAt());
return this;
}
public DataManagementPlanListingModel fromDataModelAutoComplete(DmpEntity entity) {
this.id = entity.getId().toString();
this.label = entity.getLabel();
this.groupId = entity.getGroupId();
this.creationTime = Date.from(entity.getCreatedAt());
return this;
}
public DataManagementPlanListingModel fromDataModelDatasets(DmpEntity entity) {
this.fromDataModel(entity);
this.status = entity.getStatus().getValue();
this.version = entity.getVersion();
this.creationTime = Date.from(entity.getCreatedAt());
this.modifiedTime = Date.from(entity.getUpdatedAt());
this.finalizedAt = Date.from(entity.getFinalizedAt());
// this.grant = (entity.getGrant() != null) ? entity.getGrant().getLabel() : null; //TODO
// this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
// this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
// this.isPublic = entity.isPublic();
// this.publishedAt = entity.getPublishedAt();
return this;
}
@Override
public DmpEntity toDataModel() {
DmpEntity entity = new DmpEntity();
entity.setId(UUID.fromString(this.getId()));
entity.setLabel(this.getLabel());
entity.setGroupId(this.getGroupId());
// entity.setStatus(Integer.valueOf(this.getStatus()).shortValue()); //TODO
// entity.setCreated(this.getCreationTime());
// entity.setFinalizedAt(this.getFinalizedAt());
// entity.setModified(this.getModifiedTime());
// entity.setPublic(this.getPublic());
// entity.setPublishedAt(this.getPublishedAt());
// entity.setVersion(this.getVersion());
//
// entity.setDataset(this.getDatasets().stream().map(DatasetUrlListing::toDataModel).collect(Collectors.toCollection(LinkedHashSet::new)));
// if (this.getGrant() != null && !this.getGrant().isEmpty()) {
// Grant grant = new Grant();
// grant.setLabel(this.getGrant());
// entity.setGrant(grant);
// }
// entity.setUsers(this.getUsers().stream().map(UserInfoListingModel::toDataModel).collect(Collectors.toSet()));
return entity;
}
@Override
public String getHint() {
return "dataManagementPlanListingModel";
}
}

View File

@ -1,210 +0,0 @@
package eu.eudat.models.data.listingmodels;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.model.EntityDoi;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.dataset.DatasetOverviewModel;
import eu.eudat.models.data.dmp.AssociatedProfile;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, DataManagementPlanOverviewModel> {
private String id;
private String label;
private String profile;
private Date creationTime;
private Date modifiedTime;
private Date finalizedAt;
private int version;
private int status;
private UUID groupId;
private List<DatasetOverviewModel> datasets;
private List<AssociatedProfile> associatedProfiles;
private List<DmpUser> users;
private String description;
private boolean isPublic;
private Date publishedAt;
private List<EntityDoi> dois;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getProfile() {
return profile;
}
public void setProfile(String profile) {
this.profile = profile;
}
public Date getCreationTime() {
return creationTime;
}
public void setCreationTime(Date creationTime) {
this.creationTime = creationTime;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public List<DatasetOverviewModel> getDatasets() {
return datasets;
}
public void setDatasets(List<DatasetOverviewModel> datasets) {
this.datasets = datasets;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public List<AssociatedProfile> getAssociatedProfiles() {
return associatedProfiles;
}
public void setAssociatedProfiles(List<AssociatedProfile> associatedProfiles) {
this.associatedProfiles = associatedProfiles;
}
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<DmpUser> users) {
this.users = users;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean getIsPublic() {
return isPublic;
}
public void setIsPublic(boolean aPublic) {
isPublic = aPublic;
}
public Date getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(Date publishedAt) {
this.publishedAt = publishedAt;
}
public List<EntityDoi> getDois() {
return dois;
}
public void setDois(List<EntityDoi> dois) {
this.dois = dois;
}
@Override
public DataManagementPlanOverviewModel fromDataModel(DmpEntity entity) {
this.id = entity.getId().toString();
this.label = entity.getLabel();
this.groupId = entity.getGroupId();
this.status = entity.getStatus().getValue();
// if (entity.getResearchers() != null) { //TODO
// this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
// }
// if(entity.getDois() != null){
// this.dois = entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList());
// }
return this;
}
public DataManagementPlanOverviewModel fromDataModelDatasets(DmpEntity entity) {
this.fromDataModel(entity);
this.version = entity.getVersion();
// if (entity.getGrant() != null) this.grant = new GrantOverviewModel().fromDataModel(entity.getGrant());
// if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
this.creationTime = Date.from(entity.getCreatedAt());
this.modifiedTime = Date.from(entity.getUpdatedAt());
this.finalizedAt = Date.from(entity.getFinalizedAt());
// this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
// this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled)).map(x-> new DatasetOverviewModel().fromDataModel(x)).collect(Collectors.toList());
// this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
// this.description = entity.getDescription();
// if (entity.getResearchers() != null) {
// this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
// }
//
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
// this.associatedProfiles = new LinkedList<>();
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
// try {
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
// }
// catch (Exception e) {
// associatedProfile.setData(null);
// }
// this.associatedProfiles.add(associatedProfile);
// }
// }
// this.isPublic = entity.isPublic();
// this.publishedAt = entity.getPublishedAt();
// if (entity.getDois() != null) {
// this.dois = entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList());
// } else {
// this.dois = new ArrayList<>();
// }
return this;
}
@Override
public DmpEntity toDataModel() {
return null;
}
@Override
public String getHint() {
return "dataManagementPlanOverviewModel";
}
}

View File

@ -1,107 +0,0 @@
//package eu.eudat.models.data.listingmodels;
//
//import eu.eudat.commons.enums.DmpBlueprintStatus;
//import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
//import eu.eudat.data.DmpBlueprintEntity;
//import eu.eudat.models.DataModel;
//import eu.eudat.commons.types.xml.XmlBuilder;
//import org.w3c.dom.Document;
//
//import java.time.Instant;
//import java.util.UUID;
//
///**
// * Created by ikalyvas on 3/21/2018.
// */
//public class DataManagementPlanProfileListingModel implements DataModel<DmpBlueprintEntity, DataManagementPlanProfileListingModel> {
//
// private UUID id;
//
// private String label;
//
// private DefinitionEntity definitionEntity;
//
// private DmpBlueprintStatus status;
//
// private Instant created = null;
//
// private Instant modified = Instant.now();
//
// public UUID getId() {
// return id;
// }
//
// public void setId(UUID id) {
// this.id = id;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public DefinitionEntity getDefinition() {
// return definitionEntity;
// }
//
// public void setDefinition(DefinitionEntity definitionEntity) {
// this.definitionEntity = definitionEntity;
// }
//
// public DmpBlueprintStatus getStatus() {
// return status;
// }
//
// public void setStatus(DmpBlueprintStatus status) {
// this.status = status;
// }
//
// public Instant getCreated() {
// return created;
// }
//
// public void setCreated(Instant created) {
// this.created = created;
// }
//
// public Instant getModified() {
// return modified;
// }
//
// public void setModified(Instant modified) {
// this.modified = modified;
// }
//
// @Override
// public DataManagementPlanProfileListingModel fromDataModel(DmpBlueprintEntity entity) {
// this.id = entity.getId();
// this.created = entity.getCreatedAt();
// this.definitionEntity = new DefinitionEntity().fromXml(XmlBuilder.fromXml(entity.getDefinition()).getDocumentElement());
// this.modified = entity.getUpdatedAt();
// this.label = entity.getLabel();
// this.status = entity.getStatus();
// return this;
// }
//
// @Override
// public DmpBlueprintEntity toDataModel() throws Exception {
// Document document = XmlBuilder.getDocument();
// document.appendChild(this.definitionEntity.toXml(document));
// DmpBlueprintEntity dmpBlueprint = new DmpBlueprintEntity();
// dmpBlueprint.setCreatedAt(this.created == null ? Instant.now() : this.created);
// dmpBlueprint.setDefinition(XmlBuilder.generateXml(document));
// dmpBlueprint.setId(this.id);
// dmpBlueprint.setLabel(this.label);
// dmpBlueprint.setStatus(this.status);
// dmpBlueprint.setUpdatedAt(this.modified == null ? Instant.now() : this.modified);
// return dmpBlueprint;
// }
//
// @Override
// public String getHint() {
// return null;
// }
//}

View File

@ -1,53 +0,0 @@
package eu.eudat.models.data.listingmodels;
import eu.eudat.data.DmpEntity;
import eu.eudat.models.DataModel;
public class VersionListingModel implements DataModel<DmpEntity, VersionListingModel> {
private String id;
private String groupId;
private Integer version;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
@Override
public VersionListingModel fromDataModel(DmpEntity entity) {
this.id = entity.getId().toString();
this.groupId = entity.getGroupId().toString();
this.version = entity.getVersion().intValue();
return this;
}
@Override
public DmpEntity toDataModel() throws Exception {
return null;
}
@Override
public String getHint() {
return "versionListingModel";
}
}

View File

@ -2,11 +2,8 @@ package eu.eudat.models.data.quickwizard;
public class DatasetCreateWizardModel {
private DmpCreateWizardModel dmpMeta;
private DatasetQuickWizardModel datasets;
public DmpCreateWizardModel getDmpMeta() { return dmpMeta; }
public void setDmpMeta(DmpCreateWizardModel dmpMeta) { this.dmpMeta = dmpMeta; }
public DatasetQuickWizardModel getDatasets() {
return datasets;

View File

@ -3,7 +3,6 @@ package eu.eudat.models.data.quickwizard;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
@ -23,12 +22,12 @@ public class DatasetDescriptionQuickWizardModel extends PagedDatasetProfile {
}
public DatasetWizardModel toDataModel(DataManagementPlan dmp, DescriptionTemplateEntity profile){
public DatasetWizardModel toDataModel(DescriptionTemplateEntity profile){
DatasetWizardModel newDataset = new DatasetWizardModel();
newDataset.setLabel(datasetLabel);
newDataset.setCreated(Instant.now());
// newDataset.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
newDataset.setDmp(dmp);
// newDataset.setDmp(dmp);
newDataset.setStatus(DescriptionStatus.of((short)this.getStatus()));
//newDataset.setStatus(Dataset.Status.SAVED.getValue());

View File

@ -1,16 +0,0 @@
package eu.eudat.models.data.quickwizard;
import eu.eudat.models.data.dmp.DataManagementPlan;
public class DmpCreateWizardModel {
private DatasetProfileCreateWizardModel datasetProfile;
private DataManagementPlan dmp;
public DatasetProfileCreateWizardModel getDatasetProfile() {return datasetProfile; }
public void setDatasetProfile(DatasetProfileCreateWizardModel datasetProfileCreateWizardModel) {
this.datasetProfile = datasetProfileCreateWizardModel;
}
public DataManagementPlan getDmp() { return dmp; }
public void setDmp(DataManagementPlan dmp) { this.dmp = dmp; }
}

View File

@ -1,112 +0,0 @@
package eu.eudat.models.data.quickwizard;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.model.User;
import eu.eudat.models.data.dmp.AssociatedProfile;
import javax.management.InvalidApplicationException;
import java.util.*;
public class DmpQuickWizardModel {
private UUID id;
private String label;
private int status;
private AssociatedProfile datasetProfile;
private String description;
private String language;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public void setDatasetProfile(AssociatedProfile datasetProfile) {
this.datasetProfile = datasetProfile;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(/*Grant grant, Project project,*/ UserScope userScope) throws InvalidApplicationException {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
dataManagementPlanEntity.setId(this.id);
dataManagementPlanEntity.setVersion(0);
dataManagementPlanEntity.setLabel(this.label);
//TODO
// if (grant != null) {
// eu.eudat.models.data.grant.Grant importGrant = new eu.eudat.models.data.grant.Grant();
// dataManagementPlanEntity.setGrant(importGrant.fromDataModel(grant));
// }
// if (project != null) {
// eu.eudat.models.data.project.Project importProject = new eu.eudat.models.data.project.Project();
// dataManagementPlanEntity.setProject(importProject.fromDataModel(project));
// }
if (this.datasetProfile != null) {
List<AssociatedProfile> assProfile = new LinkedList<>();
assProfile.add(this.datasetProfile);
dataManagementPlanEntity.setProfiles(assProfile);
}
dataManagementPlanEntity.setStatus((short) this.status);
dataManagementPlanEntity.setDescription(this.description);
dataManagementPlanEntity.setProperties(null);
dataManagementPlanEntity.setCreated(new Date());
List<User> user = new LinkedList<>();
User userInfo = new User();
userInfo.setId(userScope.getUserId());
// dataManagementPlanEntity.setAssociatedUsers(user);
dataManagementPlanEntity.setExtraProperties(new HashMap<>());
dataManagementPlanEntity.getExtraProperties().put("language", this.language);
dataManagementPlanEntity.getExtraProperties().put("visible", false);
dataManagementPlanEntity.getExtraProperties().put("contact", userScope.getUserId().toString());
return dataManagementPlanEntity;
}
public DescriptionTemplateEntity getDatasetProfile() {
DescriptionTemplateEntity descriptionTemplateEntity = new DescriptionTemplateEntity();
descriptionTemplateEntity.setDefinition(this.datasetProfile.getLabel());
descriptionTemplateEntity.setLabel(this.datasetProfile.getLabel());
descriptionTemplateEntity.setId(this.datasetProfile.getDescriptionTemplateId());
return descriptionTemplateEntity;
}
}

View File

@ -3,17 +3,9 @@ package eu.eudat.models.data.quickwizard;
public class QuickWizardModel {
private DmpQuickWizardModel dmp;
private DatasetQuickWizardModel datasets;
private int status;
public DmpQuickWizardModel getDmp() {
return dmp;
}
public void setDmp(DmpQuickWizardModel dmp) {
this.dmp = dmp;
}
public DatasetQuickWizardModel getDatasets() {
return datasets;
}

View File

@ -1,26 +0,0 @@
package eu.eudat.models.data.urls;
import eu.eudat.data.DmpEntity;
/**
* Created by ikalyvas on 3/19/2018.
*/
public class DataManagementPlanUrlListing extends UrlListing<DmpEntity, DataManagementPlanUrlListing> {
@Override
public DataManagementPlanUrlListing fromDataModel(DmpEntity entity) {
this.setLabel(entity.getLabel());
this.setUrl(entity.getId().toString());
return this;
}
@Override
public DmpEntity toDataModel() throws Exception {
return null;
}
@Override
public String getHint() {
return null;
}
}

View File

@ -1,54 +0,0 @@
package eu.eudat.models.validators;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel;
import eu.eudat.models.validators.fluentvalidator.FluentValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
* Created by ikalyvas on 3/7/2018.
*/
@Component("dataManagementPlanNewVersionValidator")
public class DataManagementPlanNewVersionValidator extends FluentValidator<DataManagementPlanNewVersionModel> {
private DatabaseRepository databaseRepository;
@Autowired
public DataManagementPlanNewVersionValidator(DatabaseRepository databaseRepository) {
this.databaseRepository = databaseRepository;
ruleFor(x -> {
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
List<UUID> groupIds = Arrays.asList(x.getGroupId());
criteria.setGroupIds(groupIds);
return this.databaseRepository.getDmpDao().getWithCriteria(criteria).getSingleOrDefault().getVersion();
}).compareAs(x -> x.getVersion(), ((leftItem, rightItem) -> leftItem > rightItem))
.withName("version").withMessage("datamanagementplannewversion.version.notacceptable");
ruleFor(x -> {
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
List<UUID> groupIds = Arrays.asList(x.getGroupId());
criteria.setGroupIds(groupIds);
return this.databaseRepository.getDmpDao().getWithCriteria(criteria).getSingleOrDefault().getVersion() + 1;
}).compareAs(x -> x.getVersion(), ((leftItem, rightItem) -> !leftItem.equals(rightItem)))
.withName("version").withMessage("datamanagementplannewversion.version.notnext");
}
@Override
public boolean supports(Class<?> aClass) {
return DataManagementPlanNewVersionModel.class.equals(aClass);
}
public static boolean supportsType(Class<?> aClass) {
return DataManagementPlanNewVersionModel.class.equals(aClass);
}
}

View File

@ -1,26 +0,0 @@
package eu.eudat.models.validators;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.models.validators.fluentvalidator.FluentValidator;
import org.springframework.stereotype.Component;
@Component("dataManagementPlanTableRequestValidator")
public class DataManagementPlanTableRequestValidator extends FluentValidator<DataManagementPlanTableRequest> {
public DataManagementPlanTableRequestValidator() {
ruleFor(x -> x.getOffset()).compareAs((x -> 0), (leftItem, rightItem) -> leftItem < rightItem)
.withName("offset").withMessage("datamanagementplanrequest.offset.negative");
ruleFor(x -> x.getLength()).compareAs((x -> 0), (leftItem, rightItem) -> leftItem < rightItem)
.withName("length").withMessage("datamanagementplanrequest.length.negative");
}
@Override
public boolean supports(Class<?> clazz) {
return DataManagementPlanTableRequest.class.equals(clazz);
}
public static boolean supportsType(Class<?> clazz) {
return DataManagementPlanTableRequest.class.equals(clazz);
}
}