commit
e8aef281d4
@ -0,0 +1,16 @@
|
||||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
|
||||
public class DataManagementPlanBlueprintCriteria extends Criteria<DMPProfile> {
|
||||
|
||||
private Integer status;
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DescriptionTemplateTypeDao extends DatabaseAccessLayer<DescriptionTemplateType, UUID> {
|
||||
DescriptionTemplateType findFromName(String name);
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("descriptionTemplateTypeDao")
|
||||
public class DescriptionTemplateTypeDaoImpl extends DatabaseAccess<DescriptionTemplateType> implements DescriptionTemplateTypeDao {
|
||||
|
||||
@Autowired
|
||||
public DescriptionTemplateTypeDaoImpl(DatabaseService<DescriptionTemplateType> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType findFromName(String name){
|
||||
try {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.and(builder.equal(root.get("name"), name), builder.notEqual(root.get("status"), DescriptionTemplateType.Status.DELETED.getValue()))).getSingle();
|
||||
}
|
||||
catch(Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public DescriptionTemplateType createOrUpdate(DescriptionTemplateType item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DescriptionTemplateType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DescriptionTemplateType item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplateType> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.notEqual((root.get("status")), DescriptionTemplateType.Status.DELETED.getValue()));
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<DescriptionTemplateType> createOrUpdateAsync(DescriptionTemplateType item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DMPDatasetProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DmpDatasetProfileDao extends DatabaseAccessLayer<DMPDatasetProfile, UUID> {
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.Content;
|
||||
import eu.eudat.data.entities.DMPDatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Service("dmpDatasetProfileDao")
|
||||
public class DmpDatasetProfileDaoImpl extends DatabaseAccess<DMPDatasetProfile> implements DmpDatasetProfileDao {
|
||||
@Autowired
|
||||
public DmpDatasetProfileDaoImpl(DatabaseService<DMPDatasetProfile> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile createOrUpdate(DMPDatasetProfile item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DMPDatasetProfile.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public CompletableFuture<DMPDatasetProfile> createOrUpdateAsync(DMPDatasetProfile item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DMPDatasetProfile item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPDatasetProfile> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package eu.eudat.data.entities;
|
||||
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"DMPDatasetProfile\"")
|
||||
public class DMPDatasetProfile implements DataEntity<DMPDatasetProfile, UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"dmp\"")
|
||||
private DMP dmp;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"datasetprofile\"")
|
||||
private DescriptionTemplate datasetprofile;
|
||||
|
||||
@Column(name = "\"data\"")
|
||||
private String data;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DMP getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
public void setDmp(DMP dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public DescriptionTemplate getDatasetprofile() {
|
||||
return datasetprofile;
|
||||
}
|
||||
public void setDatasetprofile(DescriptionTemplate datasetprofile) {
|
||||
this.datasetprofile = datasetprofile;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DMPDatasetProfile entity) {
|
||||
this.dmp = entity.getDmp();
|
||||
this.datasetprofile = entity.getDatasetprofile();
|
||||
this.data = entity.getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package eu.eudat.data.entities;
|
||||
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"DescriptionTemplateType\"")
|
||||
public class DescriptionTemplateType implements DataEntity<DescriptionTemplateType, UUID> {
|
||||
|
||||
public enum Status {
|
||||
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
||||
|
||||
private short value;
|
||||
|
||||
private Status(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
public short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Status fromInteger(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return SAVED;
|
||||
case 1:
|
||||
return FINALIZED;
|
||||
case 99:
|
||||
return DELETED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Description Template Type Status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
@Column(name = "\"Name\"", nullable = false)
|
||||
private String name;
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
private Short status;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DescriptionTemplateType entity) {
|
||||
this.name = entity.name;
|
||||
this.status = entity.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||
this.id = UUID.fromString((String) tuple.get(0).get(!base.isEmpty() ? base + "." + "id" : "id"));
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package eu.eudat.data.query.items.dmpblueprint;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.data.query.PaginationService;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataManagementPlanBlueprintTableRequest extends TableQuery<DataManagementPlanBlueprintCriteria, DMPProfile, UUID> {
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> applyCriteria() {
|
||||
QueryableList<DMPProfile> query = this.getQuery();
|
||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
|
||||
if (this.getCriteria().getStatus() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), this.getCriteria().getStatus()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> applyPaging(QueryableList<DMPProfile> items) {
|
||||
return PaginationService.applyPaging(items, this);
|
||||
}
|
||||
}
|
@ -1,25 +1,24 @@
|
||||
package eu.eudat.data.query.items.item.datasetprofile;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.query.PaginationService;
|
||||
import eu.eudat.data.query.definition.Query;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria,DatasetProfile, UUID> {
|
||||
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
|
||||
@Override
|
||||
public QueryableList<DatasetProfile> applyCriteria() {
|
||||
QueryableList<DatasetProfile> query = this.getQuery();
|
||||
public QueryableList<DescriptionTemplate> applyCriteria() {
|
||||
QueryableList<DescriptionTemplate> 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<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
|
||||
public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
|
||||
return PaginationService.applyPaging(items, this);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package eu.eudat.data.query.items.item.datasetprofile;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileWizardCriteria;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.query.definition.Query;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria,DatasetProfile> {
|
||||
public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria, DescriptionTemplate> {
|
||||
@Override
|
||||
public QueryableList<DatasetProfile> applyCriteria() {
|
||||
public QueryableList<DescriptionTemplate> applyCriteria() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
package eu.eudat.data.query.items.table.datasetprofile;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DatasetProfile, UUID> {
|
||||
public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
|
||||
@Override
|
||||
public QueryableList<DatasetProfile> applyCriteria() {
|
||||
QueryableList<DatasetProfile> query = this.getQuery();
|
||||
public QueryableList<DescriptionTemplate> applyCriteria() {
|
||||
QueryableList<DescriptionTemplate> 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<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
|
||||
public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,94 @@
|
||||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.exceptions.descriptiontemplate.DescriptionTemplatesWithTypeException;
|
||||
import eu.eudat.logic.managers.DescriptionTemplateTypeManager;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.descriptiontemplatetype.DescriptionTemplateTypeModel;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import eu.eudat.types.Authorities;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static eu.eudat.types.Authorities.ADMIN;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/descriptionTemplateType/"})
|
||||
public class DescriptionTemplateTypeController extends BaseController {
|
||||
|
||||
private DescriptionTemplateTypeManager descriptionTemplateTypeManager;
|
||||
|
||||
@Autowired
|
||||
public DescriptionTemplateTypeController(ApiContext apiContext, DescriptionTemplateTypeManager descriptionTemplateTypeManager){
|
||||
super(apiContext);
|
||||
this.descriptionTemplateTypeManager = descriptionTemplateTypeManager;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"create"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> create(@RequestBody DescriptionTemplateTypeModel type, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
try {
|
||||
this.descriptionTemplateTypeManager.create(type);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
}
|
||||
catch(DescriptionTemplatesWithTypeException e){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"update"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> update(@RequestBody DescriptionTemplateTypeModel type, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
try {
|
||||
this.descriptionTemplateTypeManager.update(type);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Updated"));
|
||||
}
|
||||
catch(DescriptionTemplatesWithTypeException e){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"get"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DescriptionTemplateTypeModel>>> get(@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
DataTableData<DescriptionTemplateTypeModel> dataTable = this.descriptionTemplateTypeManager.get();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DescriptionTemplateTypeModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"get/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> getSingle(@PathVariable(value = "id") UUID id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
try {
|
||||
DescriptionTemplateTypeModel typeModel = this.descriptionTemplateTypeManager.getSingle(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.NO_MESSAGE).payload(typeModel));
|
||||
}
|
||||
catch(DescriptionTemplatesWithTypeException e){
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> delete(@PathVariable(value = "id") UUID id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
try{
|
||||
this.descriptionTemplateTypeManager.delete(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted"));
|
||||
}
|
||||
catch(DescriptionTemplatesWithTypeException e){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.UNSUCCESS_DELETE).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package eu.eudat.exceptions.descriptiontemplate;
|
||||
|
||||
public class DescriptionTemplatesWithTypeException extends RuntimeException {
|
||||
|
||||
public DescriptionTemplatesWithTypeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package eu.eudat.exceptions.dmpblueprint;
|
||||
|
||||
public class DmpBlueprintUsedException extends RuntimeException {
|
||||
public DmpBlueprintUsedException() {
|
||||
}
|
||||
|
||||
public DmpBlueprintUsedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DmpBlueprintUsedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DmpBlueprintUsedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,84 @@
|
||||
package eu.eudat.logic.managers;
|
||||
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
import eu.eudat.exceptions.descriptiontemplate.DescriptionTemplatesWithTypeException;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.models.data.descriptiontemplatetype.DescriptionTemplateTypeModel;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class DescriptionTemplateTypeManager {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DescriptionTemplateTypeManager.class);
|
||||
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
public DescriptionTemplateTypeManager(ApiContext apiContext, DatabaseRepository databaseRepository) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = databaseRepository;
|
||||
}
|
||||
|
||||
public DataTableData<DescriptionTemplateTypeModel> get() {
|
||||
List<DescriptionTemplateType> types = this.databaseRepository.getDescriptionTemplateTypeDao().asQueryable().toList();
|
||||
List<DescriptionTemplateTypeModel> typesModelList = types.stream().map(type -> new DescriptionTemplateTypeModel().fromDataModel(type)).collect(Collectors.toList());
|
||||
DataTableData<DescriptionTemplateTypeModel> dataTableData = new DataTableData<>();
|
||||
dataTableData.setData(typesModelList);
|
||||
dataTableData.setTotalCount((long) typesModelList.size());
|
||||
return dataTableData;
|
||||
}
|
||||
|
||||
public DescriptionTemplateTypeModel getSingle(UUID id) throws Exception {
|
||||
DescriptionTemplateType type = this.databaseRepository.getDescriptionTemplateTypeDao().find(id);
|
||||
if (type != null) {
|
||||
return new DescriptionTemplateTypeModel().fromDataModel(type);
|
||||
}
|
||||
else {
|
||||
throw new DescriptionTemplatesWithTypeException("No description template type found with this id");
|
||||
}
|
||||
}
|
||||
|
||||
public void create(DescriptionTemplateTypeModel type) throws Exception {
|
||||
DescriptionTemplateType existed = this.databaseRepository.getDescriptionTemplateTypeDao().findFromName(type.getName());
|
||||
if (existed == null) {
|
||||
this.databaseRepository.getDescriptionTemplateTypeDao().createOrUpdate(type.toDataModel());
|
||||
}
|
||||
else {
|
||||
throw new DescriptionTemplatesWithTypeException("There is already a description template type with that name.");
|
||||
}
|
||||
}
|
||||
|
||||
public void update(DescriptionTemplateTypeModel type) throws Exception {
|
||||
DescriptionTemplateType existed = this.databaseRepository.getDescriptionTemplateTypeDao().findFromName(type.getName());
|
||||
if (existed != null) {
|
||||
this.databaseRepository.getDescriptionTemplateTypeDao().createOrUpdate(type.toDataModel());
|
||||
}
|
||||
else {
|
||||
throw new DescriptionTemplatesWithTypeException("No description template type found.");
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(UUID id) throws DescriptionTemplatesWithTypeException {
|
||||
DescriptionTemplateType type = this.databaseRepository.getDescriptionTemplateTypeDao().find(id);
|
||||
if (type != null) {
|
||||
Long descriptionsWithType = this.databaseRepository.getDatasetProfileDao().countWithType(type);
|
||||
if(descriptionsWithType == 0) {
|
||||
type.setStatus(DescriptionTemplateType.Status.DELETED.getValue());
|
||||
this.databaseRepository.getDescriptionTemplateTypeDao().createOrUpdate(type);
|
||||
}
|
||||
else{
|
||||
throw new DescriptionTemplatesWithTypeException("This type can not deleted, because Descriptions are associated with it");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,26 @@
|
||||
package eu.eudat.logic.mapper.elastic;
|
||||
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.eudat.data.entities.DMPDatasetProfile;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.elastic.entities.DatasetTempalate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DatasetTemplateMapper {
|
||||
|
||||
public static DatasetTempalate toElastic(DatasetProfile profile) {
|
||||
public static DatasetTempalate toElastic(DMPDatasetProfile profile) {
|
||||
DatasetTempalate elastic = new DatasetTempalate();
|
||||
elastic.setId(profile.getId());
|
||||
elastic.setName(profile.getLabel());
|
||||
elastic.setId(profile.getDatasetprofile().getId());
|
||||
elastic.setName(profile.getDatasetprofile().getLabel());
|
||||
try {
|
||||
elastic.setData(new ObjectMapper().readValue(profile.getData(), new TypeReference<Map<String, Object>>() {}));
|
||||
}
|
||||
catch (Exception e){
|
||||
elastic.setData(new HashMap<>());
|
||||
}
|
||||
return elastic;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package eu.eudat.logic.proxy.config;
|
||||
|
||||
public enum AuthType {
|
||||
;
|
||||
private final String name;
|
||||
|
||||
AuthType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static AuthType fromName(String name) {
|
||||
for (AuthType authType : AuthType.values()) {
|
||||
if (authType.getName().equals(name)) {
|
||||
return authType;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("AuthType [" + name + "] is not supported");
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package eu.eudat.logic.proxy.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class AuthenticationConfiguration {
|
||||
|
||||
private String authUrl;
|
||||
private String authMethod = "GET";
|
||||
private String authTokenPath;
|
||||
private String authRequestBody;
|
||||
private String type;
|
||||
|
||||
public String getAuthUrl() {
|
||||
return authUrl;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authUrl")
|
||||
public void setAuthUrl(String authUrl) {
|
||||
this.authUrl = authUrl;
|
||||
}
|
||||
|
||||
public String getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authUrlMethod")
|
||||
public void setAuthMethod(String authMethod) {
|
||||
this.authMethod = authMethod;
|
||||
}
|
||||
|
||||
public String getAuthTokenPath() {
|
||||
return authTokenPath;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authTokenJpath")
|
||||
public void setAuthTokenPath(String authTokenPath) {
|
||||
this.authTokenPath = authTokenPath;
|
||||
}
|
||||
|
||||
public String getAuthRequestBody() {
|
||||
return authRequestBody;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authUrlBody")
|
||||
public void setAuthRequestBody(String authRequestBody) {
|
||||
this.authRequestBody = authRequestBody;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authType")
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package eu.eudat.logic.proxy.config.entities;
|
||||
|
||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
||||
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GeneralUrls extends GenericUrls{
|
||||
|
||||
List<UrlConfiguration> urls;
|
||||
FetchStrategy fetchMode;
|
||||
|
||||
public GeneralUrls() {
|
||||
this.urls = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UrlConfiguration> getUrls() {
|
||||
return urls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getFetchMode() {
|
||||
return fetchMode;
|
||||
}
|
||||
|
||||
public void setFetchMode(FetchStrategy fetchMode) {
|
||||
this.fetchMode = fetchMode;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
||||
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
|
||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint;
|
||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section;
|
||||
import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ExportXmlBuilderDmpBlueprint {
|
||||
|
||||
|
||||
public File build(DataManagementPlanBlueprintListingModel dmpProfile, Environment environment) throws IOException {
|
||||
|
||||
File xmlFile = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".xml");
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true));
|
||||
Document xmlDoc = XmlBuilder.getDocument();
|
||||
Element root = xmlDoc.createElement("root");
|
||||
Element definition = xmlDoc.createElement("definition");
|
||||
// Element root = xmlDoc.createElement(dmpProfile.getLabel());
|
||||
definition.appendChild(createDefinition(dmpProfile.getDefinition(), xmlDoc));
|
||||
root.appendChild(definition);
|
||||
xmlDoc.appendChild(root);
|
||||
String xml = XmlBuilder.generateXml(xmlDoc);
|
||||
writer.write(xml);
|
||||
writer.close();
|
||||
return xmlFile;
|
||||
}
|
||||
|
||||
public Element createDefinition(DataManagementPlanBlueprint dmpDefinition, Document doc) {
|
||||
Element sections = doc.createElement("sections");
|
||||
for (Section section : dmpDefinition.getSections()) {
|
||||
sections.appendChild(section.toXml(doc));
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
||||
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
|
||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
||||
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ExportXmlBuilderDmpProfile {
|
||||
|
||||
|
||||
public File build(DataManagementPlanProfileListingModel dmpProfile, Environment environment) throws IOException {
|
||||
|
||||
File xmlFile = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".xml");
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true));
|
||||
Document xmlDoc = XmlBuilder.getDocument();
|
||||
Element root = xmlDoc.createElement("root");
|
||||
Element definition = xmlDoc.createElement("definition");
|
||||
// Element root = xmlDoc.createElement(dmpProfile.getLabel());
|
||||
definition.appendChild(createDefinition(dmpProfile.getDefinition(), xmlDoc));
|
||||
root.appendChild(definition);
|
||||
xmlDoc.appendChild(root);
|
||||
String xml = XmlBuilder.generateXml(xmlDoc);
|
||||
writer.write(xml);
|
||||
writer.close();
|
||||
return xmlFile;
|
||||
}
|
||||
|
||||
public Element createDefinition(DataManagementPlanProfile dmpDefinition, Document element) {
|
||||
Element fields = element.createElement("fieldSets");
|
||||
dmpDefinition.getFields().forEach(item -> {
|
||||
Element field = element.createElement("field");
|
||||
field.setAttribute("id", "" + item.getId());
|
||||
field.setAttribute("type", "" + item.getType());
|
||||
field.setAttribute("dataType", "" + item.getDataType());
|
||||
field.setAttribute("required", "" + item.getRequired());
|
||||
field.setAttribute("label", "" + item.getLabel());
|
||||
if(item.getValue()!=null) {
|
||||
Element value = element.createElement("value");
|
||||
value.setAttribute("value", ""+item.getValue());
|
||||
field.appendChild(value);
|
||||
}
|
||||
fields.appendChild(field);
|
||||
});
|
||||
return fields;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
||||
|
||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.UUID;
|
||||
|
||||
@XmlRootElement(name = "descriptionTemplate")
|
||||
public class DescriptionTemplate {
|
||||
|
||||
private String id;
|
||||
private String descriptionTemplateId;
|
||||
private String label;
|
||||
private Integer minMultiplicity;
|
||||
private Integer maxMultiplicity;
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "descriptionTemplateId")
|
||||
public String getDescriptionTemplateId() {
|
||||
return descriptionTemplateId;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplateId(String descriptionTemplateId) {
|
||||
this.descriptionTemplateId = descriptionTemplateId;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "label")
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "minMultiplicity")
|
||||
public Integer getMinMultiplicity() {
|
||||
return minMultiplicity;
|
||||
}
|
||||
|
||||
public void setMinMultiplicity(Integer minMultiplicity) {
|
||||
this.minMultiplicity = minMultiplicity;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "maxMultiplicity")
|
||||
public Integer getMaxMultiplicity() {
|
||||
return maxMultiplicity;
|
||||
}
|
||||
|
||||
public void setMaxMultiplicity(Integer maxMultiplicity) {
|
||||
this.maxMultiplicity = maxMultiplicity;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate toDmpBlueprintCompositeModel() {
|
||||
eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate descriptionTemplate = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate();
|
||||
descriptionTemplate.setId(UUID.fromString(this.id));
|
||||
descriptionTemplate.setDescriptionTemplateId(UUID.fromString(this.descriptionTemplateId));
|
||||
descriptionTemplate.setLabel(this.label);
|
||||
descriptionTemplate.setMinMultiplicity(this.minMultiplicity);
|
||||
descriptionTemplate.setMaxMultiplicity(this.maxMultiplicity);
|
||||
return descriptionTemplate;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "descriptionTemplates")
|
||||
public class DescriptionTemplates {
|
||||
|
||||
private List<DescriptionTemplate> descriptionTemplates;
|
||||
|
||||
@XmlElement(name = "descriptionTemplate")
|
||||
public List<DescriptionTemplate> getDescriptionTemplates() {
|
||||
return descriptionTemplates;
|
||||
}
|
||||
public void setDescriptionTemplates(List<DescriptionTemplate> descriptionTemplates) {
|
||||
this.descriptionTemplates = descriptionTemplates;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue