remove old code
This commit is contained in:
parent
aebc6056f9
commit
2f48b3bae2
|
@ -18,7 +18,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DescriptionTemplate\"")
|
||||
public class DescriptionTemplateEntity extends TenantScopedBaseEntity implements DataEntity<DescriptionTemplateEntity,UUID>{
|
||||
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> tuple, List<String> fields, String base) {
|
||||
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<DescriptionTemplateEntity, UUID> {
|
||||
|
||||
QueryableList<DescriptionTemplateEntity> getWithCriteria(DatasetProfileCriteria criteria);
|
||||
|
||||
QueryableList<DescriptionTemplateEntity> getAll();
|
||||
|
||||
QueryableList<DescriptionTemplateEntity> getAuthenticated(QueryableList<DescriptionTemplateEntity> query, UUID principal, List<Integer> roles);
|
||||
|
||||
List<DescriptionTemplateEntity> getAllIds() throws InvalidApplicationException;
|
||||
|
||||
Long countWithType(DescriptionTemplateTypeEntity type) throws InvalidApplicationException;
|
||||
|
||||
}
|
|
@ -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<DescriptionTemplateEntity> implements DatasetProfileDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetProfileDaoImpl(DatabaseService<DescriptionTemplateEntity> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplateEntity> getWithCriteria(DatasetProfileCriteria criteria) {
|
||||
QueryableList<DescriptionTemplateEntity> 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<DescriptionTemplateEntity> getAll() {
|
||||
return getDatabaseService().getQueryable(DescriptionTemplateEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DescriptionTemplateEntity> 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<DescriptionTemplateEntity> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplateEntity.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<DescriptionTemplateEntity> createOrUpdateAsync(DescriptionTemplateEntity item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateEntity find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplateEntity> getAuthenticated(QueryableList<DescriptionTemplateEntity> 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
|
||||
public Long countWithType(DescriptionTemplateTypeEntity type) throws InvalidApplicationException {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplateEntity.class).where((builder, root) -> builder.equal(root.get("type"), type)).count();
|
||||
}
|
||||
}
|
|
@ -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<DatasetProfileCriteria, DescriptionTemplateEntity, UUID> {
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplateEntity> applyCriteria() {
|
||||
QueryableList<DescriptionTemplateEntity> 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<DescriptionTemplateEntity> applyPaging(QueryableList<DescriptionTemplateEntity> items) {
|
||||
return PaginationService.applyPaging(items, this);
|
||||
}
|
||||
}
|
|
@ -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<DatasetProfileWizardCriteria, DescriptionTemplateEntity> {
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplateEntity> applyCriteria() {
|
||||
return 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<DatasetProfileCriteria, DescriptionTemplateEntity, UUID> {
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplateEntity> applyCriteria() {
|
||||
QueryableList<DescriptionTemplateEntity> 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<DescriptionTemplateEntity> applyPaging(QueryableList<DescriptionTemplateEntity> items) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -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<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.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
|
||||
|
|
|
@ -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<Object> updateDataset(@PathVariable String id, @RequestBody PropertiesModel properties) {
|
||||
eu.eudat.data.Dataset dataset = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(id));
|
||||
Map<String, Object> 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<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> 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<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
|
||||
// }
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody RequestItem<AutoCompleteLookupItem> 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<ExternalAutocompleteFieldResult> 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<Object> getDataForAutocompleteOptions(@RequestBody RequestItem<AutoCompleteOptionsLookupItem> lookupItem) {
|
||||
AutoCompleteDataEntity data = new AutoCompleteDataEntity();
|
||||
data.setAutoCompleteSingleDataList(lookupItem.getCriteria().getAutoCompleteSingleDataList());
|
||||
List<ExternalAutocompleteFieldResult> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(items);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) throws Exception {
|
||||
// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
||||
//
|
||||
// DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
|
||||
// public @ResponseBody
|
||||
// ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPublicPaged(@RequestBody DatasetPublicTableRequest datasetTableRequest) throws Exception {
|
||||
// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
|
||||
//
|
||||
// DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().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<DatasetOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||
// } catch (Exception e) {
|
||||
// if (e instanceof UnauthorisedException) {
|
||||
// return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
// } else {
|
||||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
|
||||
// public @ResponseBody
|
||||
// ResponseEntity<ResponseItem<DatasetOverviewModel>> 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<DatasetOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||
//// } catch (Exception ex) {
|
||||
//// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().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<DatasetWizardModel>().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<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
} else if (e instanceof NoResultException) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDatasets/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.datasetManager.getDatasetProfilesUsedByDatasets(datasetProfileTableRequestItem);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||
// }
|
||||
|
||||
// @RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json")
|
||||
// public @ResponseBody
|
||||
// ResponseEntity<ResponseItem<List<DataManagentPlanListingModel>>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
|
||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||
//
|
||||
// List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, this.userScope);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataManagentPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans));
|
||||
// }
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<AssociatedProfile>>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
|
||||
this.authorizationService.authorizeForce(Permission.AnonymousRole);
|
||||
|
||||
List<AssociatedProfile> dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileWizardAutocompleteRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<AssociatedProfile>>().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<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||
// }
|
||||
// catch (Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||
// }
|
||||
// }
|
||||
|
||||
// @RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json")
|
||||
// public ResponseEntity<ResponseItem<PagedDatasetProfile>> 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<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
|
||||
// }
|
||||
|
||||
/*
|
||||
* Data Export
|
||||
* */
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<byte[]> 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<ResponseItem<DatasetWizardModel>> 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<DatasetWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dataset));
|
||||
// }
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionEntity>> 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<DescriptionEntity>().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<ResponseItem<DescriptionEntity>> 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<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted"));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/unlock"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionEntity>> 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<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
||||
} catch (DatasetWizardCannotUnlockException datasetWizardCannotUnlockException) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/validate"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Boolean>> 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<Boolean>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Valid"));
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Boolean>().status(ApiMessageCode.ERROR_MESSAGE).message("Field value of " + failedField + " must be filled."));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Data Import
|
||||
* */
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||
public ResponseEntity<ResponseItem> 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<ResponseItem<DescriptionEntity>> generateIndex() throws Exception {
|
||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||
|
||||
this.datasetManager.generateIndex();
|
||||
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.datasetManager.clearIndex(); //TODO
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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<DatasetProfileListingModel> getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException {
|
||||
datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue());
|
||||
datasetProfileTableRequestItem.getCriteria().setUserId(this.userScope.getUserId());
|
||||
|
||||
QueryableList<eu.eudat.data.DescriptionTemplateEntity> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
||||
List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
|
||||
|
||||
DataTableData<DatasetProfileListingModel> data = new DataTableData<>();
|
||||
data.setData(listingModels);
|
||||
data.setTotalCount((long) listingModels.size());
|
||||
|
||||
return data;
|
||||
}
|
||||
// public DataTableData<DatasetProfileListingModel> getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException {
|
||||
// datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue());
|
||||
// datasetProfileTableRequestItem.getCriteria().setUserId(this.userScope.getUserId());
|
||||
//
|
||||
// QueryableList<eu.eudat.data.DescriptionTemplateEntity> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
||||
// List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
|
||||
//
|
||||
// DataTableData<DatasetProfileListingModel> data = new DataTableData<>();
|
||||
// data.setData(listingModels);
|
||||
// data.setTotalCount((long) listingModels.size());
|
||||
//
|
||||
// return data;
|
||||
// }
|
||||
|
||||
public List<VersionListingModel> 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<String, Object> data = new HashMap<>();
|
||||
List<Integer> 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<String, Object> data = new HashMap<>();
|
||||
// List<Integer> sections = new ArrayList<>(a.getSection());
|
||||
// data.put("dmpSectionIndex", sections);
|
||||
// associatedProfile.setData(data);
|
||||
// associatedProfiles.add(associatedProfile);
|
||||
// } catch (Exception ignored) {
|
||||
// }
|
||||
// }
|
||||
|
||||
// List<eu.eudat.models.data.dmp.Organisation> organisations = new ArrayList<>();
|
||||
// for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) {
|
||||
|
|
|
@ -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<DescriptionTemplateEntity> profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria)
|
||||
.orderBy(((builder, root) -> builder.desc(root.get("version"))))
|
||||
.toList();
|
||||
List<DescriptionTemplateEntity> profileVersions = null;
|
||||
// List<DescriptionTemplateEntity> profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria)
|
||||
// .orderBy(((builder, root) -> builder.desc(root.get("version"))))
|
||||
// .toList();
|
||||
List<DescriptionTemplateEntity> 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<String> 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<DatasetProfileListingModel> getDatasetProfilesUsedByDatasets(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException {
|
||||
datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue());
|
||||
datasetProfileTableRequestItem.getCriteria().setUserId(this.userScope.getUserId());
|
||||
|
||||
QueryableList<DescriptionTemplateEntity> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
||||
List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
|
||||
|
||||
DataTableData<DatasetProfileListingModel> data = new DataTableData<>();
|
||||
data.setData(listingModels);
|
||||
data.setTotalCount((long) listingModels.size());
|
||||
|
||||
return data;
|
||||
}
|
||||
// public DataTableData<DatasetProfileListingModel> getDatasetProfilesUsedByDatasets(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException {
|
||||
// datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue());
|
||||
// datasetProfileTableRequestItem.getCriteria().setUserId(this.userScope.getUserId());
|
||||
//
|
||||
// QueryableList<DescriptionTemplateEntity> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
||||
// List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
|
||||
//
|
||||
// DataTableData<DatasetProfileListingModel> data = new DataTableData<>();
|
||||
// data.setData(listingModels);
|
||||
// data.setTotalCount((long) listingModels.size());
|
||||
//
|
||||
// return data;
|
||||
// }
|
||||
|
||||
public void generateIndex() throws InvalidApplicationException {
|
||||
if (this.authorizationService.authorize(Permission.AdminRole)) {
|
||||
|
|
|
@ -218,68 +218,68 @@ public class DatasetProfileManager {
|
|||
}
|
||||
|
||||
public void addSemanticsInDatasetProfiles() throws XPathExpressionException, InvalidApplicationException {
|
||||
List<DescriptionTemplateEntity> 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<DescriptionTemplateEntity> 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<DescriptionTemplateEntity> 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<DescriptionTemplateEntity> 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);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<AssociatedProfile> 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<DescriptionTemplateEntity> descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList();
|
||||
criteria.setIds(null);
|
||||
criteria.setGroupIds(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getGroupId).collect(Collectors.toList()));
|
||||
descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList();
|
||||
List<AssociatedProfile> profiles = descriptionTemplateEntities.stream().map(profile -> new AssociatedProfile().fromData(profile)).collect(Collectors.toList());
|
||||
return profiles;
|
||||
}
|
||||
// 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()));
|
||||
// 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<DescriptionTemplateEntity> descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList();
|
||||
// criteria.setIds(null);
|
||||
// criteria.setGroupIds(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getGroupId).collect(Collectors.toList()));
|
||||
// descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList();
|
||||
// List<AssociatedProfile> 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);
|
||||
|
|
|
@ -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<DescriptionTemplateEntity> 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<DescriptionTemplateEntity> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String, Object> 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<String, Object> properties = new HashMap<>();
|
||||
|
|
|
@ -7,7 +7,6 @@ public interface DatabaseRepository {
|
|||
|
||||
DatasetDao getDatasetDao();
|
||||
|
||||
DatasetProfileDao getDatasetProfileDao();
|
||||
|
||||
DMPDao getDmpDao();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<T extends DataEntity, S extends DataMo
|
|||
private String grant;
|
||||
private Date finalizedAt;
|
||||
private Date publishedAt;
|
||||
private DatasetProfileOverviewModel profile;
|
||||
private int type;
|
||||
private List<DmpUser> users;
|
||||
private Boolean isPublic;
|
||||
|
@ -95,14 +93,6 @@ public abstract class RecentActivityModel<T extends DataEntity, S extends DataMo
|
|||
this.publishedAt = publishedAt;
|
||||
}
|
||||
|
||||
public DatasetProfileOverviewModel getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(DatasetProfileOverviewModel profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -2,11 +2,9 @@ package eu.eudat.models.data.dataset;
|
|||
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Dataset implements DataModel<DescriptionEntity, Dataset> {
|
||||
|
@ -19,7 +17,6 @@ public class Dataset implements DataModel<DescriptionEntity, Dataset> {
|
|||
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<DescriptionEntity, Dataset> {
|
|||
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();
|
||||
|
|
|
@ -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<DescriptionEntity, Datase
|
|||
private UUID id;
|
||||
private String label;
|
||||
private DescriptionStatus status;
|
||||
private DatasetProfileOverviewModel datasetTemplate;
|
||||
private List<DmpUser> users;
|
||||
private DataManagementPlanOverviewModel dmp;
|
||||
private String description;
|
||||
|
@ -45,13 +43,6 @@ public class DatasetOverviewModel implements DataModel<DescriptionEntity, Datase
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
public DatasetProfileOverviewModel getDatasetTemplate() {
|
||||
return datasetTemplate;
|
||||
}
|
||||
public void setDatasetTemplate(DatasetProfileOverviewModel datasetTemplate) {
|
||||
this.datasetTemplate = datasetTemplate;
|
||||
}
|
||||
|
||||
public List<DmpUser> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
|
|
@ -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<DescriptionTemplateEntity, DatasetProfileAutocompleteItem> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<DescriptionTemplateEntity, DatasetProfileListingModel> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<DescriptionTemplateEntity, DatasetProfileOverviewModel> {
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<DescriptionEntity, DatasetW
|
|||
private Integer dmpSectionIndex;
|
||||
private PagedDatasetProfile datasetProfileDefinition;
|
||||
// private List<Tag> tags; //TODO
|
||||
private DatasetProfileOverviewModel profile;
|
||||
private Boolean isProfileLatestVersion;
|
||||
private Instant modified;
|
||||
|
||||
|
@ -100,14 +98,6 @@ public class DatasetWizardModel implements DataModel<DescriptionEntity, DatasetW
|
|||
}
|
||||
|
||||
|
||||
public DatasetProfileOverviewModel getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(DatasetProfileOverviewModel profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
|
||||
// public List<Tag> getTags() {
|
||||
// return tags;
|
||||
|
|
|
@ -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<DescriptionEntity, Dataset
|
|||
private String grant;
|
||||
private String dmp;
|
||||
private String dmpId;
|
||||
private DatasetProfileOverviewModel profile;
|
||||
private DescriptionStatus status;
|
||||
private Instant created;
|
||||
private Instant modified;
|
||||
|
@ -62,14 +60,6 @@ public class DatasetListingModel implements DataModel<DescriptionEntity, Dataset
|
|||
this.dmpId = dmpId;
|
||||
}
|
||||
|
||||
public DatasetProfileOverviewModel getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(DatasetProfileOverviewModel profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public DescriptionStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -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.datasetprofile.DatasetProfileOverviewModel;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||
|
@ -28,7 +27,7 @@ public class DatasetDescriptionQuickWizardModel extends PagedDatasetProfile {
|
|||
DatasetWizardModel newDataset = new DatasetWizardModel();
|
||||
newDataset.setLabel(datasetLabel);
|
||||
newDataset.setCreated(Instant.now());
|
||||
newDataset.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
||||
// newDataset.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
||||
newDataset.setDmp(dmp);
|
||||
newDataset.setStatus(DescriptionStatus.of((short)this.getStatus()));
|
||||
//newDataset.setStatus(Dataset.Status.SAVED.getValue());
|
||||
|
|
|
@ -290,7 +290,7 @@ public class DatasetRDAMapper {
|
|||
entity.setLabel(rda.getTitle());
|
||||
entity.setDescription(rda.getDescription());
|
||||
try {
|
||||
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString()));
|
||||
//DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString()));
|
||||
//entity.setDescriptionTemplateId(profile.getId()); //TODO
|
||||
}catch(Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
|
|
Loading…
Reference in New Issue