Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development

This commit is contained in:
Konstantinos Triantafyllou 2021-12-09 16:18:48 +02:00
commit 4425a0bb5d
41 changed files with 266 additions and 89 deletions

View File

@ -7,6 +7,7 @@ import eu.eudat.queryable.queryableentity.DataEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.Set;
@ -28,6 +29,7 @@ public class DatabaseService<T extends DataEntity> {
return this.databaseCtx.getQueryable(tClass);
}
@Transactional
public T createOrUpdate(T item, Class<T> tClass) {
return this.databaseCtx.createOrUpdate(item, tClass);
}

View File

@ -16,6 +16,7 @@ import org.springframework.stereotype.Component;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.transaction.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -106,6 +107,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
}
@Override
@Transactional
public DMP createOrUpdate(DMP item) {
return this.getDatabaseService().createOrUpdate(item, DMP.class);
}

View File

@ -317,8 +317,12 @@ public class Dmp implements ElasticEntity<Dmp> {
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
}
this.created = Date.from(Instant.parse(fields.get(MapKey.CREATED.getName()).toString()));
this.modified = Date.from(Instant.parse(fields.get(MapKey.MODIFIED.getName()).toString()));
if (fields.containsKey(MapKey.CREATED.getName())) {
this.created = Date.from(Instant.parse(fields.get(MapKey.CREATED.getName()).toString()));
}
if (fields.containsKey(MapKey.MODIFIED.getName())) {
this.modified = Date.from(Instant.parse(fields.get(MapKey.MODIFIED.getName()).toString()));
}
if (fields.get(MapKey.FINALIZEDAT.getName()) != null) {
this.finalizedAt = Date.from(Instant.parse(fields.get(MapKey.FINALIZEDAT.getName()).toString()));
}

View File

@ -119,7 +119,7 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
}
searchSourceBuilder.query(boolQuery).from(criteria.getOffset()).fetchSource("id", null);
if (criteria.getSize() > 0) {
if (criteria.getSize() != null && criteria.getSize() > 0) {
searchSourceBuilder.size(criteria.getSize());
}
sortBuilders.forEach(searchSourceBuilder::sort);

View File

@ -0,0 +1,22 @@
package eu.eudat.cache;
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
import org.springframework.cache.interceptor.KeyGenerator;
import java.lang.reflect.Method;
public class ExternalUrlsKeyGenerator implements KeyGenerator {
@Override
public Object generate(Object o, Method method, Object... params) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(o.getClass().getSimpleName()).append("_");
stringBuffer.append(method.getName()).append("_");
for (Object param: params) {
if (param instanceof ExternalUrlCriteria) {
ExternalUrlCriteria externalUrlCriteria = (ExternalUrlCriteria) param;
stringBuffer.append(externalUrlCriteria);
}
}
return stringBuffer.toString();
}
}

View File

@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.caffeine.CaffeineCache;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
@ -47,4 +48,9 @@ public class ResponsesCache {
return simpleCacheManager;
}
@Bean(name = "externalUrlsKeyGenerator")
private KeyGenerator externalUrlsKeyGenerator() {
return new ExternalUrlsKeyGenerator();
}
}

View File

@ -54,6 +54,7 @@ public class DashBoardController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<RecentActivityModel>>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
}
@Deprecated
@RequestMapping(method = RequestMethod.GET, value = {"/user/recentActivity"}, produces = "application/json")
public ResponseEntity<ResponseItem<RecentActivity>> getRecentActivity(@RequestParam(name = "numOfActivities", required = false, defaultValue = "5") Integer numberOfActivities, Principal principal) {
RecentActivity statistics = dashBoardManager.getRecentActivity(principal, numberOfActivities);

View File

@ -39,11 +39,11 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.persistence.NoResultException;
import javax.transaction.Transactional;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@ -121,7 +121,7 @@ public class Datasets extends BaseController {
// }
}
@javax.transaction.Transactional
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
@ -246,7 +246,7 @@ public class Datasets extends BaseController {
* Data Management
* */
@javax.transaction.Transactional
@Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DatasetWizardModel>> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) throws Exception {
@ -262,7 +262,7 @@ public class Datasets extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message(this.getApiContext().getHelpersService().getMessageSource().getMessage("dataset.public", new Object[]{}, locale)));
}
@javax.transaction.Transactional
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<Dataset>> delete(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
@ -270,7 +270,7 @@ public class Datasets extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted"));
}
@javax.transaction.Transactional
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/unlock"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<Dataset>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
@ -318,7 +318,7 @@ public class Datasets extends BaseController {
* Data Index
* */
@javax.transaction.Transactional
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
public @ResponseBody
ResponseEntity<ResponseItem<Dataset>> generateIndex(Principal principal) throws Exception {
@ -326,7 +326,7 @@ public class Datasets extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
}
@javax.transaction.Transactional
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
public @ResponseBody
ResponseEntity<ResponseItem<Dataset>> clearIndex(Principal principal) throws Exception {

View File

@ -50,8 +50,11 @@ public class UserInvitationController extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(Principal principal) throws IllegalAccessException, InstantiationException {
List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal);
// ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(Principal principal) throws IllegalAccessException, InstantiationException {
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(Principal principal, @RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException {
System.out.println(userInfoRequestItem.getCriteria().getLike());
// List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal);
List<UserInfoInvitationModel> users = invitationsManager.getUsersWithCriteria(principal, userInfoRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users));
}
}

View File

@ -152,7 +152,7 @@ public class DashBoardManager {
if ((dmps == null || dmps == 0L) && (datasets == null || datasets == 0L)) {
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId(), roles).distinct().countAsync()
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
CompletableFuture datasetFuture = datasetRepository.getAuthenticated( datasetRepository.getWithCriteria(datasetCriteria), user, roles).countAsync()
CompletableFuture datasetFuture = datasetRepository.getAuthenticated( datasetRepository.getWithCriteria(datasetCriteria), user, roles).distinct().countAsync()
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
CompletableFuture.allOf(dmpFuture, datasetFuture).join();
} else {
@ -168,6 +168,7 @@ public class DashBoardManager {
return statistics;
}
@Deprecated
public RecentActivity getRecentActivity(Principal principal, Integer numberofactivities) {
RecentActivity activity = new RecentActivity();
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
@ -190,7 +191,7 @@ public class DashBoardManager {
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
.whenComplete((dmpActivities, throwable) -> activity.setRecentDmpActivities(dmpActivities));
CompletableFuture<List<RecentActivityData>> datasets = datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user, roles)
CompletableFuture<List<RecentActivityData>> datasets = datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user, roles).distinct()
.withHint("datasetRecentActivity")
.orderBy((builder, root) -> builder.desc(root.get("modified")))
.take(numberofactivities)
@ -312,7 +313,7 @@ public class DashBoardManager {
roles.add(UserDMP.UserDMPRoles.USER.getValue());
roles.add(UserDMP.UserDMPRoles.OWNER.getValue());
dmpList = dataManagementPlanRepository.getAuthenticated(dmpList, principal.getId(), roles);
datasetList = datasetRepository.getAuthenticated(datasetList, user, roles);
datasetList = datasetRepository.getAuthenticated(datasetList, user, roles).distinct();
}
@ -324,9 +325,11 @@ public class DashBoardManager {
recentActivityModels.addAll(dmps1.stream().map(dmp -> {
DatasetCriteria datasetCriteria1 = new DatasetCriteria();
datasetCriteria1.setDmpIds(Collections.singletonList(dmp.getId()));
datasetCriteria1.setAllVersions(false);
if (isAuthenticated) {
dmp.setDataset(retrieveRelevantDatasets(datasetCriteria1, principal.getId()));
} else {
datasetCriteria1.setIsPublic(true);
dmp.setDataset(retrieveRelevantDatasets(datasetCriteria1));
}
return new RecentDmpModel().fromDataModel(dmp);
@ -446,14 +449,14 @@ public class DashBoardManager {
roles.add(1);
datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getAuthenticated(datasetItems, userInfo, roles);
}
Long maxDatasets = datasetItems.count();
Long maxDatasets = datasetItems.distinct().count();
DatasetTableRequest datasetTableRequest = new DatasetTableRequest();
datasetTableRequest.setOffset(0);
datasetTableRequest.setLength(3);
Set<Dataset> datasetsSet = new LinkedHashSet<>();
try {
datasetItems = PaginationManager.applyPaging(datasetItems, datasetTableRequest);
List<Dataset> datasets = datasetItems.toList();
List<Dataset> datasets = datasetItems.distinct().toList();
datasetsSet.addAll(datasets);
for (int i = 0; i < maxDatasets - datasets.size(); i++) {
Dataset fakedataset = new Dataset();

View File

@ -79,6 +79,7 @@ import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.transaction.Transactional;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
@ -184,6 +185,8 @@ public class DataManagementPlanManager {
dataTable.setData(dmps1.stream().map(dmp -> {
DatasetCriteria datasetCriteria = new DatasetCriteria();
datasetCriteria.setDmpIds(Collections.singletonList(dmp.getId()));
datasetCriteria.setAllVersions(false);
datasetCriteria.setIsPublic(dataManagementPlanTableRequest.getCriteria().getIsPublic());
dmp.setDataset(retrieveRelevantDatasets(datasetCriteria, principalID));
@ -249,14 +252,14 @@ public class DataManagementPlanManager {
roles.add(1);
datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getAuthenticated(datasetItems, userInfo, roles);
}
Long maxDatasets = datasetItems.count();
Long maxDatasets = datasetItems.distinct().count();
DatasetTableRequest datasetTableRequest = new DatasetTableRequest();
datasetTableRequest.setOffset(0);
datasetTableRequest.setLength(3);
Set<Dataset> datasetsSet = new LinkedHashSet<>();
try {
datasetItems = PaginationManager.applyPaging(datasetItems, datasetTableRequest);
List<Dataset> datasets = datasetItems.toList();
List<Dataset> datasets = datasetItems.distinct().toList();
datasetsSet.addAll(datasets);
for (int i = 0; i < maxDatasets - datasets.size(); i++) {
Dataset fakedataset = new Dataset();
@ -598,6 +601,9 @@ public class DataManagementPlanManager {
datasets.add(dataset);
}
UUID dmpId = result.getId();
result.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.updateIndex(result);
return result;
@ -709,6 +715,8 @@ public class DataManagementPlanManager {
DatasetCriteria criteria1 = new DatasetCriteria();
criteria1.setDmpIds(Collections.singletonList(newDmp.getId()));
newDmp.setDataset(new HashSet<>(databaseRepository.getDatasetDao().getWithCriteria(criteria1).toList()));
UUID dmpId = newDmp.getId();
newDmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.updateIndex(newDmp);
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
@ -739,12 +747,16 @@ public class DataManagementPlanManager {
}
oldDmp.setStatus(DMP.DMPStatus.DELETED.getValue());
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(oldDmp);
UUID dmpId = oldDmp.getId();
oldDmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.updateIndex(oldDmp);
DataManagementPlanCriteria criteria1 = new DataManagementPlanCriteria();
criteria1.setAllVersions(true);
criteria1.setGroupIds(Collections.singletonList(oldDmp.getGroupId()));
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria1).toList().forEach(dmp -> {
try {
UUID tdmpId = dmp.getId();
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), tdmpId)).toList()));
this.updateIndex(dmp);
} catch (IOException e) {
logger.error(e.getMessage(), e);
@ -756,6 +768,7 @@ public class DataManagementPlanManager {
if (elastic != null) {
tags = elastic.getTags();
}
dataset.setDmp(dmp);
this.datasetManager.updateTags(dataset, tags);
} catch (Exception e) {
logger.error(e.getMessage(), e);
@ -890,7 +903,8 @@ public class DataManagementPlanManager {
if (elastic != null) {
tags = elastic.getTags();
}
UUID dmpId = tempDataset.getDmp().getId();
tempDataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.datasetManager.updateTags(tempDataset, tags);
} catch (Exception e) {
logger.error(e.getMessage(), e);
@ -1007,6 +1021,8 @@ public class DataManagementPlanManager {
throw new Exception("DMP is not finalized");
dmp.setPublic(true);
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
UUID dmpId = dmp.getId();
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.updateIndex(dmp);
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.PUBLISHED);
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
@ -1020,6 +1036,8 @@ public class DataManagementPlanManager {
if (elastic != null) {
tags = elastic.getTags();
}
UUID tmdmpId = dataset.getDmp().getId();
dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), tmdmpId)).toList()));
this.datasetManager.updateTags(dataset, tags);
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.PUBLISHED);
} catch (Exception e) {
@ -1034,6 +1052,7 @@ public class DataManagementPlanManager {
}
}
@Transactional
public void makeFinalize(UUID id, Principal principal, DatasetsToBeFinalized datasetsToBeFinalized) throws Exception {
DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(id);
if (!isUserOwnerOfDmp(dmp, principal))
@ -1104,6 +1123,8 @@ public class DataManagementPlanManager {
}
dmp.setStatus(DMP.DMPStatus.FINALISED.getValue());
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
UUID dmpId = dmp.getId();
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.updateIndex(dmp);
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
sendNotification(dmp, user, NotificationType.DMP_FINALISED);
@ -1122,6 +1143,8 @@ public class DataManagementPlanManager {
throw new Exception("DMP is already Active");
dmp.setStatus(DMP.DMPStatus.ACTIVE.getValue());
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
UUID dmpId = dmp.getId();
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.updateIndex(dmp);
metricsManager.decreaseValue(MetricNames.DMP, 1, MetricNames.FINALIZED);
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
@ -1322,7 +1345,7 @@ public class DataManagementPlanManager {
eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
if (!dmp.isPublic() && dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException();
List<Dataset> datasets = dmp.getDataset().stream().collect(Collectors.toList());
List<Dataset> datasets = dmp.getDataset().stream().filter(dataset -> dataset.getStatus() != Dmp.DMPStatus.DELETED.getValue()).collect(Collectors.toList());
/*String fileName = dmp.getLabel();
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");*/
String uuid = UUID.randomUUID().toString();
@ -1731,6 +1754,8 @@ public class DataManagementPlanManager {
databaseRepository.getDmpDao().createOrUpdate(dmp);
assignUser(dmp, me);
if (this.apiContext.getOperationsContext().getElasticRepository().getDmpRepository().getClient() != null) {
UUID dmpId = dmp.getId();
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.updateIndex(dmp);
}
dmp.getDataset().forEach(dataset -> {
@ -1753,13 +1778,13 @@ public class DataManagementPlanManager {
try {
List<Tag> tags = new ArrayList<>();
eu.eudat.elastic.entities.Dataset elastic = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset);
if (elastic != null) {
tags = elastic.getTags();
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset);
datasetWizardModel.setTags(tags);
datasetManager.getTagsFromProfile(datasetWizardModel, dataset);
datasetManager.updateTags(dataset, datasetWizardModel.getTags());
}
datasetManager.getTagsFromProfile(datasetWizardModel, dataset);
datasetManager.updateTags(dataset, datasetWizardModel.getTags());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
@ -1822,6 +1847,9 @@ public class DataManagementPlanManager {
try {
if (dmp.getUsers() != null) {
logger.info(dmp.getUsers().toString());
} else {
UUID dmpId = dmp.getId();
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
}
this.updateIndex(dmp);
} catch (IOException e) {
@ -1839,6 +1867,8 @@ public class DataManagementPlanManager {
if (elastic != null) {
tags = elastic.getTags();
}
UUID dmpId = dataset.getDmp().getId();
dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.datasetManager.updateTags(dataset, tags);
} catch (Exception e) {
logger.error(e.getMessage(), e);
@ -1859,6 +1889,8 @@ public class DataManagementPlanManager {
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().toList();
dmps.forEach(dmp -> {
try {
UUID dmpId = dmp.getId();
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.updateIndex(dmp);
} catch (IOException e) {
logger.error(e.getMessage(), e);
@ -2093,10 +2125,10 @@ public class DataManagementPlanManager {
}
dataBuilder.append(" }\n").append("}");
createData = dataBuilder.toString();
ObjectMapper mapper = new ObjectMapper();
/*ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
JsonNode createDataJSON = mapper.readTree(createData);
HttpEntity<JsonNode> request = new HttpEntity<>(createDataJSON, headers);
JsonNode createDataJSON = mapper.readTree(createData);*/
HttpEntity<String> request = new HttpEntity<>(createData, headers);
Map createResponse = null;
LinkedHashMap<String, String> links = null;
String previousDOI = this.getPreviousDOI(dmp.getGroupId(), dmp.getId());

View File

@ -192,7 +192,7 @@ public class DatasetManager {
if (datasetTableRequest.getCriteria().getRole() != null) {
roles.add(datasetTableRequest.getCriteria().getRole());
}
authItems = databaseRepository.getDatasetDao().getAuthenticated(items, userInfo, roles);
authItems = databaseRepository.getDatasetDao().getAuthenticated(items, userInfo, roles).distinct();
pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
} else {
if (principal.getId() != null && datasetTableRequest.getCriteria().getRole() != null) {
@ -598,6 +598,8 @@ public class DatasetManager {
}
dataset1.setProfile(this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(datasetWizardModel.getProfile().getId()));
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
UUID dmpId = dataset1.getDmp().getId();
dataset1.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
updateTags(dataset1, datasetWizardModel.getTags());
if (sendNotification) {
if (dataset1.getStatus() != Dataset.Status.FINALISED.getValue()) {
@ -1014,6 +1016,8 @@ public class DatasetManager {
datasetEntities.forEach(datasetEntity -> {
try {
eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(datasetEntity.getId().toString());
UUID dmpId = datasetEntity.getDmp().getId();
datasetEntity.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
updateTags(datasetEntity, dataset != null ? dataset.getTags() : null);
} catch (Exception e) {
logger.error(e.getMessage(), e);

View File

@ -176,7 +176,7 @@ public class DatasetProfileManager {
response = restTemplate.exchange(url, HttpMethod.GET, entity, Object.class);
jsonContext = JsonPath.parse(response.getBody());
jsonItems = jsonContext.read(singleData.getOptionsRoot() + "['" + singleData.getAutoCompleteOptions().getLabel() + "','" + singleData.getAutoCompleteOptions().getValue() + "','" + singleData.getAutoCompleteOptions().getSource() + "','" + "uri" + "']");
jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(singleData.getAutoCompleteOptions().getValue()), item.get(singleData.getAutoCompleteOptions().getLabel()), item.get(singleData.getAutoCompleteOptions().getSource()) != null ? item.get(singleData.getAutoCompleteOptions().getSource()) : singleData.getAutoCompleteOptions().getSource(), item.get("uri"))));
jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(parseItem(item.get(singleData.getAutoCompleteOptions().getValue())), parseItem(item.get(singleData.getAutoCompleteOptions().getLabel())), item.get(singleData.getAutoCompleteOptions().getSource()) != null ? parseItem(item.get(singleData.getAutoCompleteOptions().getSource())) : singleData.getAutoCompleteOptions().getSource(), parseItem(item.get("uri")))));
break;
case CACHED:
headers.setAccept(Collections.singletonList(MediaType.valueOf("text/plain; charset=utf-8")));
@ -202,6 +202,20 @@ public class DatasetProfileManager {
//return result;
}
private String parseItem(Object item) {
if (item instanceof String) {
return (String) item;
}
if (item instanceof List) {
List listedItems = (List) item;
return parseItem(listedItems.get(0));
}
if (item instanceof Map) {
return (String) ((Map)item).get("$");
}
return item != null ? item.toString() : null;
}
public ResponseEntity<byte[]> getDocument(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
FileEnvelope envelope = getXmlDocument(datasetProfile, label);
InputStream resource = new FileInputStream(envelope.getFile());

View File

@ -3,6 +3,7 @@ package eu.eudat.logic.managers;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
@ -82,6 +83,23 @@ public class InvitationsManager {
return userModels;
}
public List<UserInfoInvitationModel> getUsersWithCriteria(Principal principal, UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException {
List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
.getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable()
.where(((builder, root) ->
builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))), principal.getId(), Stream.of(0, 1).collect(Collectors.toList()))
.toList().stream().map(DMP::getUsers).flatMap(Collection::stream).map(UserDMP::getUser)
.filter(userInfo -> !userInfo.getId().equals(principal.getId())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId))
.filter(userInfo -> (userInfoRequestItem == null || userInfoRequestItem.getCriteria() == null || userInfoRequestItem.getCriteria().getLike() == null
|| userInfo.getName().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase())
|| (userInfo.getEmail().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase()))))
.collect(Collectors.toList());
// .where((builder, root) -> builder.like(builder.upper(root.get("name")), "%" + userInfoRequestItem.getCriteria().getLike().toUpperCase() + "%"))
List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList());
return userModels;
}
public UUID assignUserAcceptedInvitation(UUID invitationID, Principal principal) throws UnauthorisedException, JAXBException, IOException {
eu.eudat.data.entities.Invitation invitation = apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().find(invitationID);
if (invitation == null)

View File

@ -107,7 +107,10 @@ public class MetricsManager {
{MetricNames.DMP_WITH_GRANT, Gauge.build().name(MetricNames.DMP_WITH_GRANT).help("Number of Grants based on the status of the DMP that is using them").labelNames("status").register(registry.getPrometheusRegistry())},
{MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT, Gauge.build().name(MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT).help("Number of Grants based on the status of the DMP that is using them during Nexus").labelNames("status").register(registry.getPrometheusRegistry())}
{MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT, Gauge.build().name(MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT).help("Number of Grants based on the status of the DMP that is using them during Nexus").labelNames("status").register(registry.getPrometheusRegistry())},
{MetricNames.INSTALLATIONS, Gauge.build().name(MetricNames.INSTALLATIONS).help("Number of Installations").register(registry.getPrometheusRegistry())},
{MetricNames.NEXUS + MetricNames.INSTALLATIONS, Gauge.build().name(MetricNames.NEXUS + MetricNames.INSTALLATIONS).help("Number of Installations").register(registry.getPrometheusRegistry())},
}).collect(Collectors.toMap(data -> (String)data[0], data -> (Gauge) data[1]));
@ -172,6 +175,9 @@ public class MetricsManager {
long files = Files.list(Paths.get(this.environment.getProperty("userguide.path"))).count();
calculateValue(MetricNames.LANGUAGES, (int) files, null);
calculateValue(MetricNames.INSTALLATIONS, 1, null);
calculateValue(MetricNames.NEXUS + MetricNames.INSTALLATIONS, 1, null);
logger.info("Metrics calculation Completed");
}

View File

@ -67,6 +67,7 @@ public class DmpMapper {
if (dataset1 != null) {
tags = dataset1.getTags();
}
dataset.setDmp(dmp);
return datasetMapper.toElastic(dataset, tags);
} catch (Exception e) {
logger.error(e.getMessage(), e);

View File

@ -58,4 +58,16 @@ public class ExternalUrlCriteria {
public ExternalUrlCriteria() {
}
@Override
public String toString() {
return "{" +
"like='" + like + '\'' +
", page='" + page + '\'' +
", pageSize='" + pageSize + '\'' +
", funderId='" + funderId + '\'' +
", path='" + path + '\'' +
", host='" + host + '\'' +
'}';
}
}

View File

@ -64,6 +64,7 @@ public class DefaultConfigLoader implements ConfigLoader {
private void setRdaProperties() {
String filePath = environment.getProperty("configuration.rda");
logger.info("Loaded also config file: " + filePath);
BufferedReader reader;
List<String> rdaList = new LinkedList<>();
try {
@ -83,6 +84,7 @@ public class DefaultConfigLoader implements ConfigLoader {
private void setDocument() {
String filePath = environment.getProperty("configuration.h2020template");
logger.info("Loaded also config file: " + filePath);
InputStream is = null;
try {
is = getStreamFromPath(filePath);
@ -100,6 +102,7 @@ public class DefaultConfigLoader implements ConfigLoader {
private void setConfigurableProviders() {
String filePath = environment.getProperty("configuration.configurable_login_providers");
logger.info("Loaded also config file: " + filePath);
InputStream is = null;
try {
is = getStreamFromPath(filePath);
@ -206,7 +209,6 @@ public class DefaultConfigLoader implements ConfigLoader {
}
}
}
this.setKeyToSourceMap();
return keyToSourceMap;
}

View File

@ -41,7 +41,7 @@ public class RemoteFetcher {
this.configLoader = configLoader;
}
@Cacheable("repositories")
@Cacheable(value = "repositories", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getRepositories(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getRepositories().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
@ -50,28 +50,28 @@ public class RemoteFetcher {
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("grants")
@Cacheable(value = "grants", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getGrants(ExternalUrlCriteria externalUrlCriteria) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs = configLoader.getExternalUrls().getGrants().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getGrants().getFetchMode();
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("projects")
@Cacheable(value = "projects", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getProjects(ExternalUrlCriteria externalUrlCriteria) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs = configLoader.getExternalUrls().getProjects().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getProjects().getFetchMode();
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("funders")
@Cacheable(value = "funders", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getFunders(ExternalUrlCriteria externalUrlCriteria) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs = configLoader.getExternalUrls().getFunders().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getFunders().getFetchMode();
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("organisations")
@Cacheable(value = "organisations", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getOrganisations(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getOrganisations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
@ -80,7 +80,7 @@ public class RemoteFetcher {
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("registries")
@Cacheable(value = "registries", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getRegistries(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getRegistries().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
@ -89,7 +89,7 @@ public class RemoteFetcher {
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("services")
@Cacheable(value = "services", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getServices(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getServices().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
@ -98,7 +98,7 @@ public class RemoteFetcher {
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("researchers")
@Cacheable(value = "researchers", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getResearchers(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getResearchers().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
@ -116,7 +116,7 @@ public class RemoteFetcher {
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}*/
@Cacheable("externalDatasets")
@Cacheable(value = "externalDatasets", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getDatasets(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getDatasets().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
@ -125,7 +125,7 @@ public class RemoteFetcher {
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("licenses")
@Cacheable(value = "licenses", keyGenerator = "externalUrlsKeyGenerator")
public List<Map<String, String>> getlicenses(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getLicenses().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())

View File

@ -25,6 +25,12 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor;
import java.util.*;
import java.util.stream.Collectors;
@ -348,9 +354,17 @@ public class WordBuilder {
CheckBoxData data = (CheckBoxData) field.getData();
if (field.getValue() == null || field.getValue().equals("false")) return null;
return data.getLabel();
case "freetext":
case "datepicker":
case "datePicker":
case "datePicker":{
Instant instant;
try {
instant = Instant.parse((String) field.getValue());
} catch (DateTimeParseException ex) {
instant = Instant.from(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).parse((String)field.getValue()));
}
return field.getValue() != null ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(instant) : "";
}
case "freetext":
case "textarea":
case "richTextarea":
return field.getValue() != null ? field.getValue().toString(): "";

View File

@ -20,6 +20,9 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -126,7 +129,11 @@ public class ExportXmlBuilder {
Map<String, Object> jsonElement = mapper.readValue(field.getValue().toString(), Map.class);
valueField.setTextContent((jsonElement.get("label") != null ? jsonElement.get("label").toString() : jsonElement.get("name") != null ? jsonElement.get("name").toString() : ""));
} catch (IOException e) {
valueField.setTextContent(field.getValue().toString());
try {
valueField.setTextContent(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(Instant.parse(field.getValue().toString())));
} catch (Exception exc) {
valueField.setTextContent(field.getValue().toString());
}
}
}
elementField.appendChild(valueField);

View File

@ -95,14 +95,14 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
this.autoCompleteSingleDataList.add(new AutoCompleteSingleData());
this.mapFromXml(item, this.autoCompleteSingleDataList.get(0));
}
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutocomplete"));
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
return this;
}
private void mapFromXml(Element item, AutoCompleteSingleData singleData) {
singleData.url = item.getAttribute("url");
singleData.optionsRoot = item.getAttribute("optionsRoot");
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutocomplete"));
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
if (item.getAttribute("autoCompleteType") == null || item.getAttribute("autoCompleteType").equals("") ) {
singleData.autocompleteType = AutocompleteType.UNCACHED.getValue();
} else {
@ -173,7 +173,7 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
dataMap.put("label", item != null ? item.getAttribute("label") : "");
//dataMap.put("url", item != null ? item.getAttribute("url") : "");
dataMap.put("type", item != null ? item.getAttribute("type") : "autocomplete");
dataMap.put("multiAutoComplete", item != null ? Boolean.valueOf(item.getAttribute("multiAutocomplete")) : false);
dataMap.put("multiAutoComplete", item != null ? Boolean.valueOf(item.getAttribute("multiAutoComplete")) : false);
List<Map<String, Object>> autoCompletes = new ArrayList<>();
NodeList autoCompleteSingles = item.getChildNodes();
for (int i = 0; i < autoCompleteSingles.getLength(); i++) {

View File

@ -196,7 +196,7 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
this.grant = entity.getDmp() != null ? entity.getDmp().getGrant().getLabel() : "";
this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
//this.profile = entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()) : null;
this.profile = entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()) : null;
this.description = entity.getDescription();
this.status = entity.getStatus();
//this.grantAbbreviation = entity.getDmp() != null ? entity.getDmp().getGrant().getAbbreviation() : "";

View File

@ -20,6 +20,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -152,7 +156,12 @@ public class DatasetRDAMapper {
templateIdsToValues.entrySet().forEach(entry -> {
boolean isFound = foundNodes.stream().anyMatch(node -> node.get("id").asText().equals(entry.getKey()));
if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) {
rda.setAdditionalProperty(entry.getKey(), entry.getValue());
try {
Instant time = Instant.parse(entry.getValue().toString());
rda.setAdditionalProperty(entry.getKey(), DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(time));
} catch (DateTimeParseException e) {
rda.setAdditionalProperty(entry.getKey(), entry.getValue());
}
}
});

View File

@ -95,7 +95,7 @@ public class DmpRDAMapper {
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
}
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset, rda.getContributor())).collect(Collectors.toList()));
rda.setDataset(dmp.getDataset().stream().filter(dataset -> dataset.getStatus() != eu.eudat.elastic.entities.Dmp.DMPStatus.DELETED.getValue()).map(dataset -> datasetRDAMapper.toRDA(dataset, rda.getContributor())).collect(Collectors.toList()));
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray());
return rda;

View File

@ -47,6 +47,8 @@ public class ProjectRDAMapper {
((eu.eudat.data.entities.Project) entities.get("project")).setStatus((short)1);
((eu.eudat.data.entities.Project) entities.get("project")).setCreated(new Date());
((eu.eudat.data.entities.Project) entities.get("project")).setModified(new Date());
((eu.eudat.data.entities.Project) entities.get("project")).setStartdate(new Date());
((eu.eudat.data.entities.Project) entities.get("project")).setEnddate(new Date());
((eu.eudat.data.entities.Project) entities.get("project")).setType(0);
apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().createOrUpdate(((eu.eudat.data.entities.Project) entities.get("project")));
for (int i = 0; i < rda.getFunding().size(); i++) {

View File

@ -2,6 +2,7 @@ package eu.eudat.types;
public class MetricNames {
public static final String DATASET_TEMPLATE = "argos_dataset_templates";
public static final String INSTALLATIONS = "installations";
public static final String USERS = "argos_users";
public static final String DMP = "argos_managed_dmps";
public static final String DATASET = "argos_managed_dataset_descriptions";

View File

@ -75,6 +75,7 @@ export class MultipleAutoCompleteComponent extends _CustomComponentMixinBase imp
get shouldLabelFloat() { return this.focused || !this.empty; }
@Input() minLength: number = 0;
@Input() showNoResultsLabel: boolean = true;
@Input() hidePlaceholder: boolean = false;
@Input()
@ -268,7 +269,7 @@ export class MultipleAutoCompleteComponent extends _CustomComponentMixinBase imp
distinctUntilChanged(),
distinctUntilChanged(),
tap(query => this.queryValue = query),
switchMap(query => this.filter(query)));
switchMap(query => (!this.minLength || (query && query.length >= this.minLength)) ? this.filter(query) : observableOf([])));
if (this.configuration.groupingFn) { this._groupedItems = this._items.pipe(map(items => this.configuration.groupingFn(items))); }
}

View File

@ -186,6 +186,7 @@
</div>
<div class="col-12">
<div class="heading">1.4 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}</div>
<div class="hint">{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS-HINT'| translate}}</div>
<div class="full-width basic-info-input">
<table class="col-12 user-table">
<thead class="user-table-header">

View File

@ -21,7 +21,7 @@
<div class="mat-elevation-z6">
<!-- <mat-card class="row mat-card"> -->
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()" matSortActive="created" matSortDirection="desc">
<!-- Column Definition: Name -->
<ng-container cdkColumnDef="label">

View File

@ -265,6 +265,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockStatus = lockStatus;
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
this.datasetWizardModel.status = 0;
this.formGroup = this.datasetWizardModel.buildForm();
this.formGroup.get('id').setValue(null);
this.dmpService.getSingle(newDmpId).pipe(map(data => data as DmpModel))

View File

@ -10,7 +10,8 @@
<mat-form-field class="col pt-0 pb-2 mb-4 search">
<!-- <mat-label>{{'INVITATION-EDITOR.AUTOCOMPLETE-USER-EMAIL' | translate}}</mat-label> -->
<app-multiple-auto-complete [formControl]="formGroup.get('users')" placeholder="{{'INVITATION-EDITOR.AUTOCOMPLETE-USER-EMAIL' | translate}}"
[configuration]="usersAutoCompleteConfiguration" [showNoResultsLabel]="false">
[configuration]="usersAutoCompleteConfiguration" [showNoResultsLabel]="false"
[minLength]="3">
</app-multiple-auto-complete>
</mat-form-field>
<p class="d-flex m-0 hint">

View File

@ -74,7 +74,7 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
const val = typeof(item) === 'string'? item : item.email;
const regexp = new RegExp(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
return !regexp.test(val);
}
}
}]
};

View File

@ -289,10 +289,11 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-REMOVE-USER": "Remove User",
"DATASET-TEMPLATE-NO-USERS-YET": "... No users yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add User",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,10 +289,11 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-REMOVE-USER": "Remove User",
"DATASET-TEMPLATE-NO-USERS-YET": "... No users yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add User",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -84,7 +84,7 @@
"JSON-FILES": "ficheros .json",
"PRODUCED": "producido",
"RDA-SPECIFICATIONS": "de acuerdo a las especificaciones RDA",
"MACHINE-ACTIONABLE": "para PGDs procesables por máquinas",
"MACHINE-ACTIONABLE": "para PGDs procesables por máquinas",
"UPLOAD-FILE": "Subir fichero",
"REPLACE-FILE": "Reemplar ichero"
},
@ -289,10 +289,11 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "Una breve descripción acerca del Dataset, su alcance y objetivos.",
"DATASET-TEMPLATE-LANGUAGE": "Idioma de la plantilla del Dataset",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Seleccione un idioma",
"DATASET-TEMPLATE-USERS": "Usuarios",
"DATASET-TEMPLATE-NO-USERS-YET": "... Aún no hay usuarios",
"DATASET-TEMPLATE-REMOVE-USER": "Eliminar usuario",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validar y añadir usuario",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Descripción de la plantilla del Dataset",
"UNTITLED": "Sin título",
"QUESTION": "Pregunta",
@ -431,7 +432,7 @@
"FIELD-MULTIPLE-AUTOCOMPLETE": "Autocompeltado múltiple",
"FIELD-MULTIPLE-WORDLIST": "Selección múltiple",
"FIELD-CURRENCY-TITLE": "Datos de moneda",
"FIELD-CURRENCY-PLACEHOLDER": "Introduzca marcador del texto",
"FIELD-CURRENCY-PLACEHOLDER": "Introduzca marcador del texto",
"FIELD-REGISTRIES-TITLE": "Datos de registros",
"FIELD-REGISTRIES-PLACEHOLDER": "Introduzca marcador del texto",
"FIELD-SERVICES-TITLE": "Datos de servicios",
@ -1240,7 +1241,7 @@
"EXTERNAL-LINK": "Facilite una URL"
},
"HINT": {
"DESCRIPTION": "Describa brevemente el contexto y propósito del Dataset",
"DESCRIPTION": "Describa brevemente el contexto y propósito del Dataset",
"TITLE": "Una breve descripción sobre el ",
"TITLE-REST": " su alcance y objetivos."
},

View File

@ -289,10 +289,11 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-NO-USERS-YET": "... No users yet",
"DATASET-TEMPLATE-REMOVE-USER": "Remove User",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add User",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,10 +289,11 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "Uma breve descrição do que é o modelo de dados, o seu âmbito e objetivos.",
"DATASET-TEMPLATE-LANGUAGE": "Idioma do modelo de dados",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Selecione o idioma",
"DATASET-TEMPLATE-USERS": "Utilizadores",
"DATASET-TEMPLATE-REMOVE-USER": "Remover Utilizador",
"DATASET-TEMPLATE-NO-USERS-YET": "... Ainda sem utilizadores",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validar e adicionar utilizador",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Descrição do modelo de dados",
"UNTITLED": "Sem título",
"QUESTION": "Questão",

View File

@ -289,10 +289,11 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-REMOVE-USER": "Remove User",
"DATASET-TEMPLATE-NO-USERS-YET": "... No users yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add User",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,10 +289,11 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-NO-USERS-YET": "... No users yet",
"DATASET-TEMPLATE-REMOVE-USER": "Remove User",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add User",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",

View File

@ -289,10 +289,11 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-REMOVE-USER": "Remove User",
"DATASET-TEMPLATE-NO-USERS-YET": "... No users yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add User",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",