diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTemplateEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTemplateEntity.java index 5e09b40a3..2cbc55f25 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTemplateEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTemplateEntity.java @@ -18,7 +18,7 @@ import java.util.UUID; @Entity @Table(name = "\"DescriptionTemplate\"") -public class DescriptionTemplateEntity extends TenantScopedBaseEntity implements DataEntity{ +public class DescriptionTemplateEntity extends TenantScopedBaseEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) private UUID id; @@ -164,19 +164,4 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity implements public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) { this.versionStatus = versionStatus; } - - @Override - public void update(DescriptionTemplateEntity entity) { - } - - @Override - public UUID getKeys() { - return this.id; - } - - @Override - public DescriptionTemplateEntity buildFromTuple(List tuple, List fields, String base) { - this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id")); - return this; - } } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDao.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDao.java deleted file mode 100644 index d2d120c0f..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDao.java +++ /dev/null @@ -1,25 +0,0 @@ -package eu.eudat.data.dao.entities; - -import eu.eudat.data.DescriptionTemplateTypeEntity; -import eu.eudat.data.dao.DatabaseAccessLayer; -import eu.eudat.data.dao.criteria.DatasetProfileCriteria; -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.queryable.QueryableList; - -import javax.management.InvalidApplicationException; -import java.util.List; -import java.util.UUID; - -public interface DatasetProfileDao extends DatabaseAccessLayer { - - QueryableList getWithCriteria(DatasetProfileCriteria criteria); - - QueryableList getAll(); - - QueryableList getAuthenticated(QueryableList query, UUID principal, List roles); - - List getAllIds() throws InvalidApplicationException; - - Long countWithType(DescriptionTemplateTypeEntity type) throws InvalidApplicationException; - -} \ No newline at end of file diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDaoImpl.java deleted file mode 100644 index ced5e5e43..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetProfileDaoImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -package eu.eudat.data.dao.entities; - -import eu.eudat.commons.enums.DescriptionTemplateStatus; -import eu.eudat.commons.enums.IsActive; -import eu.eudat.data.DescriptionTemplateTypeEntity; -import eu.eudat.data.dao.DatabaseAccess; -import eu.eudat.data.dao.criteria.DatasetProfileCriteria; -import eu.eudat.data.dao.databaselayer.service.DatabaseService; -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.queryable.QueryableList; -import eu.eudat.queryable.types.FieldSelectionType; -import eu.eudat.queryable.types.SelectionField; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import jakarta.persistence.criteria.Join; -import jakarta.persistence.criteria.JoinType; - -import javax.management.InvalidApplicationException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -@Component("datasetProfileDao") -public class DatasetProfileDaoImpl extends DatabaseAccess implements DatasetProfileDao { - - @Autowired - public DatasetProfileDaoImpl(DatabaseService databaseService) { - super(databaseService); - } - - @Override - public QueryableList getWithCriteria(DatasetProfileCriteria criteria) { - QueryableList query = getDatabaseService().getQueryable(DescriptionTemplateEntity.class); - if (criteria.getLike() != null && !criteria.getLike().isEmpty()) - query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%")); - if (!criteria.getAllVersions()) - query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), - query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), - nestedRoot.get("groupId")), 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.getFilter() != null && criteria.getUserId() != null) { - if (criteria.getFilter().equals(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue())) { - query.initSubQuery(UUID.class).where((builder, root) -> - builder.and(root.get("id").in( - query.subQuery((builder1, root1) -> builder1.equal(root1.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId()), - Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")))), - builder.notEqual(root.get("id"), criteria.getUserId()))); - //query.where(((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId()))); - } - if (criteria.getFilter().equals(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue())) { - query.initSubQuery(UUID.class).where((builder, root) -> - builder.and(root.get("id").in( - query.subQuery((builder1, root1) -> builder1.equal(root1.join("dataset", JoinType.LEFT).join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId()), - Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")))), - builder.notEqual(root.get("id"), criteria.getUserId()))); - } - } - if (criteria.getStatus() != null) { - query.where(((builder, root) -> builder.equal(root.get("status"), criteria.getStatus()))); - } - if (criteria.getIds() != null) { - query.where(((builder, root) -> root.get("id").in(criteria.getIds()))); - } - if (criteria.getFinalized()) { - query.where(((builder, root) -> builder.equal(root.get("status"), DescriptionTemplateStatus.Finalized))); - } else { - query.where(((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive))); - } - if (criteria.getPeriodStart() != null) - query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("createdAt"), criteria.getPeriodStart())); - return query; - } - - @Override - public DescriptionTemplateEntity createOrUpdate(DescriptionTemplateEntity item) { - return this.getDatabaseService().createOrUpdate(item, DescriptionTemplateEntity.class); - } - - @Override - public DescriptionTemplateEntity find(UUID id) throws InvalidApplicationException { - return getDatabaseService().getQueryable(DescriptionTemplateEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle(); - } - - @Override - public QueryableList getAll() { - return getDatabaseService().getQueryable(DescriptionTemplateEntity.class); - } - - @Override - public List getAllIds() throws InvalidApplicationException { - return getDatabaseService().getQueryable(DescriptionTemplateEntity.class).withFields(Collections.singletonList("id")).toList(); - } - - @Override - public void delete(DescriptionTemplateEntity item) { - this.getDatabaseService().delete(item); - } - - @Override - public QueryableList asQueryable() { - return this.getDatabaseService().getQueryable(DescriptionTemplateEntity.class); - } - - @Async - @Override - public CompletableFuture createOrUpdateAsync(DescriptionTemplateEntity item) { - return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); - } - - @Override - public DescriptionTemplateEntity find(UUID id, String hint) { - throw new UnsupportedOperationException(); - } - - @Override - public QueryableList getAuthenticated(QueryableList query, UUID principal, List 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 - public Long countWithType(DescriptionTemplateTypeEntity type) throws InvalidApplicationException { - return this.getDatabaseService().getQueryable(DescriptionTemplateEntity.class).where((builder, root) -> builder.equal(root.get("type"), type)).count(); - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/datasetprofile/DatasetProfileAutocompleteRequest.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/datasetprofile/DatasetProfileAutocompleteRequest.java deleted file mode 100644 index bceb05e6f..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/datasetprofile/DatasetProfileAutocompleteRequest.java +++ /dev/null @@ -1,24 +0,0 @@ -package eu.eudat.data.query.items.item.datasetprofile; - -import eu.eudat.data.dao.criteria.DatasetProfileCriteria; -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.data.query.PaginationService; -import eu.eudat.data.query.definition.TableQuery; -import eu.eudat.queryable.QueryableList; - -import java.util.UUID; - -public class DatasetProfileAutocompleteRequest extends TableQuery { - @Override - public QueryableList applyCriteria() { - QueryableList query = this.getQuery(); - 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; - } - - @Override - public QueryableList applyPaging(QueryableList items) { - return PaginationService.applyPaging(items, this); - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/datasetprofile/DatasetProfileWizardAutocompleteRequest.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/datasetprofile/DatasetProfileWizardAutocompleteRequest.java deleted file mode 100644 index ea169920f..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/datasetprofile/DatasetProfileWizardAutocompleteRequest.java +++ /dev/null @@ -1,13 +0,0 @@ -package eu.eudat.data.query.items.item.datasetprofile; - -import eu.eudat.data.dao.criteria.DatasetProfileWizardCriteria; -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.data.query.definition.Query; -import eu.eudat.queryable.QueryableList; - -public class DatasetProfileWizardAutocompleteRequest extends Query { - @Override - public QueryableList applyCriteria() { - return null; - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/datasetprofile/DatasetProfileTableRequestItem.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/datasetprofile/DatasetProfileTableRequestItem.java deleted file mode 100644 index 044d7fb1c..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/datasetprofile/DatasetProfileTableRequestItem.java +++ /dev/null @@ -1,23 +0,0 @@ -package eu.eudat.data.query.items.table.datasetprofile; - -import eu.eudat.data.dao.criteria.DatasetProfileCriteria; -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.data.query.definition.TableQuery; -import eu.eudat.queryable.QueryableList; - -import java.util.UUID; - -public class DatasetProfileTableRequestItem extends TableQuery { - @Override - public QueryableList applyCriteria() { - QueryableList query = this.getQuery(); - 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; - } - - @Override - public QueryableList applyPaging(QueryableList items) { - return null; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index eec034d9f..d442a67a2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -3,11 +3,8 @@ package eu.eudat.controllers; import eu.eudat.authorization.Permission; import eu.eudat.criteria.DMPCriteria; -import eu.eudat.data.DmpEntity; -import eu.eudat.data.dao.criteria.DynamicFieldsCriteria; -import eu.eudat.data.dao.criteria.RequestItem; import eu.eudat.data.DescriptionEntity; -import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; +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; @@ -18,10 +15,8 @@ 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.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized; import eu.eudat.models.data.dmp.DataManagementPlan; -import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel; @@ -30,6 +25,8 @@ 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; @@ -42,9 +39,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import jakarta.activation.MimetypesFileTypeMap; -import jakarta.validation.Valid; - import javax.management.InvalidApplicationException; import java.io.File; import java.io.FileInputStream; @@ -116,14 +110,14 @@ public class DMPs extends BaseController { } - @RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDmps/paged"}, produces = "application/json") - public @ResponseBody - ResponseEntity>> getUsingDatasetProfilesPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - DataTableData datasetProfileTableData = this.dataManagementPlanManager.getDatasetProfilesUsedByDMP(datasetProfileTableRequestItem); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData)); - } +// @RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDmps/paged"}, produces = "application/json") +// public @ResponseBody +// ResponseEntity>> getUsingDatasetProfilesPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException { +// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); +// +// DataTableData datasetProfileTableData = this.dataManagementPlanManager.getDatasetProfilesUsedByDMP(datasetProfileTableRequestItem); +// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData)); +// } @RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"}) public @ResponseBody diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfileController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfileController.java deleted file mode 100644 index 00b46626b..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfileController.java +++ /dev/null @@ -1,79 +0,0 @@ -package eu.eudat.controllers; - -import eu.eudat.commons.types.descriptiontemplate.FieldEntity; -import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity; -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.data.dao.criteria.RequestItem; -import eu.eudat.logic.managers.DatasetProfileManager; -import eu.eudat.logic.services.ApiContext; -import eu.eudat.service.remotefetcher.models.ExternalAutocompleteFieldResult; -import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem; -import eu.eudat.models.data.helpers.common.AutoCompleteOptionsLookupItem; -import gr.cite.commons.web.authz.service.AuthorizationService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.management.InvalidApplicationException; -import javax.xml.xpath.XPathExpressionException; -import java.util.List; -import java.util.UUID; - -@RestController -@CrossOrigin -@RequestMapping(value = {"/api"}) -public class DatasetProfileController extends BaseController { - - private final DatasetProfileManager datasetProfileManager; - private final AuthorizationService authorizationService; - - @Autowired - public DatasetProfileController(ApiContext apiContext, DatasetProfileManager datasetProfileManager, AuthorizationService authorizationService) { - super(apiContext); - this.datasetProfileManager = datasetProfileManager; - this.authorizationService = authorizationService; - } - -/* @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/save/{id}"}, consumes = "application/json", produces = "application/json") - public ResponseEntity updateDataset(@PathVariable String id, @RequestBody PropertiesModel properties) { - eu.eudat.data.Dataset dataset = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(id)); - Map values = new HashMap<>(); - properties.toMap(values); - JSONObject jobject = new JSONObject(values); - dataset.setProperties(jobject.toString()); - dataset.setStatus((short) properties.getStatus()); - this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset); //TODO - return ResponseEntity.status(HttpStatus.OK).body(properties); - }*/ - -// @Transactional -// @RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json") -// public ResponseEntity> clone(@PathVariable String id) throws InvalidApplicationException { -// this.authorizationService.authorizeForce(Permission.AdminRole); -// -// DescriptionTemplateEntity profile = this.datasetProfileManager.clone(id); -// eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); -// datasetprofile.setLabel(profile.getLabel() + " new "); -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(datasetprofile)); -// } - - @RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}, consumes = "application/json", produces = "application/json") - public ResponseEntity getDataForAutocomplete(@RequestBody RequestItem lookupItem) throws XPathExpressionException, InvalidApplicationException { - DescriptionTemplateEntity descriptionTemplateEntity = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID())); - FieldEntity modelfield = this.datasetProfileManager.queryForField(descriptionTemplateEntity.getDefinition(), lookupItem.getCriteria().getFieldID()); - AutoCompleteDataEntity data = (AutoCompleteDataEntity) modelfield.getData(); - List items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike()); - return ResponseEntity.status(HttpStatus.OK).body(items); - } - - @RequestMapping(method = RequestMethod.POST, value = {"/search/autocompleteOptions"}, consumes = "application/json", produces = "application/json") - public ResponseEntity getDataForAutocompleteOptions(@RequestBody RequestItem lookupItem) { - AutoCompleteDataEntity data = new AutoCompleteDataEntity(); - data.setAutoCompleteSingleDataList(lookupItem.getCriteria().getAutoCompleteSingleDataList()); - List items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike()); - return ResponseEntity.status(HttpStatus.OK).body(items); - } - -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java deleted file mode 100644 index 1ddacac47..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java +++ /dev/null @@ -1,362 +0,0 @@ -package eu.eudat.controllers; - -import eu.eudat.authorization.Permission; -import eu.eudat.commons.scope.user.UserScope; -import eu.eudat.data.DescriptionEntity; -import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest; -import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException; -import eu.eudat.exceptions.security.UnauthorisedException; -import eu.eudat.logic.managers.DatasetManager; -import eu.eudat.logic.managers.DatasetWizardManager; -import eu.eudat.logic.managers.FileManager; -import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; -import eu.eudat.logic.services.ApiContext; -import eu.eudat.logic.services.forms.VisibilityRuleService; -import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl; -import eu.eudat.model.file.FileEnvelope; -import eu.eudat.models.data.datasetwizard.DatasetWizardModel; -import eu.eudat.models.data.dmp.AssociatedProfile; -import eu.eudat.models.data.helpers.responses.ResponseItem; -import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel; -import eu.eudat.types.ApiMessageCode; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.query.QueryFactory; -import jakarta.persistence.NoResultException; -import jakarta.transaction.Transactional; -import org.apache.poi.util.IOUtils; -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.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.Locale; -import java.util.UUID; - - -@RestController -@CrossOrigin -@RequestMapping(value = {"/api/datasets/"}) -public class Datasets extends BaseController { - private static final Logger logger = LoggerFactory.getLogger(Datasets.class); - - private Environment environment; - private DatasetManager datasetManager; - private ConfigLoader configLoader; - private FileManager fileManager; - private final AuthorizationService authorizationService; - private final UserScope userScope; - private final QueryFactory queryFactory; - - @Autowired - public Datasets(ApiContext apiContext, Environment environment, DatasetManager datasetManager, ConfigLoader configLoader, - FileManager fileManager, AuthorizationService authorizationService, UserScope userScope, QueryFactory queryFactory) { - super(apiContext); - this.environment = environment; - this.datasetManager = datasetManager; - this.configLoader = configLoader; - this.fileManager = fileManager; - this.authorizationService = authorizationService; - this.userScope = userScope; - this.queryFactory = queryFactory; - } - - /* - * Data Retrieval - * */ - -// @RequestMapping(method = RequestMethod.POST, value = {"paged"}, consumes = "application/json", produces = "application/json") -// public @ResponseBody -// ResponseEntity>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) throws Exception { -// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole); -// -// DataTableData dataTable = this.datasetManager.getPaged(datasetTableRequest); -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); -// } -// -// @RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json") -// public @ResponseBody -// ResponseEntity>> getPublicPaged(@RequestBody DatasetPublicTableRequest datasetTableRequest) throws Exception { -// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole); -// -// DataTableData dataTable = this.datasetManager.getPaged(datasetTableRequest); -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); -// } -// -// @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 { -// DatasetOverviewModel dataset = this.datasetManager.getOverviewSingle(id, false); -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); -// } catch (Exception e) { -// if (e instanceof UnauthorisedException) { -// return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE)); -// } else { -// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE)); -// } -// } -// } -// -// @RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"}) -// public @ResponseBody -// ResponseEntity> getOverviewSinglePublic(@PathVariable String id) throws Exception { -// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole); -// -// // try { -// DatasetOverviewModel dataset = this.datasetManager.getOverviewSingle(id, true); -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); -//// } catch (Exception ex) { -//// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage())); -//// } -// } - - @Transactional - @RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType) throws IllegalAccessException, IOException, InstantiationException { - this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole); - - try { - VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl(); - if (contentType.equals("application/xml")) { - return this.datasetManager.getDocument(id, visibilityRuleService, contentType); - } else if (contentType.equals("application/msword")) { - FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, visibilityRuleService); - InputStream resource = new FileInputStream(file.getFile()); - HttpHeaders responseHeaders = new HttpHeaders(); - responseHeaders.setContentLength(file.getFile().length()); - responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); - String fileName = file.getFilename().replace(" ", "_").replace(",", "_"); - responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName); - responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); - responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); - - byte[] content = IOUtils.toByteArray(resource); - resource.close(); - Files.deleteIfExists(file.getFile().toPath()); - return new ResponseEntity<>(content, - responseHeaders, - HttpStatus.OK); - } else { - DatasetWizardModel dataset = this.datasetManager.getSingle(id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - if (e instanceof UnauthorisedException) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE)); - } else if (e instanceof NoResultException) { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE)); - } else { - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE)); - } - } - } - -// @RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDatasets/paged"}, produces = "application/json") -// public @ResponseBody -// ResponseEntity>> getUsingDatasetProfilesPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException { -// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); -// -// DataTableData datasetProfileTableData = this.datasetManager.getDatasetProfilesUsedByDatasets(datasetProfileTableRequestItem); -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData)); -// } - -// @RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json") -// public @ResponseBody -// ResponseEntity>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest) throws IllegalAccessException, InstantiationException, InvalidApplicationException { -// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); -// -// List dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, this.userScope); -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans)); -// } - - @RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json") - public @ResponseBody - ResponseEntity>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest) throws IllegalAccessException, InstantiationException, InvalidApplicationException { - this.authorizationService.authorizeForce(Permission.AnonymousRole); - - List dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileWizardAutocompleteRequest); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans)); - } - -// @RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"}, produces = "application/json") -// public @ResponseBody -// ResponseEntity getSinglePublic(@PathVariable String id) throws Exception { -// try { -// DatasetWizardModel dataset = this.datasetManager.getSinglePublic(id); -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); -// } -// catch (Exception ex) { -// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage())); -// } -// } - -// @RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json") -// public ResponseEntity> getSingle(@PathVariable String id) throws InvalidApplicationException { -// DescriptionTemplateEntity profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); -// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile); -// PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile(); -// pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile); -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile)); -// } - - /* - * Data Export - * */ - - @RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"}) - public @ResponseBody - ResponseEntity getPDFDocument(@PathVariable String id) throws IOException, InvalidApplicationException { - this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole); - - FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, new VisibilityRuleServiceImpl()); - String fileName = file.getFilename().replace(" ", "_").replace(",", "_"); - if (fileName.endsWith(".docx")){ - fileName = fileName.substring(0, fileName.length() - 5); - } - File pdffile = null; // PDFUtils.convertToPDF(file, environment); //TODO - InputStream resource = new FileInputStream(pdffile); - - HttpHeaders responseHeaders = new HttpHeaders(); - responseHeaders.setContentLength(pdffile.length()); - responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); - responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".pdf"); - responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); - responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); - - byte[] content = 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> createOrUpdate(@RequestBody DatasetWizardModel profile) throws Exception { -// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); -// -// DatasetWizardModel dataset = new DatasetWizardModel().fromDataModel(this.datasetManager.createOrUpdate(profile)); -//// dataset.setTags(profile.getTags()); //TODO -// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dataset)); -// } - - @Transactional - @RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity> makePublic(@PathVariable UUID id, Locale locale) throws Exception { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - this.datasetManager.makePublic(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message(this.getApiContext().getHelpersService().getMessageSource().getMessage("dataset.public", new Object[]{}, locale))); - } - - @Transactional - @RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity> delete(@PathVariable(value = "id") UUID id) throws Exception { - new DatasetWizardManager().delete(this.getApiContext(), id); - this.fileManager.markAllFilesOfEntityIdAsDeleted(id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted")); - } - - @Transactional - @RequestMapping(method = RequestMethod.GET, value = {"/{id}/unlock"}, produces = "application/json") - public @ResponseBody - ResponseEntity> unlock(@PathVariable(value = "id") UUID id) throws Exception { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - try { - new DatasetWizardManager().unlock(this.getApiContext(), this.queryFactory, id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked")); - } catch (DatasetWizardCannotUnlockException datasetWizardCannotUnlockException) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage())); - } - } - - @RequestMapping(method = RequestMethod.GET, value = {"/{id}/validate"}, produces = "application/json") - public @ResponseBody - ResponseEntity> validate(@PathVariable(value = "id") UUID id) throws Exception { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - DescriptionEntity descriptionEntity = datasetManager.getEntitySingle(id); - String failedField = datasetManager.checkDatasetValidation(descriptionEntity); - if (failedField == null) { - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Valid")); - } else { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message("Field value of " + failedField + " must be filled.")); - } - } - - /* - * Data Import - * */ - - @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) - public ResponseEntity datasetXmlImport(@RequestParam("file") MultipartFile file, @RequestParam("dmpId") String dmpId, @RequestParam("datasetProfileId") String datasetProfileId) { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - try { - DescriptionEntity descriptionEntity = this.datasetManager.createDatasetFromXml(file, dmpId, datasetProfileId); - if (descriptionEntity != null){ - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); - } - else { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful.")); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful.")); - } - } - - /* - * Data Index - * */ - - @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/index"}) - public @ResponseBody - ResponseEntity> generateIndex() throws Exception { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - this.datasetManager.generateIndex(); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null)); - } - - @Transactional - @RequestMapping(method = RequestMethod.DELETE, value = {"/index"}) - public @ResponseBody - ResponseEntity> clearIndex() throws Exception { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - //this.datasetManager.clearIndex(); //TODO - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null)); - } - - -} - diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index e2930155d..d65260543 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -6,50 +6,55 @@ import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.enums.*; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.types.dmpblueprint.*; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.data.*; -import eu.eudat.data.dao.criteria.*; -import eu.eudat.data.dao.entities.*; -import eu.eudat.data.old.*; +import eu.eudat.data.dao.criteria.DataManagementPlanCriteria; +import eu.eudat.data.dao.criteria.DatasetCriteria; +import eu.eudat.data.dao.entities.DatasetDao; +import eu.eudat.data.old.FileUpload; import eu.eudat.data.query.items.table.dataset.DatasetTableRequest; -import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest; -//import eu.eudat.depositinterface.models.DmpDepositModel; import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException; import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException; import eu.eudat.exceptions.security.ForbiddenException; import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.logic.builders.entity.UserInfoBuilder; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; -import eu.eudat.model.DmpUser; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl; import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.commons.types.xml.XmlBuilder; -import eu.eudat.model.EntityDoi; -import eu.eudat.model.file.FileEnvelope; -import eu.eudat.query.*; import eu.eudat.logic.utilities.documents.types.ParagraphStyle; import eu.eudat.logic.utilities.documents.word.WordBuilder; import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder; +import eu.eudat.model.DmpUser; +import eu.eudat.model.EntityDoi; +import eu.eudat.model.file.FileEnvelope; import eu.eudat.model.persist.deposit.DepositRequest; import eu.eudat.models.HintedModelFactory; import eu.eudat.models.data.dataset.DatasetOverviewModel; -import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized; import eu.eudat.models.data.dmp.*; import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue; import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpers.common.DataTableData; -import eu.eudat.models.data.listingmodels.*; +import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel; +import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel; +import eu.eudat.models.data.listingmodels.DatasetListingModel; +import eu.eudat.models.data.listingmodels.VersionListingModel; import eu.eudat.models.data.user.composite.PagedDatasetProfile; +import eu.eudat.query.*; import eu.eudat.queryable.QueryableList; import eu.eudat.service.deposit.DepositService; import eu.eudat.service.dmpblueprint.DmpBlueprintService; import eu.eudat.types.MetricNames; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.QueryFactory; +import jakarta.transaction.Transactional; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Unmarshaller; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRun; @@ -58,18 +63,15 @@ 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.*; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; import org.w3c.dom.Document; import org.w3c.dom.Element; -import jakarta.transaction.Transactional; -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.JAXBException; -import jakarta.xml.bind.Unmarshaller; - import javax.management.InvalidApplicationException; import java.io.*; import java.math.BigInteger; @@ -79,7 +81,6 @@ import java.time.temporal.ChronoUnit; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -407,19 +408,19 @@ public class DataManagementPlanManager { // return result; // } - public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException { - datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); - datasetProfileTableRequestItem.getCriteria().setUserId(this.userScope.getUserId()); - - QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria()); - List listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); - - DataTableData data = new DataTableData<>(); - data.setData(listingModels); - data.setTotalCount((long) listingModels.size()); - - return data; - } +// public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException { +// datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); +// datasetProfileTableRequestItem.getCriteria().setUserId(this.userScope.getUserId()); +// +// QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria()); +// List listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); +// +// DataTableData data = new DataTableData<>(); +// data.setData(listingModels); +// data.setTotalCount((long) listingModels.size()); +// +// return data; +// } public List getAllVersions(String groupId, Boolean isPublic) throws InvalidApplicationException { UUID principalId = this.userScope.getUserIdSafe(); @@ -639,8 +640,8 @@ public class DataManagementPlanManager { throw new Exception("Another user have already edit that DMP."); } for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) { - if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> dataset.getProfile().getId().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null) - throw new Exception("Dataset Template for Dataset Description is missing from the DMP."); +// if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> dataset.getProfile().getId().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null) //TODO +// throw new Exception("Dataset Template for Dataset Description is missing from the DMP."); } if (dataManagementPlan.getStatus() == (int) DmpStatus.Finalized.getValue() && dmp1.getStatus().equals(DmpStatus.Finalized.getValue())) throw new Exception("DMP is finalized, therefore cannot be edited."); @@ -2197,18 +2198,18 @@ public class DataManagementPlanManager { // } // } - for (AssociatedProfileImportModels a : dataManagementPlans.get(0).getProfilesImportModels()) { - try { - eu.eudat.data.DescriptionTemplateEntity exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(a.getId()); - AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile); - Map data = new HashMap<>(); - List sections = new ArrayList<>(a.getSection()); - data.put("dmpSectionIndex", sections); - associatedProfile.setData(data); - associatedProfiles.add(associatedProfile); - } catch (Exception ignored) { - } - } +// for (AssociatedProfileImportModels a : dataManagementPlans.get(0).getProfilesImportModels()) { +// try { +// eu.eudat.data.DescriptionTemplateEntity exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(a.getId()); +// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile); +// Map data = new HashMap<>(); +// List sections = new ArrayList<>(a.getSection()); +// data.put("dmpSectionIndex", sections); +// associatedProfile.setData(data); +// associatedProfiles.add(associatedProfile); +// } catch (Exception ignored) { +// } +// } // List organisations = new ArrayList<>(); // for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) { diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index ca314e367..46757d9ee 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -16,7 +16,6 @@ import eu.eudat.data.dao.entities.DatasetDao; import eu.eudat.data.old.*; import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest; import eu.eudat.data.query.items.table.dataset.DatasetTableRequest; -import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.exceptions.security.ForbiddenException; import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.logic.builders.BuilderFactory; @@ -35,7 +34,6 @@ import eu.eudat.models.HintedModelFactory; import eu.eudat.models.data.dataset.DatasetOverviewModel; import eu.eudat.models.data.datasetImport.DatasetImportField; import eu.eudat.models.data.datasetImport.DatasetImportPagedDatasetProfile; -import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.dmp.AssociatedProfile; import eu.eudat.models.data.helpers.common.DataTableData; @@ -308,10 +306,10 @@ public class DatasetManager { uuidList.add(profileId); profileCriteria.setGroupIds(uuidList); profileCriteria.setAllVersions(true); - - List profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria) - .orderBy(((builder, root) -> builder.desc(root.get("version")))) - .toList(); + List profileVersions = null; +// List profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria) +// .orderBy(((builder, root) -> builder.desc(root.get("version")))) +// .toList(); List profileVersionsIncluded = new LinkedList<>(); // Iterate through the versions and remove those that are not included in the DMP of the dataset in question. @@ -746,7 +744,8 @@ public class DatasetManager { public String checkDatasetValidation(DescriptionEntity descriptionEntity) throws Exception { List datasetProfileValidators = new LinkedList<>(); - DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(descriptionEntity.getDescriptionTemplateId()); + DescriptionTemplateEntity profile = null; +// DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(descriptionEntity.getDescriptionTemplateId()); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes())); @@ -1009,8 +1008,10 @@ public class DatasetManager { // Checks if XML datasetProfileId GroupId matches the one selected. try { - DescriptionTemplateEntity importDescriptionTemplateEntity = databaseRepository.getDatasetProfileDao().find(UUID.fromString(importModel.getDatasetProfileId())); - DescriptionTemplateEntity latestVersionDescriptionTemplateEntity = databaseRepository.getDatasetProfileDao().find(UUID.fromString(datasetProfileId)); + DescriptionTemplateEntity importDescriptionTemplateEntity = null; + DescriptionTemplateEntity latestVersionDescriptionTemplateEntity = null; +// DescriptionTemplateEntity importDescriptionTemplateEntity = databaseRepository.getDatasetProfileDao().find(UUID.fromString(importModel.getDatasetProfileId())); +// DescriptionTemplateEntity latestVersionDescriptionTemplateEntity = databaseRepository.getDatasetProfileDao().find(UUID.fromString(datasetProfileId)); if (latestVersionDescriptionTemplateEntity.getGroupId() != importDescriptionTemplateEntity.getGroupId()) { throw new Exception(); } @@ -1079,19 +1080,19 @@ public class DatasetManager { // return pagedDatasetProfile; // } - public DataTableData getDatasetProfilesUsedByDatasets(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException { - datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue()); - datasetProfileTableRequestItem.getCriteria().setUserId(this.userScope.getUserId()); - - QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria()); - List listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); - - DataTableData data = new DataTableData<>(); - data.setData(listingModels); - data.setTotalCount((long) listingModels.size()); - - return data; - } +// public DataTableData getDatasetProfilesUsedByDatasets(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException { +// datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue()); +// datasetProfileTableRequestItem.getCriteria().setUserId(this.userScope.getUserId()); +// +// QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria()); +// List listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); +// +// DataTableData data = new DataTableData<>(); +// data.setData(listingModels); +// data.setTotalCount((long) listingModels.size()); +// +// return data; +// } public void generateIndex() throws InvalidApplicationException { if (this.authorizationService.authorize(Permission.AdminRole)) { diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index e4cf8cba6..54e54d64c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -218,68 +218,68 @@ public class DatasetProfileManager { } public void addSemanticsInDatasetProfiles() throws XPathExpressionException, InvalidApplicationException { - List ids = this.databaseRepository.getDatasetProfileDao().getAllIds(); - for(DescriptionTemplateEntity dp: ids){ - DescriptionTemplateEntity descriptionTemplateEntity = this.databaseRepository.getDatasetProfileDao().find(dp.getId()); - Document document = XmlBuilder.fromXml(descriptionTemplateEntity.getDefinition()); - XPathFactory xpathFactory = XPathFactory.newInstance(); - XPath xpath = xpathFactory.newXPath(); - XPathExpression expr = xpath.compile("//rdaCommonStandard"); - NodeList rdaProperties = (NodeList) expr.evaluate(document, XPathConstants.NODESET); - for(int i = 0; i < rdaProperties.getLength(); i++){ - Node rdaPropertyNode = rdaProperties.item(i); - String rdaProperty = rdaPropertyNode.getTextContent(); - Element schematics = document.createElement("schematics"); - Node fieldParent = rdaPropertyNode.getParentNode(); - if(rdaProperty != null && !rdaProperty.isEmpty()){ - Element schematic = document.createElement("schematic"); - schematic.setTextContent("rda." + rdaProperty); - schematics.appendChild(schematic); - } - fieldParent.insertBefore(schematics, rdaPropertyNode); - fieldParent.removeChild(rdaPropertyNode); - } - this.updateDatasetProfileXml(document, descriptionTemplateEntity); - } +// List ids = this.databaseRepository.getDatasetProfileDao().getAllIds(); +// for(DescriptionTemplateEntity dp: ids){ +// DescriptionTemplateEntity descriptionTemplateEntity = this.databaseRepository.getDatasetProfileDao().find(dp.getId()); +// Document document = XmlBuilder.fromXml(descriptionTemplateEntity.getDefinition()); +// XPathFactory xpathFactory = XPathFactory.newInstance(); +// XPath xpath = xpathFactory.newXPath(); +// XPathExpression expr = xpath.compile("//rdaCommonStandard"); +// NodeList rdaProperties = (NodeList) expr.evaluate(document, XPathConstants.NODESET); +// for(int i = 0; i < rdaProperties.getLength(); i++){ +// Node rdaPropertyNode = rdaProperties.item(i); +// String rdaProperty = rdaPropertyNode.getTextContent(); +// Element schematics = document.createElement("schematics"); +// Node fieldParent = rdaPropertyNode.getParentNode(); +// if(rdaProperty != null && !rdaProperty.isEmpty()){ +// Element schematic = document.createElement("schematic"); +// schematic.setTextContent("rda." + rdaProperty); +// schematics.appendChild(schematic); +// } +// fieldParent.insertBefore(schematics, rdaPropertyNode); +// fieldParent.removeChild(rdaPropertyNode); +// } +// this.updateDatasetProfileXml(document, descriptionTemplateEntity); +// } } public void addRdaInSemanticsInDatasetProfiles() throws XPathExpressionException, InvalidApplicationException { - List ids = this.databaseRepository.getDatasetProfileDao().getAllIds(); - for(DescriptionTemplateEntity dp: ids){ - DescriptionTemplateEntity descriptionTemplateEntity = this.databaseRepository.getDatasetProfileDao().find(dp.getId()); - Document document = XmlBuilder.fromXml(descriptionTemplateEntity.getDefinition()); - XPathFactory xpathFactory = XPathFactory.newInstance(); - XPath xpath = xpathFactory.newXPath(); - XPathExpression expr = xpath.compile("//schematic"); - NodeList schematics = (NodeList) expr.evaluate(document, XPathConstants.NODESET); - for (int i = 0; i < schematics.getLength(); i++) { - Node schematicNode = schematics.item(i); - String schematicRda = schematicNode.getTextContent(); - if (schematicRda != null && !schematicRda.isEmpty() && !schematicRda.startsWith("rda.")) { - schematicNode.setTextContent("rda." + schematicRda); - } - } - this.updateDatasetProfileXml(document, descriptionTemplateEntity); - } +// List ids = this.databaseRepository.getDatasetProfileDao().getAllIds(); +// for(DescriptionTemplateEntity dp: ids){ +// DescriptionTemplateEntity descriptionTemplateEntity = this.databaseRepository.getDatasetProfileDao().find(dp.getId()); +// Document document = XmlBuilder.fromXml(descriptionTemplateEntity.getDefinition()); +// XPathFactory xpathFactory = XPathFactory.newInstance(); +// XPath xpath = xpathFactory.newXPath(); +// XPathExpression expr = xpath.compile("//schematic"); +// NodeList schematics = (NodeList) expr.evaluate(document, XPathConstants.NODESET); +// for (int i = 0; i < schematics.getLength(); i++) { +// Node schematicNode = schematics.item(i); +// String schematicRda = schematicNode.getTextContent(); +// if (schematicRda != null && !schematicRda.isEmpty() && !schematicRda.startsWith("rda.")) { +// schematicNode.setTextContent("rda." + schematicRda); +// } +// } +// this.updateDatasetProfileXml(document, descriptionTemplateEntity); +// } } private void updateDatasetProfileXml(Document document, DescriptionTemplateEntity descriptionTemplateEntity) { - try { - DOMSource domSource = new DOMSource(document); - StringWriter writer = new StringWriter(); - StreamResult result = new StreamResult(writer); - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.transform(domSource, result); - String newDefinition = writer.toString(); - if(newDefinition != null){ - descriptionTemplateEntity.setDefinition(newDefinition); - this.databaseRepository.getDatasetProfileDao().createOrUpdate(descriptionTemplateEntity); - } - } - catch(TransformerException ex) { - logger.error(ex.getMessage(), ex); - } +// try { +// DOMSource domSource = new DOMSource(document); +// StringWriter writer = new StringWriter(); +// StreamResult result = new StreamResult(writer); +// TransformerFactory tf = TransformerFactory.newInstance(); +// Transformer transformer = tf.newTransformer(); +// transformer.setOutputProperty(OutputKeys.INDENT, "yes"); +// transformer.transform(domSource, result); +// String newDefinition = writer.toString(); +// if(newDefinition != null){ +// descriptionTemplateEntity.setDefinition(newDefinition); +// this.databaseRepository.getDatasetProfileDao().createOrUpdate(descriptionTemplateEntity); +// } +// } +// catch(TransformerException ex) { +// logger.error(ex.getMessage(), ex); +// } } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetWizardManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetWizardManager.java index f290235e6..bbd1eb986 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetWizardManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetWizardManager.java @@ -4,30 +4,21 @@ import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DmpStatus; import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.scope.user.UserScope; -import eu.eudat.data.DmpEntity; -import eu.eudat.data.dao.criteria.DatasetProfileCriteria; -import eu.eudat.data.dao.entities.DMPDao; -import eu.eudat.data.dao.entities.DatasetProfileDao; import eu.eudat.data.DescriptionEntity; -import eu.eudat.data.DescriptionTemplateEntity; +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.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest; import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException; import eu.eudat.logic.services.ApiContext; import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel; -import eu.eudat.models.data.dmp.AssociatedProfile; -import eu.eudat.models.data.dmp.DataManagementPlan; -import eu.eudat.query.DmpDescriptionTemplateQuery; import eu.eudat.queryable.QueryableList; import gr.cite.tools.data.query.QueryFactory; import javax.management.InvalidApplicationException; import java.io.IOException; -import java.util.LinkedList; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; public class DatasetWizardManager { @@ -40,20 +31,20 @@ public class DatasetWizardManager { return dataManagementPlans; } - public static List getAvailableProfiles(DMPDao dmpRepository, DatasetProfileDao profileDao, DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest) throws InstantiationException, IllegalAccessException, InvalidApplicationException { - DataManagementPlan dataManagementPlan = new DataManagementPlan().fromDataModel(dmpRepository.find(datasetProfileWizardAutocompleteRequest.getCriteria().getId())); - if (dataManagementPlan.getProfiles() == null || dataManagementPlan.getProfiles().isEmpty()) { - return new LinkedList<>(); - } - DatasetProfileCriteria criteria = new DatasetProfileCriteria(); - criteria.setIds(dataManagementPlan.getProfiles().stream().map(AssociatedProfile::getDescriptionTemplateId).collect(Collectors.toList())); - List descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList(); - criteria.setIds(null); - criteria.setGroupIds(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getGroupId).collect(Collectors.toList())); - descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList(); - List profiles = descriptionTemplateEntities.stream().map(profile -> new AssociatedProfile().fromData(profile)).collect(Collectors.toList()); - return profiles; - } +// public static List getAvailableProfiles(DMPDao dmpRepository, DatasetProfileDao profileDao, DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest) throws InstantiationException, IllegalAccessException, InvalidApplicationException { +// DataManagementPlan dataManagementPlan = new DataManagementPlan().fromDataModel(dmpRepository.find(datasetProfileWizardAutocompleteRequest.getCriteria().getId())); +// if (dataManagementPlan.getProfiles() == null || dataManagementPlan.getProfiles().isEmpty()) { +// return new LinkedList<>(); +// } +// DatasetProfileCriteria criteria = new DatasetProfileCriteria(); +// criteria.setIds(dataManagementPlan.getProfiles().stream().map(AssociatedProfile::getDescriptionTemplateId).collect(Collectors.toList())); +// List descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList(); +// criteria.setIds(null); +// criteria.setGroupIds(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getGroupId).collect(Collectors.toList())); +// descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList(); +// List profiles = descriptionTemplateEntities.stream().map(profile -> new AssociatedProfile().fromData(profile)).collect(Collectors.toList()); +// return profiles; +// } public void unlock(ApiContext apiContext, QueryFactory queryFactory, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException { DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MetricsManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MetricsManager.java index cecf1c854..09f3eb684 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MetricsManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MetricsManager.java @@ -388,7 +388,8 @@ public class MetricsManager { DatasetProfileCriteria criteria = new DatasetProfileCriteria(); criteria.setStatus(0); if (countNexus) criteria.setPeriodStart(getNexusDate()); - return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).count(); + return 0; + //return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).count(); } public long countAllFinalizedTemplates() throws InvalidApplicationException { @@ -399,7 +400,8 @@ public class MetricsManager { DatasetProfileCriteria criteria = new DatasetProfileCriteria(); criteria.setStatus(1); if (countNexus) criteria.setPeriodStart(getNexusDate()); - return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).count(); + return 0; +// return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).count(); } @Transactional @@ -413,10 +415,11 @@ public class MetricsManager { criteria.setStatus(1); criteria.setAllVersions(false); if (countNexus) criteria.setPeriodStart(getNexusDate()); - List descriptionTemplateEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList(); - DatasetCriteria datasetCriteria = new DatasetCriteria(); - datasetCriteria.setDatasetTemplates(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getId).collect(Collectors.toList())); - return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getDescriptionTemplateId()).stream().distinct().count(); +// List descriptionTemplateEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList(); +// DatasetCriteria datasetCriteria = new DatasetCriteria(); +// datasetCriteria.setDatasetTemplates(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getId).collect(Collectors.toList())); +// return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getDescriptionTemplateId()).stream().distinct().count(); + return 0; } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/prefilling/PrefillingMapper.java b/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/prefilling/PrefillingMapper.java index 1188abbc8..285d6eee1 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/prefilling/PrefillingMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/prefilling/PrefillingMapper.java @@ -16,7 +16,6 @@ import eu.eudat.service.remotefetcher.config.entities.PrefillingMapping; import eu.eudat.utilities.helpers.StreamDistinctBy; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity; -import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.service.remotefetcher.models.ExternalAutocompleteFieldResult; import org.json.JSONObject; @@ -47,7 +46,7 @@ public class PrefillingMapper { public DatasetWizardModel mapPrefilledEntityToDatasetWizard(Map prefilledEntity, PrefillingGet prefillingGet, String type, DescriptionTemplateEntity profile, DatasetManager datasetManager /*, LicenseManager licenseManager*/) throws Exception { DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); - datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile)); +// datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile)); DescriptionEntity descriptionEntity = new DescriptionEntity(); //descriptionEntity.setDescriptionTemplateId(profile.getId()); //TODO Map properties = new HashMap<>(); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepository.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepository.java index a40b22b59..b7aaab44e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepository.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepository.java @@ -7,7 +7,6 @@ public interface DatabaseRepository { DatasetDao getDatasetDao(); - DatasetProfileDao getDatasetProfileDao(); DMPDao getDmpDao(); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepositoryImpl.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepositoryImpl.java index 01aa379cd..b184a85aa 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepositoryImpl.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepositoryImpl.java @@ -10,7 +10,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository { private DatasetDao datasetDao; - private DatasetProfileDao datasetProfileDao; private DMPDao dmpDao; @@ -26,11 +25,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository { this.datasetDao = datasetDao; } - @Autowired - private void setDatasetProfileDao(DatasetProfileDao datasetProfileDao) { - this.datasetProfileDao = datasetProfileDao; - } - @Autowired private void setDmpDao(DMPDao dmpDao) { this.dmpDao = dmpDao; @@ -43,11 +37,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository { return datasetDao; } - @Override - public DatasetProfileDao getDatasetProfileDao() { - return datasetProfileDao; - } - @Override public DMPDao getDmpDao() { return dmpDao; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dashboard/recent/model/RecentActivityModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dashboard/recent/model/RecentActivityModel.java index 6451a01ca..5b1066e42 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dashboard/recent/model/RecentActivityModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dashboard/recent/model/RecentActivityModel.java @@ -2,7 +2,6 @@ package eu.eudat.models.data.dashboard.recent.model; import eu.eudat.model.DmpUser; import eu.eudat.models.DataModel; -import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.data.old.queryableentity.DataEntity; import java.util.Date; @@ -18,7 +17,6 @@ public abstract class RecentActivityModel users; private Boolean isPublic; @@ -95,14 +93,6 @@ public abstract class RecentActivityModel { @@ -19,7 +17,6 @@ public class Dataset implements DataModel { private String properties; private Date created; private DataManagementPlan dmp; - private DatasetProfileListingModel profile; public UUID getId() { return id; @@ -94,14 +91,6 @@ public class Dataset implements DataModel { this.dmp = dmp; } - public DatasetProfileListingModel getProfile() { - return profile; - } - - public void setProfile(DatasetProfileListingModel profile) { - this.profile = profile; - } - public Dataset fromDataModel(DescriptionEntity entity) { //TODO // this.id = entity.getId(); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dataset/DatasetOverviewModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dataset/DatasetOverviewModel.java index 6b8a3752c..08f79bfb9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dataset/DatasetOverviewModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dataset/DatasetOverviewModel.java @@ -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.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel; import java.time.Instant; @@ -16,7 +15,6 @@ public class DatasetOverviewModel implements DataModel users; private DataManagementPlanOverviewModel dmp; private String description; @@ -45,13 +43,6 @@ public class DatasetOverviewModel implements DataModel getUsers() { return users; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileAutocompleteItem.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileAutocompleteItem.java deleted file mode 100644 index 668a3df85..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileAutocompleteItem.java +++ /dev/null @@ -1,55 +0,0 @@ -package eu.eudat.models.data.datasetprofile; - -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.models.DataModel; - -import java.util.UUID; - - -public class DatasetProfileAutocompleteItem implements DataModel { - - private UUID id; - private String label; - private String description; - - public UUID getId() { - return id; - } - public void setId(UUID id) { - this.id = id; - } - - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } - - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - @Override - public DatasetProfileAutocompleteItem fromDataModel(DescriptionTemplateEntity entity) { - this.id = entity.getId(); - this.label = entity.getLabel(); - this.description = entity.getDescription(); - return this; - } - - @Override - public DescriptionTemplateEntity toDataModel() { - DescriptionTemplateEntity profile = new DescriptionTemplateEntity(); - profile.setId(this.id); - return profile; - } - - @Override - public String getHint() { - return null; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileListingModel.java deleted file mode 100644 index ede623854..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileListingModel.java +++ /dev/null @@ -1,92 +0,0 @@ -package eu.eudat.models.data.datasetprofile; - -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.models.DataModel; - -import java.util.Date; -import java.util.UUID; - -public class DatasetProfileListingModel implements DataModel { - - private UUID id; - private String label; - private Short status; - private Date created; - private Date modified = new Date(); - private String description; - private Short version; - private UUID groupId; - - 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 Short getStatus() { - return status; - } - public void setStatus(Short status) { - this.status = status; - } - - public Date getCreated() { - return created; - } - public void setCreated(Date created) { - this.created = created; - } - - public Date getModified() { - return modified; - } - public void setModified(Date modified) { - this.modified = modified; - } - - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - public Short getVersion() { return version; } - public void setVersion(Short version) { this.version = version; } - - public UUID getGroupId() { return groupId; } - public void setGroupId(UUID groupId) { this.groupId = groupId; } - - @Override - public DatasetProfileListingModel fromDataModel(DescriptionTemplateEntity entity) { - this.id = entity.getId(); - this.label = entity.getLabel(); - this.status = entity.getStatus().getValue(); - this.created = Date.from(entity.getCreatedAt()); - this.modified = Date.from(entity.getUpdatedAt()); - this.description = entity.getDescription(); - this.version = entity.getVersion(); - this.groupId = entity.getGroupId(); - return this; - } - - @Override - public DescriptionTemplateEntity toDataModel() { - DescriptionTemplateEntity profile = new DescriptionTemplateEntity(); - profile.setId(this.id); - return profile; - } - - @Override - public String getHint() { - return null; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileOverviewModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileOverviewModel.java deleted file mode 100644 index 30643f1a8..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileOverviewModel.java +++ /dev/null @@ -1,45 +0,0 @@ -package eu.eudat.models.data.datasetprofile; - -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.models.DataModel; - -import java.util.UUID; - -public class DatasetProfileOverviewModel implements DataModel { - private UUID id; - private String label; - - 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; - } - - @Override - public DatasetProfileOverviewModel fromDataModel(DescriptionTemplateEntity entity) { - this.id = entity.getId(); - this.label = entity.getLabel(); - return this; - } - - @Override - public DescriptionTemplateEntity toDataModel() { - DescriptionTemplateEntity entity = new DescriptionTemplateEntity(); - entity.setId(this.getId()); - entity.setLabel(this.getLabel()); - return entity; - } - - @Override - public String getHint() { - return null; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetwizard/DatasetWizardModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetwizard/DatasetWizardModel.java index d6fb42fb1..d7eaa85e4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetwizard/DatasetWizardModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetwizard/DatasetWizardModel.java @@ -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.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.dmp.DataManagementPlan; import eu.eudat.models.data.user.composite.PagedDatasetProfile; @@ -25,7 +24,6 @@ public class DatasetWizardModel implements DataModel tags; //TODO - private DatasetProfileOverviewModel profile; private Boolean isProfileLatestVersion; private Instant modified; @@ -100,14 +98,6 @@ public class DatasetWizardModel implements DataModel getTags() { // return tags; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DatasetListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DatasetListingModel.java index 5d755024a..9dca7f902 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DatasetListingModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DatasetListingModel.java @@ -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.datasetprofile.DatasetProfileOverviewModel; import java.time.Instant; import java.util.List; @@ -16,7 +15,6 @@ public class DatasetListingModel implements DataModel