no message

This commit is contained in:
Ioannis Kalyvas 2018-02-08 17:54:31 +02:00
parent 04389b0613
commit d44052299a
20 changed files with 238 additions and 131 deletions

View File

@ -21,7 +21,6 @@ import javax.transaction.Transactional;
import java.util.List;
@RestController
@CrossOrigin
@RequestMapping(value = {"/datasetwizard"})
@ -33,7 +32,8 @@ public class DatasetWizardController extends BaseController {
}
@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 {
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));
@ -45,7 +45,8 @@ public class DatasetWizardController extends BaseController {
}
@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 {
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));
@ -57,7 +58,8 @@ public class DatasetWizardController extends BaseController {
}
@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 {
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));
@ -69,9 +71,10 @@ public class DatasetWizardController extends BaseController {
@Transactional
@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 {
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));
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -1,5 +1,6 @@
package eu.eudat.dao.entities;
import java.util.Arrays;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@ -10,6 +11,8 @@ import eu.eudat.entities.Dataset;
import eu.eudat.entities.UserInfo;
import eu.eudat.models.criteria.DatasetCriteria;
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.stereotype.Component;
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()));
if (criteria.getPeriodStart() != null)
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())
query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds()));
return query;

View File

@ -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> {
}

View File

@ -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);
}
}

View File

@ -279,7 +279,7 @@ public class DMP implements Serializable, DataEntity<DMP> {
@Override
public void update(DMP entity) {
this.setAssociatedDmps(entity.associatedDmps);
this.associatedDmps = entity.associatedDmps ;
this.label = entity.getLabel();
this.status = entity.getStatus();
this.created = entity.created;

View File

@ -19,6 +19,10 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@NamedEntityGraphs({
@NamedEntityGraph(
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"),
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")})
})

View File

@ -3,12 +3,9 @@ package eu.eudat.entities;
import java.io.Serializable;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.*;
import eu.eudat.types.ApiMessageCode;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -16,58 +13,91 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name="\"UserDMP\"")
public class UserDMP {
@Table(name = "\"UserDMP\"")
public class UserDMP implements DataEntity<UserDMP> {
@Id
@GeneratedValue
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
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
@Column(name = "usr", nullable = false)
private UUID usr;
@Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
@Column(name = "dmp", nullable = false)
private UUID dmp;
private UUID id;
@Column(name = "role")
private Integer role;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="usr")
private UserInfo user;
public UUID getId() {
return id;
}
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="dmp")
private DMP dmp;
public void setId(UUID id) {
this.id = id;
}
@Column(name = "role")
private Integer role;
public UUID getId() {
return id;
}
public UUID getUsr() {
return usr;
}
public void setId(UUID id) {
this.id = id;
}
public void setUsr(UUID usr) {
this.usr = usr;
}
public UserInfo getUser() {
return user;
}
public UUID getDmp() {
return dmp;
}
public void setUser(UserInfo user) {
this.user = user;
}
public void setDmp(UUID dmp) {
this.dmp = dmp;
}
public DMP getDmp() {
return dmp;
}
public Integer getRole() {
return role;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public void setRole(Integer role) {
this.role = role;
}
public Integer getRole() {
return role;
}
public void setRole(Integer 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};
}
}

View File

@ -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;
}
}

View File

@ -70,8 +70,16 @@ public class DataManagementPlanManager {
UserInfo user = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
createProjectIfItDoesntExist(newDmp, apiContext.getDatabaseRepository().getProjectDao(), 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 {
@ -90,7 +98,8 @@ public class DataManagementPlanManager {
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());
createResearchersIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getResearcherDao());
UserInfo user = new UserInfo();
@ -159,6 +168,7 @@ public class DataManagementPlanManager {
Dataset newDataset = new Dataset();
newDataset.update(entityDataset);
newDataset.setDmp(newDmp);
newDataset.setStatus(Dataset.Status.SAVED.getValue());
if (newDataset.getDataRepositories() != null) {
newDataset.setDataRepositories(newDataset.getDataRepositories().stream().map(item -> {
DataRepository dataRepository = new DataRepository();

View File

@ -37,7 +37,7 @@ public class DatasetManager {
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
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);
dataTable.setData(datasets);
});
@ -46,13 +46,13 @@ public class DatasetManager {
dataTable.setTotalCount(count);
});
CompletableFuture.allOf(itemsFuture,countFuture).join();
CompletableFuture.allOf(itemsFuture, countFuture).join();
return dataTable;
}
public DatasetWizardModel getSingle(DatasetDao datatasetRepository, String id) throws InstantiationException, IllegalAccessException {
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());
datasetprofile.setStatus(dataset.getStatus());
if (datasetEntity.getProperties() != null) {
@ -67,9 +67,12 @@ public class DatasetManager {
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();
propertiesModelToString(profile,dataset);
propertiesModelToString(profile, dataset);
UserInfo userInfo = new UserInfo();
userInfo.setId(principal.getId());
dataset.setCreator(userInfo);
createRegistriesIfTheyDontExist(apiContext.getDatabaseRepository().getRegistryDao(), dataset);
createDataRepositoriesIfTheyDontExist(apiContext.getDatabaseRepository().getDataRepositoryDao(), dataset);
createServicesIfTheyDontExist(apiContext.getDatabaseRepository().getServiceDao(), dataset);
@ -77,8 +80,8 @@ public class DatasetManager {
return apiContext.getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
}
private static void propertiesModelToString(DatasetWizardModel datasetWizardModel,eu.eudat.entities.Dataset dataset){
Map<String,Object> values = new HashMap();
private static void propertiesModelToString(DatasetWizardModel datasetWizardModel, eu.eudat.entities.Dataset dataset) {
Map<String, Object> values = new HashMap();
PagedDatasetProfile properties = datasetWizardModel.getDatasetProfileDefinition();
properties.toMap(values);
JSONObject jobject = new JSONObject(values);

View File

@ -12,6 +12,15 @@ public class DatasetCriteria extends Criteria<Dataset>{
private Date periodStart;
private Date periodEnd;
private List<UUID> dmpIds;
private boolean allVersions;
public boolean getAllVersions() {
return allVersions;
}
public void setAllVersions(boolean allVersions) {
this.allVersions = allVersions;
}
public Integer getStatus() {
return status;

View File

@ -212,6 +212,6 @@ public class DatasetWizardModel implements DataModel<Dataset> {
@Override
public String getHint() {
return null;
return "datasetWizardModel";
}
}

View File

@ -145,6 +145,7 @@ public class DataManagementPlan implements DataModel<DMP> {
this.project = new Project();
this.project.fromDataModel(entity.getProject());
this.creator = new eu.eudat.models.userinfo.UserInfo();
this.groupId = entity.getGroupId();
if (entity.getCreator() != null) this.creator.fromDataModel(entity.getCreator());
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
@ -163,7 +164,7 @@ public class DataManagementPlan implements DataModel<DMP> {
}
this.created = entity.getCreated();
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
@ -189,7 +190,9 @@ public class DataManagementPlan implements DataModel<DMP> {
associatedProfileDoc.appendChild(associatedProfilesElement);
dataManagementPlanEntity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));
}
dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
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;
}

View File

@ -3,19 +3,22 @@ package eu.eudat.models.helpers.common;
import java.util.List;
public class DataTableData<T> {
private Long totalCount;
private List<T> data;
public Long getTotalCount() {
return totalCount;
}
public void setTotalCount(Long totalCount) {
this.totalCount = totalCount;
}
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
private Long totalCount;
private List<T> data;
public Long getTotalCount() {
return totalCount;
}
public void setTotalCount(Long totalCount) {
this.totalCount = totalCount;
}
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
}

View File

@ -8,6 +8,7 @@ import eu.eudat.queryable.predicates.NestedQuerySinglePredicate;
import eu.eudat.queryable.predicates.OrderByPredicate;
import eu.eudat.queryable.predicates.SelectPredicate;
import eu.eudat.queryable.predicates.SinglePredicate;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import org.springframework.scheduling.annotation.Async;
import org.springframework.transaction.annotation.Transactional;
@ -284,20 +285,28 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
}
@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);
this.nestedQueryRoot = subquery.from(this.tClass);
subquery.where(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.nestedQueryRoot));
subquery.select(this.manager.getCriteriaBuilder().greatest(this.nestedQueryRoot.<U>get(fields.get(0).getField())));
if (fields.get(0).getType() == FieldSelectionType.FIELD)
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;
}
@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);
this.nestedQueryRoot = subquery.from(this.tClass);
subquery.where(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.root, this.nestedQueryRoot));
subquery.select(this.manager.getCriteriaBuilder().greatest(this.nestedQueryRoot.<U>get(fields.get(0).getField())));
if (fields.get(0).getType() == FieldSelectionType.FIELD)
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;
}
}

View File

@ -4,5 +4,5 @@ package eu.eudat.queryable.types;
* Created by ikalyvas on 2/7/2018.
*/
public enum FieldSelectionType {
FIELD, COUNT, MAX
FIELD,COMPOSITE_FIELD, COUNT, MAX
}

View File

@ -21,4 +21,5 @@ public interface DatabaseRepository {
CredentialDao getCredentialDao();
UserTokenDao getUserTokenDao();
ExternalDatasetDao getExternalDatasetDao();
UserDmpDao getUserDmpDao();
}

View File

@ -10,7 +10,7 @@ import javax.persistence.EntityManager;
@Service("databaseRepository")
public class DatabaseRepositoryImpl implements DatabaseRepository{
public class DatabaseRepositoryImpl implements DatabaseRepository {
private DataRepositoryDao dataRepositoryDao;
private DatasetDao datasetDao;
@ -27,6 +27,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository{
private UserTokenDao userTokenDao;
private ExternalDatasetDao externalDatasetDao;
private UserRoleDao userRoleDao;
private UserDmpDao userDmpDao;
private EntityManager entityManager;
@ -184,4 +185,14 @@ public class DatabaseRepositoryImpl implements DatabaseRepository{
public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}
@Override
public UserDmpDao getUserDmpDao() {
return userDmpDao;
}
@Autowired
public void setUserDmpDao(UserDmpDao userDmpDao) {
this.userDmpDao = userDmpDao;
}
}

View File

@ -70,7 +70,7 @@ export class DatasetListingComponent implements OnInit {
}
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) {
@ -96,14 +96,14 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
totalCount = 0;
isLoadingResults = false;
constructor(
private _service: DatasetService,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DatasetCriteriaComponent
private _criteria: DatasetCriteriaComponent,
private dmpId: String
) {
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];
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
if (this.dmpId) request.criteria.allVersions = true;
return this._service.getPaged(request);
})
/*.catch((error: any) => {

View File

@ -3,4 +3,5 @@ import { BaseCriteria } from "../BaseCriteria";
export class DatasetCriteria extends BaseCriteria {
public status: Number;
public dmpIds: String[] = [];
public allVersions: boolean;
}