no message
This commit is contained in:
parent
04389b0613
commit
d44052299a
|
@ -21,7 +21,6 @@ import javax.transaction.Transactional;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@RequestMapping(value = {"/datasetwizard"})
|
@RequestMapping(value = {"/datasetwizard"})
|
||||||
|
@ -33,7 +32,8 @@ public class DatasetWizardController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<DataManagentPlanListingModel>>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) {
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<List<DataManagentPlanListingModel>>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) {
|
||||||
try {
|
try {
|
||||||
List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, principal);
|
List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataManagentPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataManagentPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans));
|
||||||
|
@ -45,7 +45,8 @@ public class DatasetWizardController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<AssociatedProfile>>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, Principal principal) {
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<List<AssociatedProfile>>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, Principal principal) {
|
||||||
try {
|
try {
|
||||||
List<AssociatedProfile> dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getDatabaseRepository().getDmpDao(), datasetProfileWizardAutocompleteRequest);
|
List<AssociatedProfile> dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getDatabaseRepository().getDmpDao(), datasetProfileWizardAutocompleteRequest);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<AssociatedProfile>>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<AssociatedProfile>>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans));
|
||||||
|
@ -57,7 +58,8 @@ public class DatasetWizardController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<DatasetWizardModel>> getPaged(@PathVariable String id, Principal principal) {
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<DatasetWizardModel>> getSingle(@PathVariable String id, Principal principal) {
|
||||||
try {
|
try {
|
||||||
DatasetWizardModel dataset = new DatasetManager().getSingle(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
|
DatasetWizardModel dataset = new DatasetManager().getSingle(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||||
|
@ -69,9 +71,10 @@ public class DatasetWizardController extends BaseController {
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<Dataset>> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) {
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<Dataset>> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) {
|
||||||
try {
|
try {
|
||||||
eu.eudat.entities.Dataset dataset = DatasetManager.createOrUpdate(this.getApiContext(), profile);
|
eu.eudat.entities.Dataset dataset = DatasetManager.createOrUpdate(this.getApiContext(), profile, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(null));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(null));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.dao.entities;
|
package eu.eudat.dao.entities;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@ -10,6 +11,8 @@ import eu.eudat.entities.Dataset;
|
||||||
import eu.eudat.entities.UserInfo;
|
import eu.eudat.entities.UserInfo;
|
||||||
import eu.eudat.models.criteria.DatasetCriteria;
|
import eu.eudat.models.criteria.DatasetCriteria;
|
||||||
import eu.eudat.queryable.QueryableList;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -32,6 +35,8 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||||
if (criteria.getPeriodStart() != null)
|
if (criteria.getPeriodStart() != null)
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||||
|
if (!criteria.getAllVersions())
|
||||||
|
query.where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
||||||
if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
|
if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
|
||||||
query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds()));
|
query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds()));
|
||||||
return query;
|
return query;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.eudat.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.dao.DatabaseAccessLayer;
|
||||||
|
import eu.eudat.entities.Service;
|
||||||
|
import eu.eudat.entities.UserDMP;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 2/8/2018.
|
||||||
|
*/
|
||||||
|
public interface UserDmpDao extends DatabaseAccessLayer<UserDMP, UUID> {
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package eu.eudat.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.dao.DatabaseAccess;
|
||||||
|
import eu.eudat.dao.DatabaseAccessLayer;
|
||||||
|
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||||
|
import eu.eudat.entities.Service;
|
||||||
|
import eu.eudat.entities.UserDMP;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 2/8/2018.
|
||||||
|
*/
|
||||||
|
@Component("userDmpDao")
|
||||||
|
public class UserDmpDaoImpl extends DatabaseAccess<UserDMP> implements UserDmpDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public UserDmpDaoImpl(DatabaseService<UserDMP> databaseService) {
|
||||||
|
this.setDatabaseService(databaseService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDMP createOrUpdate(UserDMP item) {
|
||||||
|
return this.getDatabaseService().createOrUpdate(item, UserDMP.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDMP find(UUID id) {
|
||||||
|
return this.getDatabaseService().getQueryable(UserDMP.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(UserDMP item) {
|
||||||
|
this.getDatabaseService().delete(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryableList<UserDMP> asQueryable() {
|
||||||
|
return this.getDatabaseService().getQueryable(UserDMP.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -279,7 +279,7 @@ public class DMP implements Serializable, DataEntity<DMP> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(DMP entity) {
|
public void update(DMP entity) {
|
||||||
this.setAssociatedDmps(entity.associatedDmps);
|
this.associatedDmps = entity.associatedDmps ;
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.status = entity.getStatus();
|
this.status = entity.getStatus();
|
||||||
this.created = entity.created;
|
this.created = entity.created;
|
||||||
|
|
|
@ -19,6 +19,10 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
@NamedEntityGraphs({
|
@NamedEntityGraphs({
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = "datasetListingModel",
|
name = "datasetListingModel",
|
||||||
|
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("dataRepositories"), @NamedAttributeNode("externalDatasets"), @NamedAttributeNode("registries"),
|
||||||
|
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}),
|
||||||
|
@NamedEntityGraph(
|
||||||
|
name = "datasetWizardModel",
|
||||||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("dataRepositories"), @NamedAttributeNode("externalDatasets"), @NamedAttributeNode("registries"),
|
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("dataRepositories"), @NamedAttributeNode("externalDatasets"), @NamedAttributeNode("registries"),
|
||||||
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")})
|
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")})
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,12 +3,9 @@ package eu.eudat.entities;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.*;
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
import org.hibernate.annotations.Type;
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
|
@ -16,8 +13,34 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"UserDMP\"")
|
@Table(name = "\"UserDMP\"")
|
||||||
public class UserDMP {
|
public class UserDMP implements DataEntity<UserDMP> {
|
||||||
|
|
||||||
|
public enum UserDMPRoles {
|
||||||
|
OWNER(0) , USER(1);
|
||||||
|
|
||||||
|
private Integer value;
|
||||||
|
|
||||||
|
private UserDMPRoles(Integer value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UserDMPRoles fromInteger(Integer value) {
|
||||||
|
switch (value) {
|
||||||
|
case 0:
|
||||||
|
return OWNER;
|
||||||
|
case 1:
|
||||||
|
return USER;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Unsupported User Dmp Role Message Code");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@ -25,13 +48,13 @@ public class UserDMP {
|
||||||
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
@Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
@Column(name = "usr", nullable = false)
|
@JoinColumn(name="usr")
|
||||||
private UUID usr;
|
private UserInfo user;
|
||||||
|
|
||||||
@Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
@Column(name = "dmp", nullable = false)
|
@JoinColumn(name="dmp")
|
||||||
private UUID dmp;
|
private DMP dmp;
|
||||||
|
|
||||||
@Column(name = "role")
|
@Column(name = "role")
|
||||||
private Integer role;
|
private Integer role;
|
||||||
|
@ -44,20 +67,19 @@ public class UserDMP {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserInfo getUser() {
|
||||||
public UUID getUsr() {
|
return user;
|
||||||
return usr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsr(UUID usr) {
|
public void setUser(UserInfo user) {
|
||||||
this.usr = usr;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDmp() {
|
public DMP getDmp() {
|
||||||
return dmp;
|
return dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmp(UUID dmp) {
|
public void setDmp(DMP dmp) {
|
||||||
this.dmp = dmp;
|
this.dmp = dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,5 +91,13 @@ public class UserDMP {
|
||||||
this.role = role;
|
this.role = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(UserDMP entity) {
|
||||||
|
this.role = entity.getRole();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package eu.eudat.entities.responses;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
|
|
||||||
public class IDLabelPair implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 4539082928100004914L;
|
|
||||||
|
|
||||||
@Column(name = "\"ID\"")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
|
|
||||||
public IDLabelPair(String id, String label) {
|
|
||||||
super();
|
|
||||||
this.id = id;
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -70,8 +70,16 @@ public class DataManagementPlanManager {
|
||||||
UserInfo user = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
UserInfo user = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||||
createProjectIfItDoesntExist(newDmp, apiContext.getDatabaseRepository().getProjectDao(), user);
|
createProjectIfItDoesntExist(newDmp, apiContext.getDatabaseRepository().getProjectDao(), user);
|
||||||
newDmp.setCreator(user);
|
newDmp.setCreator(user);
|
||||||
apiContext.getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
newDmp = apiContext.getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||||
|
if (dataManagementPlan.getAssociatedUsers().stream().filter(item -> item.getId() == principal.getId()).collect(Collectors.toList()).size() == 0) assignUser(newDmp,user,apiContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void assignUser(DMP dmp , UserInfo userInfo, ApiContext apiContext){
|
||||||
|
UserDMP userDMP = new UserDMP();
|
||||||
|
userDMP.setDmp(dmp);
|
||||||
|
userDMP.setUser(userInfo);
|
||||||
|
userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue());
|
||||||
|
apiContext.getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void newVersion(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
public static void newVersion(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||||
|
@ -90,7 +98,8 @@ public class DataManagementPlanManager {
|
||||||
copyDatasets(newDmp, apiContext.getDatabaseRepository().getDatasetDao());
|
copyDatasets(newDmp, apiContext.getDatabaseRepository().getDatasetDao());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clone(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {DMP newDmp = dataManagementPlan.toDataModel();
|
public static void clone(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||||
|
DMP newDmp = dataManagementPlan.toDataModel();
|
||||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getOrganisationDao());
|
createOrganisationsIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getOrganisationDao());
|
||||||
createResearchersIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getResearcherDao());
|
createResearchersIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getResearcherDao());
|
||||||
UserInfo user = new UserInfo();
|
UserInfo user = new UserInfo();
|
||||||
|
@ -159,6 +168,7 @@ public class DataManagementPlanManager {
|
||||||
Dataset newDataset = new Dataset();
|
Dataset newDataset = new Dataset();
|
||||||
newDataset.update(entityDataset);
|
newDataset.update(entityDataset);
|
||||||
newDataset.setDmp(newDmp);
|
newDataset.setDmp(newDmp);
|
||||||
|
newDataset.setStatus(Dataset.Status.SAVED.getValue());
|
||||||
if (newDataset.getDataRepositories() != null) {
|
if (newDataset.getDataRepositories() != null) {
|
||||||
newDataset.setDataRepositories(newDataset.getDataRepositories().stream().map(item -> {
|
newDataset.setDataRepositories(newDataset.getDataRepositories().stream().map(item -> {
|
||||||
DataRepository dataRepository = new DataRepository();
|
DataRepository dataRepository = new DataRepository();
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class DatasetManager {
|
||||||
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
|
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
|
||||||
DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>();
|
DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>();
|
||||||
|
|
||||||
CompletableFuture<List<Dataset>> itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DatasetListingModel.class)).toListAsync().whenComplete((resultList,throwable)->{
|
CompletableFuture<List<Dataset>> itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DatasetListingModel.class)).toListAsync().whenComplete((resultList, throwable) -> {
|
||||||
List<DatasetListingModel> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, DatasetListingModel>().fromDataModel(resultList, DatasetListingModel.class);
|
List<DatasetListingModel> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, DatasetListingModel>().fromDataModel(resultList, DatasetListingModel.class);
|
||||||
dataTable.setData(datasets);
|
dataTable.setData(datasets);
|
||||||
});
|
});
|
||||||
|
@ -46,13 +46,13 @@ public class DatasetManager {
|
||||||
dataTable.setTotalCount(count);
|
dataTable.setTotalCount(count);
|
||||||
});
|
});
|
||||||
|
|
||||||
CompletableFuture.allOf(itemsFuture,countFuture).join();
|
CompletableFuture.allOf(itemsFuture, countFuture).join();
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetWizardModel getSingle(DatasetDao datatasetRepository, String id) throws InstantiationException, IllegalAccessException {
|
public DatasetWizardModel getSingle(DatasetDao datatasetRepository, String id) throws InstantiationException, IllegalAccessException {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
eu.eudat.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id));
|
eu.eudat.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
||||||
datasetprofile.setStatus(dataset.getStatus());
|
datasetprofile.setStatus(dataset.getStatus());
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (datasetEntity.getProperties() != null) {
|
||||||
|
@ -67,9 +67,12 @@ public class DatasetManager {
|
||||||
return dataset;
|
return dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static eu.eudat.entities.Dataset createOrUpdate(ApiContext apiContext, DatasetWizardModel profile) throws Exception {
|
public static eu.eudat.entities.Dataset createOrUpdate(ApiContext apiContext, DatasetWizardModel profile, Principal principal) throws Exception {
|
||||||
eu.eudat.entities.Dataset dataset = profile.toDataModel();
|
eu.eudat.entities.Dataset dataset = profile.toDataModel();
|
||||||
propertiesModelToString(profile,dataset);
|
propertiesModelToString(profile, dataset);
|
||||||
|
UserInfo userInfo = new UserInfo();
|
||||||
|
userInfo.setId(principal.getId());
|
||||||
|
dataset.setCreator(userInfo);
|
||||||
createRegistriesIfTheyDontExist(apiContext.getDatabaseRepository().getRegistryDao(), dataset);
|
createRegistriesIfTheyDontExist(apiContext.getDatabaseRepository().getRegistryDao(), dataset);
|
||||||
createDataRepositoriesIfTheyDontExist(apiContext.getDatabaseRepository().getDataRepositoryDao(), dataset);
|
createDataRepositoriesIfTheyDontExist(apiContext.getDatabaseRepository().getDataRepositoryDao(), dataset);
|
||||||
createServicesIfTheyDontExist(apiContext.getDatabaseRepository().getServiceDao(), dataset);
|
createServicesIfTheyDontExist(apiContext.getDatabaseRepository().getServiceDao(), dataset);
|
||||||
|
@ -77,8 +80,8 @@ public class DatasetManager {
|
||||||
return apiContext.getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
|
return apiContext.getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void propertiesModelToString(DatasetWizardModel datasetWizardModel,eu.eudat.entities.Dataset dataset){
|
private static void propertiesModelToString(DatasetWizardModel datasetWizardModel, eu.eudat.entities.Dataset dataset) {
|
||||||
Map<String,Object> values = new HashMap();
|
Map<String, Object> values = new HashMap();
|
||||||
PagedDatasetProfile properties = datasetWizardModel.getDatasetProfileDefinition();
|
PagedDatasetProfile properties = datasetWizardModel.getDatasetProfileDefinition();
|
||||||
properties.toMap(values);
|
properties.toMap(values);
|
||||||
JSONObject jobject = new JSONObject(values);
|
JSONObject jobject = new JSONObject(values);
|
||||||
|
|
|
@ -12,6 +12,15 @@ public class DatasetCriteria extends Criteria<Dataset>{
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
private Date periodEnd;
|
private Date periodEnd;
|
||||||
private List<UUID> dmpIds;
|
private List<UUID> dmpIds;
|
||||||
|
private boolean allVersions;
|
||||||
|
|
||||||
|
public boolean getAllVersions() {
|
||||||
|
return allVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllVersions(boolean allVersions) {
|
||||||
|
this.allVersions = allVersions;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getStatus() {
|
public Integer getStatus() {
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -212,6 +212,6 @@ public class DatasetWizardModel implements DataModel<Dataset> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHint() {
|
public String getHint() {
|
||||||
return null;
|
return "datasetWizardModel";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,7 @@ public class DataManagementPlan implements DataModel<DMP> {
|
||||||
this.project = new Project();
|
this.project = new Project();
|
||||||
this.project.fromDataModel(entity.getProject());
|
this.project.fromDataModel(entity.getProject());
|
||||||
this.creator = new eu.eudat.models.userinfo.UserInfo();
|
this.creator = new eu.eudat.models.userinfo.UserInfo();
|
||||||
|
this.groupId = entity.getGroupId();
|
||||||
if (entity.getCreator() != null) this.creator.fromDataModel(entity.getCreator());
|
if (entity.getCreator() != null) this.creator.fromDataModel(entity.getCreator());
|
||||||
|
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
|
@ -163,7 +164,7 @@ public class DataManagementPlan implements DataModel<DMP> {
|
||||||
}
|
}
|
||||||
this.created = entity.getCreated();
|
this.created = entity.getCreated();
|
||||||
this.description = entity.getDescription();
|
this.description = entity.getDescription();
|
||||||
this.associatedUsers = new DomainModelConverter<eu.eudat.entities.UserInfo,UserInfo>().fromDataModel(entity.getUsers().stream().collect(Collectors.toList()),UserInfo.class);
|
this.associatedUsers = new DomainModelConverter<eu.eudat.entities.UserInfo, UserInfo>().fromDataModel(entity.getUsers().stream().collect(Collectors.toList()), UserInfo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -189,7 +190,9 @@ public class DataManagementPlan implements DataModel<DMP> {
|
||||||
associatedProfileDoc.appendChild(associatedProfilesElement);
|
associatedProfileDoc.appendChild(associatedProfilesElement);
|
||||||
dataManagementPlanEntity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));
|
dataManagementPlanEntity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));
|
||||||
}
|
}
|
||||||
|
dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
|
||||||
dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
||||||
|
dataManagementPlanEntity.setUsers(new HashSet<>(new DomainModelConverter<eu.eudat.entities.UserInfo,UserInfo>().toDataModel(this.associatedUsers)));
|
||||||
return dataManagementPlanEntity;
|
return dataManagementPlanEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,15 @@ public class DataTableData<T> {
|
||||||
public Long getTotalCount() {
|
public Long getTotalCount() {
|
||||||
return totalCount;
|
return totalCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotalCount(Long totalCount) {
|
public void setTotalCount(Long totalCount) {
|
||||||
this.totalCount = totalCount;
|
this.totalCount = totalCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<T> getData() {
|
public List<T> getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(List<T> data) {
|
public void setData(List<T> data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.queryable.predicates.NestedQuerySinglePredicate;
|
||||||
import eu.eudat.queryable.predicates.OrderByPredicate;
|
import eu.eudat.queryable.predicates.OrderByPredicate;
|
||||||
import eu.eudat.queryable.predicates.SelectPredicate;
|
import eu.eudat.queryable.predicates.SelectPredicate;
|
||||||
import eu.eudat.queryable.predicates.SinglePredicate;
|
import eu.eudat.queryable.predicates.SinglePredicate;
|
||||||
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
import eu.eudat.queryable.types.SelectionField;
|
import eu.eudat.queryable.types.SelectionField;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -284,20 +285,28 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <U extends Comparable> Subquery<U> subQueryMax(SinglePredicate<T> predicate, List<SelectionField> fields,Class<U> uClass) {
|
public <U extends Comparable> Subquery<U> subQueryMax(SinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass) {
|
||||||
Subquery<U> subquery = this.manager.getCriteriaBuilder().createQuery().subquery(uClass);
|
Subquery<U> subquery = this.manager.getCriteriaBuilder().createQuery().subquery(uClass);
|
||||||
this.nestedQueryRoot = subquery.from(this.tClass);
|
this.nestedQueryRoot = subquery.from(this.tClass);
|
||||||
subquery.where(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.nestedQueryRoot));
|
subquery.where(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.nestedQueryRoot));
|
||||||
|
if (fields.get(0).getType() == FieldSelectionType.FIELD)
|
||||||
subquery.select(this.manager.getCriteriaBuilder().greatest(this.nestedQueryRoot.<U>get(fields.get(0).getField())));
|
subquery.select(this.manager.getCriteriaBuilder().greatest(this.nestedQueryRoot.<U>get(fields.get(0).getField())));
|
||||||
|
else if (fields.get(0).getType() == FieldSelectionType.COMPOSITE_FIELD) {
|
||||||
|
subquery.select(this.manager.getCriteriaBuilder().greatest(this.nestedQueryRoot.get(fields.get(0).getField().split(":")[0]).<U>get(fields.get(0).getField().split(":")[1])));
|
||||||
|
}
|
||||||
return subquery;
|
return subquery;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <U extends Comparable> Subquery<U> subQueryMax(NestedQuerySinglePredicate<T> predicate, List<SelectionField> fields,Class<U> uClass) {
|
public <U extends Comparable> Subquery<U> subQueryMax(NestedQuerySinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass) {
|
||||||
Subquery<U> subquery = this.manager.getCriteriaBuilder().createQuery().subquery(uClass);
|
Subquery<U> subquery = this.manager.getCriteriaBuilder().createQuery().subquery(uClass);
|
||||||
this.nestedQueryRoot = subquery.from(this.tClass);
|
this.nestedQueryRoot = subquery.from(this.tClass);
|
||||||
subquery.where(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.root, this.nestedQueryRoot));
|
subquery.where(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.root, this.nestedQueryRoot));
|
||||||
|
if (fields.get(0).getType() == FieldSelectionType.FIELD)
|
||||||
subquery.select(this.manager.getCriteriaBuilder().greatest(this.nestedQueryRoot.<U>get(fields.get(0).getField())));
|
subquery.select(this.manager.getCriteriaBuilder().greatest(this.nestedQueryRoot.<U>get(fields.get(0).getField())));
|
||||||
|
else if (fields.get(0).getType() == FieldSelectionType.COMPOSITE_FIELD) {
|
||||||
|
subquery.select(this.manager.getCriteriaBuilder().greatest(this.nestedQueryRoot.get(fields.get(0).getField().split(":")[0]).<U>get(fields.get(0).getField().split(":")[1])));
|
||||||
|
}
|
||||||
return subquery;
|
return subquery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,5 @@ package eu.eudat.queryable.types;
|
||||||
* Created by ikalyvas on 2/7/2018.
|
* Created by ikalyvas on 2/7/2018.
|
||||||
*/
|
*/
|
||||||
public enum FieldSelectionType {
|
public enum FieldSelectionType {
|
||||||
FIELD, COUNT, MAX
|
FIELD,COMPOSITE_FIELD, COUNT, MAX
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,4 +21,5 @@ public interface DatabaseRepository {
|
||||||
CredentialDao getCredentialDao();
|
CredentialDao getCredentialDao();
|
||||||
UserTokenDao getUserTokenDao();
|
UserTokenDao getUserTokenDao();
|
||||||
ExternalDatasetDao getExternalDatasetDao();
|
ExternalDatasetDao getExternalDatasetDao();
|
||||||
|
UserDmpDao getUserDmpDao();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import javax.persistence.EntityManager;
|
||||||
|
|
||||||
|
|
||||||
@Service("databaseRepository")
|
@Service("databaseRepository")
|
||||||
public class DatabaseRepositoryImpl implements DatabaseRepository{
|
public class DatabaseRepositoryImpl implements DatabaseRepository {
|
||||||
|
|
||||||
private DataRepositoryDao dataRepositoryDao;
|
private DataRepositoryDao dataRepositoryDao;
|
||||||
private DatasetDao datasetDao;
|
private DatasetDao datasetDao;
|
||||||
|
@ -27,6 +27,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository{
|
||||||
private UserTokenDao userTokenDao;
|
private UserTokenDao userTokenDao;
|
||||||
private ExternalDatasetDao externalDatasetDao;
|
private ExternalDatasetDao externalDatasetDao;
|
||||||
private UserRoleDao userRoleDao;
|
private UserRoleDao userRoleDao;
|
||||||
|
private UserDmpDao userDmpDao;
|
||||||
|
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@ -184,4 +185,14 @@ public class DatabaseRepositoryImpl implements DatabaseRepository{
|
||||||
public void setEntityManager(EntityManager entityManager) {
|
public void setEntityManager(EntityManager entityManager) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDmpDao getUserDmpDao() {
|
||||||
|
return userDmpDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setUserDmpDao(UserDmpDao userDmpDao) {
|
||||||
|
this.userDmpDao = userDmpDao;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ export class DatasetListingComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
|
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
|
||||||
}
|
}
|
||||||
|
|
||||||
rowClick(rowId: String) {
|
rowClick(rowId: String) {
|
||||||
|
@ -96,14 +96,14 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
|
|
||||||
totalCount = 0;
|
totalCount = 0;
|
||||||
isLoadingResults = false;
|
isLoadingResults = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _service: DatasetService,
|
private _service: DatasetService,
|
||||||
private _paginator: MatPaginator,
|
private _paginator: MatPaginator,
|
||||||
private _sort: MatSort,
|
private _sort: MatSort,
|
||||||
private _languageService: TranslateService,
|
private _languageService: TranslateService,
|
||||||
private _snackBar: MatSnackBar,
|
private _snackBar: MatSnackBar,
|
||||||
private _criteria: DatasetCriteriaComponent
|
private _criteria: DatasetCriteriaComponent,
|
||||||
|
private dmpId: String
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
|
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
|
||||||
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||||
request.criteria = this._criteria.criteria;
|
request.criteria = this._criteria.criteria;
|
||||||
|
if (this.dmpId) request.criteria.allVersions = true;
|
||||||
return this._service.getPaged(request);
|
return this._service.getPaged(request);
|
||||||
})
|
})
|
||||||
/*.catch((error: any) => {
|
/*.catch((error: any) => {
|
||||||
|
|
|
@ -3,4 +3,5 @@ import { BaseCriteria } from "../BaseCriteria";
|
||||||
export class DatasetCriteria extends BaseCriteria {
|
export class DatasetCriteria extends BaseCriteria {
|
||||||
public status: Number;
|
public status: Number;
|
||||||
public dmpIds: String[] = [];
|
public dmpIds: String[] = [];
|
||||||
|
public allVersions: boolean;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue