Compare commits
94 Commits
return-url
...
master
Author | SHA1 | Date |
---|---|---|
Diamantis Tziotzios | e8aef281d4 | |
Diamantis Tziotzios | 00c6978594 | |
Diamantis Tziotzios | 3adb518e61 | |
Konstantina Galouni | eb74ef86b9 | |
Diamantis Tziotzios | a1ee9c82bc | |
Diamantis Tziotzios | 5e5bd39313 | |
Diamantis Tziotzios | 5e99cef60e | |
Diamantis Tziotzios | cc7edc2f49 | |
Diamantis Tziotzios | a1849c64ca | |
Diamantis Tziotzios | 192220161b | |
George Kalampokis | 87758c3e9a | |
Diamantis Tziotzios | 83342f5afa | |
Diamantis Tziotzios | 65cdb3b6ea | |
Diamantis Tziotzios | 536ba9b900 | |
Alexandros Mandilaras | 6bd3302788 | |
Diamantis Tziotzios | 4970f5812f | |
Diamantis Tziotzios | 9fed92dbcb | |
Diamantis Tziotzios | 44dab9c19a | |
Alexandros Mandilaras | 54f911d826 | |
Diamantis Tziotzios | 9879050eab | |
Diamantis Tziotzios | 8a41a7dcd9 | |
Diamantis Tziotzios | d60cc144d5 | |
Georgios Kakaletris | 9c37e5a073 | |
Georgios Kakaletris | 444c1aacb1 | |
Diamantis Tziotzios | 59d7383947 | |
Diamantis Tziotzios | 6caa1af134 | |
George Kalampokis | 74a6019a72 | |
George Kalampokis | 5c903c0f48 | |
George Kalampokis | ec8f6a6d48 | |
Bernaldo Mihasi | ecd86f413a | |
Bernaldo Mihasi | c238615b50 | |
Bernaldo Mihasi | 10d0f1fb0e | |
Bernaldo Mihasi | 846405435c | |
Bernaldo Mihasi | dfc9e14003 | |
Bernaldo Mihasi | bc1894586b | |
Bernaldo Mihasi | 2bf0a857bc | |
Bernaldo Mihasi | 3d10e8ad28 | |
Bernaldo Mihasi | 53b61853e1 | |
Bernaldo Mihasi | d644b1dc91 | |
Diamantis Tziotzios | 50c96ef821 | |
Konstantina Galouni | 0adc7044ab | |
Konstantina Galouni | 13e62fd409 | |
Diamantis Tziotzios | 7185b5d117 | |
George Kalampokis | 5f131b9823 | |
Diamantis Tziotzios | 93320f7c94 | |
Diamantis Tziotzios | 876d99ce38 | |
George Kalampokis | 7a71110033 | |
Diamantis Tziotzios | 14c267c97e | |
Diamantis Tziotzios | b04b35d62b | |
Diamantis Tziotzios | 7a8375b988 | |
Diamantis Tziotzios | 895dbcf098 | |
Diamantis Tziotzios | bd15b1e2c7 | |
George Kalampokis | faabd343a9 | |
George Kalampokis | e5a929f259 | |
George Kalampokis | d1fc10854c | |
George Kalampokis | 2537923dc0 | |
George Kalampokis | c1adbe283a | |
George Kalampokis | 1c365a191e | |
Kristian Ntavidi | 82c5586067 | |
George Kalampokis | 04f230dff1 | |
George Kalampokis | 72d88d9db4 | |
George Kalampokis | 143a4c0214 | |
George Kalampokis | e7e5ed02b3 | |
George Kalampokis | b5fcc5971e | |
Diamantis Tziotzios | c16c35225f | |
Diamantis Tziotzios | f5d266554b | |
Diamantis Tziotzios | db31597fc0 | |
Diamantis Tziotzios | 9f5054668e | |
George Kalampokis | 38986ef67b | |
Diamantis Tziotzios | bff260b85b | |
George Kalampokis | 9519300dc4 | |
George Kalampokis | 9373d3e038 | |
dtziotzios | d971f02a94 | |
Georgios Kakaletris | d3915e26e7 | |
George Kalampokis | c028aad615 | |
Diamantis Tziotzios | 4ee39074a3 | |
Diamantis Tziotzios | 1b4952a909 | |
Diamantis Tziotzios | 3ada5a0d3d | |
Diamantis Tziotzios | 63ee865dd9 | |
Diamantis Tziotzios | 2a52138124 | |
Diamantis Tziotzios | 7cf64c18f2 | |
Diamantis Tziotzios | 71d317bab7 | |
Ioannis Kalyvas | cd8b3448f5 | |
Ioannis Kalyvas | c3d4cb6fdd | |
Ioannis Kalyvas | b0ccac191f | |
Ioannis Kalyvas | 3b1f37ef22 | |
Ioannis Kalyvas | b8e040ee94 | |
Ioannis Kalyvas | 50444a0b73 | |
Diamantis Tziotzios | 85bdb7fad1 | |
annabakouli | b2e49fbb8a | |
Diamantis Tziotzios | bfc6b63067 | |
Nikolaos Laskaris | 9941c96dc2 | |
Nikolaos Laskaris | 06272c79da | |
Nikolaos Laskaris | a00eec68d8 |
|
@ -48,3 +48,4 @@ bin/
|
||||||
*.classpath
|
*.classpath
|
||||||
openDMP/dmp-backend/uploads/
|
openDMP/dmp-backend/uploads/
|
||||||
openDMP/dmp-backend/tmp/
|
openDMP/dmp-backend/tmp/
|
||||||
|
dmp-frontend/.angular/
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
|
||||||
|
**Important note: The deployment, troubleshooting, maintenance and operation of on-premises / self-served OpenDMP instances for development, testing or production use, shall be the sole responsibility of the adopter. No support is guaranteed by OpenDMP implentation team for issues that may be encountered during deployment, extension or operation of such installations.**
|
||||||
|
|
||||||
|
**Documentation is provided on a best-effort basis for the code and processes around the development, deployment and operation of OpenDMP. If you find any misalignment of the actual processes with the related documentation, please let us know so that the misalignment is addressed for the benefit of future adopters.**
|
||||||
|
|
||||||
|
|
||||||
# Using Docker Compose with Argos
|
# Using Docker Compose with Argos
|
||||||
|
|
||||||
ARGOS is an open extensible service that simplifies the management, validation, monitoring and maintenance and of Data Management Plans. It allows actors (researchers, managers, supervisors etc) to create actionable DMPs that may be freely exchanged among infrastructures for carrying out specific aspects of the Data management process in accordance with the intentions and commitment of Data owners.
|
ARGOS is an open extensible service that simplifies the management, validation, monitoring and maintenance and of Data Management Plans. It allows actors (researchers, managers, supervisors etc) to create actionable DMPs that may be freely exchanged among infrastructures for carrying out specific aspects of the Data management process in accordance with the intentions and commitment of Data owners.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
import eu.eudat.data.entities.Grant;
|
import eu.eudat.data.entities.Grant;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -10,6 +11,7 @@ import java.util.UUID;
|
||||||
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
private Date periodEnd;
|
private Date periodEnd;
|
||||||
|
private DMPProfile profile;
|
||||||
private List<eu.eudat.data.entities.Grant> grants;
|
private List<eu.eudat.data.entities.Grant> grants;
|
||||||
private boolean allVersions;
|
private boolean allVersions;
|
||||||
private List<UUID> groupIds;
|
private List<UUID> groupIds;
|
||||||
|
@ -37,6 +39,13 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||||
this.periodEnd = periodEnd;
|
this.periodEnd = periodEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DMPProfile getProfile() {
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
public void setProfile(DMPProfile profile) {
|
||||||
|
this.profile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Grant> getGrants() {
|
public List<Grant> getGrants() {
|
||||||
return grants;
|
return grants;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
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.getProfile() != null)
|
||||||
|
query.where((builder, root) -> builder.equal(root.get("profile"), criteria.getProfile()));
|
||||||
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
||||||
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
||||||
if (!criteria.getAllVersions())
|
if (!criteria.getAllVersions())
|
||||||
|
@ -75,7 +77,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
||||||
}
|
}
|
||||||
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
|
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
|
||||||
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
|
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("datasetprofile").get("id").in(criteria.getDatasetTemplates()));
|
||||||
}
|
}
|
||||||
if (criteria.getGrantStatus() != null) {
|
if (criteria.getGrantStatus() != null) {
|
||||||
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
|
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class DescriptionTemplateTypeDaoImpl extends DatabaseAccess<DescriptionTe
|
||||||
@Override
|
@Override
|
||||||
public DescriptionTemplateType findFromName(String name){
|
public DescriptionTemplateType findFromName(String name){
|
||||||
try {
|
try {
|
||||||
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal(root.get("name"), name)).getSingle();
|
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.and(builder.equal(root.get("name"), name), builder.notEqual(root.get("status"), DescriptionTemplateType.Status.DELETED.getValue()))).getSingle();
|
||||||
}
|
}
|
||||||
catch(Exception e){
|
catch(Exception e){
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -15,6 +15,8 @@ public class DataManagementPlanBlueprintTableRequest extends TableQuery<DataMana
|
||||||
QueryableList<DMPProfile> query = this.getQuery();
|
QueryableList<DMPProfile> query = this.getQuery();
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
|
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
|
||||||
|
if (this.getCriteria().getStatus() != null)
|
||||||
|
query.where((builder, root) -> builder.equal(root.get("status"), this.getCriteria().getStatus()));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||||
|
|
||||||
|
@ -222,6 +226,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>1.5.9.RELEASE</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class Admin extends BaseController {
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
|
||||||
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN ,DATASET_PROFILE_MANAGER}) Principal principal) {
|
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN ,DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||||
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
|
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
|
||||||
DatasetProfile shortenProfile = profile.toShort();
|
DatasetProfile shortenProfile = profile.toShort();
|
||||||
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||||
|
@ -80,7 +80,7 @@ public class Admin extends BaseController {
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||||
DatasetProfile shortenProfile = profile.toShort();
|
DatasetProfile shortenProfile = profile.toShort();
|
||||||
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||||
DescriptionTemplate datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
DescriptionTemplate datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||||
|
@ -124,7 +124,7 @@ public class Admin extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json")
|
||||||
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||||
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(modelDefinition);
|
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(modelDefinition);
|
||||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||||
|
@ -161,6 +161,7 @@ public class Admin extends BaseController {
|
||||||
datasetProfile.setStatus(profile.getStatus());
|
datasetProfile.setStatus(profile.getStatus());
|
||||||
datasetProfile.setDescription(profile.getDescription());
|
datasetProfile.setDescription(profile.getDescription());
|
||||||
datasetProfile.setLanguage(profile.getLanguage());
|
datasetProfile.setLanguage(profile.getLanguage());
|
||||||
|
datasetProfile.setType(profile.getType().getName());
|
||||||
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.data.entities.DMPProfile;
|
||||||
import eu.eudat.data.entities.DescriptionTemplate;
|
import eu.eudat.data.entities.DescriptionTemplate;
|
||||||
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
|
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
|
||||||
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||||
|
import eu.eudat.exceptions.dmpblueprint.DmpBlueprintUsedException;
|
||||||
import eu.eudat.logic.managers.DataManagementProfileManager;
|
import eu.eudat.logic.managers.DataManagementProfileManager;
|
||||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
@ -29,6 +30,7 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static eu.eudat.types.Authorities.ADMIN;
|
import static eu.eudat.types.Authorities.ADMIN;
|
||||||
|
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/21/2018.
|
* Created by ikalyvas on 3/21/2018.
|
||||||
|
@ -71,7 +73,7 @@ public class DMPProfileController extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSingleBlueprint/{id}"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/getSingleBlueprint/{id}"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DataManagementPlanBlueprintListingModel>> getSingleBlueprint(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
ResponseEntity<ResponseItem<DataManagementPlanBlueprintListingModel>> getSingleBlueprint(@PathVariable String id, Principal principal) {
|
||||||
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
|
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanBlueprintListingModel));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanBlueprintListingModel));
|
||||||
}
|
}
|
||||||
|
@ -90,6 +92,26 @@ public class DMPProfileController extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanBlueprintListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanBlueprintListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public ResponseEntity<ResponseItem<DataManagementPlanBlueprintListingModel>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||||
|
DataManagementPlanBlueprintListingModel dmpBlueprint = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
|
||||||
|
dmpBlueprint.setLabel(dmpBlueprint.getLabel() + " new ");
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().payload(dmpBlueprint));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<Void>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||||
|
try {
|
||||||
|
this.dataManagementProfileManager.inactivate(id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
|
} catch (DmpBlueprintUsedException exception) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IOException {
|
ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IOException {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.logic.managers.DatasetProfileManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
|
import eu.eudat.models.data.datasetprofile.DatasetProfileWithPrefillingPropertyModel;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -42,5 +43,12 @@ public class DatasetProfiles extends BaseController {
|
||||||
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
|
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getAllWithPrefilling"}, produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>> getAllWithPrefilling(@RequestBody DatasetProfileTableRequestItem tableRequestItem) {
|
||||||
|
List<DatasetProfileWithPrefillingPropertyModel> datasetProfileTableData = this.datasetProfileManager.getAllWithPrefilling(tableRequestItem);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package eu.eudat.exceptions.dmpblueprint;
|
||||||
|
|
||||||
|
public class DmpBlueprintUsedException extends RuntimeException {
|
||||||
|
public DmpBlueprintUsedException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpBlueprintUsedException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpBlueprintUsedException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpBlueprintUsedException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.logic.builders.entity;
|
package eu.eudat.logic.builders.entity;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DescriptionTemplate;
|
import eu.eudat.data.entities.DescriptionTemplate;
|
||||||
|
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||||
import eu.eudat.logic.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.entities.Dataset;
|
import eu.eudat.data.entities.Dataset;
|
||||||
|
|
||||||
|
@ -17,6 +18,8 @@ public class DatasetProfileBuilder extends Builder<DescriptionTemplate> {
|
||||||
|
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
|
private DescriptionTemplateType type;
|
||||||
|
|
||||||
private Set<Dataset> dataset;
|
private Set<Dataset> dataset;
|
||||||
|
|
||||||
private String definition;
|
private String definition;
|
||||||
|
@ -41,6 +44,11 @@ public class DatasetProfileBuilder extends Builder<DescriptionTemplate> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DatasetProfileBuilder type(DescriptionTemplateType type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DatasetProfileBuilder dataset(Set<Dataset> dataset) {
|
public DatasetProfileBuilder dataset(Set<Dataset> dataset) {
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
return this;
|
return this;
|
||||||
|
@ -88,6 +96,7 @@ public class DatasetProfileBuilder extends Builder<DescriptionTemplate> {
|
||||||
descriptionTemplate.setModified(modified);
|
descriptionTemplate.setModified(modified);
|
||||||
descriptionTemplate.setLabel(label);
|
descriptionTemplate.setLabel(label);
|
||||||
descriptionTemplate.setLanguage(language);
|
descriptionTemplate.setLanguage(language);
|
||||||
|
descriptionTemplate.setType(type);
|
||||||
return descriptionTemplate;
|
return descriptionTemplate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.managers;
|
||||||
import eu.eudat.data.dao.entities.DatasetDao;
|
import eu.eudat.data.dao.entities.DatasetDao;
|
||||||
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
||||||
import eu.eudat.data.entities.DescriptionTemplate;
|
import eu.eudat.data.entities.DescriptionTemplate;
|
||||||
|
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||||
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
|
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
|
||||||
import eu.eudat.logic.builders.entity.DatasetProfileBuilder;
|
import eu.eudat.logic.builders.entity.DatasetProfileBuilder;
|
||||||
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel;
|
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel;
|
||||||
|
@ -18,8 +19,9 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class AdminManager {
|
public class AdminManager {
|
||||||
|
|
||||||
public static DescriptionTemplate generateViewStyleDefinition(DatasetProfile profile, ApiContext apiContext) {
|
public static DescriptionTemplate generateViewStyleDefinition(DatasetProfile profile, ApiContext apiContext) throws Exception {
|
||||||
ViewStyleModel viewStyleModel = new ViewStyleModel();
|
ViewStyleModel viewStyleModel = new ViewStyleModel();
|
||||||
|
viewStyleModel.setEnablePrefilling(profile.isEnablePrefilling());
|
||||||
viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section.class));
|
viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section.class));
|
||||||
viewStyleModel.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Page.class));
|
viewStyleModel.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Page.class));
|
||||||
Document viewStyleDoc = XmlBuilder.getDocument();
|
Document viewStyleDoc = XmlBuilder.getDocument();
|
||||||
|
@ -35,8 +37,17 @@ public class AdminManager {
|
||||||
profile.setLanguage("en");
|
profile.setLanguage("en");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DescriptionTemplateType type;
|
||||||
|
try {
|
||||||
|
type = apiContext.getOperationsContext().getDatabaseRepository().getDescriptionTemplateTypeDao().findFromName(profile.getType());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new Exception("Description template type '" + profile.getType() + "' could not be found.");
|
||||||
|
}
|
||||||
|
|
||||||
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel())
|
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel())
|
||||||
.status(profile.getStatus()).created(new Date()).description(profile.getDescription()).language(profile.getLanguage())
|
.status(profile.getStatus()).created(new Date()).description(profile.getDescription()).language(profile.getLanguage())
|
||||||
|
.type(type)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (descriptionTemplate.getGroupId() == null) {
|
if (descriptionTemplate.getGroupId() == null) {
|
||||||
|
|
|
@ -202,14 +202,14 @@ public class DashBoardManager {
|
||||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
||||||
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
|
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
|
||||||
|
|
||||||
CompletableFuture<List<RecentActivityData>> grants = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user)
|
/*CompletableFuture<List<RecentActivityData>> grants = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user)
|
||||||
.withHint("grantRecentActivity")
|
.withHint("grantRecentActivity")
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.take(numberofactivities)
|
.take(numberofactivities)
|
||||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
||||||
.whenComplete((grantActivities, throwable) -> activity.setRecentGrantActivities(grantActivities));
|
.whenComplete((grantActivities, throwable) -> activity.setRecentGrantActivities(grantActivities));*/
|
||||||
|
|
||||||
CompletableFuture.allOf(grants, dmps, datasets).join();
|
CompletableFuture.allOf(/*grants, */dmps, datasets).join();
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
||||||
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
||||||
|
@ -66,6 +68,7 @@ import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.types.Authorities;
|
import eu.eudat.types.Authorities;
|
||||||
import eu.eudat.types.MetricNames;
|
import eu.eudat.types.MetricNames;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||||
|
@ -143,6 +146,7 @@ public class DataManagementPlanManager {
|
||||||
public DataTableData<DataManagementPlanListingModel> getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
public DataTableData<DataManagementPlanListingModel> getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||||
UUID principalID = principal.getId();
|
UUID principalID = principal.getId();
|
||||||
List<Dmp> dmps = null;
|
List<Dmp> dmps = null;
|
||||||
|
|
||||||
QueryableList<DMP> items = null;
|
QueryableList<DMP> items = null;
|
||||||
QueryableList<DMP> authItems = null;
|
QueryableList<DMP> authItems = null;
|
||||||
Long totalData = 0L;
|
Long totalData = 0L;
|
||||||
|
@ -480,7 +484,7 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
DMP newDmp = dataManagementPlan.toDataModel();
|
DMP newDmp = dataManagementPlan.toDataModel();
|
||||||
if(dataManagementPlan.getProfile() != null){
|
if(dataManagementPlan.getProfile() != null){
|
||||||
DMPProfile dmpProfile = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(dataManagementPlan.getProfile().getId());
|
DMPProfile dmpProfile = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(dataManagementPlan.getProfile());
|
||||||
newDmp.setProfile(dmpProfile);
|
newDmp.setProfile(dmpProfile);
|
||||||
}
|
}
|
||||||
if (newDmp.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
if (newDmp.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
||||||
|
@ -527,7 +531,7 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
||||||
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
|
if (newDmp.getGrant() != null && newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
|
||||||
checkIfUserCanEditGrant(newDmp, user);
|
checkIfUserCanEditGrant(newDmp, user);
|
||||||
}
|
}
|
||||||
assignGrandUserIfInternal(newDmp, user);
|
assignGrandUserIfInternal(newDmp, user);
|
||||||
|
@ -540,14 +544,24 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newDmp.getId() != null){
|
if(newDmp.getId() != null){
|
||||||
|
UUID dmpId = newDmp.getId();
|
||||||
|
List<DMPDatasetProfile> dmpDatasetProfiles = apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().asQueryable()
|
||||||
|
.where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList();
|
||||||
|
for (DMPDatasetProfile dmpDatasetProfile : dmpDatasetProfiles) {
|
||||||
|
if (newDmp.getAssociatedDmps().stream().filter(dmpDatasetProfile1 -> dmpDatasetProfile1.getId() != null).noneMatch(dmpDatasetProfile1 -> dmpDatasetProfile1.getId().equals(dmpDatasetProfile.getId()))) {
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().delete(dmpDatasetProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
|
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().createOrUpdate(dmpDatasetProfile);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().createOrUpdate(dmpDatasetProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
||||||
|
if (newDmp.getGrant() != null) {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
|
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||||
|
|
||||||
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
|
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
|
||||||
|
@ -716,7 +730,7 @@ public class DataManagementPlanManager {
|
||||||
newDmp.setId(null);
|
newDmp.setId(null);
|
||||||
|
|
||||||
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
||||||
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
|
if (newDmp.getGrant() != null && newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
|
||||||
checkIfUserCanEditGrant(newDmp, user);
|
checkIfUserCanEditGrant(newDmp, user);
|
||||||
}
|
}
|
||||||
assignGrandUserIfInternal(newDmp, user);
|
assignGrandUserIfInternal(newDmp, user);
|
||||||
|
@ -728,6 +742,7 @@ public class DataManagementPlanManager {
|
||||||
assignProjectUserIfInternal(newDmp, user);
|
assignProjectUserIfInternal(newDmp, user);
|
||||||
}
|
}
|
||||||
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
||||||
|
if (newDmp.getGrant() != null) {
|
||||||
if (newDmp.getGrant().getStartdate() == null) {
|
if (newDmp.getGrant().getStartdate() == null) {
|
||||||
newDmp.getGrant().setStartdate(new Date());
|
newDmp.getGrant().setStartdate(new Date());
|
||||||
}
|
}
|
||||||
|
@ -736,6 +751,7 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
|
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
|
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
|
||||||
newDmp.setId(tempDmp.getId());
|
newDmp.setId(tempDmp.getId());
|
||||||
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
|
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
|
||||||
|
@ -803,7 +819,7 @@ public class DataManagementPlanManager {
|
||||||
newDmp.setId(null);
|
newDmp.setId(null);
|
||||||
|
|
||||||
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
||||||
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
|
if (newDmp.getGrant() != null && newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
|
||||||
checkIfUserCanEditGrant(newDmp, user);
|
checkIfUserCanEditGrant(newDmp, user);
|
||||||
}
|
}
|
||||||
assignGrandUserIfInternal(newDmp, user);
|
assignGrandUserIfInternal(newDmp, user);
|
||||||
|
@ -815,8 +831,10 @@ public class DataManagementPlanManager {
|
||||||
assignProjectUserIfInternal(newDmp, user);
|
assignProjectUserIfInternal(newDmp, user);
|
||||||
}
|
}
|
||||||
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
||||||
|
if (newDmp.getGrant() != null) {
|
||||||
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
|
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
|
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
|
||||||
newDmp.setId(tempDmp.getId());
|
newDmp.setId(tempDmp.getId());
|
||||||
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
|
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
|
||||||
|
@ -1353,151 +1371,184 @@ public class DataManagementPlanManager {
|
||||||
dmpBlueprintModel.fromDataModel(dmpProfile);
|
dmpBlueprintModel.fromDataModel(dmpProfile);
|
||||||
DataManagementPlanBlueprint dmpBlueprint = dmpBlueprintModel.getDefinition();
|
DataManagementPlanBlueprint dmpBlueprint = dmpBlueprintModel.getDefinition();
|
||||||
for(Section section: dmpBlueprint.getSections()) {
|
for(Section section: dmpBlueprint.getSections()) {
|
||||||
wordBuilder.addParagraphContent("Section " + section.getOrdinal(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
|
wordBuilder.addParagraphContent(section.getOrdinal() + ". " + section.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
|
||||||
XWPFParagraph sectionInfoParagraph = document.createParagraph();
|
// XWPFParagraph sectionInfoParagraph = document.createParagraph();
|
||||||
sectionInfoParagraph.setSpacingBetween(1.0);
|
// sectionInfoParagraph.setSpacingBetween(1.0);
|
||||||
XWPFRun runSectionTitle = sectionInfoParagraph.createRun();
|
// XWPFRun runSectionTitle = sectionInfoParagraph.createRun();
|
||||||
runSectionTitle.setText("Title: ");
|
// runSectionTitle.setText("Title: ");
|
||||||
runSectionTitle.setColor("000000");
|
// runSectionTitle.setColor("000000");
|
||||||
XWPFRun runSectionTitleText = sectionInfoParagraph.createRun();
|
// XWPFRun runSectionTitleText = sectionInfoParagraph.createRun();
|
||||||
runSectionTitleText.setText(section.getLabel());
|
// runSectionTitleText.setText(section.getLabel());
|
||||||
runSectionTitleText.setColor("116a78");
|
// runSectionTitleText.setColor("116a78");
|
||||||
XWPFParagraph sectionDescriptionParagraph = document.createParagraph();
|
// XWPFParagraph sectionDescriptionParagraph = document.createParagraph();
|
||||||
XWPFRun runSectionDescription = sectionDescriptionParagraph.createRun();
|
// XWPFRun runSectionDescription = sectionDescriptionParagraph.createRun();
|
||||||
runSectionDescription.setText("Description: ");
|
// runSectionDescription.setText("Description: ");
|
||||||
runSectionDescription.setColor("000000");
|
// runSectionDescription.setColor("000000");
|
||||||
XWPFRun runSectionDescriptionText = sectionDescriptionParagraph.createRun();
|
// XWPFRun runSectionDescriptionText = sectionDescriptionParagraph.createRun();
|
||||||
runSectionDescriptionText.setText(section.getDescription());
|
// runSectionDescriptionText.setText(section.getDescription());
|
||||||
runSectionDescriptionText.setColor("116a78");
|
// runSectionDescriptionText.setColor("116a78");
|
||||||
|
|
||||||
wordBuilder.addParagraphContent("Section Fields", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
|
//wordBuilder.addParagraphContent("Section Fields", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
|
||||||
section.getFields().sort(Comparator.comparingInt(FieldModel::getOrdinal));
|
section.getFields().sort(Comparator.comparingInt(FieldModel::getOrdinal));
|
||||||
for (FieldModel field : section.getFields()) {
|
for (FieldModel field : section.getFields()) {
|
||||||
if (field.getCategory() == FieldCategory.SYSTEM) {
|
if (field.getCategory() == FieldCategory.SYSTEM) {
|
||||||
SystemField systemField = field.toSystemField();
|
SystemField systemField = field.toSystemField();
|
||||||
|
if (systemField.getType() == SystemFieldType.LANGUAGE) continue;
|
||||||
XWPFParagraph systemFieldParagraph = document.createParagraph();
|
XWPFParagraph systemFieldParagraph = document.createParagraph();
|
||||||
systemFieldParagraph.setSpacingBetween(1.0);
|
// systemFieldParagraph.setSpacingBetween(1.0);
|
||||||
XWPFRun runSyStemFieldTitle = systemFieldParagraph.createRun();
|
XWPFRun runSyStemFieldTitle = systemFieldParagraph.createRun();
|
||||||
runSyStemFieldTitle.setText("Title: ");
|
runSyStemFieldTitle.setText(systemField.getLabel() + ": ");
|
||||||
runSyStemFieldTitle.setColor("000000");
|
runSyStemFieldTitle.setColor("000000");
|
||||||
XWPFRun runSystemFieldTitleText = systemFieldParagraph.createRun();
|
// XWPFRun runSystemFieldTitleText = systemFieldParagraph.createRun();
|
||||||
runSystemFieldTitleText.setText(systemField.getLabel());
|
// runSystemFieldTitleText.setText(systemField.getLabel());
|
||||||
runSystemFieldTitleText.setColor("116a78");
|
// runSystemFieldTitleText.setColor("116a78");
|
||||||
if(systemField.getDescription() != null && !systemField.getDescription().isEmpty()){
|
// if(systemField.getDescription() != null && !systemField.getDescription().isEmpty()){
|
||||||
XWPFParagraph systemFieldDescription = document.createParagraph();
|
// XWPFParagraph systemFieldDescription = document.createParagraph();
|
||||||
systemFieldDescription.setSpacingBetween(1.0);
|
// systemFieldDescription.setSpacingBetween(1.0);
|
||||||
XWPFRun runSyStemFieldDescription = systemFieldDescription.createRun();
|
// XWPFRun runSyStemFieldDescription = systemFieldDescription.createRun();
|
||||||
runSyStemFieldDescription.setText("Description: ");
|
// runSyStemFieldDescription.setText("Description: ");
|
||||||
runSyStemFieldDescription.setColor("000000");
|
// runSyStemFieldDescription.setColor("000000");
|
||||||
XWPFRun runSystemFieldDescriptionText = systemFieldDescription.createRun();
|
// XWPFRun runSystemFieldDescriptionText = systemFieldDescription.createRun();
|
||||||
runSystemFieldDescriptionText.setText(systemField.getDescription());
|
// runSystemFieldDescriptionText.setText(systemField.getDescription());
|
||||||
runSystemFieldDescriptionText.setColor("116a78");
|
// runSystemFieldDescriptionText.setColor("116a78");
|
||||||
}
|
// }
|
||||||
XWPFParagraph systemFieldInput = document.createParagraph();
|
// XWPFParagraph systemFieldInput = document.createParagraph();
|
||||||
systemFieldInput.setSpacingBetween(1.0);
|
// systemFieldInput.setSpacingBetween(1.0);
|
||||||
XWPFRun runInput = systemFieldInput.createRun();
|
// XWPFRun runInput = systemFieldInput.createRun();
|
||||||
runInput.setText("Input: ");
|
// runInput.setText("Input: ");
|
||||||
runInput.setColor("000000");
|
// runInput.setColor("000000");
|
||||||
switch (systemField.getType()) {
|
switch (systemField.getType()) {
|
||||||
case TEXT:
|
case TEXT:
|
||||||
XWPFRun runTitle = systemFieldInput.createRun();
|
XWPFRun runTitle = systemFieldParagraph.createRun();
|
||||||
runTitle.setText(dmpEntity.getLabel());
|
runTitle.setText(dmpEntity.getLabel());
|
||||||
runTitle.setColor("116a78");
|
runTitle.setColor("116a78");
|
||||||
break;
|
break;
|
||||||
case HTML_TEXT:
|
case HTML_TEXT:
|
||||||
XWPFRun runDescription = systemFieldInput.createRun();
|
wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||||
runDescription.setText(dmpEntity.getDescription());
|
|
||||||
runDescription.setColor("116a78");
|
|
||||||
break;
|
break;
|
||||||
case RESEARCHERS:
|
case RESEARCHERS:
|
||||||
for (Researcher researcher : dmpEntity.getResearchers()) {
|
for (Researcher researcher : dmpEntity.getResearchers()) {
|
||||||
XWPFRun runResearcher = systemFieldInput.createRun();
|
XWPFRun runResearcher = systemFieldParagraph.createRun();
|
||||||
runResearcher.setText("• " + researcher.getLabel());
|
runResearcher.addBreak();
|
||||||
|
runResearcher.setText(researcher.getLabel());
|
||||||
runResearcher.setColor("116a78");
|
runResearcher.setColor("116a78");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ORGANIZATIONS:
|
case ORGANIZATIONS:
|
||||||
for (Organisation organisation : dmpEntity.getOrganisations()) {
|
for (Organisation organisation : dmpEntity.getOrganisations()) {
|
||||||
XWPFRun runOrganisation = systemFieldInput.createRun();
|
XWPFRun runOrganisation = systemFieldParagraph.createRun();
|
||||||
runOrganisation.setText("• " + organisation.getLabel());
|
runOrganisation.addBreak();
|
||||||
|
runOrganisation.setText(organisation.getLabel());
|
||||||
runOrganisation.setColor("116a78");
|
runOrganisation.setColor("116a78");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LANGUAGE:
|
// case LANGUAGE:
|
||||||
XWPFRun runLanguage = systemFieldInput.createRun();
|
// XWPFRun runLanguage = systemFieldParagraph.createRun();
|
||||||
runLanguage.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("language").toString());
|
// runLanguage.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("language").toString());
|
||||||
runLanguage.setColor("116a78");
|
// runLanguage.setColor("116a78");
|
||||||
break;
|
// break;
|
||||||
case CONTACT:
|
case CONTACT:
|
||||||
XWPFRun runContact = systemFieldInput.createRun();
|
XWPFRun runContact = systemFieldParagraph.createRun();
|
||||||
runContact.setText(dmpEntity.getCreator().getName());
|
runContact.setText(dmpEntity.getCreator() == null ? "" : dmpEntity.getCreator().getName());
|
||||||
runContact.setColor("116a78");
|
runContact.setColor("116a78");
|
||||||
break;
|
break;
|
||||||
case FUNDER:
|
case FUNDER:
|
||||||
XWPFRun runFunder = systemFieldInput.createRun();
|
if (dmpEntity.getGrant() != null && dmpEntity.getGrant().getFunder() != null) {
|
||||||
|
XWPFRun runFunder = systemFieldParagraph.createRun();
|
||||||
runFunder.setText(dmpEntity.getGrant().getFunder().getLabel());
|
runFunder.setText(dmpEntity.getGrant().getFunder().getLabel());
|
||||||
runFunder.setColor("116a78");
|
runFunder.setColor("116a78");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GRANT:
|
case GRANT:
|
||||||
XWPFRun runGrant = systemFieldInput.createRun();
|
if (dmpEntity.getGrant() != null) {
|
||||||
|
XWPFRun runGrant = systemFieldParagraph.createRun();
|
||||||
runGrant.setText(dmpEntity.getGrant().getLabel());
|
runGrant.setText(dmpEntity.getGrant().getLabel());
|
||||||
runGrant.setColor("116a78");
|
runGrant.setColor("116a78");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PROJECT:
|
case PROJECT:
|
||||||
XWPFRun runProject = systemFieldInput.createRun();
|
if (dmpEntity.getProject() != null) {
|
||||||
|
XWPFRun runProject = systemFieldParagraph.createRun();
|
||||||
runProject.setText(dmpEntity.getProject().getLabel());
|
runProject.setText(dmpEntity.getProject().getLabel());
|
||||||
runProject.setColor("116a78");
|
runProject.setColor("116a78");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LICENSE:
|
case LICENSE:
|
||||||
XWPFRun runLicense = systemFieldInput.createRun();
|
Map extraProperties = objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class);
|
||||||
runLicense.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("license").toString());
|
if (extraProperties.containsKey("license")) {
|
||||||
|
Map<String, String> license = ((Map<String, String>) extraProperties.get("license"));
|
||||||
|
if (license != null && !StringUtils.isEmpty(license.get("pid"))) {
|
||||||
|
XWPFRun runLicense = systemFieldParagraph.createRun();
|
||||||
|
runLicense.setText(license.get("pid").toString());
|
||||||
runLicense.setColor("116a78");
|
runLicense.setColor("116a78");
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ACCESS_RIGHTS:
|
case ACCESS_RIGHTS:
|
||||||
XWPFRun runAccessRights = systemFieldInput.createRun();
|
Map extraPropertiesMap = objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class);
|
||||||
runAccessRights.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("visible").toString());
|
if (extraPropertiesMap.containsKey("visible")) {
|
||||||
|
XWPFRun runAccessRights = systemFieldParagraph.createRun();
|
||||||
|
runAccessRights.setText(Boolean.valueOf(extraPropertiesMap.get("visible").toString()) ? "Public" : "Restricted");
|
||||||
runAccessRights.setColor("116a78");
|
runAccessRights.setColor("116a78");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
document.createParagraph();
|
//document.createParagraph();
|
||||||
}
|
} else if (field.getCategory() == FieldCategory.EXTRA) {
|
||||||
else if(field.getCategory() == FieldCategory.EXTRA){
|
|
||||||
|
Map dmpProperties = objectMapper.readValue(dmpEntity.getProperties(), HashMap.class);
|
||||||
|
if (dmpProperties != null && (!dmpProperties.containsKey(field.getId().toString()) || StringUtils.isEmpty((String) dmpProperties.get(field.getId().toString()))))
|
||||||
|
continue;
|
||||||
ExtraField extraField = field.toExtraField();
|
ExtraField extraField = field.toExtraField();
|
||||||
XWPFParagraph extraFieldParagraph = document.createParagraph();
|
XWPFParagraph extraFieldParagraph = document.createParagraph();
|
||||||
extraFieldParagraph.setSpacingBetween(1.0);
|
extraFieldParagraph.setSpacingBetween(1.0);
|
||||||
XWPFRun runExtraFieldLabel = extraFieldParagraph.createRun();
|
XWPFRun runExtraFieldLabel = extraFieldParagraph.createRun();
|
||||||
runExtraFieldLabel.setText(extraField.getLabel());
|
runExtraFieldLabel.setText(extraField.getLabel() + ": ");
|
||||||
runExtraFieldLabel.setColor("116a78");
|
runExtraFieldLabel.setColor("000000");
|
||||||
if(extraField.getDescription() != null && !extraField.getDescription().isEmpty()){
|
// if(extraField.getDescription() != null && !extraField.getDescription().isEmpty()){
|
||||||
XWPFRun runExtraFieldDescription = extraFieldParagraph.createRun();
|
// XWPFRun runExtraFieldDescription = extraFieldParagraph.createRun();
|
||||||
runExtraFieldDescription.setText(extraField.getDescription());
|
// runExtraFieldDescription.setText(extraField.getDescription());
|
||||||
runExtraFieldDescription.setColor("116a78");
|
// runExtraFieldDescription.setColor("116a78");
|
||||||
}
|
// }
|
||||||
XWPFRun runExtraFieldInput = extraFieldParagraph.createRun();
|
XWPFRun runExtraFieldInput = extraFieldParagraph.createRun();
|
||||||
runExtraFieldInput.setText(extraField.getLabel());
|
switch (extraField.getType()) {
|
||||||
|
case TEXT:
|
||||||
|
runExtraFieldInput.setText((String) dmpProperties.get(field.getId().toString()));
|
||||||
runExtraFieldInput.setColor("116a78");
|
runExtraFieldInput.setColor("116a78");
|
||||||
|
break;
|
||||||
|
case RICH_TEXT:
|
||||||
|
wordBuilder.addParagraphContent(dmpProperties.get(field.getId().toString()), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||||
|
// runExtraFieldInput.setText((String) dmpProperties.get(field.getId().toString()));
|
||||||
|
// runExtraFieldInput.setColor("116a78");
|
||||||
|
break;
|
||||||
|
case DATE:
|
||||||
|
runExtraFieldInput.setText((String) dmpProperties.get(field.getId().toString()));
|
||||||
|
runExtraFieldInput.setColor("116a78");
|
||||||
|
break;
|
||||||
|
case NUMBER:
|
||||||
|
runExtraFieldInput.setText((String) dmpProperties.get(field.getId().toString()));
|
||||||
|
runExtraFieldInput.setColor("116a78");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!section.getDescriptionTemplates().isEmpty()){
|
//if(!section.getDescriptionTemplates().isEmpty()){
|
||||||
wordBuilder.addParagraphContent("Section descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
|
|
||||||
wordBuilder.addParagraphContent("Description Templates", document, ParagraphStyle.HEADER4, BigInteger.ZERO, 0);
|
|
||||||
for(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate descriptionTemplate: section.getDescriptionTemplates()){
|
|
||||||
XWPFParagraph templateParagraph = document.createParagraph();
|
|
||||||
XWPFRun runTemplateLabel = templateParagraph.createRun();
|
|
||||||
runTemplateLabel.setText("• " + descriptionTemplate.getLabel());
|
|
||||||
runTemplateLabel.setColor("116a78");
|
|
||||||
}
|
|
||||||
|
|
||||||
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
||||||
final Boolean isPublic = dmpEntity.isPublic();
|
final Boolean isPublic = dmpEntity.isPublic();
|
||||||
dmpEntity.getDataset().stream()
|
List<Dataset> datasets = dmpEntity.getDataset().stream()
|
||||||
.filter(item -> item.getStatus() != Dataset.Status.CANCELED.getValue())
|
.filter(item -> item.getStatus() != Dataset.Status.CANCELED.getValue())
|
||||||
.filter(item -> item.getStatus() != Dataset.Status.DELETED.getValue())
|
.filter(item -> item.getStatus() != Dataset.Status.DELETED.getValue())
|
||||||
.filter(item -> !isPublic && !isFinalized || item.getStatus() == Dataset.Status.FINALISED.getValue())
|
.filter(item -> !isPublic && !isFinalized || item.getStatus() == Dataset.Status.FINALISED.getValue())
|
||||||
.filter(item -> item.getDmpSectionIndex().equals(section.getOrdinal() - 1))
|
.filter(item -> item.getDmpSectionIndex().equals(section.getOrdinal() - 1))
|
||||||
.sorted(Comparator.comparing(Dataset::getCreated))
|
.sorted(Comparator.comparing(Dataset::getCreated)).collect(Collectors.toList());
|
||||||
.forEach(datasetEntity -> {
|
|
||||||
|
if (datasets.size() > 0)
|
||||||
|
wordBuilder.addParagraphContent("Descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
|
||||||
|
for (Dataset datasetEntity : datasets) {
|
||||||
|
|
||||||
|
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (datasetEntity.getProperties() != null) {
|
||||||
//ObjectMapper objectMapper = new ObjectMapper();
|
//ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
@ -1516,7 +1567,7 @@ public class DataManagementPlanManager {
|
||||||
datasetDescriptionParagraph.setStyle("Heading4");
|
datasetDescriptionParagraph.setStyle("Heading4");
|
||||||
datasetDescriptionParagraph.setSpacingBetween(1.5);
|
datasetDescriptionParagraph.setSpacingBetween(1.5);
|
||||||
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
|
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
|
||||||
datasetDescriptionRun.setText("Dataset Description");
|
datasetDescriptionRun.setText(datasetEntity.getLabel());
|
||||||
//datasetDescriptionRun.setColor("2E75B6");
|
//datasetDescriptionRun.setColor("2E75B6");
|
||||||
//datasetDescriptionRun.setBold(true);
|
//datasetDescriptionRun.setBold(true);
|
||||||
datasetDescriptionRun.setFontSize(15);
|
datasetDescriptionRun.setFontSize(15);
|
||||||
|
@ -1524,20 +1575,26 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
// Custom style for the Dataset title.
|
// Custom style for the Dataset title.
|
||||||
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||||
XWPFParagraph datasetLabelParagraph = document.createParagraph();
|
// XWPFParagraph datasetLabelParagraph = document.createParagraph();
|
||||||
// datasetLabelParagraph.setStyle("Heading2");
|
//// datasetLabelParagraph.setStyle("Heading2");
|
||||||
datasetLabelParagraph.setSpacingBetween(1.0);
|
// datasetLabelParagraph.setSpacingBetween(1.0);
|
||||||
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
|
// XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
|
||||||
runDatasetTitle1.setText("Title: ");
|
// runDatasetTitle1.setText("Title: ");
|
||||||
runDatasetTitle1.setColor("000000");
|
// runDatasetTitle1.setColor("000000");
|
||||||
//runDatasetTitle1.setBold(true);
|
// //runDatasetTitle1.setBold(true);
|
||||||
//runDatasetTitle1.setFontSize(12);
|
// //runDatasetTitle1.setFontSize(12);
|
||||||
XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
|
// XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
|
||||||
runDatasetTitle.setText(datasetEntity.getLabel());
|
// runDatasetTitle.setText(datasetEntity.getLabel());
|
||||||
runDatasetTitle.setColor("116a78");
|
// runDatasetTitle.setColor("116a78");
|
||||||
//runDatasetTitle.setBold(true);
|
//runDatasetTitle.setBold(true);
|
||||||
//runDatasetTitle.setFontSize(12);
|
//runDatasetTitle.setFontSize(12);
|
||||||
|
|
||||||
|
XWPFParagraph descriptionParagraph = document.createParagraph();
|
||||||
|
// XWPFRun descriptionParagraphRun = descriptionParagraph.createRun();
|
||||||
|
// descriptionParagraphRun.setText("Description: ");
|
||||||
|
// descriptionParagraphRun.setColor("000000");
|
||||||
|
wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||||
|
|
||||||
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
|
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
|
||||||
// datasetTemplateParagraph.setStyle("Heading3");
|
// datasetTemplateParagraph.setStyle("Heading3");
|
||||||
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
|
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
|
||||||
|
@ -1589,10 +1646,10 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
XWPFParagraph datasetDescParagraph = document.createParagraph();
|
XWPFParagraph datasetDescParagraph = document.createParagraph();
|
||||||
XWPFRun runDatasetDescription1 = datasetDescParagraph.createRun();
|
XWPFRun runDatasetDescription1 = datasetDescParagraph.createRun();
|
||||||
runDatasetDescription1.setText("Description: ");
|
runDatasetDescription1.setText("Type: ");
|
||||||
runDatasetDescription1.setColor("000000");
|
runDatasetDescription1.setColor("000000");
|
||||||
XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
|
XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
|
||||||
runDatasetDescription.setText(datasetEntity.getProfile().getLabel());
|
runDatasetDescription.setText(datasetEntity.getProfile().getType().getName());
|
||||||
runDatasetDescription.setColor("116a78");
|
runDatasetDescription.setColor("116a78");
|
||||||
//wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
//wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||||
|
|
||||||
|
@ -1609,8 +1666,8 @@ public class DataManagementPlanManager {
|
||||||
// Page break at the end of the Dataset.
|
// Page break at the end of the Dataset.
|
||||||
XWPFParagraph parBreakDataset = document.createParagraph();
|
XWPFParagraph parBreakDataset = document.createParagraph();
|
||||||
parBreakDataset.setPageBreak(true);
|
parBreakDataset.setPageBreak(true);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Removes the top empty headings.
|
// // Removes the top empty headings.
|
||||||
|
@ -1708,9 +1765,9 @@ public class DataManagementPlanManager {
|
||||||
Element dmpProfileId = xmlDoc.createElement("dmpProfileId");
|
Element dmpProfileId = xmlDoc.createElement("dmpProfileId");
|
||||||
dmpProfileId.setTextContent(dmpProfile.getId().toString());
|
dmpProfileId.setTextContent(dmpProfile.getId().toString());
|
||||||
dmpProfileElement.appendChild(dmpProfileId);
|
dmpProfileElement.appendChild(dmpProfileId);
|
||||||
Element values = xmlDoc.createElement("values");
|
// Element values = xmlDoc.createElement("values");
|
||||||
values.setTextContent(dmpProfile.getDefinition());
|
// values.setTextContent(dmpProfile.getDefinition());
|
||||||
dmpProfileElement.appendChild(values);
|
// dmpProfileElement.appendChild(values);
|
||||||
}
|
}
|
||||||
dmpElement.appendChild(dmpProfileElement);
|
dmpElement.appendChild(dmpProfileElement);
|
||||||
|
|
||||||
|
@ -1750,7 +1807,7 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
// Funder.
|
// Funder.
|
||||||
Element funder = xmlDoc.createElement("funder");
|
Element funder = xmlDoc.createElement("funder");
|
||||||
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal) && this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.FUNDER, principal)) {
|
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal) && this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.FUNDER, principal) && dmp.getGrant() != null) {
|
||||||
Element funderLabel = xmlDoc.createElement("label");
|
Element funderLabel = xmlDoc.createElement("label");
|
||||||
Element funderId = xmlDoc.createElement("id");
|
Element funderId = xmlDoc.createElement("id");
|
||||||
funderLabel.setTextContent(dmp.getGrant().getFunder().getLabel());
|
funderLabel.setTextContent(dmp.getGrant().getFunder().getLabel());
|
||||||
|
@ -1768,7 +1825,7 @@ public class DataManagementPlanManager {
|
||||||
dmpElement.appendChild(funder);
|
dmpElement.appendChild(funder);
|
||||||
// Grant.
|
// Grant.
|
||||||
Element grant = xmlDoc.createElement("grant");
|
Element grant = xmlDoc.createElement("grant");
|
||||||
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal)) {
|
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal) && dmp.getGrant() != null) {
|
||||||
Element grantLabel = xmlDoc.createElement("label");
|
Element grantLabel = xmlDoc.createElement("label");
|
||||||
Element grantId = xmlDoc.createElement("id");
|
Element grantId = xmlDoc.createElement("id");
|
||||||
grantLabel.setTextContent(dmp.getGrant().getLabel());
|
grantLabel.setTextContent(dmp.getGrant().getLabel());
|
||||||
|
@ -1786,7 +1843,7 @@ public class DataManagementPlanManager {
|
||||||
dmpElement.appendChild(grant);
|
dmpElement.appendChild(grant);
|
||||||
// Project.
|
// Project.
|
||||||
Element project = xmlDoc.createElement("project");
|
Element project = xmlDoc.createElement("project");
|
||||||
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.PROJECT, principal)) {
|
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.PROJECT, principal) && dmp.getProject() != null) {
|
||||||
Element projectId = xmlDoc.createElement("id");
|
Element projectId = xmlDoc.createElement("id");
|
||||||
Element projectLabel = xmlDoc.createElement("label");
|
Element projectLabel = xmlDoc.createElement("label");
|
||||||
Element projectDescription = xmlDoc.createElement("description");
|
Element projectDescription = xmlDoc.createElement("description");
|
||||||
|
@ -1830,8 +1887,33 @@ public class DataManagementPlanManager {
|
||||||
researchersElement.appendChild(researcherElement);
|
researchersElement.appendChild(researcherElement);
|
||||||
}
|
}
|
||||||
dmpElement.appendChild(researchersElement);
|
dmpElement.appendChild(researchersElement);
|
||||||
Element datasetsElement = xmlDoc.createElement("datasets");
|
|
||||||
|
|
||||||
|
Element extraFields = xmlDoc.createElement("extraFields");
|
||||||
|
Map<String, Object> dmpProperties = new ObjectMapper().readValue(dmp.getProperties(), new TypeReference<Map<String, Object>>() {});
|
||||||
|
DataManagementPlanBlueprint blueprint = this.dataManagementProfileManager.getSingleBlueprint(dmp.getProfile().getId().toString(), principal).getDefinition();
|
||||||
|
blueprint.getSections().forEach(section -> {
|
||||||
|
section.getFields().forEach(fieldModel -> {
|
||||||
|
if (fieldModel.getCategory() == FieldCategory.EXTRA) {
|
||||||
|
Element extraField = xmlDoc.createElement("extraField");
|
||||||
|
Element extraFieldId = xmlDoc.createElement("id");
|
||||||
|
extraFieldId.setTextContent(fieldModel.getId().toString());
|
||||||
|
Element extraFieldLabel = xmlDoc.createElement("label");
|
||||||
|
extraFieldLabel.setTextContent(fieldModel.getLabel());
|
||||||
|
Element extraFieldValue = xmlDoc.createElement("value");
|
||||||
|
Object value = dmpProperties.get(fieldModel.getId().toString());
|
||||||
|
if (value != null) {
|
||||||
|
extraFieldValue.setTextContent((String) value);
|
||||||
|
}
|
||||||
|
extraField.appendChild(extraFieldId);
|
||||||
|
extraField.appendChild(extraFieldLabel);
|
||||||
|
extraField.appendChild(extraFieldValue);
|
||||||
|
extraFields.appendChild(extraField);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
dmpElement.appendChild(extraFields);
|
||||||
|
|
||||||
|
Element datasetsElement = xmlDoc.createElement("datasets");
|
||||||
for (Dataset dataset : datasets) {
|
for (Dataset dataset : datasets) {
|
||||||
Element datasetElement = xmlDoc.createElement("dataset");
|
Element datasetElement = xmlDoc.createElement("dataset");
|
||||||
datasetElement.setAttribute("name", dataset.getLabel());
|
datasetElement.setAttribute("name", dataset.getLabel());
|
||||||
|
@ -1840,6 +1922,10 @@ public class DataManagementPlanManager {
|
||||||
datasetElement.appendChild(datasetDescriptionElement);
|
datasetElement.appendChild(datasetDescriptionElement);
|
||||||
datasetDescriptionElement.setTextContent(dataset.getDescription());
|
datasetDescriptionElement.setTextContent(dataset.getDescription());
|
||||||
|
|
||||||
|
Element datasetDmpSectionIndex = xmlDoc.createElement("dmpSectionIndex");
|
||||||
|
datasetElement.appendChild(datasetDmpSectionIndex);
|
||||||
|
datasetDmpSectionIndex.setTextContent(String.valueOf(dataset.getDmpSectionIndex()));
|
||||||
|
|
||||||
Element datsetProfileElement = xmlDoc.createElement("profile-id");
|
Element datsetProfileElement = xmlDoc.createElement("profile-id");
|
||||||
datasetElement.appendChild(datsetProfileElement);
|
datasetElement.appendChild(datsetProfileElement);
|
||||||
datsetProfileElement.setTextContent(dataset.getProfile().getId().toString());
|
datsetProfileElement.setTextContent(dataset.getProfile().getId().toString());
|
||||||
|
@ -1860,8 +1946,8 @@ public class DataManagementPlanManager {
|
||||||
datasetElement.appendChild(xmlBuilder.createPages(pagedDatasetProfile.getPages(), visibilityRuleService, xmlDoc));
|
datasetElement.appendChild(xmlBuilder.createPages(pagedDatasetProfile.getPages(), visibilityRuleService, xmlDoc));
|
||||||
datasetsElement.appendChild(datasetElement);
|
datasetsElement.appendChild(datasetElement);
|
||||||
}
|
}
|
||||||
Element profiles = xmlDoc.createElement("profiles");
|
|
||||||
|
|
||||||
|
Element profiles = xmlDoc.createElement("profiles");
|
||||||
// Get DatasetProfiles from DMP to add to XML.
|
// Get DatasetProfiles from DMP to add to XML.
|
||||||
for (DMPDatasetProfile dmpDescriptionProfile : dmp.getAssociatedDmps()) {
|
for (DMPDatasetProfile dmpDescriptionProfile : dmp.getAssociatedDmps()) {
|
||||||
DescriptionTemplate descriptionTemplate = dmpDescriptionProfile.getDatasetprofile();
|
DescriptionTemplate descriptionTemplate = dmpDescriptionProfile.getDatasetprofile();
|
||||||
|
@ -1878,6 +1964,15 @@ public class DataManagementPlanManager {
|
||||||
Element profileVersion = xmlDoc.createElement("profileVersion");
|
Element profileVersion = xmlDoc.createElement("profileVersion");
|
||||||
profileVersion.setTextContent(String.valueOf(descriptionTemplate.getVersion()));
|
profileVersion.setTextContent(String.valueOf(descriptionTemplate.getVersion()));
|
||||||
profile.appendChild(profileVersion);
|
profile.appendChild(profileVersion);
|
||||||
|
Element profileInSections = xmlDoc.createElement("profileInSections");
|
||||||
|
Map<String, Object> data = new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {});
|
||||||
|
List<Integer> sections = (List<Integer>) data.get("dmpSectionIndex");
|
||||||
|
for(int section: sections) {
|
||||||
|
Element profileInSection = xmlDoc.createElement("section");
|
||||||
|
profileInSection.setTextContent(String.valueOf(section));
|
||||||
|
profileInSections.appendChild(profileInSection);
|
||||||
|
}
|
||||||
|
profile.appendChild(profileInSections);
|
||||||
profiles.appendChild(profile);
|
profiles.appendChild(profile);
|
||||||
}
|
}
|
||||||
dmpElement.appendChild(profiles);
|
dmpElement.appendChild(profiles);
|
||||||
|
@ -1988,19 +2083,27 @@ public class DataManagementPlanManager {
|
||||||
// Creates new dataManagementPlan to fill it with the data model that was parsed from the xml.
|
// Creates new dataManagementPlan to fill it with the data model that was parsed from the xml.
|
||||||
// Creates properties.
|
// Creates properties.
|
||||||
DataManagementPlanEditorModel dm = new DataManagementPlanEditorModel();
|
DataManagementPlanEditorModel dm = new DataManagementPlanEditorModel();
|
||||||
// DataManagementPlanProfile dmpProfile = new DataManagementPlanProfile();
|
|
||||||
//
|
|
||||||
// List<Field> fieldList = new LinkedList<>();
|
|
||||||
// Field field = new Field();
|
|
||||||
// field.setLabel(dataManagementPlans.get(0).getDmpProfile().getDmpProfileName());
|
|
||||||
// field.setId(dataManagementPlans.get(0).getDmpProfile().getDmpProfileId());
|
|
||||||
//
|
|
||||||
// fieldList.add(field);
|
|
||||||
// dmpProfile.setFields(fieldList);
|
|
||||||
|
|
||||||
/*Tuple tuple = new Tuple();
|
DmpProfileImportModel dmpProfileImportModel = dataManagementPlans.get(0).getDmpProfile();
|
||||||
tuple.setId(dataManagementPlans.get(0).getDmpProfile().getDmpProfileId());
|
UUID profileId = null;
|
||||||
tuple.setLabel(dataManagementPlans.get(0).getDmpProfile().getDmpProfileName());*/
|
if (dmpProfileImportModel != null) {
|
||||||
|
profileId = dmpProfileImportModel.getDmpProfileId();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profileId = UUID.fromString("86635178-36a6-484f-9057-a934e4eeecd5");
|
||||||
|
}
|
||||||
|
dm.setProfile(profileId);
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Object> dmpPropertiesMap = new HashMap<>();
|
||||||
|
if (dataManagementPlans.get(0).getExtraFieldsImportModels() != null) {
|
||||||
|
for (ExtraFieldsImportModels extraField: dataManagementPlans.get(0).getExtraFieldsImportModels()) {
|
||||||
|
dmpPropertiesMap.put(extraField.getId(), extraField.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dm.setProperties(dmpPropertiesMap);
|
||||||
|
|
||||||
|
if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), SystemFieldType.FUNDER, principal)) {
|
||||||
eu.eudat.models.data.funder.Funder funder = new eu.eudat.models.data.funder.Funder();
|
eu.eudat.models.data.funder.Funder funder = new eu.eudat.models.data.funder.Funder();
|
||||||
FunderImportModels funderImport = dataManagementPlans.get(0).getFunderImportModels();
|
FunderImportModels funderImport = dataManagementPlans.get(0).getFunderImportModels();
|
||||||
funder.setId(funderImport.getId());
|
funder.setId(funderImport.getId());
|
||||||
|
@ -2008,6 +2111,10 @@ public class DataManagementPlanManager {
|
||||||
FunderDMPEditorModel funderEditor = new FunderDMPEditorModel();
|
FunderDMPEditorModel funderEditor = new FunderDMPEditorModel();
|
||||||
funderEditor.setExistFunder(funder);
|
funderEditor.setExistFunder(funder);
|
||||||
|
|
||||||
|
dm.setFunder(funderEditor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), SystemFieldType.GRANT, principal)) {
|
||||||
eu.eudat.models.data.grant.Grant grant = new eu.eudat.models.data.grant.Grant();
|
eu.eudat.models.data.grant.Grant grant = new eu.eudat.models.data.grant.Grant();
|
||||||
GrantImportModels grantImport = dataManagementPlans.get(0).getGrantImport();
|
GrantImportModels grantImport = dataManagementPlans.get(0).getGrantImport();
|
||||||
grant.setId(grantImport.getId());
|
grant.setId(grantImport.getId());
|
||||||
|
@ -2017,6 +2124,10 @@ public class DataManagementPlanManager {
|
||||||
GrantDMPEditorModel grantEditor = new GrantDMPEditorModel();
|
GrantDMPEditorModel grantEditor = new GrantDMPEditorModel();
|
||||||
grantEditor.setExistGrant(grant);
|
grantEditor.setExistGrant(grant);
|
||||||
|
|
||||||
|
dm.setGrant(grantEditor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), SystemFieldType.PROJECT, principal)) {
|
||||||
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
||||||
ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImportModels();
|
ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImportModels();
|
||||||
project.setId(projectImport.getId());
|
project.setId(projectImport.getId());
|
||||||
|
@ -2024,23 +2135,31 @@ public class DataManagementPlanManager {
|
||||||
ProjectDMPEditorModel projectEditor = new ProjectDMPEditorModel();
|
ProjectDMPEditorModel projectEditor = new ProjectDMPEditorModel();
|
||||||
projectEditor.setExistProject(project);
|
projectEditor.setExistProject(project);
|
||||||
|
|
||||||
|
dm.setProject(projectEditor);
|
||||||
|
}
|
||||||
|
|
||||||
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
|
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
|
||||||
if (profiles != null && profiles.length > 0) {
|
// if (profiles != null && profiles.length > 0) {
|
||||||
for (String profile : profiles) {
|
// for (String profile : profiles) {
|
||||||
DescriptionTemplate exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(profile));
|
// DescriptionTemplate exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(profile));
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
|
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
|
||||||
associatedProfiles.add(associatedProfile);
|
// associatedProfiles.add(associatedProfile);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
for (AssociatedProfileImportModels a : dataManagementPlans.get(0).getProfilesImportModels()) {
|
for (AssociatedProfileImportModels a : dataManagementPlans.get(0).getProfilesImportModels()) {
|
||||||
try {
|
try {
|
||||||
DescriptionTemplate exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(a.getId());
|
DescriptionTemplate exProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(a.getId());
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
|
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(exProfile);
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
List<Integer> sections = new ArrayList<>(a.getSection());
|
||||||
|
data.put("dmpSectionIndex", sections);
|
||||||
|
associatedProfile.setData(data);
|
||||||
associatedProfiles.add(associatedProfile);
|
associatedProfiles.add(associatedProfile);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<eu.eudat.models.data.dmp.Organisation> organisations = new ArrayList<>();
|
List<eu.eudat.models.data.dmp.Organisation> organisations = new ArrayList<>();
|
||||||
for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) {
|
for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) {
|
||||||
eu.eudat.models.data.dmp.Organisation organisation = new eu.eudat.models.data.dmp.Organisation();
|
eu.eudat.models.data.dmp.Organisation organisation = new eu.eudat.models.data.dmp.Organisation();
|
||||||
|
@ -2049,6 +2168,7 @@ public class DataManagementPlanManager {
|
||||||
organisation.setKey(organisation.getReference().split(":")[0]);
|
organisation.setKey(organisation.getReference().split(":")[0]);
|
||||||
organisations.add(organisation);
|
organisations.add(organisation);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<eu.eudat.models.data.dmp.Researcher> researchers = new LinkedList<>();
|
List<eu.eudat.models.data.dmp.Researcher> researchers = new LinkedList<>();
|
||||||
for (ResearcherImportModels res : dataManagementPlans.get(0).getResearchersImportModels()) {
|
for (ResearcherImportModels res : dataManagementPlans.get(0).getResearchersImportModels()) {
|
||||||
eu.eudat.models.data.dmp.Researcher researcher = new eu.eudat.models.data.dmp.Researcher();
|
eu.eudat.models.data.dmp.Researcher researcher = new eu.eudat.models.data.dmp.Researcher();
|
||||||
|
@ -2064,9 +2184,6 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
// Sets properties.
|
// Sets properties.
|
||||||
dm.setLabel(files[0].getOriginalFilename()); // Sets label.
|
dm.setLabel(files[0].getOriginalFilename()); // Sets label.
|
||||||
dm.setGrant(grantEditor); //Sets grant property.
|
|
||||||
dm.setFunder(funderEditor);
|
|
||||||
dm.setProject(projectEditor);
|
|
||||||
dm.setDescription(dataManagementPlans.get(0).getDescriptionImport()); // Sets description property.
|
dm.setDescription(dataManagementPlans.get(0).getDescriptionImport()); // Sets description property.
|
||||||
dm.setProfiles(associatedProfiles);
|
dm.setProfiles(associatedProfiles);
|
||||||
dm.setOrganisations(organisations); // Sets organisations property.
|
dm.setOrganisations(organisations); // Sets organisations property.
|
||||||
|
@ -2112,6 +2229,7 @@ public class DataManagementPlanManager {
|
||||||
for (DatasetImportModels das: dataManagementPlans.get(0).getDatasetImportModels()) {
|
for (DatasetImportModels das: dataManagementPlans.get(0).getDatasetImportModels()) {
|
||||||
eu.eudat.data.entities.Dataset dataset = new eu.eudat.data.entities.Dataset();
|
eu.eudat.data.entities.Dataset dataset = new eu.eudat.data.entities.Dataset();
|
||||||
dataset.setLabel(das.getName());
|
dataset.setLabel(das.getName());
|
||||||
|
dataset.setDmpSectionIndex(das.getDmpSectionIndex());
|
||||||
try {
|
try {
|
||||||
dataset.setProfile(databaseRepository.getDatasetProfileDao().find(das.getProfile()));
|
dataset.setProfile(databaseRepository.getDatasetProfileDao().find(das.getProfile()));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
@ -2168,6 +2286,11 @@ public class DataManagementPlanManager {
|
||||||
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
this.updateIndex(dmp);
|
this.updateIndex(dmp);
|
||||||
}
|
}
|
||||||
|
for(DMPDatasetProfile dmpDatasetProfile : dmp.getAssociatedDmps()){
|
||||||
|
dmpDatasetProfile.setDmp(dmp);
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().createOrUpdate(dmpDatasetProfile);
|
||||||
|
}
|
||||||
|
|
||||||
dmp.getDataset().forEach(dataset -> {
|
dmp.getDataset().forEach(dataset -> {
|
||||||
dataset.setStatus(Dataset.Status.SAVED.getValue());
|
dataset.setStatus(Dataset.Status.SAVED.getValue());
|
||||||
dataset.setCreated(new Date());
|
dataset.setCreated(new Date());
|
||||||
|
@ -2227,19 +2350,19 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assignGrandUserIfInternal(DMP dmp, UserInfo user) {
|
private void assignGrandUserIfInternal(DMP dmp, UserInfo user) {
|
||||||
if (dmp.getGrant().getCreationUser() == null && (dmp.getGrant().getReference() != null && dmp.getGrant().getReference().startsWith("dmp:"))) {
|
if (dmp.getGrant() != null && dmp.getGrant().getCreationUser() == null && (dmp.getGrant().getReference() != null && dmp.getGrant().getReference().startsWith("dmp:"))) {
|
||||||
dmp.getGrant().setCreationUser(user);
|
dmp.getGrant().setCreationUser(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assignFunderUserIfInternal(DMP dmp, UserInfo user) {
|
private void assignFunderUserIfInternal(DMP dmp, UserInfo user) {
|
||||||
if (dmp.getGrant().getFunder().getCreationUser() == null && ( dmp.getGrant().getFunder().getReference() != null && dmp.getGrant().getFunder().getReference().startsWith("dmp:"))) {
|
if (dmp.getGrant() != null && dmp.getGrant().getFunder() != null && dmp.getGrant().getFunder().getCreationUser() == null && ( dmp.getGrant().getFunder().getReference() != null && dmp.getGrant().getFunder().getReference().startsWith("dmp:"))) {
|
||||||
dmp.getGrant().getFunder().setCreationUser(user);
|
dmp.getGrant().getFunder().setCreationUser(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assignProjectUserIfInternal(DMP dmp, UserInfo user) {
|
private void assignProjectUserIfInternal(DMP dmp, UserInfo user) {
|
||||||
if (dmp.getProject().getCreationUser() == null && (dmp.getProject().getReference() != null && dmp.getProject().getReference().startsWith("dmp:"))) {
|
if (dmp.getProject() != null && dmp.getProject().getCreationUser() == null && (dmp.getProject().getReference() != null && dmp.getProject().getReference().startsWith("dmp:"))) {
|
||||||
dmp.getProject().setCreationUser(user);
|
dmp.getProject().setCreationUser(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2319,7 +2442,7 @@ public class DataManagementPlanManager {
|
||||||
* */
|
* */
|
||||||
|
|
||||||
private void checkIfUserCanEditGrant(DMP dmp, UserInfo user) throws Exception{
|
private void checkIfUserCanEditGrant(DMP dmp, UserInfo user) throws Exception{
|
||||||
if (dmp.getGrant().getId() != null) {
|
if (dmp.getGrant() != null && dmp.getGrant().getId() != null) {
|
||||||
Grant grant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(dmp.getGrant().getId());
|
Grant grant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(dmp.getGrant().getId());
|
||||||
if (grant.getFunder() != null && dmp.getGrant().getFunder() != null
|
if (grant.getFunder() != null && dmp.getGrant().getFunder() != null
|
||||||
&& !grant.getFunder().getId().equals(dmp.getGrant().getFunder().getId())) {
|
&& !grant.getFunder().getId().equals(dmp.getGrant().getFunder().getId())) {
|
||||||
|
|
|
@ -2,11 +2,17 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
import com.jayway.jsonpath.DocumentContext;
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.dao.criteria.RequestItem;
|
import eu.eudat.data.dao.criteria.RequestItem;
|
||||||
|
import eu.eudat.data.dao.entities.DatasetDao;
|
||||||
|
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
||||||
import eu.eudat.data.entities.DMPProfile;
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
|
import eu.eudat.data.entities.DescriptionTemplate;
|
||||||
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
|
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
|
||||||
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
||||||
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||||
|
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
|
||||||
|
import eu.eudat.exceptions.dmpblueprint.DmpBlueprintUsedException;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
|
@ -108,6 +114,11 @@ public class DataManagementProfileManager {
|
||||||
return dataManagementPlanBlueprintListingModel;
|
return dataManagementPlanBlueprintListingModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean fieldInBlueprint(String id, SystemFieldType type, Principal principal) {
|
||||||
|
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
|
||||||
|
return this.fieldInBlueprint(dmpProfile, type, principal);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean fieldInBlueprint(DMPProfile dmpProfile, SystemFieldType type, Principal principal) {
|
public boolean fieldInBlueprint(DMPProfile dmpProfile, SystemFieldType type, Principal principal) {
|
||||||
DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel();
|
DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel();
|
||||||
dmpBlueprint.fromDataModel(dmpProfile);
|
dmpBlueprint.fromDataModel(dmpProfile);
|
||||||
|
@ -124,6 +135,17 @@ public class DataManagementProfileManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Integer> sectionIndexesForDescriptionTemplate(DMPProfile dmpProfile, UUID descriptionTemplateId) {
|
||||||
|
DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel();
|
||||||
|
dmpBlueprint.fromDataModel(dmpProfile);
|
||||||
|
List<Integer> sectionIndexes = new ArrayList<>();
|
||||||
|
for(int i = 0; i < dmpBlueprint.getDefinition().getSections().size(); i++) {
|
||||||
|
Section section = dmpBlueprint.getDefinition().getSections().get(i);
|
||||||
|
if(section.getHasTemplates() && section.getDescriptionTemplates().stream().anyMatch(x -> x.getDescriptionTemplateId().equals(descriptionTemplateId))) sectionIndexes.add(i);
|
||||||
|
}
|
||||||
|
return sectionIndexes;
|
||||||
|
}
|
||||||
|
|
||||||
public List<DataManagementPlanProfileListingModel> getWithCriteria(DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException {
|
public List<DataManagementPlanProfileListingModel> getWithCriteria(DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException {
|
||||||
QueryableList<DMPProfile> items = databaseRepository.getDmpProfileDao().getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria());
|
QueryableList<DMPProfile> items = databaseRepository.getDmpProfileDao().getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria());
|
||||||
List<DataManagementPlanProfileListingModel> datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item));
|
List<DataManagementPlanProfileListingModel> datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item));
|
||||||
|
@ -140,6 +162,18 @@ public class DataManagementProfileManager {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void inactivate(String id) {
|
||||||
|
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
|
||||||
|
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||||
|
dataManagementPlanCriteria.setProfile(dmpProfile);
|
||||||
|
if (dmpProfile.getStatus() == DMPProfile.Status.SAVED.getValue() || databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).count() == 0) {
|
||||||
|
dmpProfile.setStatus(DMPProfile.Status.DELETED.getValue());
|
||||||
|
databaseRepository.getDmpProfileDao().createOrUpdate(dmpProfile);
|
||||||
|
} else {
|
||||||
|
throw new DmpBlueprintUsedException("This blueprint can not deleted, because DMPs are associated with it");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ResponseEntity<byte[]> getDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException {
|
public ResponseEntity<byte[]> getDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException {
|
||||||
FileEnvelope envelope = getXmlDocument(dmpProfile);
|
FileEnvelope envelope = getXmlDocument(dmpProfile);
|
||||||
InputStream resource = new FileInputStream(envelope.getFile());
|
InputStream resource = new FileInputStream(envelope.getFile());
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
|
||||||
import com.jayway.jsonpath.JsonPath;
|
|
||||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||||
import eu.eudat.data.entities.DescriptionTemplate;
|
import eu.eudat.data.entities.DescriptionTemplate;
|
||||||
import eu.eudat.data.entities.UserDatasetProfile;
|
import eu.eudat.data.entities.UserDatasetProfile;
|
||||||
|
@ -10,17 +8,21 @@ import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteR
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||||
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
|
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
|
||||||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
||||||
import eu.eudat.logic.proxy.config.Semantic;
|
import eu.eudat.logic.proxy.config.*;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
|
import eu.eudat.logic.proxy.config.entities.GeneralUrls;
|
||||||
|
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
||||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
|
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
|
||||||
|
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||||
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
|
import eu.eudat.models.data.datasetprofile.DatasetProfileWithPrefillingPropertyModel;
|
||||||
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field;
|
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
|
@ -34,10 +36,11 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -54,6 +57,8 @@ import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
import javax.xml.xpath.*;
|
import javax.xml.xpath.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -64,20 +69,20 @@ public class DatasetProfileManager {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DatasetProfileManager.class);
|
private static final Logger logger = LoggerFactory.getLogger(DatasetProfileManager.class);
|
||||||
private static final List<String> cache = new ArrayList<>();
|
private static final List<String> cache = new ArrayList<>();
|
||||||
|
|
||||||
private ApiContext apiContext;
|
private final ApiContext apiContext;
|
||||||
private DatabaseRepository databaseRepository;
|
private final DatabaseRepository databaseRepository;
|
||||||
private Environment environment;
|
private final Environment environment;
|
||||||
private ConfigLoader configLoader;
|
private final ConfigLoader configLoader;
|
||||||
|
|
||||||
private final MetricsManager metricsManager;
|
private final MetricsManager metricsManager;
|
||||||
|
private final RemoteFetcher remoteFetcher;
|
||||||
@Autowired
|
@Autowired
|
||||||
public DatasetProfileManager(ApiContext apiContext, Environment environment, ConfigLoader configLoader, MetricsManager metricsManager) {
|
public DatasetProfileManager(ApiContext apiContext, Environment environment, ConfigLoader configLoader, MetricsManager metricsManager, RemoteFetcher remoteFetcher) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
this.metricsManager = metricsManager;
|
this.metricsManager = metricsManager;
|
||||||
|
this.remoteFetcher = remoteFetcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -129,6 +134,21 @@ public class DatasetProfileManager {
|
||||||
return datasetProfiles;
|
return datasetProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<DatasetProfileWithPrefillingPropertyModel> getAllWithPrefilling(DatasetProfileTableRequestItem tableRequestItem) {
|
||||||
|
List<DatasetProfileWithPrefillingPropertyModel> datasetProfiles = new ArrayList<>();
|
||||||
|
if (!tableRequestItem.getCriteria().getIds().isEmpty()) {
|
||||||
|
tableRequestItem.getCriteria().getIds().forEach(id -> {
|
||||||
|
DatasetProfile datasetProfile = this.getDatasetProfile(id.toString());
|
||||||
|
DatasetProfileWithPrefillingPropertyModel profileModel = new DatasetProfileWithPrefillingPropertyModel();
|
||||||
|
profileModel.setId(id);
|
||||||
|
profileModel.setLabel(datasetProfile.getLabel());
|
||||||
|
profileModel.setEnablePrefilling(datasetProfile.isEnablePrefilling());
|
||||||
|
datasetProfiles.add(profileModel);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return datasetProfiles;
|
||||||
|
}
|
||||||
|
|
||||||
public eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field queryForField(String xml, String fieldId) throws XPathExpressionException {
|
public eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field queryForField(String xml, String fieldId) throws XPathExpressionException {
|
||||||
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field field = new Field();
|
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field field = new Field();
|
||||||
Document document = XmlBuilder.fromXml(xml);
|
Document document = XmlBuilder.fromXml(xml);
|
||||||
|
@ -141,8 +161,8 @@ public class DatasetProfileManager {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ExternalAutocompleteFieldModel> getAutocomplete(AutoCompleteData data, String like) {
|
public List<ExternalAutocompleteFieldModel> getAutocomplete(AutoCompleteData data, String like) {
|
||||||
List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
|
/*List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
|
||||||
SimpleClientHttpRequestFactory simpleFactory = new SimpleClientHttpRequestFactory();
|
SimpleClientHttpRequestFactory simpleFactory = new SimpleClientHttpRequestFactory();
|
||||||
|
|
||||||
RestTemplate restTemplate = new RestTemplate(simpleFactory);
|
RestTemplate restTemplate = new RestTemplate(simpleFactory);
|
||||||
|
@ -205,8 +225,72 @@ public class DatasetProfileManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.stream().sorted(Comparator.comparing(ExternalAutocompleteFieldModel::getLabel)).collect(Collectors.toList());
|
return result.stream().sorted(Comparator.comparing(ExternalAutocompleteFieldModel::getLabel)).collect(Collectors.toList());
|
||||||
|
*/
|
||||||
//return result;
|
List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
|
||||||
|
ExternalUrlCriteria urlCriteria = new ExternalUrlCriteria();
|
||||||
|
GeneralUrls genericUrls = new GeneralUrls();
|
||||||
|
int ordinal = 1;
|
||||||
|
List<Map<String, String>> rawResults = new ArrayList<>();
|
||||||
|
genericUrls.setFetchMode(FetchStrategy.FIRST);
|
||||||
|
urlCriteria.setLike(like);
|
||||||
|
for (AutoCompleteData.AutoCompleteSingleData singleData : data.getAutoCompleteSingleDataList()) {
|
||||||
|
UrlConfiguration urlConfiguration = new UrlConfiguration();
|
||||||
|
try {
|
||||||
|
URI uri;
|
||||||
|
if (singleData.getUrl().contains("?")) {
|
||||||
|
uri = new URI(singleData.getUrl().substring(0, singleData.getUrl().lastIndexOf("?")));
|
||||||
|
} else {
|
||||||
|
uri = new URI(singleData.getUrl());
|
||||||
|
}
|
||||||
|
String source = singleData.getAutoCompleteOptions().getSource();
|
||||||
|
source = source != null && !source.isEmpty() ? source : uri.getHost();
|
||||||
|
String uriString = singleData.getAutoCompleteOptions().getUri();
|
||||||
|
uriString = uriString != null && !uriString.isEmpty() ? uriString : "uri";
|
||||||
|
String parsedUrl = singleData.getUrl();
|
||||||
|
parsedUrl = parsedUrl.replace("%20", " ");
|
||||||
|
parsedUrl = parsedUrl.replace("%22", "\"");
|
||||||
|
while (parsedUrl.contains("&")) {
|
||||||
|
parsedUrl = parsedUrl.replace("&", "&");
|
||||||
|
}
|
||||||
|
urlConfiguration.setUrl(parsedUrl);
|
||||||
|
urlConfiguration.setOrdinal(ordinal);
|
||||||
|
urlConfiguration.setType("External");
|
||||||
|
urlConfiguration.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
urlConfiguration.setFirstpage("1");
|
||||||
|
urlConfiguration.setRequestType(singleData.getMethod() != null ? singleData.getMethod() : "GET");
|
||||||
|
DataUrlConfiguration dataUrlConfiguration = new DataUrlConfiguration();
|
||||||
|
dataUrlConfiguration.setPath(singleData.getOptionsRoot());
|
||||||
|
DataFieldsUrlConfiguration fieldsUrlConfiguration = new DataFieldsUrlConfiguration();
|
||||||
|
fieldsUrlConfiguration.setId(singleData.getAutoCompleteOptions().getValue());
|
||||||
|
fieldsUrlConfiguration.setName(singleData.getAutoCompleteOptions().getLabel());
|
||||||
|
fieldsUrlConfiguration.setSource(singleData.getAutoCompleteOptions().getSource().isEmpty()? null : singleData.getAutoCompleteOptions().getSource());
|
||||||
|
fieldsUrlConfiguration.setUri(uriString);
|
||||||
|
dataUrlConfiguration.setFieldsUrlConfiguration(fieldsUrlConfiguration);
|
||||||
|
urlConfiguration.setKey(source);
|
||||||
|
urlConfiguration.setLabel(source);
|
||||||
|
urlConfiguration.setData(dataUrlConfiguration);
|
||||||
|
if (singleData.getHasAuth()) {
|
||||||
|
AuthenticationConfiguration authenticationConfiguration = new AuthenticationConfiguration();
|
||||||
|
authenticationConfiguration.setAuthUrl(singleData.getAuth().getUrl());
|
||||||
|
authenticationConfiguration.setAuthMethod(singleData.getAuth().getMethod());
|
||||||
|
authenticationConfiguration.setAuthTokenPath(singleData.getAuth().getPath());
|
||||||
|
authenticationConfiguration.setAuthRequestBody(singleData.getAuth().getBody());
|
||||||
|
authenticationConfiguration.setType(singleData.getAuth().getType());
|
||||||
|
urlConfiguration.setAuth(authenticationConfiguration);
|
||||||
|
}
|
||||||
|
genericUrls.getUrls().add(urlConfiguration);
|
||||||
|
List<Map<String, String>> singleResults = this.remoteFetcher.getExternalGeneric(urlCriteria, genericUrls);
|
||||||
|
if (!singleResults.isEmpty() && !singleResults.get(0).containsKey("source") && !singleData.getAutoCompleteOptions().getSource().isEmpty()) {
|
||||||
|
singleResults.forEach(singleResult -> singleResult.put("source", singleData.getAutoCompleteOptions().getSource()));
|
||||||
|
}
|
||||||
|
rawResults.addAll(singleResults);
|
||||||
|
genericUrls.getUrls().clear();
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rawResults.forEach(item -> result.add(new ExternalAutocompleteFieldModel(parseItem(item.get("pid")), parseItem(item.get("name")), parseItem(item.get("source")), parseItem(item.get("uri")))));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String parseItem(Object item) {
|
private static String parseItem(Object item) {
|
||||||
|
|
|
@ -140,6 +140,7 @@ public class GrantManager {
|
||||||
|
|
||||||
grants.add(grant);
|
grants.add(grant);
|
||||||
}
|
}
|
||||||
|
grants = grants.stream().filter(grant -> grant.getLabel() != null).collect(Collectors.toList());
|
||||||
grants.sort(Comparator.comparing(Grant::getLabel));
|
grants.sort(Comparator.comparing(Grant::getLabel));
|
||||||
grants = grants.stream().filter(listHelper.distinctByKey(Grant::getLabel)).collect(Collectors.toList());
|
grants = grants.stream().filter(listHelper.distinctByKey(Grant::getLabel)).collect(Collectors.toList());
|
||||||
return grants;
|
return grants;
|
||||||
|
|
|
@ -27,11 +27,13 @@ public class PrefillingManager {
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
private final DatasetManager datasetManager;
|
private final DatasetManager datasetManager;
|
||||||
private final LicenseManager licenseManager;
|
private final LicenseManager licenseManager;
|
||||||
|
private final PrefillingMapper prefillingMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public PrefillingManager(ApiContext apiContext, ConfigLoader configLoader, DatasetManager datasetManager, LicenseManager licenseManager) {
|
public PrefillingManager(ApiContext apiContext, ConfigLoader configLoader, DatasetManager datasetManager, LicenseManager licenseManager, PrefillingMapper prefillingMapper) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
|
this.prefillingMapper = prefillingMapper;
|
||||||
this.objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
this.objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
this.datasetManager = datasetManager;
|
this.datasetManager = datasetManager;
|
||||||
this.licenseManager = licenseManager;
|
this.licenseManager = licenseManager;
|
||||||
|
@ -62,14 +64,14 @@ public class PrefillingManager {
|
||||||
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
||||||
Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId);
|
Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId);
|
||||||
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
||||||
return PrefillingMapper.mapPrefilledEntityToDatasetWizard(prefillingEntity, prefillingGet, prefillingConfig.getType(), descriptionTemplate, datasetManager, licenseManager);
|
return prefillingMapper.mapPrefilledEntityToDatasetWizard(prefillingEntity, prefillingGet, prefillingConfig.getType(), descriptionTemplate, datasetManager, licenseManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> data, String configId, UUID profileId) throws Exception {
|
public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> data, String configId, UUID profileId) throws Exception {
|
||||||
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
|
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
|
||||||
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
||||||
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
|
||||||
return PrefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), descriptionTemplate, datasetManager, licenseManager);
|
return prefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), descriptionTemplate, datasetManager, licenseManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> getSingle(String url, String id) {
|
private Map<String, Object> getSingle(String url, String id) {
|
||||||
|
|
|
@ -27,6 +27,8 @@ import eu.eudat.models.data.license.LicenseModel;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -35,11 +37,18 @@ import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class PrefillingMapper {
|
public class PrefillingMapper {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(PrefillingMapper.class);
|
private static final Logger logger = LoggerFactory.getLogger(PrefillingMapper.class);
|
||||||
private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
|
private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
|
||||||
|
private final DatasetProfileManager datasetProfileManager;
|
||||||
|
|
||||||
public static DatasetWizardModel mapPrefilledEntityToDatasetWizard(Map<String, Object> prefilledEntity, PrefillingGet prefillingGet, String type,
|
@Autowired
|
||||||
|
public PrefillingMapper(DatasetProfileManager datasetProfileManager) {
|
||||||
|
this.datasetProfileManager = datasetProfileManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetWizardModel mapPrefilledEntityToDatasetWizard(Map<String, Object> prefilledEntity, PrefillingGet prefillingGet, String type,
|
||||||
DescriptionTemplate profile, DatasetManager datasetManager, LicenseManager licenseManager) throws Exception {
|
DescriptionTemplate profile, DatasetManager datasetManager, LicenseManager licenseManager) throws Exception {
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
||||||
|
@ -77,7 +86,7 @@ public class PrefillingMapper {
|
||||||
return datasetWizardModel;
|
return datasetWizardModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setValue(PrefillingMapping prefillingMapping, String value, DatasetWizardModel datasetWizardModel, JsonNode parentNode, Map<String, Object> properties, String type, LicenseManager licenseManager) throws InvocationTargetException, IllegalAccessException, JsonProcessingException {
|
private void setValue(PrefillingMapping prefillingMapping, String value, DatasetWizardModel datasetWizardModel, JsonNode parentNode, Map<String, Object> properties, String type, LicenseManager licenseManager) throws InvocationTargetException, IllegalAccessException, JsonProcessingException {
|
||||||
String trimRegex = prefillingMapping.getTrimRegex() != null ? prefillingMapping.getTrimRegex() : "";
|
String trimRegex = prefillingMapping.getTrimRegex() != null ? prefillingMapping.getTrimRegex() : "";
|
||||||
if (!value.startsWith("\"") && !value.startsWith("[") && !value.equals("null")) {
|
if (!value.startsWith("\"") && !value.startsWith("[") && !value.equals("null")) {
|
||||||
value = "\"" + value + "\"";
|
value = "\"" + value + "\"";
|
||||||
|
@ -216,7 +225,7 @@ public class PrefillingMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object parseComboBoxValues(JsonNode node, List<String> parsedValues) throws JsonProcessingException {
|
private Object parseComboBoxValues(JsonNode node, List<String> parsedValues) throws JsonProcessingException {
|
||||||
List<Object> normalizedValues = new ArrayList<>();
|
List<Object> normalizedValues = new ArrayList<>();
|
||||||
boolean isMultiSelect;
|
boolean isMultiSelect;
|
||||||
String type = node.isArray() ? node.get(0).get("data").get("type").asText() : node.get("data").get("type").asText();
|
String type = node.isArray() ? node.get(0).get("data").get("type").asText() : node.get("data").get("type").asText();
|
||||||
|
@ -227,7 +236,7 @@ public class PrefillingMapper {
|
||||||
for (String format : parsedValues) {
|
for (String format : parsedValues) {
|
||||||
List<ExternalAutocompleteFieldModel> result = new ArrayList<>();
|
List<ExternalAutocompleteFieldModel> result = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
result = DatasetProfileManager.getAutocomplete(autoCompleteData, format);
|
result = datasetProfileManager.getAutocomplete(autoCompleteData, format);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package eu.eudat.logic.proxy.config;
|
||||||
|
|
||||||
|
public enum AuthType {
|
||||||
|
;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
AuthType(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AuthType fromName(String name) {
|
||||||
|
for (AuthType authType : AuthType.values()) {
|
||||||
|
if (authType.getName().equals(name)) {
|
||||||
|
return authType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("AuthType [" + name + "] is not supported");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package eu.eudat.logic.proxy.config;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
|
||||||
|
public class AuthenticationConfiguration {
|
||||||
|
|
||||||
|
private String authUrl;
|
||||||
|
private String authMethod = "GET";
|
||||||
|
private String authTokenPath;
|
||||||
|
private String authRequestBody;
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public String getAuthUrl() {
|
||||||
|
return authUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authUrl")
|
||||||
|
public void setAuthUrl(String authUrl) {
|
||||||
|
this.authUrl = authUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthMethod() {
|
||||||
|
return authMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authUrlMethod")
|
||||||
|
public void setAuthMethod(String authMethod) {
|
||||||
|
this.authMethod = authMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthTokenPath() {
|
||||||
|
return authTokenPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authTokenJpath")
|
||||||
|
public void setAuthTokenPath(String authTokenPath) {
|
||||||
|
this.authTokenPath = authTokenPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthRequestBody() {
|
||||||
|
return authRequestBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authUrlBody")
|
||||||
|
public void setAuthRequestBody(String authRequestBody) {
|
||||||
|
this.authRequestBody = authRequestBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "authType")
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ public class UrlConfiguration {
|
||||||
private String requestType = "GET";
|
private String requestType = "GET";
|
||||||
private String requestBody = "";
|
private String requestBody = "";
|
||||||
private String filterType = "remote";
|
private String filterType = "remote";
|
||||||
|
private AuthenticationConfiguration auth;
|
||||||
|
|
||||||
private List<QueryConfig> queries;
|
private List<QueryConfig> queries;
|
||||||
|
|
||||||
|
@ -143,4 +144,13 @@ public class UrlConfiguration {
|
||||||
public void setQueries(List<QueryConfig> queries) {
|
public void setQueries(List<QueryConfig> queries) {
|
||||||
this.queries = queries;
|
this.queries = queries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AuthenticationConfiguration getAuth() {
|
||||||
|
return auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name="authentication")
|
||||||
|
public void setAuth(AuthenticationConfiguration auth) {
|
||||||
|
this.auth = auth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package eu.eudat.logic.proxy.config.entities;
|
||||||
|
|
||||||
|
import eu.eudat.logic.proxy.config.FetchStrategy;
|
||||||
|
import eu.eudat.logic.proxy.config.UrlConfiguration;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GeneralUrls extends GenericUrls{
|
||||||
|
|
||||||
|
List<UrlConfiguration> urls;
|
||||||
|
FetchStrategy fetchMode;
|
||||||
|
|
||||||
|
public GeneralUrls() {
|
||||||
|
this.urls = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UrlConfiguration> getUrls() {
|
||||||
|
return urls;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FetchStrategy getFetchMode() {
|
||||||
|
return fetchMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFetchMode(FetchStrategy fetchMode) {
|
||||||
|
this.fetchMode = fetchMode;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,9 +15,14 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||||
|
import org.springframework.http.codec.json.Jackson2JsonDecoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import reactor.netty.http.client.HttpClient;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
@ -33,10 +38,16 @@ public class RemoteFetcher {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
|
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
|
||||||
|
|
||||||
private ConfigLoader configLoader;
|
private ConfigLoader configLoader;
|
||||||
|
private final WebClient client;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public RemoteFetcher(ConfigLoader configLoader) {
|
public RemoteFetcher(ConfigLoader configLoader) {
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
|
this.client = WebClient.builder().codecs(clientCodecConfigurer -> {
|
||||||
|
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
|
||||||
|
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
|
||||||
|
}
|
||||||
|
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(value = "repositories", keyGenerator = "externalUrlsKeyGenerator")
|
@Cacheable(value = "repositories", keyGenerator = "externalUrlsKeyGenerator")
|
||||||
|
@ -198,7 +209,11 @@ public class RemoteFetcher {
|
||||||
ifFunderQueryExist(urlConfiguration, externalUrlCriteria);
|
ifFunderQueryExist(urlConfiguration, externalUrlCriteria);
|
||||||
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
|
||||||
try {
|
try {
|
||||||
results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalUrlCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries()));
|
String auth = null;
|
||||||
|
if (urlConfiguration.getAuth() != null) {
|
||||||
|
auth = this.getAuthentication(urlConfiguration.getAuth());
|
||||||
|
}
|
||||||
|
results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalUrlCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries(), auth));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getLocalizedMessage(), e);
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -217,6 +232,19 @@ public class RemoteFetcher {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAuthentication(AuthenticationConfiguration authenticationConfiguration) {
|
||||||
|
HttpMethod method = HttpMethod.valueOf(authenticationConfiguration.getAuthMethod());
|
||||||
|
Map<String, Object> reponse = this.client.method(method).uri(authenticationConfiguration.getAuthUrl())
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.bodyValue(this.parseBodyString(authenticationConfiguration.getAuthRequestBody()))
|
||||||
|
.exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
|
||||||
|
})).block();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return authenticationConfiguration.getType() + " " + reponse.get(authenticationConfiguration.getAuthTokenPath());
|
||||||
|
}
|
||||||
|
|
||||||
private List<Map<String, Object>> getAllWithData(List<UrlConfiguration> urlConfigs, ExternalUrlCriteria externalUrlCriteria) {
|
private List<Map<String, Object>> getAllWithData(List<UrlConfiguration> urlConfigs, ExternalUrlCriteria externalUrlCriteria) {
|
||||||
|
|
||||||
List<Map<String, Object>> results = new LinkedList<>();
|
List<Map<String, Object>> results = new LinkedList<>();
|
||||||
|
@ -273,7 +301,7 @@ public class RemoteFetcher {
|
||||||
protected String replaceCriteriaOnUrl(String path, ExternalUrlCriteria externalUrlCriteria, String firstPage, List<QueryConfig> queries) {
|
protected String replaceCriteriaOnUrl(String path, ExternalUrlCriteria externalUrlCriteria, String firstPage, List<QueryConfig> queries) {
|
||||||
String completedPath = path;
|
String completedPath = path;
|
||||||
if (externalUrlCriteria.getLike() != null) {
|
if (externalUrlCriteria.getLike() != null) {
|
||||||
if ((path.contains("openaire") || path.contains("orcid") || path.contains("ror")) && externalUrlCriteria.getLike().equals("")) {
|
if ((path.contains("openaire") || path.contains("orcid") || path.contains("ror") || path.contains("fairsharing")) && externalUrlCriteria.getLike().equals("")) {
|
||||||
completedPath = completedPath.replaceAll("\\{like}", "*");
|
completedPath = completedPath.replaceAll("\\{like}", "*");
|
||||||
completedPath = completedPath.replaceAll("\\{query}", "*");
|
completedPath = completedPath.replaceAll("\\{query}", "*");
|
||||||
} else {
|
} else {
|
||||||
|
@ -329,13 +357,13 @@ public class RemoteFetcher {
|
||||||
return completedPath;
|
return completedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final DataUrlConfiguration jsonDataPath, final String jsonPaginationPath, ExternalUrlCriteria externalUrlCriteria, String tag, String key, String contentType, String firstPage, String requestBody, String requestType, String filterType, List<QueryConfig> queries) throws Exception {
|
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final DataUrlConfiguration jsonDataPath, final String jsonPaginationPath, ExternalUrlCriteria externalUrlCriteria, String tag, String key, String contentType, String firstPage, String requestBody, String requestType, String filterType, List<QueryConfig> queries, String auth) throws Exception {
|
||||||
Set<Integer> pages = new HashSet<>();
|
Set<Integer> pages = new HashSet<>();
|
||||||
|
|
||||||
String replacedPath = replaceCriteriaOnUrl(path, externalUrlCriteria, firstPage, queries);
|
String replacedPath = replaceCriteriaOnUrl(path, externalUrlCriteria, firstPage, queries);
|
||||||
String replacedBody = replaceCriteriaOnUrl(requestBody, externalUrlCriteria, firstPage, queries);
|
String replacedBody = replaceCriteriaOnUrl(requestBody, externalUrlCriteria, firstPage, queries);
|
||||||
|
|
||||||
Results results = getResultsFromUrl(replacedPath, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType);
|
Results results = getResultsFromUrl(replacedPath, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType, auth);
|
||||||
if(results != null) {
|
if(results != null) {
|
||||||
if (filterType != null && filterType.equals("local") && (externalUrlCriteria.getLike() != null && !externalUrlCriteria.getLike().isEmpty())) {
|
if (filterType != null && filterType.equals("local") && (externalUrlCriteria.getLike() != null && !externalUrlCriteria.getLike().isEmpty())) {
|
||||||
results.setResults(results.getResults().stream()
|
results.setResults(results.getResults().stream()
|
||||||
|
@ -354,7 +382,7 @@ public class RemoteFetcher {
|
||||||
throw new HugeResultSet("The submitted search query " + externalUrlCriteria.getLike() + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
|
throw new HugeResultSet("The submitted search query " + externalUrlCriteria.getLike() + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
|
||||||
|
|
||||||
Optional<Results> optionalResults = pages.parallelStream()
|
Optional<Results> optionalResults = pages.parallelStream()
|
||||||
.map(page -> getResultsFromUrl(path + "&page=" + page, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType))
|
.map(page -> getResultsFromUrl(path + "&page=" + page, jsonDataPath, jsonPaginationPath, contentType, replacedBody, requestType, auth))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.reduce((result1, result2) -> {
|
.reduce((result1, result2) -> {
|
||||||
result1.getResults().addAll(result2.getResults());
|
result1.getResults().addAll(result2.getResults());
|
||||||
|
@ -387,7 +415,7 @@ public class RemoteFetcher {
|
||||||
JsonNode jsonBody = new ObjectMapper().readTree(replacedBody);
|
JsonNode jsonBody = new ObjectMapper().readTree(replacedBody);
|
||||||
entity = new HttpEntity<>(jsonBody, headers);
|
entity = new HttpEntity<>(jsonBody, headers);
|
||||||
|
|
||||||
response = restTemplate.exchange(replacedPath, HttpMethod.resolve(requestType), entity, String.class);
|
response = restTemplate.exchange(replacedPath, HttpMethod.valueOf(requestType), entity, String.class);
|
||||||
if (response.getStatusCode() == HttpStatus.OK) {
|
if (response.getStatusCode() == HttpStatus.OK) {
|
||||||
if (response.getHeaders().get("Content-Type").get(0).contains("json")) {
|
if (response.getHeaders().get("Content-Type").get(0).contains("json")) {
|
||||||
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
||||||
|
@ -403,12 +431,12 @@ public class RemoteFetcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Results getResultsFromUrl(String urlString, DataUrlConfiguration jsonDataPath, String jsonPaginationPath, String contentType, String requestBody, String requestType) {
|
protected Results getResultsFromUrl(String urlString, DataUrlConfiguration jsonDataPath, String jsonPaginationPath, String contentType, String requestBody, String requestType, String auth) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
//RestTemplate restTemplate = new RestTemplate(new SimpleClientHttpRequestFactory());
|
||||||
HttpHeaders headers = new HttpHeaders();
|
//HttpHeaders headers = new HttpHeaders();
|
||||||
HttpEntity<JsonNode> entity;
|
//HttpEntity<JsonNode> entity;
|
||||||
ResponseEntity<String> response;
|
ResponseEntity<String> response;
|
||||||
/*
|
/*
|
||||||
* URL url = new URL(urlString.replaceAll(" ", "%20"));
|
* URL url = new URL(urlString.replaceAll(" ", "%20"));
|
||||||
|
@ -416,14 +444,27 @@ public class RemoteFetcher {
|
||||||
* HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
* HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
* con.setRequestMethod("GET");
|
* con.setRequestMethod("GET");
|
||||||
*/
|
*/
|
||||||
if (contentType != null && !contentType.isEmpty()) {
|
/* if (contentType != null && !contentType.isEmpty()) {
|
||||||
headers.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
headers.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
||||||
headers.setContentType(MediaType.valueOf(contentType));
|
headers.setContentType(MediaType.valueOf(contentType));
|
||||||
}
|
}
|
||||||
|
if (auth != null) {
|
||||||
|
headers.set("Authorization", auth);
|
||||||
|
}*/
|
||||||
JsonNode jsonBody = new ObjectMapper().readTree(requestBody);
|
JsonNode jsonBody = new ObjectMapper().readTree(requestBody);
|
||||||
entity = new HttpEntity<>(jsonBody, headers);
|
// entity = new HttpEntity<>(jsonBody, headers);
|
||||||
|
|
||||||
response = restTemplate.exchange(urlString, HttpMethod.resolve(requestType), entity, String.class);
|
|
||||||
|
response = this.client.method(HttpMethod.valueOf(requestType)).uri(urlString).headers(httpHeaders -> {
|
||||||
|
if (contentType != null && !contentType.isEmpty()) {
|
||||||
|
httpHeaders.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
||||||
|
httpHeaders.setContentType(MediaType.valueOf(contentType));
|
||||||
|
}
|
||||||
|
if (auth != null) {
|
||||||
|
httpHeaders.set("Authorization", auth);
|
||||||
|
}
|
||||||
|
}).bodyValue(jsonBody).retrieve().toEntity(String.class).block();
|
||||||
|
//response = restTemplate.exchange(urlString, HttpMethod.resolve(requestType), entity, String.class);
|
||||||
if (response.getStatusCode() == HttpStatus.OK) { // success
|
if (response.getStatusCode() == HttpStatus.OK) { // success
|
||||||
//do here all the parsing
|
//do here all the parsing
|
||||||
Results results = new Results();
|
Results results = new Results();
|
||||||
|
@ -431,7 +472,7 @@ public class RemoteFetcher {
|
||||||
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
||||||
|
|
||||||
if (jsonDataPath.getFieldsUrlConfiguration().getPath() != null) {
|
if (jsonDataPath.getFieldsUrlConfiguration().getPath() != null) {
|
||||||
results = RemoteFetcherUtils.getFromJsonWithRecursiveFetching(jsonContext, jsonDataPath, this, requestBody, requestType);
|
results = RemoteFetcherUtils.getFromJsonWithRecursiveFetching(jsonContext, jsonDataPath, this, requestBody, requestType, auth);
|
||||||
} else if (jsonDataPath.getFieldsUrlConfiguration().getFirstName() != null) {
|
} else if (jsonDataPath.getFieldsUrlConfiguration().getFirstName() != null) {
|
||||||
results = RemoteFetcherUtils.getFromJsonWithFirstAndLastName(jsonContext, jsonDataPath);
|
results = RemoteFetcherUtils.getFromJsonWithFirstAndLastName(jsonContext, jsonDataPath);
|
||||||
} else {
|
} else {
|
||||||
|
@ -553,8 +594,18 @@ public class RemoteFetcher {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String parseBodyString(String bodyString) {
|
||||||
|
String finalBodyString = bodyString;
|
||||||
|
if (bodyString.contains("{env:")) {
|
||||||
|
int index = bodyString.indexOf("{env: ");
|
||||||
|
while (index >= 0) {
|
||||||
|
int endIndex = bodyString.indexOf("}", index + 6);
|
||||||
|
String envName = bodyString.substring(index + 6, endIndex);
|
||||||
|
finalBodyString = finalBodyString.replace("{env: " + envName + "}", System.getenv(envName));
|
||||||
|
index = bodyString.indexOf("{env: ", index + 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return finalBodyString;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class RemoteFetcherUtils {
|
||||||
new HashMap<>(1, 1));
|
new HashMap<>(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Results getFromJsonWithRecursiveFetching(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath, RemoteFetcher remoteFetcher, String requestBody, String requestType) {
|
public static Results getFromJsonWithRecursiveFetching(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath, RemoteFetcher remoteFetcher, String requestBody, String requestType, String auth) {
|
||||||
Results results = new Results(parseData(jsonContext, jsonDataPath),
|
Results results = new Results(parseData(jsonContext, jsonDataPath),
|
||||||
new HashMap<>(1, 1));
|
new HashMap<>(1, 1));
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class RemoteFetcherUtils {
|
||||||
externalUrlCriteria.setPath(result.get("path"));
|
externalUrlCriteria.setPath(result.get("path"));
|
||||||
externalUrlCriteria.setHost(result.get("host"));
|
externalUrlCriteria.setHost(result.get("host"));
|
||||||
String replacedPath = remoteFetcher.replaceCriteriaOnUrl(jsonDataPath.getUrlConfiguration().getUrl(), externalUrlCriteria, jsonDataPath.getUrlConfiguration().getFirstpage(), jsonDataPath.getUrlConfiguration().getQueries());
|
String replacedPath = remoteFetcher.replaceCriteriaOnUrl(jsonDataPath.getUrlConfiguration().getUrl(), externalUrlCriteria, jsonDataPath.getUrlConfiguration().getFirstpage(), jsonDataPath.getUrlConfiguration().getQueries());
|
||||||
return remoteFetcher.getResultsFromUrl(replacedPath, jsonDataPath.getUrlConfiguration().getData(), jsonDataPath.getUrlConfiguration().getData().getPath(), jsonDataPath.getUrlConfiguration().getContentType(), requestBody, requestType);
|
return remoteFetcher.getResultsFromUrl(replacedPath, jsonDataPath.getUrlConfiguration().getData(), jsonDataPath.getUrlConfiguration().getData().getPath(), jsonDataPath.getUrlConfiguration().getContentType(), requestBody, requestType, auth);
|
||||||
}).filter(Objects::nonNull).map(results1 -> results1.getResults().get(0)).collect(Collectors.toList());
|
}).filter(Objects::nonNull).map(results1 -> results1.getResults().get(0)).collect(Collectors.toList());
|
||||||
return new Results(multiResults, new HashMap<>(1, 1));
|
return new Results(multiResults, new HashMap<>(1, 1));
|
||||||
}
|
}
|
||||||
|
@ -98,11 +98,25 @@ public class RemoteFetcherUtils {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
value = value.replace("'", "");
|
value = value.replace("'", "");
|
||||||
|
if (value.contains(".")) {
|
||||||
|
String[] parts = value.split("\\.");
|
||||||
|
Map<String, Object> tempMap = stringObjectMap;
|
||||||
|
for (int i = 0; i < parts.length; i++) {
|
||||||
|
if (tempMap.containsKey(parts[i])) {
|
||||||
|
if (i + 1 < parts.length) {
|
||||||
|
tempMap = (Map<String, Object>) tempMap.get(parts[i]);
|
||||||
|
} else {
|
||||||
|
parsedData.get(parsedData.size() - 1).put(field.getName().equals("types") ? "tags" : value, normalizeValue(tempMap.get(parts[i]), (field.getName().equals("types") || field.getName().equals("uri"))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (stringObjectMap.containsKey(value)) {
|
if (stringObjectMap.containsKey(value)) {
|
||||||
parsedData.get(parsedData.size() - 1).put(field.getName().equals("types") ? "tags" : value, normalizeValue(stringObjectMap.get(value), (field.getName().equals("types") || field.getName().equals("uri"))));
|
parsedData.get(parsedData.size() - 1).put(field.getName().equals("types") ? "tags" : value, normalizeValue(stringObjectMap.get(value), (field.getName().equals("types") || field.getName().equals("uri"))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
logger.error(e.getLocalizedMessage(), e);
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +149,8 @@ public class RemoteFetcherUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (value instanceof Map) {
|
} else if (value instanceof Map) {
|
||||||
return ((Map<String, String>)value).get("content");
|
String key = ((Map<String, String>)value).containsKey("$") ? "$" : "content";
|
||||||
|
return ((Map<String, String>)value).get(key);
|
||||||
}
|
}
|
||||||
return value != null ? value.toString() : null;
|
return value != null ? value.toString() : null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
import org.apache.poi.xwpf.usermodel.*;
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
import org.apache.xmlbeans.XmlCursor;
|
import org.apache.xmlbeans.XmlCursor;
|
||||||
|
import org.apache.xmlbeans.XmlObject;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
@ -1019,32 +1020,15 @@ public class WordBuilder {
|
||||||
int descrParPos = -1;
|
int descrParPos = -1;
|
||||||
XWPFParagraph descrPar = null;
|
XWPFParagraph descrPar = null;
|
||||||
for(XWPFParagraph p: document.getParagraphs()){
|
for(XWPFParagraph p: document.getParagraphs()){
|
||||||
List<XWPFRun> runs = p.getRuns();
|
|
||||||
if(runs != null){
|
if( dmpEntity != null) {
|
||||||
for(XWPFRun r : runs){
|
this.replaceTextSegment(p, "'{ARGOS.DMP.TITLE}'", dmpEntity.getLabel());
|
||||||
String text = r.getText(0);
|
this.replaceTextSegment(p, "'{ARGOS.DMP.VERSION}'", "Version " + dmpEntity.getVersion());
|
||||||
if(text != null){
|
|
||||||
if(text.contains("{ARGOS.DMP.TITLE}")) {
|
|
||||||
text = text.replace("{ARGOS.DMP.TITLE}", dmpEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
} else if(text.contains("{ARGOS.DMP.VERSION}")) {
|
|
||||||
text = text.replace("{ARGOS.DMP.VERSION}", "Version " + dmpEntity.getVersion());
|
|
||||||
r.setText(text, 0);
|
|
||||||
} else if(datasetEntity != null && text.contains("{ARGOS.DATASET.TITLE}")) {
|
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
// } else if(text.equals("Description") && ((!isDataset && (dmpEntity == null || dmpEntity.getDescription() != null)) || (isDataset && (datasetEntity == null || datasetEntity.getDescription() == null)))) {
|
|
||||||
// r.setText("", 0);
|
|
||||||
} else if((dmpEntity != null && text.contains("{ARGOS.DMP.DESCRIPTION}") && !isDataset) || (datasetEntity != null && text.contains("{ARGOS.DATASET.DESCRIPTION}") && isDataset)) {
|
|
||||||
descrParPos = parPos;
|
|
||||||
descrPar = p;
|
|
||||||
if(dmpEntity != null && !isDataset) {
|
|
||||||
text = text.replace("{ARGOS.DMP.DESCRIPTION}", "");
|
|
||||||
} else if(datasetEntity != null && isDataset) {
|
|
||||||
text = text.replace("{ARGOS.DATASET.DESCRIPTION}", "");
|
|
||||||
}
|
}
|
||||||
r.setText(text, 0);
|
if( datasetEntity != null) {
|
||||||
} else if(text.equals("{ARGOS.DMP.RESEARCHERS}")) {
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", datasetEntity.getLabel());
|
||||||
|
}
|
||||||
|
|
||||||
String researchersNames = "";
|
String researchersNames = "";
|
||||||
Set<Researcher> researchers = dmpEntity.getResearchers();
|
Set<Researcher> researchers = dmpEntity.getResearchers();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -1052,27 +1036,28 @@ public class WordBuilder {
|
||||||
i++;
|
i++;
|
||||||
researchersNames += researcher.getLabel() + (i < researchers.size() ? ", " : "");
|
researchersNames += researcher.getLabel() + (i < researchers.size() ? ", " : "");
|
||||||
}
|
}
|
||||||
text = text.replace("{ARGOS.DMP.RESEARCHERS}", researchersNames);
|
this.replaceTextSegment(p, "'{ARGOS.DMP.RESEARCHERS}'", researchersNames, 15);
|
||||||
r.setText(text, 0);
|
|
||||||
r.setFontSize(17);
|
|
||||||
} else if(text.equals("{ARGOS.DMP.ORGANIZATIONS}")) {
|
|
||||||
String organisationsNames = "";
|
String organisationsNames = "";
|
||||||
Set<Organisation> organisations = dmpEntity.getOrganisations();
|
Set<Organisation> organisations = dmpEntity.getOrganisations();
|
||||||
int i = 0;
|
i = 0;
|
||||||
for(Organisation organisation : organisations){
|
for(Organisation organisation : organisations){
|
||||||
i++;
|
i++;
|
||||||
organisationsNames += organisation.getLabel() + (i < organisations.size() ? ", " : "");
|
organisationsNames += organisation.getLabel() + (i < organisations.size() ? ", " : "");
|
||||||
}
|
}
|
||||||
text = text.replace("{ARGOS.DMP.ORGANIZATIONS}", organisationsNames);
|
this.replaceTextSegment(p, "'{ARGOS.DMP.ORGANIZATIONS}'", organisationsNames, 15);
|
||||||
r.setText(text, 0);
|
|
||||||
r.setFontSize(17);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parPos++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(this.textSegmentExists(p,"'{ARGOS.DMP.DESCRIPTION}'")) {
|
||||||
|
descrParPos = parPos;
|
||||||
|
descrPar = p;
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DESCRIPTION}'", "");
|
||||||
|
}
|
||||||
|
if(this.textSegmentExists(p,"'{ARGOS.DATASET.DESCRIPTION}'")) {
|
||||||
|
descrParPos = parPos;
|
||||||
|
descrPar = p;
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.DESCRIPTION}'", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
if((descrParPos != -1) && (dmpEntity!=null) && (dmpEntity.getDescription() != null) && !isDataset) {
|
if((descrParPos != -1) && (dmpEntity!=null) && (dmpEntity.getDescription() != null) && !isDataset) {
|
||||||
XmlCursor cursor = descrPar.getCTP().newCursor();
|
XmlCursor cursor = descrPar.getCTP().newCursor();
|
||||||
cursor.toNextSibling();
|
cursor.toNextSibling();
|
||||||
|
@ -1096,7 +1081,7 @@ public class WordBuilder {
|
||||||
XWPFParagraph p = it.next().getCell(0).getParagraphs().get(0);
|
XWPFParagraph p = it.next().getCell(0).getParagraphs().get(0);
|
||||||
XWPFRun run = p.createRun();
|
XWPFRun run = p.createRun();
|
||||||
run.setText(dmpEntity.getGrant().getFunder().getLabel());
|
run.setText(dmpEntity.getGrant().getFunder().getLabel());
|
||||||
run.setFontSize(17);
|
run.setFontSize(15);
|
||||||
p.setAlignment(ParagraphAlignment.CENTER);
|
p.setAlignment(ParagraphAlignment.CENTER);
|
||||||
}
|
}
|
||||||
it = tbl.getRows().iterator();
|
it = tbl.getRows().iterator();
|
||||||
|
@ -1111,7 +1096,7 @@ public class WordBuilder {
|
||||||
text += parts.length > 1 ? "/ No "+parts[parts.length - 1] : "";
|
text += parts.length > 1 ? "/ No "+parts[parts.length - 1] : "";
|
||||||
}
|
}
|
||||||
run.setText(text);
|
run.setText(text);
|
||||||
run.setFontSize(17);
|
run.setFontSize(15);
|
||||||
p.setAlignment(ParagraphAlignment.CENTER);
|
p.setAlignment(ParagraphAlignment.CENTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1119,43 +1104,165 @@ public class WordBuilder {
|
||||||
public void fillFooter(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document, boolean isDataset) {
|
public void fillFooter(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document, boolean isDataset) {
|
||||||
document.getFooterList().forEach(xwpfFooter -> {
|
document.getFooterList().forEach(xwpfFooter -> {
|
||||||
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
||||||
if(runs != null){
|
for(XWPFParagraph p : xwpfFooter.getParagraphs()){
|
||||||
for(XWPFRun r : runs){
|
if(p != null){
|
||||||
String text = r.getText(0);
|
if( dmpEntity != null) {
|
||||||
if(text != null){
|
this.replaceTextSegment(p, "'{ARGOS.DMP.TITLE}'", dmpEntity.getLabel());
|
||||||
if(text.contains("{ARGOS.DMP.TITLE}")){
|
|
||||||
text = text.replace("{ARGOS.DMP.TITLE}", dmpEntity.getLabel());
|
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
}
|
||||||
if(text.contains("{ARGOS.DATASET.TITLE}") && datasetEntity != null){
|
if( datasetEntity != null) {
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
this.replaceTextSegment(p, "'{ARGOS.DATASET.TITLE}'", datasetEntity.getLabel());
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
}
|
||||||
if(text.contains("{ARGOS.DMP.LICENSE}")){
|
Map<String, String> license = null;
|
||||||
try {
|
try {
|
||||||
Map<String, String> license = ((Map<String, String>) mapper.readValue(dmpEntity.getExtraProperties(), Map.class).get("license"));
|
license = ((Map<String, String>) mapper.readValue(dmpEntity.getExtraProperties(), Map.class).get("license"));
|
||||||
text = text.replace("{ARGOS.DMP.LICENSE}", license.get("pid"));
|
if (license != null && license.get("pid") != null) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", license.get("pid"));
|
||||||
|
} else {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", "License: -");
|
||||||
}
|
}
|
||||||
catch (JsonProcessingException | NullPointerException e){
|
} catch (JsonProcessingException e) {
|
||||||
text = text.replace("{ARGOS.DMP.LICENSE}", "License: -");
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LICENSE}'", "License: -");
|
||||||
}
|
}
|
||||||
r.setText(text, 0);
|
if(dmpEntity.getDois() != null && !dmpEntity.getDois().isEmpty()) {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DOI}'", dmpEntity.getDois().iterator().next().getDoi());
|
||||||
|
} else {
|
||||||
|
this.replaceTextSegment(p, "'{ARGOS.DMP.DOI}'", "-");
|
||||||
}
|
}
|
||||||
if(text.contains("{ARGOS.DMP.DOI}")){
|
|
||||||
if(dmpEntity.getDois() != null && !dmpEntity.getDois().isEmpty())
|
|
||||||
text = text.replace("{ARGOS.DMP.DOI}", dmpEntity.getDois().iterator().next().getDoi());
|
|
||||||
else
|
|
||||||
text = text.replace("{ARGOS.DMP.DOI}", "-");
|
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
|
||||||
if(text.contains("{ARGOS.DMP.LAST_MODIFIED}")){
|
|
||||||
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
text = text.replace("{ARGOS.DMP.LAST_MODIFIED}", formatter.format(dmpEntity.getModified()));
|
this.replaceTextSegment(p, "'{ARGOS.DMP.LAST_MODIFIED}'", formatter.format(dmpEntity.getModified()));
|
||||||
r.setText(text, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean textSegmentExists(XWPFParagraph paragraph, String textToFind) {
|
||||||
|
TextSegment foundTextSegment = null;
|
||||||
|
PositionInParagraph startPos = new PositionInParagraph(0, 0, 0);
|
||||||
|
while((foundTextSegment = this.searchText(paragraph, textToFind, startPos)) != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceTextSegment(XWPFParagraph paragraph, String textToFind, String replacement) {
|
||||||
|
this.replaceTextSegment(paragraph, textToFind, replacement, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceTextSegment(XWPFParagraph paragraph, String textToFind, String replacement, Integer fontSize) {
|
||||||
|
TextSegment foundTextSegment = null;
|
||||||
|
PositionInParagraph startPos = new PositionInParagraph(0, 0, 0);
|
||||||
|
while((foundTextSegment = this.searchText(paragraph, textToFind, startPos)) != null) { // search all text segments having text to find
|
||||||
|
|
||||||
|
System.out.println(foundTextSegment.getBeginRun()+":"+foundTextSegment.getBeginText()+":"+foundTextSegment.getBeginChar());
|
||||||
|
System.out.println(foundTextSegment.getEndRun()+":"+foundTextSegment.getEndText()+":"+foundTextSegment.getEndChar());
|
||||||
|
|
||||||
|
// maybe there is text before textToFind in begin run
|
||||||
|
XWPFRun beginRun = paragraph.getRuns().get(foundTextSegment.getBeginRun());
|
||||||
|
String textInBeginRun = beginRun.getText(foundTextSegment.getBeginText());
|
||||||
|
String textBefore = textInBeginRun.substring(0, foundTextSegment.getBeginChar()); // we only need the text before
|
||||||
|
|
||||||
|
// maybe there is text after textToFind in end run
|
||||||
|
XWPFRun endRun = paragraph.getRuns().get(foundTextSegment.getEndRun());
|
||||||
|
String textInEndRun = endRun.getText(foundTextSegment.getEndText());
|
||||||
|
String textAfter = textInEndRun.substring(foundTextSegment.getEndChar() + 1); // we only need the text after
|
||||||
|
|
||||||
|
if (foundTextSegment.getEndRun() == foundTextSegment.getBeginRun()) {
|
||||||
|
textInBeginRun = textBefore + replacement + textAfter; // if we have only one run, we need the text before, then the replacement, then the text after in that run
|
||||||
|
} else {
|
||||||
|
textInBeginRun = textBefore + replacement; // else we need the text before followed by the replacement in begin run
|
||||||
|
endRun.setText(textAfter, foundTextSegment.getEndText()); // and the text after in end run
|
||||||
|
}
|
||||||
|
|
||||||
|
beginRun.setText(textInBeginRun, foundTextSegment.getBeginText());
|
||||||
|
if (fontSize != null) {
|
||||||
|
beginRun.setFontSize(fontSize);
|
||||||
|
}
|
||||||
|
// runs between begin run and end run needs to be removed
|
||||||
|
for (int runBetween = foundTextSegment.getEndRun() - 1; runBetween > foundTextSegment.getBeginRun(); runBetween--) {
|
||||||
|
paragraph.removeRun(runBetween); // remove not needed runs
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this methods parse the paragraph and search for the string searched.
|
||||||
|
* If it finds the string, it will return true and the position of the String
|
||||||
|
* will be saved in the parameter startPos.
|
||||||
|
*
|
||||||
|
* @param searched
|
||||||
|
* @param startPos
|
||||||
|
*/
|
||||||
|
private TextSegment searchText(XWPFParagraph paragraph, String searched, PositionInParagraph startPos) {
|
||||||
|
int startRun = startPos.getRun(),
|
||||||
|
startText = startPos.getText(),
|
||||||
|
startChar = startPos.getChar();
|
||||||
|
int beginRunPos = 0, candCharPos = 0;
|
||||||
|
boolean newList = false;
|
||||||
|
|
||||||
|
//CTR[] rArray = paragraph.getRArray(); //This does not contain all runs. It lacks hyperlink runs for ex.
|
||||||
|
java.util.List<XWPFRun> runs = paragraph.getRuns();
|
||||||
|
|
||||||
|
int beginTextPos = 0, beginCharPos = 0; //must be outside the for loop
|
||||||
|
|
||||||
|
//for (int runPos = startRun; runPos < rArray.length; runPos++) {
|
||||||
|
for (int runPos = startRun; runPos < runs.size(); runPos++) {
|
||||||
|
//int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos; //int beginTextPos = 0, beginCharPos = 0 must be outside the for loop
|
||||||
|
int textPos = 0, charPos;
|
||||||
|
//CTR ctRun = rArray[runPos];
|
||||||
|
CTR ctRun = runs.get(runPos).getCTR();
|
||||||
|
XmlCursor c = ctRun.newCursor();
|
||||||
|
c.selectPath("./*");
|
||||||
|
try {
|
||||||
|
while (c.toNextSelection()) {
|
||||||
|
XmlObject o = c.getObject();
|
||||||
|
if (o instanceof CTText) {
|
||||||
|
if (textPos >= startText) {
|
||||||
|
String candidate = ((CTText) o).getStringValue();
|
||||||
|
if (runPos == startRun) {
|
||||||
|
charPos = startChar;
|
||||||
|
} else {
|
||||||
|
charPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; charPos < candidate.length(); charPos++) {
|
||||||
|
if ((candidate.charAt(charPos) == searched.charAt(0)) && (candCharPos == 0)) {
|
||||||
|
beginTextPos = textPos;
|
||||||
|
beginCharPos = charPos;
|
||||||
|
beginRunPos = runPos;
|
||||||
|
newList = true;
|
||||||
|
}
|
||||||
|
if (candidate.charAt(charPos) == searched.charAt(candCharPos)) {
|
||||||
|
if (candCharPos + 1 < searched.length()) {
|
||||||
|
candCharPos++;
|
||||||
|
} else if (newList) {
|
||||||
|
TextSegment segment = new TextSegment();
|
||||||
|
segment.setBeginRun(beginRunPos);
|
||||||
|
segment.setBeginText(beginTextPos);
|
||||||
|
segment.setBeginChar(beginCharPos);
|
||||||
|
segment.setEndRun(runPos);
|
||||||
|
segment.setEndText(textPos);
|
||||||
|
segment.setEndChar(charPos);
|
||||||
|
return segment;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
candCharPos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textPos++;
|
||||||
|
} else if (o instanceof CTProofErr) {
|
||||||
|
c.removeXml();
|
||||||
|
} else if (o instanceof CTRPr) {
|
||||||
|
//do nothing
|
||||||
|
} else {
|
||||||
|
candCharPos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
c.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ public class ExportXmlBuilderDatasetProfile {
|
||||||
Element pages = (Element)xmlDoc.getFirstChild();
|
Element pages = (Element)xmlDoc.getFirstChild();
|
||||||
pages.setAttribute("description", datasetProfile.getDescription());
|
pages.setAttribute("description", datasetProfile.getDescription());
|
||||||
pages.setAttribute("language", datasetProfile.getLanguage());
|
pages.setAttribute("language", datasetProfile.getLanguage());
|
||||||
|
pages.setAttribute("type", datasetProfile.getType());
|
||||||
|
pages.setAttribute("enablePrefilling", String.valueOf(datasetProfile.isEnablePrefilling()));
|
||||||
String xml = XmlBuilder.generateXml(xmlDoc);
|
String xml = XmlBuilder.generateXml(xmlDoc);
|
||||||
writer.write(xml);
|
writer.write(xml);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
|
@ -14,6 +14,8 @@ public class DatasetProfile {
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
private String language;
|
private String language;
|
||||||
|
private String type;
|
||||||
|
private boolean enablePrefilling;
|
||||||
|
|
||||||
private List<Page> page;
|
private List<Page> page;
|
||||||
|
|
||||||
|
@ -44,12 +46,32 @@ public class DatasetProfile {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "type")
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "enablePrefilling")
|
||||||
|
public boolean isEnablePrefilling() {
|
||||||
|
return enablePrefilling;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnablePrefilling(boolean enablePrefilling) {
|
||||||
|
this.enablePrefilling = enablePrefilling;
|
||||||
|
}
|
||||||
|
|
||||||
public eu.eudat.models.data.admin.composite.DatasetProfile toAdminCompositeModel(String label){
|
public eu.eudat.models.data.admin.composite.DatasetProfile toAdminCompositeModel(String label){
|
||||||
eu.eudat.models.data.admin.composite.DatasetProfile newDatasetEntityProfile = new eu.eudat.models.data.admin.composite.DatasetProfile();
|
eu.eudat.models.data.admin.composite.DatasetProfile newDatasetEntityProfile = new eu.eudat.models.data.admin.composite.DatasetProfile();
|
||||||
newDatasetEntityProfile.setLabel(label);
|
newDatasetEntityProfile.setLabel(label);
|
||||||
newDatasetEntityProfile.setStatus(DescriptionTemplate.Status.SAVED.getValue());
|
newDatasetEntityProfile.setStatus(DescriptionTemplate.Status.SAVED.getValue());
|
||||||
newDatasetEntityProfile.setDescription(description);
|
newDatasetEntityProfile.setDescription(description);
|
||||||
newDatasetEntityProfile.setLanguage(language);
|
newDatasetEntityProfile.setLanguage(language);
|
||||||
|
newDatasetEntityProfile.setType(type);
|
||||||
|
newDatasetEntityProfile.setEnablePrefilling(enablePrefilling);
|
||||||
List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>();
|
List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>();
|
||||||
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionDatasetEntity = new LinkedList<>();
|
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionDatasetEntity = new LinkedList<>();
|
||||||
for (Page xmlPage: page) {
|
for (Page xmlPage: page) {
|
||||||
|
|
|
@ -12,8 +12,8 @@ public class DescriptionTemplate {
|
||||||
private String id;
|
private String id;
|
||||||
private String descriptionTemplateId;
|
private String descriptionTemplateId;
|
||||||
private String label;
|
private String label;
|
||||||
private int minMultiplicity;
|
private Integer minMultiplicity;
|
||||||
private int maxMultiplicity;
|
private Integer maxMultiplicity;
|
||||||
|
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -43,20 +43,20 @@ public class DescriptionTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute(name = "minMultiplicity")
|
@XmlAttribute(name = "minMultiplicity")
|
||||||
public int getMinMultiplicity() {
|
public Integer getMinMultiplicity() {
|
||||||
return minMultiplicity;
|
return minMultiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinMultiplicity(int minMultiplicity) {
|
public void setMinMultiplicity(Integer minMultiplicity) {
|
||||||
this.minMultiplicity = minMultiplicity;
|
this.minMultiplicity = minMultiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute(name = "maxMultiplicity")
|
@XmlAttribute(name = "maxMultiplicity")
|
||||||
public int getMaxMultiplicity() {
|
public Integer getMaxMultiplicity() {
|
||||||
return maxMultiplicity;
|
return maxMultiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxMultiplicity(int maxMultiplicity) {
|
public void setMaxMultiplicity(Integer maxMultiplicity) {
|
||||||
this.maxMultiplicity = maxMultiplicity;
|
this.maxMultiplicity = maxMultiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class DatasetProfile {
|
||||||
private String label;
|
private String label;
|
||||||
private String description;
|
private String description;
|
||||||
private String type;
|
private String type;
|
||||||
|
private boolean enablePrefilling;
|
||||||
private List<Page> pages;
|
private List<Page> pages;
|
||||||
private List<Section> sections;
|
private List<Section> sections;
|
||||||
private Short status;
|
private Short status;
|
||||||
|
@ -43,6 +44,13 @@ public class DatasetProfile {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnablePrefilling() {
|
||||||
|
return enablePrefilling;
|
||||||
|
}
|
||||||
|
public void setEnablePrefilling(boolean enablePrefilling) {
|
||||||
|
this.enablePrefilling = enablePrefilling;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Page> getPages() {
|
public List<Page> getPages() {
|
||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +88,7 @@ public class DatasetProfile {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) {
|
public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) {
|
||||||
|
this.enablePrefilling = viewStyle.isEnablePrefilling();
|
||||||
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
|
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
|
||||||
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
|
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
|
||||||
}
|
}
|
||||||
|
@ -89,6 +98,7 @@ public class DatasetProfile {
|
||||||
shortProfile.setLabel(this.label);
|
shortProfile.setLabel(this.label);
|
||||||
shortProfile.setDescription(this.description);
|
shortProfile.setDescription(this.description);
|
||||||
shortProfile.setType(this.type);
|
shortProfile.setType(this.type);
|
||||||
|
shortProfile.setEnablePrefilling(this.enablePrefilling);
|
||||||
List<Section> shortSection = new LinkedList<>();
|
List<Section> shortSection = new LinkedList<>();
|
||||||
for (Section toshortSection : this.getSections()) {
|
for (Section toshortSection : this.getSections()) {
|
||||||
shortSection.add(toshortSection.toShort());
|
shortSection.add(toshortSection.toShort());
|
||||||
|
|
|
@ -10,11 +10,62 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
|
|
||||||
|
public static class AuthAutoCompleteData {
|
||||||
|
private String url;
|
||||||
|
private String method;
|
||||||
|
private String body;
|
||||||
|
private String path;
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMethod() {
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethod(String method) {
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBody(String body) {
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
public static class AutoCompleteSingleData {
|
public static class AutoCompleteSingleData {
|
||||||
private int autocompleteType;
|
private int autocompleteType;
|
||||||
private String url;
|
private String url;
|
||||||
private ComboBoxData.Option autoCompleteOptions;
|
private ComboBoxData.Option autoCompleteOptions;
|
||||||
private String optionsRoot;
|
private String optionsRoot;
|
||||||
|
private Boolean hasAuth;
|
||||||
|
private AuthAutoCompleteData auth;
|
||||||
|
private String method;
|
||||||
|
|
||||||
public int getAutocompleteType() {
|
public int getAutocompleteType() {
|
||||||
return autocompleteType;
|
return autocompleteType;
|
||||||
|
@ -38,12 +89,36 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getHasAuth() {
|
||||||
|
return hasAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasAuth(Boolean hasAuth) {
|
||||||
|
this.hasAuth = hasAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthAutoCompleteData getAuth() {
|
||||||
|
return auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuth(AuthAutoCompleteData auth) {
|
||||||
|
this.auth = auth;
|
||||||
|
}
|
||||||
|
|
||||||
public ComboBoxData.Option getAutoCompleteOptions() {
|
public ComboBoxData.Option getAutoCompleteOptions() {
|
||||||
return autoCompleteOptions;
|
return autoCompleteOptions;
|
||||||
}
|
}
|
||||||
public void setAutoCompleteOptions(ComboBoxData.Option autoCompleteOptions) {
|
public void setAutoCompleteOptions(ComboBoxData.Option autoCompleteOptions) {
|
||||||
this.autoCompleteOptions = autoCompleteOptions;
|
this.autoCompleteOptions = autoCompleteOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMethod() {
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethod(String method) {
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean multiAutoComplete;
|
private Boolean multiAutoComplete;
|
||||||
|
@ -70,11 +145,22 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
parent.setAttribute("url", singleData.url);
|
parent.setAttribute("url", singleData.url);
|
||||||
parent.setAttribute("optionsRoot", singleData.optionsRoot);
|
parent.setAttribute("optionsRoot", singleData.optionsRoot);
|
||||||
parent.setAttribute("autoCompleteType", Integer.toString(singleData.autocompleteType));
|
parent.setAttribute("autoCompleteType", Integer.toString(singleData.autocompleteType));
|
||||||
|
parent.setAttribute("hasAuth", Boolean.toString(singleData.hasAuth));
|
||||||
|
parent.setAttribute("method", singleData.method);
|
||||||
Element element = doc.createElement("option");
|
Element element = doc.createElement("option");
|
||||||
element.setAttribute("label", singleData.autoCompleteOptions.getLabel());
|
element.setAttribute("label", singleData.autoCompleteOptions.getLabel());
|
||||||
element.setAttribute("value", singleData.autoCompleteOptions.getValue());
|
element.setAttribute("value", singleData.autoCompleteOptions.getValue());
|
||||||
element.setAttribute("source", singleData.autoCompleteOptions.getSource());
|
element.setAttribute("source", singleData.autoCompleteOptions.getSource());
|
||||||
parent.appendChild(element);
|
parent.appendChild(element);
|
||||||
|
if (singleData.hasAuth) {
|
||||||
|
Element authElement = doc.createElement("auth");
|
||||||
|
authElement.setAttribute("url", singleData.auth.url);
|
||||||
|
authElement.setAttribute("method", singleData.auth.method);
|
||||||
|
authElement.setAttribute("body", singleData.auth.body);
|
||||||
|
authElement.setAttribute("path", singleData.auth.path);
|
||||||
|
authElement.setAttribute("type", singleData.auth.type);
|
||||||
|
parent.appendChild(authElement);
|
||||||
|
}
|
||||||
root.appendChild(parent);
|
root.appendChild(parent);
|
||||||
}
|
}
|
||||||
return root;
|
return root;
|
||||||
|
@ -108,6 +194,8 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
} else {
|
} else {
|
||||||
singleData.autocompleteType = AutocompleteType.fromValue(Integer.parseInt(item.getAttribute("autoCompleteType"))).getValue();
|
singleData.autocompleteType = AutocompleteType.fromValue(Integer.parseInt(item.getAttribute("autoCompleteType"))).getValue();
|
||||||
}
|
}
|
||||||
|
singleData.hasAuth = Boolean.parseBoolean(item.getAttribute("hasAuth"));
|
||||||
|
singleData.method = item.hasAttribute("method") ? item.getAttribute("method") : "GET";
|
||||||
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
||||||
if (optionElement != null) {
|
if (optionElement != null) {
|
||||||
singleData.autoCompleteOptions = new Option();
|
singleData.autoCompleteOptions = new Option();
|
||||||
|
@ -116,6 +204,17 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
singleData.autoCompleteOptions.setSource(optionElement.getAttribute("source"));
|
singleData.autoCompleteOptions.setSource(optionElement.getAttribute("source"));
|
||||||
singleData.autoCompleteOptions.setUri(optionElement.getAttribute("uri"));
|
singleData.autoCompleteOptions.setUri(optionElement.getAttribute("uri"));
|
||||||
}
|
}
|
||||||
|
if (singleData.hasAuth) {
|
||||||
|
Element authElement = (Element) item.getElementsByTagName("auth").item(0);
|
||||||
|
if (authElement != null) {
|
||||||
|
singleData.auth = new AuthAutoCompleteData();
|
||||||
|
singleData.auth.setUrl(authElement.getAttribute("url"));
|
||||||
|
singleData.auth.setMethod(authElement.getAttribute("method"));
|
||||||
|
singleData.auth.setBody(authElement.getAttribute("body"));
|
||||||
|
singleData.auth.setPath(authElement.getAttribute("path"));
|
||||||
|
singleData.auth.setType(authElement.getAttribute("type"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -141,6 +240,8 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions = new Option();
|
this.autoCompleteSingleDataList.get(i).autoCompleteOptions = new Option();
|
||||||
this.autoCompleteSingleDataList.get(i).url = (String) singleData.get("url");
|
this.autoCompleteSingleDataList.get(i).url = (String) singleData.get("url");
|
||||||
this.autoCompleteSingleDataList.get(i).optionsRoot = (String) singleData.get("optionsRoot");
|
this.autoCompleteSingleDataList.get(i).optionsRoot = (String) singleData.get("optionsRoot");
|
||||||
|
this.autoCompleteSingleDataList.get(i).hasAuth = (Boolean) singleData.get("hasAuth");
|
||||||
|
this.autoCompleteSingleDataList.get(i).method = singleData.containsKey("method") ? (String) singleData.get("method") : "GET";
|
||||||
|
|
||||||
if (singleData.get("autoCompleteType") == null) {
|
if (singleData.get("autoCompleteType") == null) {
|
||||||
this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.UNCACHED.getValue();
|
this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.UNCACHED.getValue();
|
||||||
|
@ -154,6 +255,17 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setSource(options.get("source"));
|
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setSource(options.get("source"));
|
||||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setUri(options.get("uri"));
|
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setUri(options.get("uri"));
|
||||||
}
|
}
|
||||||
|
if (this.autoCompleteSingleDataList.get(i).hasAuth) {
|
||||||
|
Map<String, String> auth = (Map<String, String>) singleData.get("auth");
|
||||||
|
if (auth != null) {
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth = new AuthAutoCompleteData();
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setUrl(auth.get("url"));
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setType(auth.get("type"));
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setPath(auth.get("path"));
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setBody(auth.get("body"));
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setMethod(auth.get("method"));
|
||||||
|
}
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,6 +302,8 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
node.appendChild(autoCompleteSingles.item(i));
|
node.appendChild(autoCompleteSingles.item(i));
|
||||||
node.setAttribute("url", item.getAttribute("url"));
|
node.setAttribute("url", item.getAttribute("url"));
|
||||||
node.setAttribute("optionsRoot", item.getAttribute("optionsRoot"));
|
node.setAttribute("optionsRoot", item.getAttribute("optionsRoot"));
|
||||||
|
node.setAttribute("hasAuth", item.getAttribute("hasAuth"));
|
||||||
|
node.setAttribute("method", item.hasAttribute("method") ? item.getAttribute("method") : "GET");
|
||||||
autoCompletes.add(singleToMap(node));
|
autoCompletes.add(singleToMap(node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,6 +328,16 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
return dataMap;
|
return dataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> authToMap(Element item){
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
||||||
|
dataMap.put("method", item != null ? item.getAttribute("method") : "");
|
||||||
|
dataMap.put("body", item != null ? item.getAttribute("body") : "");
|
||||||
|
dataMap.put("path", item != null ? item.getAttribute("path") : "");
|
||||||
|
dataMap.put("type", item != null ? item.getAttribute("type") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, Object> singleToMap(Element item) {
|
private Map<String, Object> singleToMap(Element item) {
|
||||||
Map<String, Object> dataMap = new HashMap<>();
|
Map<String, Object> dataMap = new HashMap<>();
|
||||||
if (!item.getAttribute("autoCompleteType").isEmpty()) {
|
if (!item.getAttribute("autoCompleteType").isEmpty()) {
|
||||||
|
@ -221,8 +345,12 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
}
|
}
|
||||||
dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
|
dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
|
||||||
dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
||||||
|
dataMap.put("hasAuth", item != null ? item.getAttribute("hasAuth") : "false");
|
||||||
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
||||||
dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
|
dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
|
||||||
|
Element authElement = (Element) item.getElementsByTagName("auth").item(0);
|
||||||
|
dataMap.put("auth", item != null ? authToMap(authElement) : null);
|
||||||
|
dataMap.put("method", item != null && item.hasAttribute("method") ? item.getAttribute("method") : "GET");
|
||||||
return dataMap;
|
return dataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package eu.eudat.models.data.datasetprofile;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DatasetProfileWithPrefillingPropertyModel {
|
||||||
|
private UUID id;
|
||||||
|
private String label;
|
||||||
|
private boolean enablePrefilling;
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnablePrefilling() {
|
||||||
|
return enablePrefilling;
|
||||||
|
}
|
||||||
|
public void setEnablePrefilling(boolean enablePrefilling) {
|
||||||
|
this.enablePrefilling = enablePrefilling;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +1,31 @@
|
||||||
package eu.eudat.models.data.dmp;
|
package eu.eudat.models.data.dmp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
@XmlRootElement(name = "profile")
|
@XmlRootElement(name = "profile")
|
||||||
public class AssociatedProfileImportModels {
|
public class AssociatedProfileImportModels {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
|
private List<Integer> section;
|
||||||
|
|
||||||
@XmlElement(name = "profileId")
|
@XmlElement(name = "profileId")
|
||||||
public UUID getId() { return id; }
|
public UUID getId() { return id; }
|
||||||
public void setId(UUID id) { this.id = id; }
|
public void setId(UUID id) { this.id = id; }
|
||||||
|
|
||||||
@XmlElement(name = "profilelabel")
|
@XmlElement(name = "profileLabel")
|
||||||
public String getLabel() { return label; }
|
public String getLabel() { return label; }
|
||||||
public void setLabel(String label) { this.label = label; }
|
public void setLabel(String label) { this.label = label; }
|
||||||
|
|
||||||
|
@XmlElementWrapper(name="profileInSections")
|
||||||
|
@XmlElement(name = "section")
|
||||||
|
public List<Integer> getSection() {
|
||||||
|
return section;
|
||||||
|
}
|
||||||
|
public void setSection(List<Integer> section) {
|
||||||
|
this.section = section;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,10 +381,12 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
if (this.properties != null) {
|
if (this.properties != null) {
|
||||||
this.extraFields = new ArrayList<>();
|
this.extraFields = new ArrayList<>();
|
||||||
this.properties.forEach((id, value) -> {
|
this.properties.forEach((id, value) -> {
|
||||||
|
if (value != null) {
|
||||||
ExtraFieldModel extraField = new ExtraFieldModel();
|
ExtraFieldModel extraField = new ExtraFieldModel();
|
||||||
extraField.setId(id);
|
extraField.setId(id);
|
||||||
extraField.setValue(value.toString());
|
extraField.setValue(value.toString());
|
||||||
this.extraFields.add(extraField);
|
this.extraFields.add(extraField);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
private Tuple<UUID, String> profile;
|
private UUID profile;
|
||||||
private int version;
|
private int version;
|
||||||
private int status;
|
private int status;
|
||||||
private boolean lockable;
|
private boolean lockable;
|
||||||
|
@ -53,10 +53,10 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tuple<UUID, String> getProfile() {
|
public UUID getProfile() {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
public void setProfile(Tuple<UUID, String> profile) {
|
public void setProfile(UUID profile) {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanEditorModel fromDataModel(DMP entity) {
|
public DataManagementPlanEditorModel fromDataModel(DMP entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
this.profile = entity.getProfile() != null ? entity.getProfile().getId() : null;
|
||||||
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.version = entity.getVersion();
|
this.version = entity.getVersion();
|
||||||
|
@ -289,7 +289,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
||||||
DMP dataManagementPlanEntity = new DMP();
|
DMP dataManagementPlanEntity = new DMP();
|
||||||
if (this.profile != null) {
|
if (this.profile != null) {
|
||||||
DMPProfile dmpProfile = new DMPProfile();
|
DMPProfile dmpProfile = new DMPProfile();
|
||||||
dmpProfile.setId(this.profile.getId());
|
dmpProfile.setId(this.profile);
|
||||||
dataManagementPlanEntity.setProfile(dmpProfile);
|
dataManagementPlanEntity.setProfile(dmpProfile);
|
||||||
}
|
}
|
||||||
dataManagementPlanEntity.setId(this.id);
|
dataManagementPlanEntity.setId(this.id);
|
||||||
|
@ -302,7 +302,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
||||||
if (this.grant != null) {
|
if (this.grant != null) {
|
||||||
if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
|
if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
|
||||||
dataManagementPlanEntity.setGrant(this.grant.getExistGrant().toDataModel());
|
dataManagementPlanEntity.setGrant(this.grant.getExistGrant().toDataModel());
|
||||||
else {
|
else if (this.grant.getLabel() != null) {
|
||||||
Grant grant = new Grant();
|
Grant grant = new Grant();
|
||||||
grant.setId(UUID.randomUUID());
|
grant.setId(UUID.randomUUID());
|
||||||
grant.setAbbreviation("");
|
grant.setAbbreviation("");
|
||||||
|
@ -342,7 +342,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
||||||
if (this.project != null) {
|
if (this.project != null) {
|
||||||
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
||||||
dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
|
dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
|
||||||
else {
|
else if (this.project.getLabel() != null) {
|
||||||
Project project = new Project();
|
Project project = new Project();
|
||||||
project.setId(UUID.randomUUID());
|
project.setId(UUID.randomUUID());
|
||||||
project.setAbbreviation("");
|
project.setAbbreviation("");
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
if (this.grant != null) {
|
if (this.grant != null) {
|
||||||
if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
|
if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
|
||||||
entity.setGrant(this.grant.getExistGrant().toDataModel());
|
entity.setGrant(this.grant.getExistGrant().toDataModel());
|
||||||
else {
|
else if (this.grant.getLabel() != null) {
|
||||||
eu.eudat.data.entities.Grant grant = new eu.eudat.data.entities.Grant();
|
eu.eudat.data.entities.Grant grant = new eu.eudat.data.entities.Grant();
|
||||||
grant.setId(UUID.randomUUID());
|
grant.setId(UUID.randomUUID());
|
||||||
grant.setAbbreviation("");
|
grant.setAbbreviation("");
|
||||||
|
@ -236,7 +236,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
if (this.project != null) {
|
if (this.project != null) {
|
||||||
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
||||||
entity.setProject(this.project.getExistProject().toDataModel());
|
entity.setProject(this.project.getExistProject().toDataModel());
|
||||||
else {
|
else if (this.project.getLabel() != null) {
|
||||||
Project project = new Project();
|
Project project = new Project();
|
||||||
project.setId(UUID.randomUUID());
|
project.setId(UUID.randomUUID());
|
||||||
project.setAbbreviation("");
|
project.setAbbreviation("");
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class DatasetImportModels {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private UUID profile;
|
private UUID profile;
|
||||||
|
private int dmpSectionIndex;
|
||||||
private HashMap<String, String> fieldImportModels;
|
private HashMap<String, String> fieldImportModels;
|
||||||
|
|
||||||
@XmlAttribute(name ="name")
|
@XmlAttribute(name ="name")
|
||||||
|
@ -27,6 +28,7 @@ public class DatasetImportModels {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "profile-id")
|
||||||
public UUID getProfile() {
|
public UUID getProfile() {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +36,14 @@ public class DatasetImportModels {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "dmpSectionIndex")
|
||||||
|
public int getDmpSectionIndex() {
|
||||||
|
return dmpSectionIndex;
|
||||||
|
}
|
||||||
|
public void setDmpSectionIndex(int dmpSectionIndex) {
|
||||||
|
this.dmpSectionIndex = dmpSectionIndex;
|
||||||
|
}
|
||||||
|
|
||||||
@XmlJavaTypeAdapter(PageAdapter.class)
|
@XmlJavaTypeAdapter(PageAdapter.class)
|
||||||
@XmlElement(name = "pages")
|
@XmlElement(name = "pages")
|
||||||
public HashMap<String, String> getFieldImportModels() {
|
public HashMap<String, String> getFieldImportModels() {
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class DmpImportModel {
|
||||||
private List<OrganisationImportModel> organisationImportModels;
|
private List<OrganisationImportModel> organisationImportModels;
|
||||||
private List<ResearcherImportModels> researchersImportModels;
|
private List<ResearcherImportModels> researchersImportModels;
|
||||||
private List<UserInfoImportModels> associatedUsersImportModels;
|
private List<UserInfoImportModels> associatedUsersImportModels;
|
||||||
|
private List<ExtraFieldsImportModels> extraFieldsImportModels;
|
||||||
private List<DynamicFieldWithValueImportModels> dynamicFieldsImportModels;
|
private List<DynamicFieldWithValueImportModels> dynamicFieldsImportModels;
|
||||||
private List<DatasetImportModels> datasetImportModels;
|
private List<DatasetImportModels> datasetImportModels;
|
||||||
private String language;
|
private String language;
|
||||||
|
@ -104,6 +105,15 @@ public class DmpImportModel {
|
||||||
this.associatedUsersImportModels = associatedUsersImportModels;
|
this.associatedUsersImportModels = associatedUsersImportModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlElementWrapper(name="extraFields")
|
||||||
|
@XmlElement(name = "extraField")
|
||||||
|
public List<ExtraFieldsImportModels> getExtraFieldsImportModels() {
|
||||||
|
return extraFieldsImportModels;
|
||||||
|
}
|
||||||
|
public void setExtraFieldsImportModels(List<ExtraFieldsImportModels> extraFieldsImportModels) {
|
||||||
|
this.extraFieldsImportModels = extraFieldsImportModels;
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElementWrapper(name="dynamicFieldWithValues")
|
@XmlElementWrapper(name="dynamicFieldWithValues")
|
||||||
@XmlElement(name = "dynamicFieldWithValue")
|
@XmlElement(name = "dynamicFieldWithValue")
|
||||||
public List<DynamicFieldWithValueImportModels> getDynamicFieldsImportModels() {
|
public List<DynamicFieldWithValueImportModels> getDynamicFieldsImportModels() {
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package eu.eudat.models.data.dmp;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "extraField")
|
||||||
|
public class ExtraFieldsImportModels {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String label;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
@XmlElement(name = "id")
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "label")
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "value")
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,9 +11,18 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
|
public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
|
||||||
|
private boolean enablePrefilling;
|
||||||
private List<Section> sections;
|
private List<Section> sections;
|
||||||
private List<Page> pages;
|
private List<Page> pages;
|
||||||
|
|
||||||
|
public boolean isEnablePrefilling() {
|
||||||
|
return enablePrefilling;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnablePrefilling(boolean enablePrefilling) {
|
||||||
|
this.enablePrefilling = enablePrefilling;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Section> getSections() {
|
public List<Section> getSections() {
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +42,8 @@ public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
|
||||||
@Override
|
@Override
|
||||||
public Element toXml(Document doc) {
|
public Element toXml(Document doc) {
|
||||||
Element root = doc.createElement("root");
|
Element root = doc.createElement("root");
|
||||||
|
Element prefilling = doc.createElement("enablePrefilling");
|
||||||
|
prefilling.setTextContent(String.valueOf(this.enablePrefilling));
|
||||||
Element sections = doc.createElement("sections");
|
Element sections = doc.createElement("sections");
|
||||||
Element pages = doc.createElement("pages");
|
Element pages = doc.createElement("pages");
|
||||||
for (Section section : this.sections) {
|
for (Section section : this.sections) {
|
||||||
|
@ -44,6 +55,7 @@ public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
|
||||||
pages.appendChild(page.toXml(doc));
|
pages.appendChild(page.toXml(doc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
root.appendChild(prefilling);
|
||||||
root.appendChild(pages);
|
root.appendChild(pages);
|
||||||
root.appendChild(sections);
|
root.appendChild(sections);
|
||||||
return root;
|
return root;
|
||||||
|
@ -52,6 +64,12 @@ public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
|
||||||
@Override
|
@Override
|
||||||
public ViewStyleModel fromXml(Element element) {
|
public ViewStyleModel fromXml(Element element) {
|
||||||
|
|
||||||
|
this.enablePrefilling = true;
|
||||||
|
Element prefilling = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "enablePrefilling");
|
||||||
|
if (prefilling != null) {
|
||||||
|
this.enablePrefilling = Boolean.parseBoolean(prefilling.getChildNodes().item(0).getNodeValue());
|
||||||
|
}
|
||||||
|
|
||||||
this.sections = new LinkedList();
|
this.sections = new LinkedList();
|
||||||
Element sections = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
|
Element sections = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
|
||||||
if (sections != null) {
|
if (sections != null) {
|
||||||
|
|
|
@ -55,8 +55,8 @@ public class DescriptionTemplate implements XmlSerializable<DescriptionTemplate>
|
||||||
rootElement.setAttribute("id", this.getId().toString());
|
rootElement.setAttribute("id", this.getId().toString());
|
||||||
rootElement.setAttribute("descriptionTemplateId", this.getDescriptionTemplateId().toString());
|
rootElement.setAttribute("descriptionTemplateId", this.getDescriptionTemplateId().toString());
|
||||||
rootElement.setAttribute("label", this.label);
|
rootElement.setAttribute("label", this.label);
|
||||||
rootElement.setAttribute("minMultiplicity", String.valueOf(this.minMultiplicity));
|
if (this.minMultiplicity != null) rootElement.setAttribute("minMultiplicity", String.valueOf(this.minMultiplicity));
|
||||||
rootElement.setAttribute("maxMultiplicity", String.valueOf(this.maxMultiplicity));
|
if (this.maxMultiplicity != null) rootElement.setAttribute("maxMultiplicity", String.valueOf(this.maxMultiplicity));
|
||||||
return rootElement;
|
return rootElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import java.util.Map;
|
||||||
public class DatasetProfile implements PropertiesModelBuilder {
|
public class DatasetProfile implements PropertiesModelBuilder {
|
||||||
private String description;
|
private String description;
|
||||||
private String language;
|
private String language;
|
||||||
|
private String type;
|
||||||
|
private boolean enablePrefilling;
|
||||||
private List<Section> sections;
|
private List<Section> sections;
|
||||||
private List<Rule> rules;
|
private List<Rule> rules;
|
||||||
private List<Page> pages;
|
private List<Page> pages;
|
||||||
|
@ -33,6 +35,22 @@ public class DatasetProfile implements PropertiesModelBuilder {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnablePrefilling() {
|
||||||
|
return enablePrefilling;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnablePrefilling(boolean enablePrefilling) {
|
||||||
|
this.enablePrefilling = enablePrefilling;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Section> getSections() {
|
public List<Section> getSections() {
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +85,7 @@ public class DatasetProfile implements PropertiesModelBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) {
|
public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) {
|
||||||
|
this.enablePrefilling = viewStyle.isEnablePrefilling();
|
||||||
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
|
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
|
||||||
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
|
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
|
||||||
this.rules = ModelBuilderCollector.collectRules(viewStyle.getSections());
|
this.rules = ModelBuilderCollector.collectRules(viewStyle.getSections());
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class DatasetRDAMapper {
|
||||||
rda.setTitle(dataset.getLabel());
|
rda.setTitle(dataset.getLabel());
|
||||||
rda.setDescription(dataset.getDescription());
|
rda.setDescription(dataset.getDescription());
|
||||||
rda.setAdditionalProperty("template", dataset.getProfile().getId());
|
rda.setAdditionalProperty("template", dataset.getProfile().getId());
|
||||||
|
rda.setAdditionalProperty("dmpSectionIndex", dataset.getDmpSectionIndex());
|
||||||
try {
|
try {
|
||||||
JSONObject jObject = new JSONObject(dataset.getProperties());
|
JSONObject jObject = new JSONObject(dataset.getProperties());
|
||||||
Map<String, Object> templateIdsToValues = jObject.toMap();
|
Map<String, Object> templateIdsToValues = jObject.toMap();
|
||||||
|
@ -284,6 +285,12 @@ public class DatasetRDAMapper {
|
||||||
eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset();
|
eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset();
|
||||||
entity.setLabel(rda.getTitle());
|
entity.setLabel(rda.getTitle());
|
||||||
entity.setDescription(rda.getDescription());
|
entity.setDescription(rda.getDescription());
|
||||||
|
if (rda.getAdditionalProperties().get("dmpSectionIndex") != null) {
|
||||||
|
entity.setDmpSectionIndex(Integer.parseInt(rda.getAdditionalProperties().get("dmpSectionIndex").toString()));
|
||||||
|
} else {
|
||||||
|
entity.setDmpSectionIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString()));
|
DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString()));
|
||||||
entity.setProfile(profile);
|
entity.setProfile(profile);
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package eu.eudat.models.rda.mapper;
|
package eu.eudat.models.rda.mapper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.entities.*;
|
import eu.eudat.data.entities.*;
|
||||||
|
import eu.eudat.logic.managers.DataManagementProfileManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
||||||
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
import eu.eudat.models.rda.Dmp;
|
import eu.eudat.models.rda.Dmp;
|
||||||
import eu.eudat.models.rda.DmpId;
|
import eu.eudat.models.rda.DmpId;
|
||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
|
@ -24,13 +27,13 @@ public class DmpRDAMapper {
|
||||||
|
|
||||||
private DatasetRDAMapper datasetRDAMapper;
|
private DatasetRDAMapper datasetRDAMapper;
|
||||||
private ApiContext apiContext;
|
private ApiContext apiContext;
|
||||||
|
private DataManagementProfileManager dataManagementProfileManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) throws IOException {
|
public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext, DataManagementProfileManager dataManagementProfileManager) throws IOException {
|
||||||
this.datasetRDAMapper = datasetRDAMapper;
|
this.datasetRDAMapper = datasetRDAMapper;
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
|
this.dataManagementProfileManager = dataManagementProfileManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -116,10 +119,15 @@ public class DmpRDAMapper {
|
||||||
}
|
}
|
||||||
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).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)).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)).collect(Collectors.toList()));
|
||||||
if (dmp.getProject() != null) {
|
|
||||||
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
|
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
|
||||||
}
|
|
||||||
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray());
|
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(item -> item.getDatasetprofile().getId().toString()).toArray());
|
||||||
|
rda.setAdditionalProperty("blueprintId", dmp.getProfile().getId());
|
||||||
|
rda.setAdditionalProperty("license", extraProperties.get("license"));
|
||||||
|
rda.setAdditionalProperty("visible", extraProperties.get("visible"));
|
||||||
|
rda.setAdditionalProperty("publicDate", extraProperties.get("publicDate"));
|
||||||
|
rda.setAdditionalProperty("contact", extraProperties.get("contact"));
|
||||||
|
rda.setAdditionalProperty("dmpProperties", dmp.getProperties());
|
||||||
return rda;
|
return rda;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,26 +146,46 @@ public class DmpRDAMapper {
|
||||||
entity.setDois(new HashSet<>());
|
entity.setDois(new HashSet<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty() && entity.getId() != null) {
|
|
||||||
entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(x -> this.getProfile(x, entity.getId())).filter(Objects::nonNull).collect(Collectors.toSet()));
|
String blueprintId = (String) rda.getAdditionalProperties().get("blueprintId");
|
||||||
}
|
DMPProfile blueprint = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(UUID.fromString(blueprintId));
|
||||||
if (entity.getAssociatedDmps() == null) {
|
entity.setProfile(blueprint);
|
||||||
entity.setAssociatedDmps(new HashSet<>());
|
|
||||||
}
|
if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty()) {
|
||||||
if (profiles != null && entity.getId() != null) {
|
List<DescriptionTemplate> descriptionTemplates = ((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
for (String profile : profiles) {
|
Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
|
||||||
entity.getAssociatedDmps().add(this.getProfile(profile, entity.getId()));
|
for (DescriptionTemplate profile : descriptionTemplates) {
|
||||||
|
DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
|
||||||
|
dmpDatasetProfile.setDmp(entity);
|
||||||
|
dmpDatasetProfile.setDatasetprofile(profile);
|
||||||
|
String indexes = this.dataManagementProfileManager.sectionIndexesForDescriptionTemplate(blueprint, profile.getId()).stream()
|
||||||
|
.map(String::valueOf) // convert each int to a string
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
dmpDatasetProfile.setData("{\"dmpSectionIndex\":[" + indexes + "]}");
|
||||||
|
dmpDatasetProfiles.add(dmpDatasetProfile);
|
||||||
}
|
}
|
||||||
|
entity.setAssociatedDmps(dmpDatasetProfiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (entity.getAssociatedDmps() == null) {
|
||||||
|
// entity.setAssociatedDmps(new HashSet<>());
|
||||||
|
// }
|
||||||
|
// if (profiles != null && entity.getId() != null) {
|
||||||
|
// for (String profile : profiles) {
|
||||||
|
// entity.getAssociatedDmps().add(this.getProfile(profile, entity.getId()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
if (rda.getContributor() != null && !rda.getContributor().isEmpty() && rda.getContributor().get(0).getContributorId() != null) {
|
if (rda.getContributor() != null && !rda.getContributor().isEmpty() && rda.getContributor().get(0).getContributorId() != null) {
|
||||||
entity.setResearchers(rda.getContributor().stream().filter(r -> r.getContributorId() != null).map(ContributorRDAMapper::toEntity).filter(StreamDistinctBy.distinctByKey(Researcher::getReference)).collect(Collectors.toSet()));
|
entity.setResearchers(rda.getContributor().stream().filter(r -> r.getContributorId() != null).map(ContributorRDAMapper::toEntity).filter(StreamDistinctBy.distinctByKey(Researcher::getReference)).collect(Collectors.toSet()));
|
||||||
}
|
}
|
||||||
entity.setCreated(rda.getCreated());
|
entity.setCreated(rda.getCreated());
|
||||||
entity.setModified(rda.getModified());
|
entity.setModified(rda.getModified());
|
||||||
entity.setDescription(rda.getDescription());
|
entity.setDescription(rda.getDescription());
|
||||||
DescriptionTemplate defaultProfile = ((DescriptionTemplate)entity.getAssociatedDmps().toArray()[0]);
|
if(entity.getAssociatedDmps().size() > 0) {
|
||||||
|
DescriptionTemplate defaultProfile = entity.getAssociatedDmps().stream().findFirst().get().getDatasetprofile();
|
||||||
entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, defaultProfile)).collect(Collectors.toSet()));
|
entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, defaultProfile)).collect(Collectors.toSet()));
|
||||||
if (rda.getProject().size() > 0) {
|
}
|
||||||
|
if (rda.getProject() != null && rda.getProject().size() > 0) {
|
||||||
Map<String, Object> result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext);
|
Map<String, Object> result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext);
|
||||||
entity.setProject((Project) result.get("project"));
|
entity.setProject((Project) result.get("project"));
|
||||||
result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue()));
|
result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue()));
|
||||||
|
@ -165,16 +193,19 @@ public class DmpRDAMapper {
|
||||||
|
|
||||||
Map<String, Object> extraProperties = new HashMap<>();
|
Map<String, Object> extraProperties = new HashMap<>();
|
||||||
extraProperties.put("language", LanguageRDAMapper.mapRDAIsoToLanguageIso(rda.getLanguage()));
|
extraProperties.put("language", LanguageRDAMapper.mapRDAIsoToLanguageIso(rda.getLanguage()));
|
||||||
|
if (rda.getAdditionalProperties().get("license") != null) extraProperties.put("license", rda.getAdditionalProperties().get("license"));
|
||||||
|
if (rda.getAdditionalProperties().get("visible") != null) extraProperties.put("visible", rda.getAdditionalProperties().get("visible"));
|
||||||
|
if (rda.getAdditionalProperties().get("publicDate") != null) extraProperties.put("publicDate", rda.getAdditionalProperties().get("publicDate"));
|
||||||
|
if (rda.getAdditionalProperties().get("contact") != null) extraProperties.put("contact", rda.getAdditionalProperties().get("contact"));
|
||||||
entity.setExtraProperties(JSONObject.toJSONString(extraProperties));
|
entity.setExtraProperties(JSONObject.toJSONString(extraProperties));
|
||||||
|
|
||||||
|
if (rda.getAdditionalProperties().get("dmpProperties") != null) entity.setProperties(rda.getAdditionalProperties().get("dmpProperties").toString());
|
||||||
|
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DMPDatasetProfile getProfile(String descriptionTemplateId, UUID dmpId) {
|
private DescriptionTemplate getProfile(String id) {
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().asQueryable().where(((builder, root) -> builder.and(
|
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().asQueryable().where(((builder, root) -> builder.equal(root.get("id"), UUID.fromString(id)))).getSingleOrDefault();
|
||||||
builder.equal(root.get("datasetprofile"), UUID.fromString(descriptionTemplateId)),
|
|
||||||
builder.equal(root.get("dmp"), dmpId))
|
|
||||||
)).getSingleOrDefault();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,13 @@ public class ProjectRDAMapper {
|
||||||
public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) {
|
public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) {
|
||||||
Project rda = new Project();
|
Project rda = new Project();
|
||||||
try {
|
try {
|
||||||
rda.setTitle(project.getLabel());
|
rda.setTitle(grant.getLabel());
|
||||||
rda.setDescription(project.getDescription());
|
rda.setDescription(grant.getDescription());
|
||||||
if (project.getStartdate() != null) {
|
if (grant.getStartdate() != null) {
|
||||||
rda.setStart(project.getStartdate().toString());
|
rda.setStart(grant.getStartdate().toString());
|
||||||
}
|
}
|
||||||
if (project.getEnddate() != null) {
|
if (grant.getEnddate() != null) {
|
||||||
rda.setEnd(project.getEnddate().toString());
|
rda.setEnd(grant.getEnddate().toString());
|
||||||
}
|
}
|
||||||
rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant)));
|
rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant)));
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -13,7 +13,7 @@ ADD COLUMN "Type" uuid;
|
||||||
INSERT INTO public."DescriptionTemplateType" ("ID", "Name", "Status")
|
INSERT INTO public."DescriptionTemplateType" ("ID", "Name", "Status")
|
||||||
VALUES ('709a8400-10ca-11ee-be56-0242ac120002', 'Dataset', 1);
|
VALUES ('709a8400-10ca-11ee-be56-0242ac120002', 'Dataset', 1);
|
||||||
|
|
||||||
UPDATE public."DescriptionTemplate" SET ("Type") = '709a8400-10ca-11ee-be56-0242ac120002';
|
UPDATE public."DescriptionTemplate" SET "Type" = '709a8400-10ca-11ee-be56-0242ac120002';
|
||||||
|
|
||||||
ALTER TABLE public."DescriptionTemplate"
|
ALTER TABLE public."DescriptionTemplate"
|
||||||
ALTER COLUMN "Type" SET NOT NULL;
|
ALTER COLUMN "Type" SET NOT NULL;
|
||||||
|
|
|
@ -4,7 +4,7 @@ BEGIN
|
||||||
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||||
IF FOUND THEN RETURN; END IF;
|
IF FOUND THEN RETURN; END IF;
|
||||||
|
|
||||||
INSERT INTO public."DMPProfile" VALUES ('86635178-36a6-484f-9057-a934e4eeecd5', 'Dmp Default Blueprint', '<root><sections><section id="f94e50e0-cb97-4c65-8b88-e5db6badd41d" label="Main Info" description="A DMP in Argos consists of key information about research, such as purpose, objectives and researchers involved, but also about documentation of research datasets that highlight the steps followed and the means used across data management activities." ordinal="1" hasTemplates="false"><systemFields><systemField id="e62c3fa2-4cbe-41bf-a00e-ad722c7c7da1" type="0" label="Title of DMP" placeholder="Title of DMP" description="" required="true" ordinal="1"></systemField><systemField id="eed2871d-5201-401e-8453-87afbeac77e3" type="1" label="Description" placeholder="Fill with description" description="Briefly describe the context and purpose of the DMP" required="true" ordinal="2"></systemField><systemField id="41a0b1db-b186-467d-8edf-7d3b2456f95e" type="2" label="Researchers" placeholder="Select researchers" description="Add here the names of people that have produced, processed, analysed the data described in the DMP." required="false" ordinal="3"></systemField><systemField id="0f0afb55-a11b-41db-a4d0-67ebb74d8685" type="3" label="Organizations" placeholder="Select organization" description="Add here the names of the organizations contributing to the creation and revision of the DMPs" required="false" ordinal="4"></systemField><systemField id="db493026-3130-4730-9b93-da6b77d2eea4" type="4" label="Language" placeholder="Language" description="Select the language of your DMP" required="true" ordinal="5"></systemField><systemField id="22deb104-1c46-4ea8-8261-8fdc9500dca2" type="5" label="Contact" placeholder="Contact" description="" required="true" ordinal="6"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="3c2608e5-9320-4d94-9ed7-1eab9500d84b" label="Funding" description="Add here information about the scope, funding, actors of your DMP and decide on access and re-use issues for the DMP output that you are creating." ordinal="2" hasTemplates="false"><systemFields><systemField id="527af8fe-27b0-4715-9e1e-35a2fce834a1" type="6" label="Funding organizations" placeholder="Funder" description="Select a funder of your research or add new" required="true" ordinal="1"></systemField><systemField id="4d12904e-2501-4d57-8d2b-1ac795c297e7" type="7" label="Grants" placeholder="Grant" description="Find the grant of your research or add new" required="true" ordinal="2"></systemField><systemField id="82f235c8-98fc-48d1-8245-36ab08f01036" type="8" label="Project" placeholder="Project" description="Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted." required="false" ordinal="3"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="2a77e1f6-9989-4aeb-acd9-48e911a92abd" label="License" description="Each DMP can contain specific license informatation over how much open and available it is, that way you can determine who can see your dataset and for how long that data will be private." ordinal="3" hasTemplates="false"><systemFields><systemField id="75c31705-6731-45dd-9853-75c5d0627439" type="9" label="License" placeholder="License" description="Assign a license to your DMP by selecting the most appropriate from the list." required="false" ordinal="1"></systemField><systemField id="990df932-eae6-44ca-85da-5378b010f439" type="10" label="Access Rights" placeholder="Access Rights" description="Choose how the DMP is displayed after is published on Zenodo. By choosing Open Access, the DMP will be open on Zenodo after the Publication Date. By choosing Restricted Access, the DMP will be restricted after the publication is made." required="false" ordinal="2"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="0db7845b-0e7c-41df-8d91-cbca97995fd5" label="Dataset Info" description="Datasets are documented following pre-defined templates which set the content of dataset descriptions. In Argos, a DMP can contain as many dataset descriptions as the datasets it documents." ordinal="4" hasTemplates="true"><systemFields></systemFields><descriptionTemplates></descriptionTemplates></section></sections></root>',1, now(),now());
|
INSERT INTO public."DMPProfile" VALUES ('86635178-36a6-484f-9057-a934e4eeecd5', 'Dmp Default Blueprint', '<root><sections><section id="f94e50e0-cb97-4c65-8b88-e5db6badd41d" label="Main Info" description="" ordinal="1" hasTemplates="false"><systemFields><systemField id="e62c3fa2-4cbe-41bf-a00e-ad722c7c7da1" type="0" label="Title of DMP" placeholder="Title of DMP" description="" required="true" ordinal="1"></systemField><systemField id="eed2871d-5201-401e-8453-87afbeac77e3" type="1" label="Description" placeholder="Fill with description" description="Briefly describe the context and purpose of the DMP" required="true" ordinal="2"></systemField><systemField id="41a0b1db-b186-467d-8edf-7d3b2456f95e" type="2" label="Researchers" placeholder="Select researchers" description="Add here the names of people that have produced, processed, analysed the data described in the DMP." required="false" ordinal="3"></systemField><systemField id="0f0afb55-a11b-41db-a4d0-67ebb74d8685" type="3" label="Organizations" placeholder="Select organization" description="Add here the names of the organizations contributing to the creation and revision of the DMPs" required="false" ordinal="4"></systemField><systemField id="db493026-3130-4730-9b93-da6b77d2eea4" type="4" label="Language" placeholder="Language" description="Select the language of your DMP" required="true" ordinal="5"></systemField><systemField id="22deb104-1c46-4ea8-8261-8fdc9500dca2" type="5" label="Contact" placeholder="Contact" description="" required="true" ordinal="6"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="3c2608e5-9320-4d94-9ed7-1eab9500d84b" label="Funding" description="" ordinal="2" hasTemplates="false"><systemFields><systemField id="527af8fe-27b0-4715-9e1e-35a2fce834a1" type="6" label="Funding organizations" placeholder="Funder" description="Select a funder of your research or add new" required="true" ordinal="1"></systemField><systemField id="4d12904e-2501-4d57-8d2b-1ac795c297e7" type="7" label="Grants" placeholder="Grant" description="Find the grant of your research or add new" required="true" ordinal="2"></systemField><systemField id="82f235c8-98fc-48d1-8245-36ab08f01036" type="8" label="Project" placeholder="Project" description="Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted." required="false" ordinal="3"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="2a77e1f6-9989-4aeb-acd9-48e911a92abd" label="License" description="" ordinal="3" hasTemplates="false"><systemFields><systemField id="75c31705-6731-45dd-9853-75c5d0627439" type="9" label="License" placeholder="License" description="Assign a license to your DMP by selecting the most appropriate from the list." required="false" ordinal="1"></systemField><systemField id="990df932-eae6-44ca-85da-5378b010f439" type="10" label="Access Rights" placeholder="Access Rights" description="Choose how the DMP is displayed after is published on Zenodo. By choosing Open Access, the DMP will be open on Zenodo after the Publication Date. By choosing Restricted Access, the DMP will be restricted after the publication is made." required="false" ordinal="2"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="0db7845b-0e7c-41df-8d91-cbca97995fd5" label="Templates" description="" ordinal="4" hasTemplates="true"><systemFields></systemFields><descriptionTemplates></descriptionTemplates></section></sections></root>',1, now(),now());
|
||||||
UPDATE public."DMP" SET "Profile" = '86635178-36a6-484f-9057-a934e4eeecd5' WHERE "Profile" IS NULL;
|
UPDATE public."DMP" SET "Profile" = '86635178-36a6-484f-9057-a934e4eeecd5' WHERE "Profile" IS NULL;
|
||||||
UPDATE public."Dataset" SET "DmpSectionIndex" = '3' WHERE "DmpSectionIndex" IS NULL;
|
UPDATE public."Dataset" SET "DmpSectionIndex" = '3' WHERE "DmpSectionIndex" IS NULL;
|
||||||
UPDATE public."DMPDatasetProfile" SET "data" = '{"dmpSectionIndex":[3]}' WHERE "data" IS NULL;
|
UPDATE public."DMPDatasetProfile" SET "data" = '{"dmpSectionIndex":[3]}' WHERE "data" IS NULL;
|
||||||
|
|
|
@ -25,7 +25,4 @@
|
||||||
<app-notification *ngIf="!onlySplash"></app-notification>
|
<app-notification *ngIf="!onlySplash"></app-notification>
|
||||||
<router-outlet *ngIf="onlySplash"></router-outlet>
|
<router-outlet *ngIf="onlySplash"></router-outlet>
|
||||||
|
|
||||||
<ngx-guided-tour
|
<ngx-guided-tour [skipText]="'DASHBOARD.TOUR-GUIDE.LEAVE-TOUR'| translate" [nextText]="'DASHBOARD.TOUR-GUIDE.GOT-IT'| translate"></ngx-guided-tour>
|
||||||
[skipText]="'DASHBOARD.TOUR-GUIDE.LEAVE-TOUR'| translate"
|
|
||||||
[nextText]="'DASHBOARD.TOUR-GUIDE.GOT-IT'| translate"
|
|
||||||
></ngx-guided-tour>
|
|
|
@ -40,3 +40,70 @@
|
||||||
::ng-deep .mat-chip {
|
::ng-deep .mat-chip {
|
||||||
height: auto !important;
|
height: auto !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notification-header {
|
||||||
|
height: 64px;
|
||||||
|
background: var(--unnamed-color-var(--primary-color)) 0% 0% no-repeat padding-box;
|
||||||
|
background: var(--primary-color) 0% 0% no-repeat padding-box;
|
||||||
|
box-shadow: 0px 3px 6px #00000029;
|
||||||
|
padding: 0.6rem;
|
||||||
|
margin: 30px 0px 0px 0px;
|
||||||
|
border-radius: 4px;
|
||||||
|
opacity: 1;
|
||||||
|
|
||||||
|
.info {
|
||||||
|
flex: 2;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-discard-btn {
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid #ffffff;
|
||||||
|
color: white;
|
||||||
|
border-radius: 30px;
|
||||||
|
opacity: 1;
|
||||||
|
width: 110px;
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-title {
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #ffffff;
|
||||||
|
opacity: 0.75;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-subtitle {
|
||||||
|
text-align: left;
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 16px;
|
||||||
|
opacity: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.notification-link {
|
||||||
|
color: #ffffff;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-save-btn {
|
||||||
|
background: #ffffff 0% 0% no-repeat padding-box !important;
|
||||||
|
border-radius: 30px;
|
||||||
|
opacity: 1;
|
||||||
|
width: 110px;
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
|
@ -20,6 +20,8 @@ import { MatomoInjector } from 'ngx-matomo';
|
||||||
import { MatomoService } from './core/services/matomo/matomo-service';
|
import { MatomoService } from './core/services/matomo/matomo-service';
|
||||||
import { SideNavService } from './core/services/sidenav/side-nav.sevice';
|
import { SideNavService } from './core/services/sidenav/side-nav.sevice';
|
||||||
import { MatSidenav } from '@angular/material/sidenav';
|
import { MatSidenav } from '@angular/material/sidenav';
|
||||||
|
import { runInThisContext } from 'vm';
|
||||||
|
import * as moment from 'moment';
|
||||||
|
|
||||||
|
|
||||||
declare const gapi: any;
|
declare const gapi: any;
|
||||||
|
@ -52,7 +54,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||||
private cookieService: CookieService,
|
private cookieService: CookieService,
|
||||||
private ccService: NgcCookieConsentService,
|
private ccService: NgcCookieConsentService,
|
||||||
private language: LanguageService,
|
private language: LanguageService,
|
||||||
private configurationService: ConfigurationService,
|
public configurationService: ConfigurationService,
|
||||||
private location: Location,
|
private location: Location,
|
||||||
private matomoService: MatomoService,
|
private matomoService: MatomoService,
|
||||||
private sidenavService: SideNavService
|
private sidenavService: SideNavService
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { UserInfoListingModel } from "../../user/user-info-listing";
|
||||||
export interface DatasetProfile {
|
export interface DatasetProfile {
|
||||||
label: string;
|
label: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
enablePrefilling: boolean;
|
||||||
sections: Section[];
|
sections: Section[];
|
||||||
pages: Page[];
|
pages: Page[];
|
||||||
status: number;
|
status: number;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
export enum AuthType {
|
||||||
|
BEARER = 'Bearer'
|
||||||
|
}
|
|
@ -12,11 +12,22 @@ export interface AutoCompleteFieldData extends FieldData {
|
||||||
multiAutoComplete: boolean;
|
multiAutoComplete: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AuthAutoCompleteData extends FieldData {
|
||||||
|
url: string;
|
||||||
|
method: string;
|
||||||
|
body: string;
|
||||||
|
path: string;
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AutoCompleteSingleData extends FieldData {
|
export interface AutoCompleteSingleData extends FieldData {
|
||||||
url: string;
|
url: string;
|
||||||
optionsRoot: string;
|
optionsRoot: string;
|
||||||
autoCompleteOptions: FieldDataOption;
|
autoCompleteOptions: FieldDataOption;
|
||||||
autocompleteType: number;
|
autocompleteType: number;
|
||||||
|
hasAuth: boolean;
|
||||||
|
method: string;
|
||||||
|
auth: AuthAutoCompleteData;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CheckBoxFieldData extends FieldData {
|
export interface CheckBoxFieldData extends FieldData {
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
export enum HtmlMethod {
|
||||||
|
GET = 'GET',
|
||||||
|
POST = 'POST',
|
||||||
|
PUT = 'PUT',
|
||||||
|
PATCH = 'PATCH'
|
||||||
|
}
|
|
@ -5,6 +5,12 @@ export interface DatasetProfileModel {
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DatasetProfileWithPrefillingModel {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
enablePrefilling: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
// export class DatasetProfileModel implements Serializable<DatasetProfileModel> {
|
// export class DatasetProfileModel implements Serializable<DatasetProfileModel> {
|
||||||
// public id: String;
|
// public id: String;
|
||||||
// public label: String;
|
// public label: String;
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { BaseCriteria } from "../base-criteria";
|
||||||
export class DatasetProfileCriteria extends BaseCriteria {
|
export class DatasetProfileCriteria extends BaseCriteria {
|
||||||
public id: String;
|
public id: String;
|
||||||
public groupIds: string[];
|
public groupIds: string[];
|
||||||
|
public ids: string[];
|
||||||
public allVersions: boolean;
|
public allVersions: boolean;
|
||||||
public finalized: boolean = true;
|
public finalized: boolean = true;
|
||||||
public status: number;
|
public status: number;
|
||||||
|
|
|
@ -101,6 +101,21 @@ export class ConfigurationService extends BaseComponent {
|
||||||
return this._maxFileSizeInMB;
|
return this._maxFileSizeInMB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _newReleaseNotificationLink: number;
|
||||||
|
get newReleaseNotificationLink(): number {
|
||||||
|
return this._newReleaseNotificationLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _newReleaseNotificationExpires: number;
|
||||||
|
get newReleaseNotificationExpires(): number {
|
||||||
|
return this._newReleaseNotificationExpires;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _newReleaseNotificationVersionCode: number;
|
||||||
|
get newReleaseNotificationVersionCode(): number {
|
||||||
|
return this._newReleaseNotificationVersionCode;
|
||||||
|
}
|
||||||
|
|
||||||
public loadConfiguration(): Promise<any> {
|
public loadConfiguration(): Promise<any> {
|
||||||
return new Promise((r, e) => {
|
return new Promise((r, e) => {
|
||||||
|
|
||||||
|
@ -146,6 +161,9 @@ export class ConfigurationService extends BaseComponent {
|
||||||
this._matomoSiteId = config.matomo.siteId;
|
this._matomoSiteId = config.matomo.siteId;
|
||||||
}
|
}
|
||||||
this._maxFileSizeInMB = config.maxFileSizeInMB;
|
this._maxFileSizeInMB = config.maxFileSizeInMB;
|
||||||
|
this._newReleaseNotificationExpires = config.newReleaseNotification?.expires;
|
||||||
|
this._newReleaseNotificationLink = config.newReleaseNotification?.link;
|
||||||
|
this._newReleaseNotificationVersionCode = config.newReleaseNotification?.versionCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { environment } from '../../../../environments/environment';
|
|
||||||
import { DataTableData } from '../../model/data-table/data-table-data';
|
import { DataTableData } from '../../model/data-table/data-table-data';
|
||||||
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
||||||
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
|
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
|
||||||
import { DatasetProfileModel } from '../../model/dataset/dataset-profile';
|
import { DatasetProfileModel, DatasetProfileWithPrefillingModel } from '../../model/dataset/dataset-profile';
|
||||||
import { DatasetCriteria } from '../../query/dataset/dataset-criteria';
|
import { DatasetCriteria } from '../../query/dataset/dataset-criteria';
|
||||||
import { ExploreDatasetCriteriaModel } from '../../query/explore-dataset/explore-dataset-criteria';
|
import { ExploreDatasetCriteriaModel } from '../../query/explore-dataset/explore-dataset-criteria';
|
||||||
import { BaseHttpService } from '../http/base-http.service';
|
import { BaseHttpService } from '../http/base-http.service';
|
||||||
|
@ -43,6 +42,10 @@ export class DatasetService {
|
||||||
return this.http.post<DatasetProfileModel[]>(this.configurationSevice.server + 'datasetprofiles/getAll', dataTableRequest);
|
return this.http.post<DatasetProfileModel[]>(this.configurationSevice.server + 'datasetprofiles/getAll', dataTableRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDatasetProfilesWithPrefilling(dataTableRequest: DataTableRequest<DatasetProfileCriteria>): Observable<DatasetProfileWithPrefillingModel[]> {
|
||||||
|
return this.http.post<DatasetProfileWithPrefillingModel[]>(this.configurationSevice.server + 'datasetprofiles/getAllWithPrefilling', dataTableRequest);
|
||||||
|
}
|
||||||
|
|
||||||
getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) {
|
getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) {
|
||||||
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetProfilesUsedByDatasets/paged', dataTableRequest);
|
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetProfilesUsedByDatasets/paged', dataTableRequest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,14 @@ export class DmpProfileService {
|
||||||
return this.http.post(this.actionUrl + "upload", formData, { params: params });
|
return this.http.post(this.actionUrl + "upload", formData, { params: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clone(id: string): Observable<DmpBlueprint> {
|
||||||
|
return this.http.post<DmpBlueprint>(this.actionUrl + 'clone/' + id, { headers: this.headers });
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: string): Observable<any> {
|
||||||
|
return this.http.delete<any>(this.actionUrl + id, { headers: this.headers });
|
||||||
|
}
|
||||||
|
|
||||||
externalAutocomplete(lookUpItem: RequestItem<DmpProfileExternalAutocompleteCriteria>): Observable<any> {
|
externalAutocomplete(lookUpItem: RequestItem<DmpProfileExternalAutocompleteCriteria>): Observable<any> {
|
||||||
return this.httpClient.post(this.actionUrl + 'search/autocomplete', lookUpItem);
|
return this.httpClient.post(this.actionUrl + 'search/autocomplete', lookUpItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,10 @@ export class PrefillingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPrefillingDataset(pid: string, profileId: string, configId: string): Observable<DatasetWizardModel> {
|
public getPrefillingDataset(pid: string, profileId: string, configId: string): Observable<DatasetWizardModel> {
|
||||||
return this.http.get<DatasetWizardModel>(this.actionUrl + '/generate/' + encodeURIComponent(pid) + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), { headers: this.headers });
|
return this.http.get<DatasetWizardModel>(this.actionUrl + 'generate/' + encodeURIComponent(pid) + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPrefillingDatasetUsingData(data: any, profileId: string, configId: string): Observable<DatasetWizardModel> {
|
public getPrefillingDatasetUsingData(data: any, profileId: string, configId: string): Observable<DatasetWizardModel> {
|
||||||
return this.http.post<DatasetWizardModel>(this.actionUrl + '/generateUsingData' + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), data, { headers: this.headers });
|
return this.http.post<DatasetWizardModel>(this.actionUrl + 'generateUsingData' + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), data, { headers: this.headers });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,5 +37,6 @@ export interface MultipleAutoCompleteConfiguration {
|
||||||
autoSelectFirstOptionOnBlur?: boolean;
|
autoSelectFirstOptionOnBlur?: boolean;
|
||||||
|
|
||||||
appendClassToItem?: {class: string, applyFunc: (item:any) => boolean}[];
|
appendClassToItem?: {class: string, applyFunc: (item:any) => boolean}[];
|
||||||
|
canRemoveItem?: (selectedItem: any) => boolean;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,6 +221,9 @@ export class MultipleAutoCompleteComponent extends _CustomComponentMixinBase imp
|
||||||
if (changes['configuration'] && changes['configuration'].isFirstChange) {
|
if (changes['configuration'] && changes['configuration'].isFirstChange) {
|
||||||
this.getSelectedItems(this.value);
|
this.getSelectedItems(this.value);
|
||||||
}
|
}
|
||||||
|
if (changes['value'] && !changes['value'].isFirstChange()) {
|
||||||
|
this.getSelectedItems(this.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectedItems(value: any) {
|
getSelectedItems(value: any) {
|
||||||
|
@ -480,6 +483,10 @@ export class MultipleAutoCompleteComponent extends _CustomComponentMixinBase imp
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
if (this.configuration.canRemoveItem != null && !this.configuration.canRemoveItem(item)) {
|
||||||
|
event.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const valueToDelete = this._valueToAssign(item);
|
const valueToDelete = this._valueToAssign(item);
|
||||||
this.value = this.value.filter(x => this.stringify(x) !== this.stringify(valueToDelete)); //TODO, maybe we need to implement equality here differently.
|
this.value = this.value.filter(x => this.stringify(x) !== this.stringify(valueToDelete)); //TODO, maybe we need to implement equality here differently.
|
||||||
this.optionRemoved.emit(item);
|
this.optionRemoved.emit(item);
|
||||||
|
|
|
@ -47,7 +47,8 @@ export class RichTextEditorComponent {
|
||||||
{ name: 'H3 header', class: '', tag: 'h3' },
|
{ name: 'H3 header', class: '', tag: 'h3' },
|
||||||
{ name: 'H4 header', class: '', tag: 'h4' },
|
{ name: 'H4 header', class: '', tag: 'h4' },
|
||||||
{ name: 'H5 header', class: '', tag: 'h5'},
|
{ name: 'H5 header', class: '', tag: 'h5'},
|
||||||
{ name: 'H6 header', class: '', tag: 'h6'}
|
{ name: 'H6 header', class: '', tag: 'h6'},
|
||||||
|
{ name: 'Highlight', class: 'highlight', tag: ''}
|
||||||
],
|
],
|
||||||
toolbarHiddenButtons: [
|
toolbarHiddenButtons: [
|
||||||
[
|
[
|
||||||
|
@ -56,7 +57,7 @@ export class RichTextEditorComponent {
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'fontSize',
|
'fontSize',
|
||||||
// 'backgroundColor',
|
'backgroundColor',
|
||||||
// 'customClasses',
|
// 'customClasses',
|
||||||
'insertImage',
|
'insertImage',
|
||||||
'insertVideo',
|
'insertVideo',
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { FormGroup, Validators } from "@angular/forms";
|
||||||
|
import { FieldDataEditorModel } from "./field-data-editor-model";
|
||||||
|
import { AuthAutoCompleteData, AutoCompleteSingleData } from "@app/core/model/dataset-profile-definition/field-data/field-data";
|
||||||
|
|
||||||
|
export class AuthFieldEditorModel extends FieldDataEditorModel<AuthFieldEditorModel> {
|
||||||
|
url: string;
|
||||||
|
method: string;
|
||||||
|
body: string;
|
||||||
|
path: string;
|
||||||
|
type: string;
|
||||||
|
|
||||||
|
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
|
||||||
|
const formGroup = this.formBuilder.group({
|
||||||
|
method: [{ value: this.method, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.method')) }],
|
||||||
|
url: [{ value: this.url, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.url')) }, [Validators.required]],
|
||||||
|
body: [{ value: this.body, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.body')) }],
|
||||||
|
path: [{ value: this.path, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.path')) }, [Validators.required]],
|
||||||
|
type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.type')) }, [Validators.required]]
|
||||||
|
});
|
||||||
|
|
||||||
|
return formGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromModel(item: AuthAutoCompleteData): AuthFieldEditorModel {
|
||||||
|
if (item) {
|
||||||
|
this.url = item.url;
|
||||||
|
this.method = item.method;
|
||||||
|
this.body = item.body;
|
||||||
|
this.path = item.path;
|
||||||
|
this.type = item.type;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profil
|
||||||
import { FieldDataOptionEditorModel } from './field-data-option-editor-model';
|
import { FieldDataOptionEditorModel } from './field-data-option-editor-model';
|
||||||
import { FormGroup, Validators } from '@angular/forms';
|
import { FormGroup, Validators } from '@angular/forms';
|
||||||
import { AutoCompleteFieldData, AutoCompleteSingleData } from '@app/core/model/dataset-profile-definition/field-data/field-data';
|
import { AutoCompleteFieldData, AutoCompleteSingleData } from '@app/core/model/dataset-profile-definition/field-data/field-data';
|
||||||
|
import { AuthFieldEditorModel } from './auto-complete-auth-field-data.model';
|
||||||
|
|
||||||
export class AutoCompleteSingleDataEditorModel extends FieldDataEditorModel<AutoCompleteSingleDataEditorModel> {
|
export class AutoCompleteSingleDataEditorModel extends FieldDataEditorModel<AutoCompleteSingleDataEditorModel> {
|
||||||
|
|
||||||
|
@ -11,6 +12,9 @@ export class AutoCompleteSingleDataEditorModel extends FieldDataEditorModel<Auto
|
||||||
|
|
||||||
public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
|
public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
|
||||||
public autoCompleteType: number;
|
public autoCompleteType: number;
|
||||||
|
public method: string;
|
||||||
|
public hasAuth: boolean;
|
||||||
|
public auth: AuthFieldEditorModel = new AuthFieldEditorModel();
|
||||||
//public multiAutoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
|
//public multiAutoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
|
||||||
|
|
||||||
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
|
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
|
||||||
|
@ -18,9 +22,12 @@ export class AutoCompleteSingleDataEditorModel extends FieldDataEditorModel<Auto
|
||||||
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.label')) }],
|
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.label')) }],
|
||||||
url: [{ value: this.url, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.url')) },[Validators.required]],
|
url: [{ value: this.url, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.url')) },[Validators.required]],
|
||||||
optionsRoot: [{ value: this.optionsRoot, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.optionsRoot')) }, [Validators.required]],
|
optionsRoot: [{ value: this.optionsRoot, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.optionsRoot')) }, [Validators.required]],
|
||||||
autoCompleteType: [{ value: this.autoCompleteType, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.autoCompleteType')) }]
|
autoCompleteType: [{ value: this.autoCompleteType, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.autoCompleteType')) }],
|
||||||
|
hasAuth: [{ value: this.hasAuth, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.hasAuth')) }],
|
||||||
|
method: [{ value: this.method, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.method')) }]
|
||||||
});
|
});
|
||||||
formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm(disabled, skipDisable));
|
formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm(disabled, skipDisable));
|
||||||
|
formGroup.addControl('auth', this.auth.buildForm(disabled, skipDisable));
|
||||||
|
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +37,10 @@ export class AutoCompleteSingleDataEditorModel extends FieldDataEditorModel<Auto
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
this.optionsRoot = item.optionsRoot;
|
this.optionsRoot = item.optionsRoot;
|
||||||
this.autoCompleteType = item.autocompleteType;
|
this.autoCompleteType = item.autocompleteType;
|
||||||
|
this.hasAuth = item.hasAuth;
|
||||||
|
this.method = item.method ? item.method : 'GET';
|
||||||
this.autoCompleteOptions = new FieldDataOptionEditorModel().fromModel(item.autoCompleteOptions);
|
this.autoCompleteOptions = new FieldDataOptionEditorModel().fromModel(item.autoCompleteOptions);
|
||||||
|
this.auth = new AuthFieldEditorModel().fromModel(item.auth);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,15 +37,21 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngFor="let singleForm of multiForm.controls; let i = index" class="row">
|
<div *ngFor="let singleForm of multiForm.controls; let i = index" class="row">
|
||||||
<mat-form-field class="col-12">
|
<!-- <mat-form-field class="col-12">
|
||||||
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TYPE' | translate}}</mat-label>
|
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TYPE' | translate}}</mat-label>
|
||||||
<mat-select [formControl]="singleForm.get('autoCompleteType')">
|
<mat-select [formControl]="singleForm.get('autoCompleteType')">
|
||||||
<mat-option [value]="0">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TYPE-UNCACHED' | translate}}</mat-option>
|
<mat-option [value]="0">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TYPE-UNCACHED' | translate}}</mat-option>
|
||||||
<mat-option [value]="1">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TYPE-CACHED' | translate}}</mat-option>
|
<mat-option [value]="1">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TYPE-CACHED' | translate}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
|
</mat-form-field> -->
|
||||||
|
<mat-form-field class="col-md-6">
|
||||||
|
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-METHOD' | translate}}</mat-label>
|
||||||
|
<mat-select [formControl]="singleForm.get('method')">
|
||||||
|
<mat-option *ngFor="let method of htmlMethods | keyvalue" [value]="method.value">{{method.value}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field class="col-md-12">
|
<mat-form-field class="col-md-6">
|
||||||
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}}</mat-label>
|
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}}</mat-label>
|
||||||
<input matInput [formControl]="singleForm.get('url')">
|
<input matInput [formControl]="singleForm.get('url')">
|
||||||
<mat-error *ngIf="singleForm.get('url').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="singleForm.get('url').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
@ -70,6 +76,37 @@
|
||||||
<input matInput [formControl]="singleForm.get('autoCompleteOptions').get('source')">
|
<input matInput [formControl]="singleForm.get('autoCompleteOptions').get('source')">
|
||||||
<mat-error *ngIf="singleForm.get('autoCompleteOptions').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="singleForm.get('autoCompleteOptions').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<mat-checkbox class="col-12" [formControl]="singleForm.get('hasAuth')">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-HAS-AUTH' | translate}}</mat-checkbox>
|
||||||
|
<div *ngIf="singleForm.get('hasAuth').value === true" class="row">
|
||||||
|
<mat-form-field class="col-md-6">
|
||||||
|
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-METHOD' | translate}}</mat-label>
|
||||||
|
<mat-select [formControl]="singleForm.get('auth').get('method')">
|
||||||
|
<mat-option *ngFor="let method of htmlMethods | keyvalue" [value]="method.value">{{method.value}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field class="col-md-6">
|
||||||
|
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}}</mat-label>
|
||||||
|
<input matInput [formControl]="singleForm.get('auth').get('url')">
|
||||||
|
<mat-error *ngIf="singleForm.get('auth').get('url').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field class="col-md-6">
|
||||||
|
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-TYPE' | translate}}</mat-label>
|
||||||
|
<mat-select [formControl]="singleForm.get('auth').get('type')">
|
||||||
|
<mat-option *ngFor="let type of authTypes | keyvalue" [value]="type.value">{{type.value}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field class="col-md-6">
|
||||||
|
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}}</mat-label>
|
||||||
|
<input matInput [formControl]="singleForm.get('auth').get('path')">
|
||||||
|
<mat-error *ngIf="singleForm.get('auth').get('path').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field class="col-md-12">
|
||||||
|
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-BODY' | translate}}</mat-label>
|
||||||
|
<textarea matInput [formControl]="singleForm.get('auth').get('body')"></textarea>
|
||||||
|
<mat-error *ngIf="singleForm.get('auth').get('body').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button mat-button type="button" (click)="removeSource(i)"><mat-icon>delete</mat-icon></button>
|
<button mat-button type="button" (click)="removeSource(i)"><mat-icon>delete</mat-icon></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ import { FormGroup, FormArray, AbstractControl } from '@angular/forms';
|
||||||
import { DatasetProfileComboBoxType } from '../../../../../../../core/common/enum/dataset-profile-combo-box-type';
|
import { DatasetProfileComboBoxType } from '../../../../../../../core/common/enum/dataset-profile-combo-box-type';
|
||||||
import { AutoCompleteFieldDataEditorModel } from '../../../../admin/field-data/auto-complete-field-data-editor-model';
|
import { AutoCompleteFieldDataEditorModel } from '../../../../admin/field-data/auto-complete-field-data-editor-model';
|
||||||
import { AutoCompleteSingleDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data';
|
import { AutoCompleteSingleDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data';
|
||||||
|
import { HtmlMethod } from '@app/core/model/dataset-profile-definition/html-method.enum';
|
||||||
|
import { AuthType } from '@app/core/model/dataset-profile-definition/auth-type.enum';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-profile-editor-auto-complete-field-component',
|
selector: 'app-dataset-profile-editor-auto-complete-field-component',
|
||||||
|
@ -11,6 +13,9 @@ import { AutoCompleteSingleDataEditorModel } from '@app/ui/admin/dataset-profile
|
||||||
})
|
})
|
||||||
export class DatasetProfileEditorAutoCompleteFieldComponent implements OnInit {
|
export class DatasetProfileEditorAutoCompleteFieldComponent implements OnInit {
|
||||||
|
|
||||||
|
public htmlMethods = HtmlMethod;
|
||||||
|
public authTypes = AuthType;
|
||||||
|
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
private data: AutoCompleteFieldDataEditorModel = new AutoCompleteFieldDataEditorModel();
|
private data: AutoCompleteFieldDataEditorModel = new AutoCompleteFieldDataEditorModel();
|
||||||
multiForm: FormArray;
|
multiForm: FormArray;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
<input matInput [formControl]="form.get('data').get('options').get(''+i).get('value')">
|
<input matInput [formControl]="form.get('data').get('options').get(''+i).get('value')">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button mat-icon-button class="col-auto" (click)="deleteRow(i)" type="button"
|
<button mat-icon-button class="col-auto" (click)="deleteRow(i)" type="button"
|
||||||
[disabled]="this.form.disabled">
|
[disabled]="form.get('data').get('options').get(''+i).get('label').disabled || form.get('data').get('options').get(''+i).get('value').disabled">
|
||||||
<mat-icon>delete</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,6 +16,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
|
||||||
public version: number;
|
public version: number;
|
||||||
private description: string;
|
private description: string;
|
||||||
private type: string;
|
private type: string;
|
||||||
|
public enablePrefilling: boolean;
|
||||||
private language: string;
|
private language: string;
|
||||||
private users: UserInfoListingModel[] = [];
|
private users: UserInfoListingModel[] = [];
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
|
||||||
if (item.pages) { this.pages = item.pages.map(x => new PageEditorModel().fromModel(x)); }
|
if (item.pages) { this.pages = item.pages.map(x => new PageEditorModel().fromModel(x)); }
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
this.type = item.type;
|
this.type = item.type;
|
||||||
|
this.enablePrefilling = item.enablePrefilling;
|
||||||
this.status = item.status;
|
this.status = item.status;
|
||||||
this.version = item.version;
|
this.version = item.version;
|
||||||
this.description = item.description;
|
this.description = item.description;
|
||||||
|
@ -37,6 +39,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
|
||||||
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.label')) }, [Validators.required]],
|
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.label')) }, [Validators.required]],
|
||||||
description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.description')) }, [Validators.required]],
|
description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.description')) }, [Validators.required]],
|
||||||
type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.type')) }, [Validators.required]],
|
type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.type')) }, [Validators.required]],
|
||||||
|
enablePrefilling: [{ value: this.enablePrefilling, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.enablePrefilling')) }, []],
|
||||||
language: [{ value: this.language, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.language')) }, [Validators.required]],
|
language: [{ value: this.language, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.language')) }, [Validators.required]],
|
||||||
status: [{ value: this.status, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.status')) }],
|
status: [{ value: this.status, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.status')) }],
|
||||||
version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }],
|
version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }],
|
||||||
|
|
|
@ -170,7 +170,15 @@
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="heading">1.5 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}</div>
|
<div class="heading">1.5 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-PREFILLING'| translate}}</div>
|
||||||
|
<div class="full-width basic-info-input">
|
||||||
|
<mat-checkbox [formControl]="form.get('enablePrefilling')">
|
||||||
|
{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-ENABLE-PREFILLING'| translate}}
|
||||||
|
</mat-checkbox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="heading">1.6 {{'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="hint">{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS-HINT'| translate}}</div>
|
||||||
<div class="full-width basic-info-input">
|
<div class="full-width basic-info-input">
|
||||||
<table class="col-12 user-table">
|
<table class="col-12 user-table">
|
||||||
|
|
|
@ -214,6 +214,7 @@ export class DatasetProfileEditorComponent extends CheckDeactivateBaseComponent
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.dataModel = new DatasetProfileEditorModel();
|
this.dataModel = new DatasetProfileEditorModel();
|
||||||
|
this.dataModel.enablePrefilling = true;
|
||||||
this.form = this.dataModel.buildForm();
|
this.form = this.dataModel.buildForm();
|
||||||
// this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]);
|
// this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { AdminAuthGuard } from '@app/core/admin-auth-guard.service';
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', component: DmpProfileListingComponent, canActivate: [AdminAuthGuard] },
|
{ path: '', component: DmpProfileListingComponent, canActivate: [AdminAuthGuard] },
|
||||||
{ path: 'new', component: DmpProfileEditorComponent, canActivate: [AdminAuthGuard], data: { title: 'GENERAL.TITLES.DMP-BLUEPRINT-NEW' } },
|
{ path: 'new', component: DmpProfileEditorComponent, canActivate: [AdminAuthGuard], data: { title: 'GENERAL.TITLES.DMP-BLUEPRINT-NEW' } },
|
||||||
|
{ path: 'clone/:cloneid', component: DmpProfileEditorComponent, canActivate: [AdminAuthGuard], data: { title: 'GENERAL.TITLES.DMP-BLUEPRINT-CLONE' } },
|
||||||
{ path: ':id', component: DmpProfileEditorComponent, canActivate: [AdminAuthGuard], data: { title: 'GENERAL.TITLES.DMP-BLUEPRINT-EDIT' } },
|
{ path: ':id', component: DmpProfileEditorComponent, canActivate: [AdminAuthGuard], data: { title: 'GENERAL.TITLES.DMP-BLUEPRINT-EDIT' } },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ export class DmpBlueprintDefinitionEditor {
|
||||||
const formBuilder = new FormBuilder();
|
const formBuilder = new FormBuilder();
|
||||||
const formGroup = formBuilder.group({});
|
const formGroup = formBuilder.group({});
|
||||||
const sectionsFormArray = new Array<FormGroup>();
|
const sectionsFormArray = new Array<FormGroup>();
|
||||||
this.sections.forEach(item => {
|
this.sections.sort((a, b) => a.ordinal - b.ordinal).forEach(item => {
|
||||||
const form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
sectionsFormArray.push(form);
|
sectionsFormArray.push(form);
|
||||||
});
|
});
|
||||||
|
@ -103,7 +103,7 @@ export class SectionDmpBlueprintEditor {
|
||||||
});
|
});
|
||||||
const formBuilder = new FormBuilder();
|
const formBuilder = new FormBuilder();
|
||||||
const fieldsFormArray = new Array<FormGroup>();
|
const fieldsFormArray = new Array<FormGroup>();
|
||||||
this.fields.forEach(item => {
|
this.fields.sort((a, b) => a.ordinal - b.ordinal).forEach(item => {
|
||||||
const form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
fieldsFormArray.push(form);
|
fieldsFormArray.push(form);
|
||||||
});
|
});
|
||||||
|
@ -121,7 +121,7 @@ export class SectionDmpBlueprintEditor {
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
baseContext.validation.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
baseContext.validation.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
||||||
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
|
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
|
||||||
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
|
baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] });
|
||||||
baseContext.validation.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'ordinal')] });
|
baseContext.validation.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'ordinal')] });
|
||||||
baseContext.validation.push({ key: 'hasTemplates', validators: [BackendErrorValidator(this.validationErrorModel, 'hasTemplates')] });
|
baseContext.validation.push({ key: 'hasTemplates', validators: [BackendErrorValidator(this.validationErrorModel, 'hasTemplates')] });
|
||||||
baseContext.validation.push({ key: 'descriptionTemplates', validators: [BackendErrorValidator(this.validationErrorModel, 'descriptionTemplates')] });
|
baseContext.validation.push({ key: 'descriptionTemplates', validators: [BackendErrorValidator(this.validationErrorModel, 'descriptionTemplates')] });
|
||||||
|
|
|
@ -2,7 +2,11 @@
|
||||||
<div class="container-fluid dmp-profile-editor">
|
<div class="container-fluid dmp-profile-editor">
|
||||||
<div class="row align-items-center mb-4" *ngIf="formGroup">
|
<div class="row align-items-center mb-4" *ngIf="formGroup">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<h3 *ngIf="isNew">{{'DMP-PROFILE-EDITOR.TITLE.NEW' | translate}}</h3>
|
<h3 *ngIf="isNew && !isClone">{{'DMP-PROFILE-EDITOR.TITLE.NEW' | translate}}</h3>
|
||||||
|
<h3 *ngIf="isNew && isClone">
|
||||||
|
<span>{{'DMP-PROFILE-EDITOR.TITLE.NEW-PROFILE-CLONE' | translate}}</span>
|
||||||
|
{{formGroup.get('label').value}}
|
||||||
|
</h3>
|
||||||
<h3 *ngIf="!isNew">{{formGroup.get('label').value}}</h3>
|
<h3 *ngIf="!isNew">{{formGroup.get('label').value}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col"></div>
|
<div class="col"></div>
|
||||||
|
@ -65,7 +69,7 @@
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>Section description</mat-label>
|
<mat-label>Section description</mat-label>
|
||||||
<input matInput type="text" name="description" formControlName="description" required>
|
<input matInput type="text" name="description" formControlName="description">
|
||||||
<mat-error *ngIf="section.get('description').hasError('required')">
|
<mat-error *ngIf="section.get('description').hasError('required')">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
@ -82,7 +86,7 @@
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>System fields</mat-label>
|
<mat-label>System fields</mat-label>
|
||||||
<mat-select multiple [disabled]="viewOnly" [value]="systemFieldListPerSection[sectionIndex]">
|
<mat-select multiple [disabled]="viewOnly" [value]="systemFieldListPerSection[sectionIndex]">
|
||||||
<mat-option *ngFor="let f of fieldList" [disabled]="systemFieldDisabled(f.type, sectionIndex)" [value]="f.type" (click)="selectedFieldType(f.label, f.type, sectionIndex)">{{f.label}}</mat-option>
|
<mat-option *ngFor="let f of fieldList" [disabled]="systemFieldDisabled(f.type, sectionIndex)" [value]="f.type" (click)="selectedFieldType(f.type, sectionIndex)">{{f.label}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="fieldsArray(sectionIndex).hasError('required')">
|
<mat-error *ngIf="fieldsArray(sectionIndex).hasError('required')">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
@ -206,7 +210,7 @@
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<mat-checkbox formControlName="hasTemplates">
|
<mat-checkbox formControlName="hasTemplates" (change)="checkForProfiles($event, sectionIndex)">
|
||||||
Description Templates
|
Description Templates
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
@ -218,7 +222,7 @@
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>Description Templates</mat-label>
|
<mat-label>Description Templates</mat-label>
|
||||||
<app-multiple-auto-complete placeholder="Description Templates" [disabled]="viewOnly" [value]="descriptionTemplatesPerSection[sectionIndex]" [hidePlaceholder]="true" required='false' [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event, sectionIndex)" (optionSelected)="onOptionSelected($event, sectionIndex)">
|
<app-multiple-auto-complete placeholder="Description Templates" [disabled]="viewOnly" [value]="descriptionTemplatesPerSection[sectionIndex]" [hidePlaceholder]="true" required='false' [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event, sectionIndex)" (optionActionClicked)="onPreviewTemplate($event, sectionIndex)" (optionSelected)="onOptionSelected($event, sectionIndex)">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
<!-- <button matSuffix class="input-btn" (click)="allAvailableProfiles($event)">
|
<!-- <button matSuffix class="input-btn" (click)="allAvailableProfiles($event)">
|
||||||
<mat-icon class="icon-btn">view_list</mat-icon>
|
<mat-icon class="icon-btn">view_list</mat-icon>
|
||||||
|
|
|
@ -49,6 +49,7 @@ import { FormValidationErrorsDialogComponent } from '@common/forms/form-validati
|
||||||
export class DmpProfileEditorComponent extends BaseComponent implements AfterViewInit {
|
export class DmpProfileEditorComponent extends BaseComponent implements AfterViewInit {
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
|
isClone = false;
|
||||||
viewOnly = false;
|
viewOnly = false;
|
||||||
dmpProfileModel: DmpProfileEditorModel;
|
dmpProfileModel: DmpProfileEditorModel;
|
||||||
dmpBlueprintModel: DmpBlueprintEditor;
|
dmpBlueprintModel: DmpBlueprintEditor;
|
||||||
|
@ -74,7 +75,6 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
{label: 'License', type: SystemFieldType.LICENSE},
|
{label: 'License', type: SystemFieldType.LICENSE},
|
||||||
{label: 'Access Rights', type: SystemFieldType.ACCESS_RIGHTS}
|
{label: 'Access Rights', type: SystemFieldType.ACCESS_RIGHTS}
|
||||||
];
|
];
|
||||||
selectedSystemFields: string[] = [];
|
|
||||||
systemFieldListPerSection: Array<Array<any>> = new Array();
|
systemFieldListPerSection: Array<Array<any>> = new Array();
|
||||||
descriptionTemplatesPerSection: Array<Array<DatasetProfileModel>> = new Array<Array<DatasetProfileModel>>();
|
descriptionTemplatesPerSection: Array<Array<DatasetProfileModel>> = new Array<Array<DatasetProfileModel>>();
|
||||||
|
|
||||||
|
@ -113,6 +113,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe((params: Params) => {
|
.subscribe((params: Params) => {
|
||||||
this.dmpProfileId = params['id'];
|
this.dmpProfileId = params['id'];
|
||||||
|
const cloneId = params['cloneid'];
|
||||||
|
|
||||||
if (this.dmpProfileId != null) {
|
if (this.dmpProfileId != null) {
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
|
@ -133,6 +134,21 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
url: '/dmp-profiles/' + this.dmpProfileId
|
url: '/dmp-profiles/' + this.dmpProfileId
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
} else if (cloneId != null) {
|
||||||
|
this.isClone = true;
|
||||||
|
this.dmpProfileService.clone(cloneId).pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
data => {
|
||||||
|
this.dmpBlueprintModel = new DmpBlueprintEditor().fromModel(data);
|
||||||
|
this.dmpBlueprintModel.id = null;
|
||||||
|
this.dmpBlueprintModel.created = null;
|
||||||
|
this.dmpBlueprintModel.status = DmpProfileStatus.Draft;
|
||||||
|
this.formGroup = this.dmpBlueprintModel.buildForm();
|
||||||
|
this.buildSystemFields();
|
||||||
|
this.fillDescriptionTemplatesInMultAutocomplete();
|
||||||
|
},
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.dmpProfileModel = new DmpProfileEditorModel();
|
this.dmpProfileModel = new DmpProfileEditorModel();
|
||||||
this.dmpBlueprintModel = new DmpBlueprintEditor();
|
this.dmpBlueprintModel = new DmpBlueprintEditor();
|
||||||
|
@ -176,6 +192,13 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkForProfiles(event, sectionIndex: number) {
|
||||||
|
if (event.checked === false) {
|
||||||
|
this.descriptionTemplatesPerSection[sectionIndex] = new Array<DatasetProfileModel>();
|
||||||
|
this.descriptionTemplatesArray(sectionIndex).clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
|
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
|
||||||
const request = new DataTableRequest<DatasetProfileCriteria>(null, null, { fields: ['+label'] });
|
const request = new DataTableRequest<DatasetProfileCriteria>(null, null, { fields: ['+label'] });
|
||||||
const criteria = new DatasetProfileCriteria();
|
const criteria = new DatasetProfileCriteria();
|
||||||
|
@ -195,10 +218,17 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
section.ordinal = this.sectionsArray().length + 1;
|
section.ordinal = this.sectionsArray().length + 1;
|
||||||
section.hasTemplates = false;
|
section.hasTemplates = false;
|
||||||
this.sectionsArray().push(section.buildForm());
|
this.sectionsArray().push(section.buildForm());
|
||||||
|
this.systemFieldListPerSection.push(new Array());
|
||||||
|
this.descriptionTemplatesPerSection.push(new Array());
|
||||||
}
|
}
|
||||||
|
|
||||||
removeSection(sectionIndex: number): void {
|
removeSection(sectionIndex: number): void {
|
||||||
|
this.systemFieldListPerSection.splice(sectionIndex, 1);
|
||||||
|
this.descriptionTemplatesPerSection.splice(sectionIndex, 1);
|
||||||
this.sectionsArray().removeAt(sectionIndex);
|
this.sectionsArray().removeAt(sectionIndex);
|
||||||
|
this.sectionsArray().controls.forEach((section, index) => {
|
||||||
|
section.get('ordinal').setValue(index + 1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldsArray(sectionIndex: number): FormArray {
|
fieldsArray(sectionIndex: number): FormArray {
|
||||||
|
@ -219,6 +249,9 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
|
|
||||||
removeField(sectionIndex: number, fieldIndex: number): void {
|
removeField(sectionIndex: number, fieldIndex: number): void {
|
||||||
this.fieldsArray(sectionIndex).removeAt(fieldIndex);
|
this.fieldsArray(sectionIndex).removeAt(fieldIndex);
|
||||||
|
this.fieldsArray(sectionIndex).controls.forEach((field, index) => {
|
||||||
|
field.get('ordinal').setValue(index + 1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
systemFieldsArray(sectionIndex: number): FormArray {
|
systemFieldsArray(sectionIndex: number): FormArray {
|
||||||
|
@ -245,14 +278,15 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
return this.fieldList.find(f => f.type == type).label;
|
return this.fieldList.find(f => f.type == type).label;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedFieldType(systemField: string, type: SystemFieldType, sectionIndex: number): void {
|
selectedFieldType(type: SystemFieldType, sectionIndex: number): void {
|
||||||
let index = this.selectedSystemFields.indexOf(systemField);
|
if (this.systemFieldDisabled(type, sectionIndex)) return;
|
||||||
|
let index = this.systemFieldListPerSection[sectionIndex].indexOf(type);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
this.selectedSystemFields.push(systemField);
|
this.systemFieldListPerSection[sectionIndex].push(type);
|
||||||
this.addSystemField(sectionIndex, type);
|
this.addSystemField(sectionIndex, type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.selectedSystemFields.splice(index, 1);
|
this.systemFieldListPerSection[sectionIndex].splice(index, 1);
|
||||||
this.removeSystemField(sectionIndex, type);
|
this.removeSystemField(sectionIndex, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,6 +307,9 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
}
|
}
|
||||||
|
|
||||||
removeSystemFieldWithIndex(sectionIndex: number, fieldIndex: number): void {
|
removeSystemFieldWithIndex(sectionIndex: number, fieldIndex: number): void {
|
||||||
|
let type: SystemFieldType = this.fieldsArray(sectionIndex).at(fieldIndex).get('type').value;
|
||||||
|
let index = this.systemFieldListPerSection[sectionIndex].indexOf(type);
|
||||||
|
this.systemFieldListPerSection[sectionIndex] = this.systemFieldListPerSection[sectionIndex].filter(types => types != type);
|
||||||
this.fieldsArray(sectionIndex).removeAt(fieldIndex);
|
this.fieldsArray(sectionIndex).removeAt(fieldIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,11 +369,19 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
drop(event: CdkDragDrop<string[]>, sectionIndex: number) {
|
drop(event: CdkDragDrop<string[]>, sectionIndex: number) {
|
||||||
moveItemInArray(this.fieldsArray(sectionIndex).controls, event.previousIndex, event.currentIndex);
|
moveItemInArray(this.fieldsArray(sectionIndex).controls, event.previousIndex, event.currentIndex);
|
||||||
moveItemInArray(this.fieldsArray(sectionIndex).value, event.previousIndex, event.currentIndex);
|
moveItemInArray(this.fieldsArray(sectionIndex).value, event.previousIndex, event.currentIndex);
|
||||||
|
this.fieldsArray(sectionIndex).controls.forEach((field, index) => {
|
||||||
|
field.get('ordinal').setValue(index + 1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
dropSections(event: CdkDragDrop<string[]>) {
|
dropSections(event: CdkDragDrop<string[]>) {
|
||||||
moveItemInArray(this.sectionsArray().controls, event.previousIndex, event.currentIndex);
|
moveItemInArray(this.sectionsArray().controls, event.previousIndex, event.currentIndex);
|
||||||
moveItemInArray(this.sectionsArray().value, event.previousIndex, event.currentIndex);
|
moveItemInArray(this.sectionsArray().value, event.previousIndex, event.currentIndex);
|
||||||
|
this.sectionsArray().controls.forEach((section, index) => {
|
||||||
|
section.get('ordinal').setValue(index + 1);
|
||||||
|
});
|
||||||
|
moveItemInArray(this.systemFieldListPerSection, event.previousIndex, event.currentIndex);
|
||||||
|
moveItemInArray(this.descriptionTemplatesPerSection, event.previousIndex, event.currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
moveItemInFormArray(formArray: FormArray, fromIndex: number, toIndex: number): void {
|
moveItemInFormArray(formArray: FormArray, fromIndex: number, toIndex: number): void {
|
||||||
|
@ -360,36 +405,30 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
foundIndex !== -1 && this.descriptionTemplatesArray(sectionIndex).removeAt(foundIndex);
|
foundIndex !== -1 && this.descriptionTemplatesArray(sectionIndex).removeAt(foundIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// onPreviewTemplate(event, sectionIndex: number) {
|
onPreviewTemplate(event, sectionIndex: number) {
|
||||||
// const dialogRef = this.dialog.open(DatasetPreviewDialogComponent, {
|
const dialogRef = this.dialog.open(DatasetPreviewDialogComponent, {
|
||||||
// width: '590px',
|
width: '590px',
|
||||||
// minHeight: '200px',
|
minHeight: '200px',
|
||||||
// restoreFocus: false,
|
restoreFocus: false,
|
||||||
// data: {
|
data: {
|
||||||
// template: event
|
template: event
|
||||||
// },
|
},
|
||||||
// panelClass: 'custom-modalbox'
|
panelClass: 'custom-modalbox'
|
||||||
// });
|
});
|
||||||
// dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
// if (result) {
|
if (result) {
|
||||||
// let profiles = this.sectionsArray().at(sectionIndex).get('descriptionTemplates').value;//this.formGroup.get('profiles').value;
|
const profile: DescriptionTemplatesInSectionEditor = new DescriptionTemplatesInSectionEditor();
|
||||||
// const profile: DescriptionTemplatesInSectionEditor = new DescriptionTemplatesInSectionEditor();
|
profile.id = Guid.create().toString();
|
||||||
// profile.id = Guid.create().toString();
|
profile.descriptionTemplateId = event.id;
|
||||||
// profile.descriptionTemplateId = event.id;
|
profile.label = event.label;
|
||||||
// profile.label = event.label;
|
this.descriptionTemplatesArray(sectionIndex).push(profile.buildForm());
|
||||||
// profiles.push(profile.buildForm());
|
|
||||||
// this.sectionsArray().at(sectionIndex).get('descriptionTemplates').setValue(profiles);//this.formGroup.get('profiles').setValue(profiles);
|
const items = this.descriptionTemplatesPerSection[sectionIndex];
|
||||||
// this.profilesAutoCompleteConfiguration = {
|
items.push({id: event.id, label: event.label, description: ""});
|
||||||
// filterFn: this.filterProfiles.bind(this),
|
this.descriptionTemplatesPerSection[sectionIndex] = [...items];
|
||||||
// initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
}
|
||||||
// displayFn: (item) => item['label'],
|
});
|
||||||
// titleFn: (item) => item['label'],
|
}
|
||||||
// subtitleFn: (item) => item['description'],
|
|
||||||
// popupItemActionIcon: 'visibility'
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
onOptionSelected(item, sectionIndex){
|
onOptionSelected(item, sectionIndex){
|
||||||
const profile: DescriptionTemplatesInSectionEditor = new DescriptionTemplatesInSectionEditor();
|
const profile: DescriptionTemplatesInSectionEditor = new DescriptionTemplatesInSectionEditor();
|
||||||
|
@ -430,12 +469,12 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
|
|
||||||
hasTitle(): boolean {
|
hasTitle(): boolean {
|
||||||
const dmpBlueprint: DmpBlueprint = this.formGroup.value;
|
const dmpBlueprint: DmpBlueprint = this.formGroup.value;
|
||||||
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category as unknown === 'SYSTEM' && field.type === SystemFieldType.TEXT));
|
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category === FieldCategory.SYSTEM || field.category as unknown === 'SYSTEM') && field.type === SystemFieldType.TEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
hasDescription(): boolean {
|
hasDescription(): boolean {
|
||||||
const dmpBlueprint: DmpBlueprint = this.formGroup.value;
|
const dmpBlueprint: DmpBlueprint = this.formGroup.value;
|
||||||
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category as unknown === 'SYSTEM' && field.type === SystemFieldType.HTML_TEXT));
|
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category === FieldCategory.SYSTEM || field.category as unknown === 'SYSTEM') && field.type === SystemFieldType.HTML_TEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
hasDescriptionTemplates(): boolean {
|
hasDescriptionTemplates(): boolean {
|
||||||
|
@ -539,6 +578,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
.subscribe(
|
.subscribe(
|
||||||
confirmed =>{
|
confirmed =>{
|
||||||
if(confirmed){
|
if(confirmed){
|
||||||
|
if(this.formGroup.get('status').value == DmpProfileStatus.Draft) {
|
||||||
this.formGroup.get('status').setValue(DmpProfileStatus.Deleted);
|
this.formGroup.get('status').setValue(DmpProfileStatus.Deleted);
|
||||||
this.dmpProfileService.createBlueprint(this.formGroup.value)
|
this.dmpProfileService.createBlueprint(this.formGroup.value)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
@ -547,6 +587,21 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this.dmpProfileService.delete(this.dmpProfileId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
complete => this.onCallbackSuccess(),
|
||||||
|
error => {
|
||||||
|
if (error.error.statusCode == 674) {
|
||||||
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DMP-BLUEPRINT-DELETE'), SnackBarNotificationLevel.Error);
|
||||||
|
} else {
|
||||||
|
this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
<div class="dmp-criteria">
|
<div class="row align-items-end">
|
||||||
<div class="row justify-content-end">
|
<div class="col-auto">
|
||||||
<div class="col-auto search-container">
|
<div class="d-lg-inline-block pr-2 text-muted">
|
||||||
|
<span>{{'CRITERIA.USERS.SHOW' | translate}}:</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<mat-form-field class="status-form-field">
|
||||||
|
<mat-select [(ngModel)]="criteria.status" (ngModelChange)="controlModified()" placeholder=" {{'CRITERIA.BLUEPRINT.STATUS' | translate}}">
|
||||||
|
<mat-option [value]="null">{{'BLUEPRINT-STATUS.NONE' | translate}}</mat-option>
|
||||||
|
<mat-option [value]="0">{{'BLUEPRINT-STATUS.DRAFT' | translate}}</mat-option>
|
||||||
|
<mat-option [value]="1">{{'BLUEPRINT-STATUS.FINALIZED' | translate}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-auto ml-lg-auto">
|
||||||
<mat-form-field class="search-form-field">
|
<mat-form-field class="search-form-field">
|
||||||
<input matInput placeholder=" {{'CRITERIA.DMP.LIKE'| translate}}" name="grantCriteriaLike"
|
<input matInput placeholder=" {{'CRITERIA.BLUEPRINT.LIKE'| translate}}" name="dmpBlueprintLike"
|
||||||
[(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
|
[(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
|
||||||
<mat-icon matPrefix>search</mat-icon>
|
<mat-icon matPrefix>search</mat-icon>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
|
.mat-form-field{
|
||||||
|
display: inline-block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host ::ng-deep .status-form-field .mat-form-field-wrapper {
|
||||||
|
background-color: white !important;
|
||||||
|
padding-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
:host ::ng-deep .search-form-field .mat-form-field-wrapper {
|
:host ::ng-deep .search-form-field .mat-form-field-wrapper {
|
||||||
background-color: white !important;
|
background-color: white !important;
|
||||||
padding-bottom: 0 !important;
|
padding-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
:host ::ng-deep .search-container .mat-form-field-appearance-outline .mat-form-field-infix {
|
|
||||||
|
:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix {
|
||||||
padding: 0.3rem 0rem 0.6rem 0rem !important;
|
padding: 0.3rem 0rem 0.6rem 0rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dmp-criteria{
|
|
||||||
margin-top: 3em;
|
|
||||||
margin-bottom: 0em;
|
|
||||||
}
|
|
|
@ -1,14 +1,10 @@
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { GrantListingModel } from '@app/core/model/grant/grant-listing';
|
import { DmpBlueprintCriteria } from '@app/core/query/dmp/dmp-blueprint-criteria';
|
||||||
import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria';
|
|
||||||
import { DmpProfileCriteria } from '@app/core/query/dmp/dmp-profile-criteria';
|
|
||||||
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
|
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
|
||||||
import { DialodConfirmationUploadDmpProfiles } from '@app/ui/admin/dmp-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
|
|
||||||
import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component';
|
import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component';
|
||||||
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-profile-criteria-component',
|
selector: 'app-dmp-profile-criteria-component',
|
||||||
|
@ -17,11 +13,8 @@ import { takeUntil } from 'rxjs/operators';
|
||||||
})
|
})
|
||||||
export class DmpProfileCriteriaComponent extends BaseCriteriaComponent implements OnInit {
|
export class DmpProfileCriteriaComponent extends BaseCriteriaComponent implements OnInit {
|
||||||
|
|
||||||
@Input()
|
public criteria: DmpBlueprintCriteria = new DmpBlueprintCriteria();
|
||||||
showGrant: boolean;
|
|
||||||
public criteria: DmpProfileCriteria = new DmpProfileCriteria();
|
|
||||||
filteringGrantsAsync = false;
|
|
||||||
filteredGrants: GrantListingModel[];
|
|
||||||
constructor(
|
constructor(
|
||||||
private dmpProfileService: DmpProfileService,
|
private dmpProfileService: DmpProfileService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
|
@ -32,10 +25,10 @@ export class DmpProfileCriteriaComponent extends BaseCriteriaComponent implement
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
if (this.criteria == null) { this.criteria = new DmpCriteria(); }
|
if (this.criteria == null) { this.criteria = new DmpBlueprintCriteria(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
setCriteria(criteria: DmpProfileCriteria): void {
|
setCriteria(criteria: DmpBlueprintCriteria): void {
|
||||||
this.criteria = criteria;
|
this.criteria = criteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 mt-5">
|
||||||
<app-dmp-profile-criteria-component></app-dmp-profile-criteria-component>
|
<app-dmp-profile-criteria-component></app-dmp-profile-criteria-component>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mat-elevation-z6">
|
<div class="mat-elevation-z6">
|
||||||
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
|
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()" matSortActive="created" matSortDirection="desc">
|
||||||
|
|
||||||
<!-- Column Definition: Name -->
|
<!-- Column Definition: Name -->
|
||||||
<ng-container cdkColumnDef="label">
|
<ng-container cdkColumnDef="label">
|
||||||
|
@ -30,6 +35,13 @@
|
||||||
<mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
|
<mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Column Definition: Created -->
|
||||||
|
<ng-container cdkColumnDef="created">
|
||||||
|
<mat-header-cell *matHeaderCellDef mat-sort-header="created">
|
||||||
|
{{'DMP-PROFILE-LISTING.COLUMNS.CREATED' | translate}}</mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let row">{{row.created | date:'short'}}</mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<!-- Column Definition: status -->
|
<!-- Column Definition: status -->
|
||||||
<ng-container cdkColumnDef="status">
|
<ng-container cdkColumnDef="status">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header="status">
|
<mat-header-cell *matHeaderCellDef mat-sort-header="status">
|
||||||
|
@ -41,14 +53,29 @@
|
||||||
</mat-cell>
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Column Definition: Created -->
|
|
||||||
<ng-container cdkColumnDef="created">
|
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header="created">
|
|
||||||
{{'DMP-PROFILE-LISTING.COLUMNS.CREATED' | translate}}</mat-header-cell>
|
|
||||||
<mat-cell *matCellDef="let row">{{row.created | date:'shortDate'}}</mat-cell>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<!-- Column Definition: Submission Time -->
|
<!-- Column Definition: Submission Time -->
|
||||||
|
<ng-container cdkColumnDef="actions">
|
||||||
|
<mat-header-cell *matHeaderCellDef><!-- {{'DATASET-PROFILE-LISTING.COLUMNS.ACTIONS' | translate}} -->
|
||||||
|
</mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
|
||||||
|
<mat-menu #actionsMenu="matMenu">
|
||||||
|
<button mat-menu-item (click)="clone(row.id)">
|
||||||
|
<mat-icon>filter_none</mat-icon>{{'DMP-PROFILE-LISTING.ACTIONS.CLONE' | translate}}
|
||||||
|
</button>
|
||||||
|
<button mat-menu-item (click)="downloadXML(row.id)" *ngIf="row.status === dmpBlueprintStatus.Finalized">
|
||||||
|
<mat-icon>download</mat-icon>
|
||||||
|
{{'DMP-PROFILE-LISTING.ACTIONS.DOWNLOAD-XML' | translate}}
|
||||||
|
</button>
|
||||||
|
<button mat-menu-item (click)="deleteTemplate(row.id)">
|
||||||
|
<mat-icon>delete</mat-icon>
|
||||||
|
{{'DMP-PROFILE-LISTING.ACTIONS.DELETE' | translate}}
|
||||||
|
</button>
|
||||||
|
</mat-menu>
|
||||||
|
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
||||||
|
<mat-icon>more_horiz</mat-icon>
|
||||||
|
</button>
|
||||||
|
</mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||||
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
|
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
import { DataSource } from '@angular/cdk/table';
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
||||||
|
@ -21,6 +21,11 @@ import { TranslateService } from '@ngx-translate/core';
|
||||||
import { merge as observableMerge, Observable, of as observableOf } from 'rxjs';
|
import { merge as observableMerge, Observable, of as observableOf } from 'rxjs';
|
||||||
import { map, startWith, switchMap, takeUntil } from 'rxjs/operators';
|
import { map, startWith, switchMap, takeUntil } from 'rxjs/operators';
|
||||||
import { DialodConfirmationUploadDmpProfiles } from './criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
|
import { DialodConfirmationUploadDmpProfiles } from './criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
|
||||||
|
import { DmpBlueprintCriteria } from '@app/core/query/dmp/dmp-blueprint-criteria';
|
||||||
|
import { DmpBlueprintListing } from '@app/core/model/dmp/dmp-blueprint/dmp-blueprint-listing';
|
||||||
|
import { DmpProfileStatus } from '@app/core/common/enum/dmp-profile-status';
|
||||||
|
import * as FileSaver from 'file-saver';
|
||||||
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -35,11 +40,12 @@ export class DmpProfileListingComponent extends BaseComponent implements OnInit
|
||||||
@ViewChild(DmpProfileCriteriaComponent, { static: true }) criteria: DmpProfileCriteriaComponent;
|
@ViewChild(DmpProfileCriteriaComponent, { static: true }) criteria: DmpProfileCriteriaComponent;
|
||||||
|
|
||||||
dataSource: DatasetDataSource | null;
|
dataSource: DatasetDataSource | null;
|
||||||
displayedColumns: String[] = ['label', 'status', 'created'];
|
displayedColumns: String[] = ['label', 'created', 'status', 'actions'];
|
||||||
pageEvent: PageEvent;
|
pageEvent: PageEvent;
|
||||||
titlePrefix: String;
|
titlePrefix: String;
|
||||||
dmpId: String;
|
dmpId: String;
|
||||||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||||
|
dmpBlueprintStatus = DmpProfileStatus;
|
||||||
|
|
||||||
statuses = [
|
statuses = [
|
||||||
{ value: '0', viewValue: 'DMP-PROFILE-LISTING.STATUS.DRAFT' },// active
|
{ value: '0', viewValue: 'DMP-PROFILE-LISTING.STATUS.DRAFT' },// active
|
||||||
|
@ -81,12 +87,81 @@ export class DmpProfileListingComponent extends BaseComponent implements OnInit
|
||||||
this.dataSource = new DatasetDataSource(this.dmpProfileService, this._paginator, this.sort, this.criteria);
|
this.dataSource = new DatasetDataSource(this.dmpProfileService, this._paginator, this.sort, this.criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clone(id: string) {
|
||||||
|
this.router.navigate(['dmp-profiles/clone/' + id]);
|
||||||
|
}
|
||||||
|
|
||||||
rowClick(rowId: String) {
|
rowClick(rowId: String) {
|
||||||
this.router.navigate(['dmp-profiles/' + rowId]);
|
this.router.navigate(['dmp-profiles/' + rowId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultCriteria(): DmpProfileCriteria {
|
downloadXML(dmpProfileId: string): void {
|
||||||
const defaultCriteria = new DmpProfileCriteria();
|
this.dmpProfileService.downloadXML(dmpProfileId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(response => {
|
||||||
|
const blob = new Blob([response.body], { type: 'application/xml' });
|
||||||
|
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
||||||
|
FileSaver.saveAs(blob, filename);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getFilenameFromContentDispositionHeader(header: string): string {
|
||||||
|
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
||||||
|
|
||||||
|
const matches = header.match(regex);
|
||||||
|
let filename: string;
|
||||||
|
for (let i = 0; i < matches.length; i++) {
|
||||||
|
const match = matches[i];
|
||||||
|
if (match.includes('filename="')) {
|
||||||
|
filename = match.substring(10, match.length - 1);
|
||||||
|
break;
|
||||||
|
} else if (match.includes('filename=')) {
|
||||||
|
filename = match.substring(9);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteTemplate(id: string) {
|
||||||
|
if (id) {
|
||||||
|
this.dialog.open(ConfirmationDialogComponent,{data:{
|
||||||
|
isDeleteConfirmation: true,
|
||||||
|
confirmButton: this.languageService.instant('DMP-PROFILE-EDITOR.CONFIRM-DELETE-DIALOG.CONFIRM-BUTTON'),
|
||||||
|
cancelButton: this.languageService.instant("DMP-PROFILE-EDITOR.CONFIRM-DELETE-DIALOG.CANCEL-BUTTON"),
|
||||||
|
message: this.languageService.instant("DMP-PROFILE-EDITOR.CONFIRM-DELETE-DIALOG.MESSAGE")
|
||||||
|
}})
|
||||||
|
.afterClosed()
|
||||||
|
.subscribe(
|
||||||
|
confirmed =>{
|
||||||
|
if(confirmed){
|
||||||
|
this.dmpProfileService.delete(id)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
complete => {
|
||||||
|
this.uiNotificationService.snackBarNotification(this.languageService.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DMP-BLUEPRINT-DELETE'), SnackBarNotificationLevel.Success);
|
||||||
|
this.refresh();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.onCallbackError(error);
|
||||||
|
if (error.error.statusCode == 674) {
|
||||||
|
this.uiNotificationService.snackBarNotification(this.languageService.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DMP-BLUEPRINT-DELETE'), SnackBarNotificationLevel.Error);
|
||||||
|
} else {
|
||||||
|
this.uiNotificationService.snackBarNotification(this.languageService.instant(error.message), SnackBarNotificationLevel.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onCallbackError(errorResponse: HttpErrorResponse) {
|
||||||
|
this.uiNotificationService.snackBarNotification(errorResponse.message, SnackBarNotificationLevel.Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
getDefaultCriteria(): DmpBlueprintCriteria {
|
||||||
|
const defaultCriteria = new DmpBlueprintCriteria();
|
||||||
return defaultCriteria;
|
return defaultCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +217,7 @@ export class DmpProfileListingComponent extends BaseComponent implements OnInit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DatasetDataSource extends DataSource<DmpProfileListing> {
|
export class DatasetDataSource extends DataSource<DmpBlueprintListing> {
|
||||||
|
|
||||||
totalCount = 0;
|
totalCount = 0;
|
||||||
|
|
||||||
|
@ -156,7 +231,7 @@ export class DatasetDataSource extends DataSource<DmpProfileListing> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<DmpProfileListing[]> {
|
connect(): Observable<DmpBlueprintListing[]> {
|
||||||
const displayDataChanges = [
|
const displayDataChanges = [
|
||||||
this._paginator.page
|
this._paginator.page
|
||||||
//this._sort.matSortChange
|
//this._sort.matSortChange
|
||||||
|
@ -168,9 +243,9 @@ export class DatasetDataSource extends DataSource<DmpProfileListing> {
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
let fields: Array<string> = new Array();
|
let fields: Array<string> = new Array();
|
||||||
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<DmpProfileCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
const request = new DataTableRequest<DmpBlueprintCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||||
request.criteria = this._criteria.criteria;
|
request.criteria = this._criteria.criteria;
|
||||||
return this._service.getPaged(request);
|
return this._service.getPagedBlueprint(request);
|
||||||
}),
|
}),
|
||||||
/*.catch((error: any) => {
|
/*.catch((error: any) => {
|
||||||
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
|
|
|
@ -3,6 +3,26 @@
|
||||||
<div *ngIf="this.dashboardStatisticsData">
|
<div *ngIf="this.dashboardStatisticsData">
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
<div class="row">
|
||||||
|
<div *ngIf="newReleaseNotificationVisible" class="new-releases-card col-auto mt-0 mr-4" [style.display]="isVisible ? 'block' : 'none'">
|
||||||
|
<a class="col-auto d-flex" (click)="dismissNewReleaseNotification()"><span class="ml-auto mt-3 material-icons clear-icon">clear</span></a>
|
||||||
|
<div class="row new-releases-hint-container m-0">
|
||||||
|
<p class="new-releases-chip mb-0 col-auto">{{'NEW-RELEASE-NOTIFICATION.HINT' | translate}}</p>
|
||||||
|
</div>
|
||||||
|
<p class="new-releases-title mb-0 pt-4">{{'NEW-RELEASE-NOTIFICATION.TITLE' | translate}}</p>
|
||||||
|
<p class="new-releases-content mb-0">{{'NEW-RELEASE-NOTIFICATION.BODY' | translate}}</p>
|
||||||
|
|
||||||
|
<div class="row d-flex align-items-center mt-4" *ngIf="this.configurationService.newReleaseNotificationLink">
|
||||||
|
<div class="col-auto d-flex">
|
||||||
|
<a class="notification-link" href="{{this.configurationService.newReleaseNotificationLink}}" target="_blank">
|
||||||
|
<button mat-raised-button type="button" class="col-auto align-self-center new-releases-btn">{{'NEW-RELEASE-NOTIFICATION.ACTIONS.LEARN-MORE' | translate}}</button>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<span class="new-releases-logo">
|
||||||
|
<img src="../../../assets/images/new-releases-logo.png">
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="card col-auto mt-0" [style.display]="isVisible ? 'block' : 'none'">
|
<div class="card col-auto mt-0" [style.display]="isVisible ? 'block' : 'none'">
|
||||||
<a *ngIf="this.hasDmps()" class="col-auto d-flex" (click)="closeCard()"><span class="ml-auto mt-3 material-icons clear-icon">clear</span></a>
|
<a *ngIf="this.hasDmps()" class="col-auto d-flex" (click)="closeCard()"><span class="ml-auto mt-3 material-icons clear-icon">clear</span></a>
|
||||||
|
|
||||||
|
@ -29,11 +49,11 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div *ngIf="this.hasDmps()" class="col">
|
<div *ngIf="this.hasDmps()" class="col">
|
||||||
<div class="latest-activity-title">{{'DASHBOARD.LATEST-ACTIVITY' | translate}}</div>
|
<div class="latest-activity-title">{{'DASHBOARD.LATEST-ACTIVITY' | translate}}</div>
|
||||||
<mat-tab-group mat-align-tabs="start" class="remove-border-bottom"
|
<mat-tab-group mat-align-tabs="start" class="remove-border-bottom" [selectedIndex]="indexFromCurrentType" (selectedTabChange)="currentType = $event.tab.ariaLabel">
|
||||||
[selectedIndex]="indexFromCurrentType" (selectedTabChange)="currentType = $event.tab.ariaLabel">
|
|
||||||
<!-- <mat-tab aria-label="recent" label="{{'DASHBOARD.ALL' | translate}} ({{totalRecents}})">-->
|
<!-- <mat-tab aria-label="recent" label="{{'DASHBOARD.ALL' | translate}} ({{totalRecents}})">-->
|
||||||
<mat-tab aria-label="recent" label="{{'DASHBOARD.ALL' | translate}}">
|
<mat-tab aria-label="recent" label="{{'DASHBOARD.ALL' | translate}}">
|
||||||
<app-recent-edited-activity (totalCountRecentEdited)="onCountAllRecent($event)" [isActive]="currentType == 'recent'"></app-recent-edited-activity>
|
<app-recent-edited-activity (totalCountRecentEdited)="onCountAllRecent($event)" [isActive]="currentType == 'recent'"></app-recent-edited-activity>
|
||||||
|
@ -129,8 +149,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="hasDmps()" class="col activity">
|
<div *ngIf="hasDmps()" class="col activity">
|
||||||
<div class="latest-activity-title">{{'DASHBOARD.LATEST-ACTIVITY' | translate}}</div>
|
<div class="latest-activity-title">{{'DASHBOARD.LATEST-ACTIVITY' | translate}}</div>
|
||||||
<mat-tab-group mat-align-tabs="start" class="remove-border-bottom" (
|
<mat-tab-group mat-align-tabs="start" class="remove-border-bottom" ( [selectedIndex]="indexFromCurrentType" selectedTabChange)="currentType = $event.tab.ariaLabel">
|
||||||
[selectedIndex]="indexFromCurrentType" selectedTabChange)="currentType = $event.tab.ariaLabel">
|
|
||||||
<!-- <mat-tab aria-label="recent" label="{{'DASHBOARD.ALL' | translate}} ({{totalRecents}})">-->
|
<!-- <mat-tab aria-label="recent" label="{{'DASHBOARD.ALL' | translate}} ({{totalRecents}})">-->
|
||||||
<mat-tab aria-label="recent" label="{{'DASHBOARD.ALL' | translate}}">
|
<mat-tab aria-label="recent" label="{{'DASHBOARD.ALL' | translate}}">
|
||||||
<app-recent-edited-activity (totalCountRecentEdited)="onCountAllRecent($event)" [isActive]="currentType == 'recent'"></app-recent-edited-activity>
|
<app-recent-edited-activity (totalCountRecentEdited)="onCountAllRecent($event)" [isActive]="currentType == 'recent'"></app-recent-edited-activity>
|
||||||
|
|
|
@ -425,6 +425,87 @@ input[type="text"] {
|
||||||
padding: 0.3rem 0rem 0.6rem 0rem !important;
|
padding: 0.3rem 0rem 0.6rem 0rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new-releases-hint-container {
|
||||||
|
padding-left: 40px;
|
||||||
|
/* padding-top: 40px; */
|
||||||
|
padding-right: 55px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-releases-card {
|
||||||
|
box-shadow: 0px 3px 6px #00000029;
|
||||||
|
max-width: 712px;
|
||||||
|
min-width: 17.5rem;
|
||||||
|
margin-top: 0rem;
|
||||||
|
margin-bottom: 3.75rem;
|
||||||
|
|
||||||
|
background: transparent linear-gradient(127deg, #EDAEB3 0%, #E1368A 100%) 0% 0% no-repeat padding-box;
|
||||||
|
border-radius: 6px;
|
||||||
|
opacity: 1;
|
||||||
|
padding-bottom: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-releases-btn {
|
||||||
|
height: 40px;
|
||||||
|
margin-left: 40px;
|
||||||
|
|
||||||
|
background: var(--primary-color) 0% 0% no-repeat padding-box;
|
||||||
|
border-radius: 30px;
|
||||||
|
opacity: 1;
|
||||||
|
color: #FFFFFF;
|
||||||
|
padding-right: 2em;
|
||||||
|
padding-left: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-releases-chip {
|
||||||
|
// margin-bottom: 1em;
|
||||||
|
// margin-left: 2.5em;
|
||||||
|
// margin-right: 2.5em;
|
||||||
|
color: #fff;
|
||||||
|
/* text-transform: uppercase; */
|
||||||
|
text-align: center;
|
||||||
|
font-weight: 500;
|
||||||
|
/* max-width: 160px; */
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
background: #EAEAEA 0% 0% no-repeat padding-box;
|
||||||
|
border-radius: 30px;
|
||||||
|
opacity: 0.7;
|
||||||
|
/* font: normal normal bold 12px/21px Aileron; */
|
||||||
|
letter-spacing: 0.12px;
|
||||||
|
color: #6E6E6E;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-releases-title {
|
||||||
|
text-align: left;
|
||||||
|
font: Bold 30px/34px Roboto;
|
||||||
|
letter-spacing: 0px;
|
||||||
|
color: #212121;
|
||||||
|
padding-left: 40px;
|
||||||
|
/* padding-top: 40px; */
|
||||||
|
padding-right: 55px;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-releases-content {
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 300;
|
||||||
|
font-size: 1rem;
|
||||||
|
letter-spacing: 0px;
|
||||||
|
color: #212121;
|
||||||
|
padding-left: 40px;
|
||||||
|
font: normal normal normal 16px/24px Roboto;
|
||||||
|
padding-top: 36px;
|
||||||
|
padding-right: 55px;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-releases-logo {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* ::ng-deep .mat-tab-group {
|
/* ::ng-deep .mat-tab-group {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,9 @@ import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/serv
|
||||||
import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service';
|
import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service';
|
||||||
import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants';
|
import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants';
|
||||||
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
||||||
|
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
||||||
|
import * as moment from 'moment';
|
||||||
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -73,6 +76,7 @@ export class DashboardComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
importFileText: string;
|
importFileText: string;
|
||||||
startWizardText: string;
|
startWizardText: string;
|
||||||
currentType: string = "recent";
|
currentType: string = "recent";
|
||||||
|
newReleaseNotificationVisible = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
@ -89,7 +93,9 @@ export class DashboardComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
private language: TranslateService,
|
private language: TranslateService,
|
||||||
private uiNotificationService: UiNotificationService,
|
private uiNotificationService: UiNotificationService,
|
||||||
private guidedTourService: GuidedTourService,
|
private guidedTourService: GuidedTourService,
|
||||||
private matomoService: MatomoService
|
private matomoService: MatomoService,
|
||||||
|
private cookieService: CookieService,
|
||||||
|
public configurationService: ConfigurationService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
// this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
|
// this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
|
||||||
|
@ -154,6 +160,8 @@ export class DashboardComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
this.filteredOptions = this.searchControl.valueChanges.pipe(mergeMap(x => {
|
this.filteredOptions = this.searchControl.valueChanges.pipe(mergeMap(x => {
|
||||||
return this.searchBarService.search(x);
|
return this.searchBarService.search(x);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this.newReleaseNotificationVisible = this.isNewReleaseNotificationVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
public get indexFromCurrentType() {
|
public get indexFromCurrentType() {
|
||||||
|
@ -400,4 +408,26 @@ export class DashboardComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
// viewAllPublicDatasetsClicked() {
|
// viewAllPublicDatasetsClicked() {
|
||||||
// this.router.navigate(['explore']);
|
// this.router.navigate(['explore']);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
dismissNewReleaseNotification() {
|
||||||
|
this.cookieService.set('new-release-dismiss-' + this.configurationService.newReleaseNotificationVersionCode, 'true', 5000, null, null, false, 'Lax');
|
||||||
|
this.newReleaseNotificationVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
isNewReleaseNotificationVisible() {
|
||||||
|
if (this.configurationService.newReleaseNotificationVersionCode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.configurationService.newReleaseNotificationExpires == null && this.configurationService.newReleaseNotificationLink == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.configurationService.newReleaseNotificationExpires != null && moment(this.configurationService.newReleaseNotificationExpires).tz('UTC') < moment.utc()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.cookieService.get('new-release-dismiss-' + this.configurationService.newReleaseNotificationVersionCode) === 'true') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ export class DatasetCopyDialogueComponent {
|
||||||
map(result => {
|
map(result => {
|
||||||
this.dmpModel = result
|
this.dmpModel = result
|
||||||
this.dmpModel.profiles.forEach((element) => {
|
this.dmpModel.profiles.forEach((element) => {
|
||||||
if (element.id == this.data.datasetProfileId) {
|
if (element.descriptionTemplateId == this.data.datasetProfileId) {
|
||||||
this.data.datasetProfileExist = true;
|
this.data.datasetProfileExist = true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select placeholder="{{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
|
<mat-select placeholder="{{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
|
||||||
<mat-option *ngFor="let profile of availableProfiles" [value]="profile">
|
<mat-option *ngFor="let profile of availableProfiles" [value]="profile">
|
||||||
<div (click)="checkMinMax($event, profile)">
|
<div>
|
||||||
{{profile.label}}
|
{{profile.label}}
|
||||||
</div>
|
</div>
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
|
|
@ -49,8 +49,13 @@ export class DatasetEditorComponent extends BaseComponent {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
checkMinMax(event, profile: DatasetProfileModel) {
|
ngOnInit() {
|
||||||
event.stopPropagation();
|
this.formGroup.get('profile').valueChanges.pipe(takeUntil(this._destroyed)).subscribe(x => {
|
||||||
|
this.checkMinMax(x);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
checkMinMax(profile: DatasetProfileModel) {
|
||||||
const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value;
|
const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value;
|
||||||
const blueprintId = this.formGroup.get('dmp').value.profile.id;
|
const blueprintId = this.formGroup.get('dmp').value.profile.id;
|
||||||
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||||
|
@ -70,22 +75,14 @@ export class DatasetEditorComponent extends BaseComponent {
|
||||||
if (count === foundTemplate.maxMultiplicity) {
|
if (count === foundTemplate.maxMultiplicity) {
|
||||||
this.dialog.open(PopupNotificationDialogComponent, {
|
this.dialog.open(PopupNotificationDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
title: 'Max datasets using this template.',
|
title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'),
|
||||||
message: 'Select another profile.'
|
message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE')
|
||||||
}, maxWidth: '30em'
|
}, maxWidth: '30em'
|
||||||
});
|
});
|
||||||
}
|
this.formGroup.get('profile').reset();
|
||||||
else{
|
|
||||||
this.formGroup.get('profile').setValue(profile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
this.formGroup.get('profile').setValue(profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.formGroup.get('profile').setValue(profile);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,9 @@ import {PrefillDatasetComponent} from "@app/ui/dataset/dataset-wizard/prefill-da
|
||||||
import { ToCEntry, ToCEntryType } from "@app/ui/misc/dataset-description-form/dataset-description.component";
|
import { ToCEntry, ToCEntryType } from "@app/ui/misc/dataset-description-form/dataset-description.component";
|
||||||
import { dispatchFakeEvent } from "@angular/cdk/testing/testbed/fake-events";
|
import { dispatchFakeEvent } from "@angular/cdk/testing/testbed/fake-events";
|
||||||
import { DmpDatasetProfile } from '@app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile';
|
import { DmpDatasetProfile } from '@app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile';
|
||||||
|
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
|
||||||
|
import { DatasetService } from '@app/core/services/dataset/dataset.service';
|
||||||
|
import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-wizard-component',
|
selector: 'app-dataset-wizard-component',
|
||||||
|
@ -98,6 +101,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
dmpId: string;
|
dmpId: string;
|
||||||
dmpSectionIndex: number;
|
dmpSectionIndex: number;
|
||||||
availableDescriptionTemplates: DatasetProfileModel[] = [];
|
availableDescriptionTemplates: DatasetProfileModel[] = [];
|
||||||
|
availableDescriptionTemplatesForPrefilling: DatasetProfileModel[] = [];
|
||||||
newDmpId: string;
|
newDmpId: string;
|
||||||
publicId: string;
|
publicId: string;
|
||||||
profileUpdateId: string;
|
profileUpdateId: string;
|
||||||
|
@ -127,12 +131,14 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private datasetWizardService: DatasetWizardService,
|
private datasetWizardService: DatasetWizardService,
|
||||||
|
private datasetService: DatasetService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public language: TranslateService,
|
public language: TranslateService,
|
||||||
public externalSourcesService: ExternalSourcesService,
|
public externalSourcesService: ExternalSourcesService,
|
||||||
public dmpService: DmpService,
|
public dmpService: DmpService,
|
||||||
|
private dmpProfileService: DmpProfileService,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
public externalSourcesConfigurationService: ExternalSourcesConfigurationService,
|
public externalSourcesConfigurationService: ExternalSourcesConfigurationService,
|
||||||
private uiNotificationService: UiNotificationService,
|
private uiNotificationService: UiNotificationService,
|
||||||
|
@ -199,6 +205,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
|
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
|
||||||
this.lockStatus = lockStatus;
|
this.lockStatus = lockStatus;
|
||||||
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
||||||
|
this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex;
|
||||||
this.needsUpdate();
|
this.needsUpdate();
|
||||||
this.breadCrumbs = observableOf([
|
this.breadCrumbs = observableOf([
|
||||||
{
|
{
|
||||||
|
@ -216,7 +223,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
this.formGroup = this.datasetWizardModel.buildForm();
|
this.formGroup = this.datasetWizardModel.buildForm();
|
||||||
let profiles = this.datasetWizardModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.datasetWizardModel.dmpSectionIndex));
|
let profiles = this.datasetWizardModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.datasetWizardModel.dmpSectionIndex));
|
||||||
for (var profile of profiles) {
|
for (var profile of profiles) {
|
||||||
this.availableDescriptionTemplates.push({id: profile.descriptionTemplateId, label: profile.label, description: ""})
|
this.addToAvailableDescriptionTemplates(this.availableDescriptionTemplates, { id: profile.descriptionTemplateId, label: profile.label, description: "" });
|
||||||
}
|
}
|
||||||
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
||||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||||
|
@ -278,17 +285,33 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
this.formGroup = this.datasetWizardModel.buildForm();
|
this.formGroup = this.datasetWizardModel.buildForm();
|
||||||
let profiles = this.datasetWizardModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.dmpSectionIndex));
|
let profiles = this.datasetWizardModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.dmpSectionIndex));
|
||||||
for (var profile of profiles) {
|
for (var profile of profiles) {
|
||||||
this.availableDescriptionTemplates.push({id: profile.descriptionTemplateId, label: profile.label, description: ""})
|
this.addToAvailableDescriptionTemplates(this.availableDescriptionTemplates, { id: profile.descriptionTemplateId, label: profile.label, description: "" });
|
||||||
}
|
}
|
||||||
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
||||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||||
this.formGroup.get('dmp').disable();
|
this.formGroup.get('dmp').disable();
|
||||||
|
this.dmpProfileService.getSingleBlueprint(data.profile.id)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
const request: DataTableRequest<DatasetProfileCriteria> = new DataTableRequest<DatasetProfileCriteria>(null, null, null);
|
||||||
|
request.criteria = new DatasetProfileCriteria();
|
||||||
|
request.criteria.ids = [];
|
||||||
|
this.availableDescriptionTemplates.forEach(template => request.criteria.ids.push(template.id));
|
||||||
|
this.datasetService.getDatasetProfilesWithPrefilling(request)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(items => {
|
||||||
|
items.forEach(template => {
|
||||||
|
if (template.enablePrefilling) {
|
||||||
|
this.addToAvailableDescriptionTemplates(this.availableDescriptionTemplatesForPrefilling, { id: template.id, label: template.label, description: '' });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (this.availableDescriptionTemplatesForPrefilling.length > 0) {
|
||||||
const dialogRef = this.dialog.open(PrefillDatasetComponent, {
|
const dialogRef = this.dialog.open(PrefillDatasetComponent, {
|
||||||
width: '590px',
|
width: '590px',
|
||||||
minHeight: '200px',
|
minHeight: '200px',
|
||||||
restoreFocus: false,
|
restoreFocus: false,
|
||||||
data: {
|
data: {
|
||||||
availableProfiles: this.availableDescriptionTemplates,
|
availableProfiles: this.availableDescriptionTemplatesForPrefilling,
|
||||||
datasetFormGroup: this.formGroup
|
datasetFormGroup: this.formGroup
|
||||||
},
|
},
|
||||||
panelClass: 'custom-modalbox'
|
panelClass: 'custom-modalbox'
|
||||||
|
@ -305,6 +328,9 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
this.registerFormListeners();
|
this.registerFormListeners();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
this.loadDatasetProfiles();
|
this.loadDatasetProfiles();
|
||||||
this.registerFormListeners();
|
this.registerFormListeners();
|
||||||
// this.availableProfiles = data.profiles;
|
// this.availableProfiles = data.profiles;
|
||||||
|
@ -347,6 +373,10 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
this.datasetWizardModel.dmp = data;
|
this.datasetWizardModel.dmp = data;
|
||||||
this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp);
|
this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp);
|
||||||
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
||||||
|
const descipptionTemplateiNNewDmp:DmpDatasetProfile = this.datasetWizardModel.dmp?.profiles?.find(x => x.descriptionTemplateId === this.datasetWizardModel.profile.id);
|
||||||
|
|
||||||
|
this.dmpSectionIndex = descipptionTemplateiNNewDmp?.data?.dmpSectionIndex?.length > 0 ? descipptionTemplateiNNewDmp?.data?.dmpSectionIndex[0] : 0;
|
||||||
|
this.formGroup.get('dmpSectionIndex').setValue(this.dmpSectionIndex);
|
||||||
|
|
||||||
this.loadDatasetProfiles();
|
this.loadDatasetProfiles();
|
||||||
this.breadCrumbs = observableOf([
|
this.breadCrumbs = observableOf([
|
||||||
|
@ -478,6 +508,13 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addToAvailableDescriptionTemplates(list: DatasetProfileModel[], item: DatasetProfileModel) {
|
||||||
|
if (list.some(x => x.id === item.id)) {
|
||||||
|
list.splice(list.findIndex(x => x.id === item.id), 1)
|
||||||
|
}
|
||||||
|
list.push(item);
|
||||||
|
}
|
||||||
|
|
||||||
// private _listenersSubscription:Subscription = new Subscription();
|
// private _listenersSubscription:Subscription = new Subscription();
|
||||||
registerFormListeners() {
|
registerFormListeners() {
|
||||||
// const dmpSubscription =
|
// const dmpSubscription =
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<mat-form-field class="col-md-12">
|
<mat-form-field class="col-md-12">
|
||||||
<mat-select placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
|
<mat-select placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
|
||||||
<mat-option *ngFor="let profile of data.availableProfiles" [value]="profile">
|
<mat-option *ngFor="let profile of data.availableProfiles" [value]="profile">
|
||||||
<div (click)="checkMinMax($event, profile)">
|
<div>
|
||||||
{{profile.label}}
|
{{profile.label}}
|
||||||
</div>
|
</div>
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {FormBuilder, FormGroup, Validators} from "@angular/forms";
|
||||||
import { DatasetProfileModel } from "@app/core/model/dataset/dataset-profile";
|
import { DatasetProfileModel } from "@app/core/model/dataset/dataset-profile";
|
||||||
import { DmpProfileService } from "@app/core/services/dmp/dmp-profile.service";
|
import { DmpProfileService } from "@app/core/services/dmp/dmp-profile.service";
|
||||||
import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component";
|
import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component";
|
||||||
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'prefill-dataset-component',
|
selector: 'prefill-dataset-component',
|
||||||
|
@ -28,6 +29,7 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
private prefillingService: PrefillingService,
|
private prefillingService: PrefillingService,
|
||||||
private dmpProfileService: DmpProfileService,
|
private dmpProfileService: DmpProfileService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
|
private language: TranslateService,
|
||||||
private progressIndicationService: ProgressIndicationService,
|
private progressIndicationService: ProgressIndicationService,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any) {
|
@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||||
|
@ -53,6 +55,10 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
titleFn: (item) => item['name'],
|
titleFn: (item) => item['name'],
|
||||||
subtitleFn: (item) => item['pid']
|
subtitleFn: (item) => item['pid']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.prefillForm.get('profile').valueChanges.pipe(takeUntil(this._destroyed)).subscribe(x => {
|
||||||
|
this.checkMinMax(x);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addProfileIfUsedLessThanMax(profile: DatasetProfileModel) {
|
addProfileIfUsedLessThanMax(profile: DatasetProfileModel) {
|
||||||
|
@ -87,8 +93,7 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMinMax(event, profile: DatasetProfileModel) {
|
checkMinMax(profile: DatasetProfileModel) {
|
||||||
event.stopPropagation();
|
|
||||||
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
|
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
|
||||||
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
|
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
|
||||||
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||||
|
@ -108,22 +113,14 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
if(count === foundTemplate.maxMultiplicity){
|
if(count === foundTemplate.maxMultiplicity){
|
||||||
this.dialog.open(PopupNotificationDialogComponent, {
|
this.dialog.open(PopupNotificationDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
title: 'Max datasets using this template.',
|
title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'),
|
||||||
message: 'Select another profile.'
|
message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE')
|
||||||
}, maxWidth: '30em'
|
}, maxWidth: '30em'
|
||||||
});
|
});
|
||||||
}
|
this.prefillForm.get('profile').reset();
|
||||||
else{
|
|
||||||
this.prefillForm.get('profile').setValue(profile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
this.prefillForm.get('profile').setValue(profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.prefillForm.get('profile').setValue(profile);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,9 +51,9 @@
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
<ul *ngIf="hasProfile(i)" class="add-dataset-option">
|
<ul *ngIf="dmp?.id && hasProfile(i)" class="add-dataset-option">
|
||||||
<li>
|
<li>
|
||||||
<a class="add-dataset-action" (click)="addDataset(i)">
|
<a class="add-dataset-action" [routerLink]="['/datasets/new/' + dmp.id + '/' + i]">
|
||||||
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-FOR-SECTION' | translate}}
|
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-FOR-SECTION' | translate}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -83,8 +83,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto formForStep0" id="editor-form" *ngIf="this.step === 0 && this.isNew">
|
<div class="col-auto formForStep0" id="editor-form" *ngIf="this.step === 0 && this.isNew">
|
||||||
<div class="col-12 blueprint-section" [hidden]="this.step !== 0">
|
<div class="col-12 blueprint-section" [hidden]="this.step !== 0">
|
||||||
<div class="input-form">
|
<div class="">
|
||||||
<div class="heading2">0.1 Title of DMP *</div>
|
<div class="heading2">Title of DMP *</div>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>Title</mat-label>
|
<mat-label>Title</mat-label>
|
||||||
<input matInput type="text" name="label" [formControl]="formGroup.get('label')" required>
|
<input matInput type="text" name="label" [formControl]="formGroup.get('label')" required>
|
||||||
|
@ -94,14 +94,14 @@
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> -->
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> -->
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-form">
|
<div class="">
|
||||||
<div class="heading2">0.2 Description of DMP *</div>
|
<div class="heading2">Description of DMP *</div>
|
||||||
<rich-text-editor-component [parentFormGroup]="formGroup" [controlName]="'description'"
|
<rich-text-editor-component [parentFormGroup]="formGroup" [controlName]="'description'"
|
||||||
[placeholder]="'Fill with description'" [required]="true">
|
[placeholder]="'Fill with description'" [required]="true">
|
||||||
</rich-text-editor-component>
|
</rich-text-editor-component>
|
||||||
</div>
|
</div>
|
||||||
<div class="dmp-blueprint-form" style="margin-top: 3%;">
|
<div class="" style="margin-top: 3%;">
|
||||||
<div class="heading2">0.3 Blueprint of DMP *</div>
|
<div class="heading2">Blueprint of DMP *</div>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>Select blueprint</mat-label>
|
<mat-label>Select blueprint</mat-label>
|
||||||
<app-single-auto-complete [required]="false" [formControl]="formGroup.get('profile')" placeholder="Select blueprint" [configuration]="dmpBlueprintAutoCompleteConfiguration">
|
<app-single-auto-complete [required]="false" [formControl]="formGroup.get('profile')" placeholder="Select blueprint" [configuration]="dmpBlueprintAutoCompleteConfiguration">
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<button mat-button class="action-btn" [disabled]="selectedDmpBlueprintDefinition == null" (click)="selectBlueprint()">Next</button>
|
<button mat-button class="action-btn" [disabled]="selectedDmpBlueprintDefinition == null || !(formGroup.get('label').valid && formGroup.get('description').valid)" (click)="selectBlueprint()">Next</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-7" *ngIf="formGroup.get('profile').value == null || (formGroup.get('profile').value && formGroup.get('profile').value.id !== defaultBlueprintId)">
|
<div class="col-7" *ngIf="formGroup.get('profile').value == null || (formGroup.get('profile').value && formGroup.get('profile').value.id !== defaultBlueprintId)">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -138,11 +138,11 @@
|
||||||
<div *ngFor="let field of section.fields; let j=index">
|
<div *ngFor="let field of section.fields; let j=index">
|
||||||
<div class="heading">{{i + 1}}.{{j + 1}} {{field.label}}<span *ngIf="field.required">*</span></div>
|
<div class="heading">{{i + 1}}.{{j + 1}} {{field.label}}<span *ngIf="field.required">*</span></div>
|
||||||
<div *ngIf="field.description != null && field.description.length > 0" class="hint">{{field.description}}</div>
|
<div *ngIf="field.description != null && field.description.length > 0" class="hint">{{field.description}}</div>
|
||||||
<div class="input-form">
|
<div class="">
|
||||||
<div *ngIf="field.category === 'SYSTEM'">
|
<div *ngIf="field.category === 'SYSTEM'">
|
||||||
<div *ngIf="field.type == 0">
|
<div *ngIf="field.type == 0">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" [formControl]="formGroup.get('label')" required>
|
<input matInput placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.NAME' | translate)}}" type="text" name="label" [formControl]="formGroup.get('label')" required>
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
|
||||||
{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">
|
<mat-error *ngIf="formGroup.get('label').hasError('required')">
|
||||||
|
@ -151,12 +151,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 1">
|
<div *ngIf="field.type == 1">
|
||||||
<rich-text-editor-component [parentFormGroup]="formGroup" [controlName]="'description'"
|
<rich-text-editor-component [parentFormGroup]="formGroup" [controlName]="'description'"
|
||||||
[placeholder]="'DMP-EDITOR.PLACEHOLDER.DESCRIPTION'" [required]="field.required">
|
[placeholder]="field?.placeholder?.length > 0 ? field.placeholder : 'DMP-EDITOR.PLACEHOLDER.DESCRIPTION'" [required]="field.required">
|
||||||
</rich-text-editor-component>
|
</rich-text-editor-component>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 2">
|
<div *ngIf="field.type == 2">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{'DMP-EDITOR.PLACEHOLDER.RESEARCHERS' | translate}}</mat-label>
|
<mat-label>{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.PLACEHOLDER.RESEARCHERS' | translate)}}</mat-label>
|
||||||
<app-multiple-auto-complete [formControl]="formGroup.get('researchers')" [configuration]="researchersAutoCompleteConfiguration">
|
<app-multiple-auto-complete [formControl]="formGroup.get('researchers')" [configuration]="researchersAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('researchers').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('researchers').hasError('backendError')">
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 3">
|
<div *ngIf="field.type == 3">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{'DMP-EDITOR.PLACEHOLDER.ORGANIZATION' | translate}}</mat-label>
|
<mat-label>{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.PLACEHOLDER.ORGANIZATION' | translate)}}</mat-label>
|
||||||
<app-multiple-auto-complete [formControl]="formGroup.get('organisations')" [configuration]="organisationsAutoCompleteConfiguration">
|
<app-multiple-auto-complete [formControl]="formGroup.get('organisations')" [configuration]="organisationsAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('organisations').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('organisations').hasError('backendError')">
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 4">
|
<div *ngIf="field.type == 4">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}" required>
|
<mat-select [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.LANGUAGE' | translate)}}" required>
|
||||||
<mat-option *ngFor="let lang of getLanguageInfos()" [value]="lang.code">
|
<mat-option *ngFor="let lang of getLanguageInfos()" [value]="lang.code">
|
||||||
{{ lang.name }}
|
{{ lang.name }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
@ -205,7 +205,7 @@
|
||||||
<div *ngIf="field.type == 5">
|
<div *ngIf="field.type == 5">
|
||||||
<div class="contact-form">
|
<div class="contact-form">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('contact')" placeholder="{{'DMP-EDITOR.FIELDS.CONTACT' | translate}}">
|
<mat-select [formControl]="formGroup.get('extraProperties').get('contact')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.CONTACT' | translate)}}">
|
||||||
<mat-option *ngFor="let vis of getAssociates()" [value]="vis.id">
|
<mat-option *ngFor="let vis of getAssociates()" [value]="vis.id">
|
||||||
{{vis.name | translate}}
|
{{vis.name | translate}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
@ -218,17 +218,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 6">
|
<div *ngIf="field.type == 6">
|
||||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [type]="1" (onFormChanged)="formChanged()"></funding-info>
|
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [field]="field" [type]="1" (onFormChanged)="formChanged()"></funding-info>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 7">
|
<div *ngIf="field.type == 7">
|
||||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [type]="2" (onFormChanged)="formChanged()"></funding-info>
|
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [field]="field" [type]="2" (onFormChanged)="formChanged()"></funding-info>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 8">
|
<div *ngIf="field.type == 8">
|
||||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [type]="3" (onFormChanged)="formChanged()"></funding-info>
|
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [field]="field" [type]="3" (onFormChanged)="formChanged()"></funding-info>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 9">
|
<div *ngIf="field.type == 9">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<app-single-auto-complete [formControl]="formGroup.get('extraProperties').get('license')" placeholder="{{'DMP-EDITOR.FIELDS.LICENSE' | translate}}" [configuration]="licenseAutoCompleteConfiguration">
|
<app-single-auto-complete [formControl]="formGroup.get('extraProperties').get('license')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.LICENSE' | translate)}}" [configuration]="licenseAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('license').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('extraProperties').get('license').hasError('backendError')">
|
||||||
{{formGroup.get('extraProperties').get('license').getError('backendError').message}}</mat-error>
|
{{formGroup.get('extraProperties').get('license').getError('backendError').message}}</mat-error>
|
||||||
|
@ -238,7 +238,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.type == 10">
|
<div *ngIf="field.type == 10">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('visible')" placeholder="{{'DMP-EDITOR.FIELDS.VISIBILITY' | translate}}">
|
<mat-select [formControl]="formGroup.get('extraProperties').get('visible')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.VISIBILITY' | translate)}}">
|
||||||
<mat-option *ngFor="let vis of visibles" [value]="vis.value">
|
<mat-option *ngFor="let vis of visibles" [value]="vis.value">
|
||||||
{{vis.name | translate}}
|
{{vis.name | translate}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
@ -267,7 +267,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.category === 'EXTRA'">
|
<div *ngIf="field.category === 'EXTRA' && formGroup.get('extraFields')?.controls?.length > 0">
|
||||||
<div *ngIf="field.type === extraFieldTypesEnum.TEXT">
|
<div *ngIf="field.type === extraFieldTypesEnum.TEXT">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="{{field.placeholder}}" type="text" name="value" [formControl]="formGroup.get('extraFields').get(getExtraFieldIndex(field.id)).get('value')" [required]="field.required">
|
<input matInput placeholder="{{field.placeholder}}" type="text" name="value" [formControl]="formGroup.get('extraFields').get(getExtraFieldIndex(field.id)).get('value')" [required]="field.required">
|
||||||
|
@ -305,11 +305,11 @@
|
||||||
<div class="col-12 card" *ngIf="section.hasTemplates">
|
<div class="col-12 card" *ngIf="section.hasTemplates">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="input-form">
|
<div class="">
|
||||||
<div class="heading">Description templates</div>
|
<div class="heading">Description templates</div>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}</mat-label>
|
<mat-label>{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}</mat-label>
|
||||||
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}" [hidePlaceholder]="true" required='true' [value]="sectionTemplates[section.ordinal - 1]" [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event, i)" (optionActionClicked)="onPreviewTemplate($event, i)" (optionSelected)="onOptionSelected($event, i)">
|
<app-multiple-auto-complete placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate)}}" [hidePlaceholder]="true" required='true' [value]="sectionTemplates[section.ordinal - 1]" [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event, i)" (optionActionClicked)="onPreviewTemplate($event, i)" (optionSelected)="onOptionSelected($event, i)">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
|
||||||
{{formGroup.get('profiles').getError('backendError').message}}</mat-error>
|
{{formGroup.get('profiles').getError('backendError').message}}</mat-error>
|
||||||
|
|
|
@ -357,13 +357,13 @@ a:hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-form {
|
.input-form {
|
||||||
text-align: left;
|
// text-align: left;
|
||||||
font-weight: 400;
|
// font-weight: 400;
|
||||||
font-size: 16px;
|
// font-size: 16px;
|
||||||
letter-spacing: 0.15px;
|
// letter-spacing: 0.15px;
|
||||||
color: #7d7d7d;
|
// color: #7d7d7d;
|
||||||
opacity: 1;
|
// opacity: 1;
|
||||||
margin-bottom: 1rem;
|
// margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.insert-manually {
|
.insert-manually {
|
||||||
|
@ -425,5 +425,13 @@ a:hover {
|
||||||
|
|
||||||
::ng-deep .input-form .mat-form-field-appearance-outline .mat-form-field-infix {
|
::ng-deep .input-form .mat-form-field-appearance-outline .mat-form-field-infix {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
padding: 0.6em 0 1em 0 !important;
|
// padding: 0.6em 0 1em 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix {
|
||||||
|
padding: 1em 0 1em 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix {
|
||||||
|
// padding: 0rem 0rem 0.4rem 0rem !important;
|
||||||
|
// }
|
|
@ -56,6 +56,8 @@ import { PopupNotificationDialogComponent } from '@app/library/notification/popu
|
||||||
import { GrantEditorModel } from '@app/ui/grant/editor/grant-editor.model';
|
import { GrantEditorModel } from '@app/ui/grant/editor/grant-editor.model';
|
||||||
import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component';
|
import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component';
|
||||||
import { DmpProfileStatus } from '@app/core/common/enum/dmp-profile-status';
|
import { DmpProfileStatus } from '@app/core/common/enum/dmp-profile-status';
|
||||||
|
import { DatasetService } from '@app/core/services/dataset/dataset.service';
|
||||||
|
import { runInThisContext } from 'vm';
|
||||||
|
|
||||||
interface Visible {
|
interface Visible {
|
||||||
value: boolean;
|
value: boolean;
|
||||||
|
@ -132,6 +134,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dmpProfileService: DmpProfileService,
|
private dmpProfileService: DmpProfileService,
|
||||||
|
private datasetService: DatasetService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
@ -159,81 +162,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
|
|
||||||
if (itemId != null) {
|
if (itemId != null) {
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
this.dmpService.getSingle(itemId).pipe(map(data => data as DmpModel))
|
this.getItem(itemId);
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(async data => {
|
|
||||||
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
|
|
||||||
this.lockStatus = lockStatus;
|
|
||||||
|
|
||||||
this.dmp = new DmpEditorModel();
|
|
||||||
this.dmp.grant = new GrantTabModel();
|
|
||||||
this.dmp.project = new ProjectFormModel();
|
|
||||||
this.dmp.funder = new FunderFormModel();
|
|
||||||
this.dmp.extraProperties = new ExtraPropertiesFormModel();
|
|
||||||
this.dmp.fromModel(data);
|
|
||||||
this.formGroup = this.dmp.buildForm();
|
|
||||||
|
|
||||||
this.datasets = this.formGroup.get('datasets') as FormArray;
|
|
||||||
|
|
||||||
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
|
||||||
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
|
||||||
this.dmpProfileService.getSingleBlueprint(this.formGroup.get('profile').value)
|
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(result => {
|
|
||||||
this.selectedDmpBlueprintDefinition = result.definition;
|
|
||||||
this.checkForGrant();
|
|
||||||
this.checkForFunder();
|
|
||||||
this.checkForProject();
|
|
||||||
this.buildExtraFields();
|
|
||||||
this.formGroup.get('profile').setValue(result);
|
|
||||||
this.maxStep = this.selectedDmpBlueprintDefinition.sections.length;
|
|
||||||
this.step = 1;
|
|
||||||
this.addProfiles(this.dmp.profiles);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep;
|
|
||||||
|
|
||||||
this.setIsUserOwner();
|
|
||||||
if (!this.isUserOwner) {
|
|
||||||
|
|
||||||
if(this.isUserMember()){
|
|
||||||
this.router.navigate(['plans', 'overview', itemId]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.isFinalized = true;
|
|
||||||
this.formGroup.disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.dmp.status === DmpStatus.Finalized || lockStatus) {
|
|
||||||
this.isFinalized = true;
|
|
||||||
this.formGroup.disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.authService.current() != null) {
|
|
||||||
if (!lockStatus) {
|
|
||||||
this.lock = new LockModel(data.id, this.getUserFromDMP());
|
|
||||||
|
|
||||||
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
|
|
||||||
this.lock.id = Guid.parse(result);
|
|
||||||
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.associatedUsers = data.associatedUsers;
|
|
||||||
this.people = data.users;
|
|
||||||
this.formGroup.valueChanges.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(x => {
|
|
||||||
this.formChanged();
|
|
||||||
});
|
|
||||||
if(this.lockStatus){
|
|
||||||
this.dialog.open(PopupNotificationDialogComponent,{data:{
|
|
||||||
title:this.language.instant('DMP-EDITOR.LOCKED.TITLE'),
|
|
||||||
message:this.language.instant('DMP-EDITOR.LOCKED.MESSAGE')
|
|
||||||
}, maxWidth:'30em'});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.dmp = new DmpEditorModel();
|
this.dmp = new DmpEditorModel();
|
||||||
|
@ -302,10 +231,92 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
displayFn: (item) => item['label'],
|
displayFn: (item) => item['label'],
|
||||||
titleFn: (item) => item['label'],
|
titleFn: (item) => item['label'],
|
||||||
subtitleFn: (item) => item['description'],
|
subtitleFn: (item) => item['description'],
|
||||||
popupItemActionIcon: 'visibility'
|
popupItemActionIcon: 'visibility',
|
||||||
|
canRemoveItem: (item) => this.canRemoveItem(item)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getItem(itemId: String) {
|
||||||
|
this.dmpService.getSingle(itemId).pipe(map(data => data as DmpModel))
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(async data => {
|
||||||
|
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
|
||||||
|
this.lockStatus = lockStatus;
|
||||||
|
|
||||||
|
this.dmp = new DmpEditorModel();
|
||||||
|
this.dmp.grant = new GrantTabModel();
|
||||||
|
this.dmp.project = new ProjectFormModel();
|
||||||
|
this.dmp.funder = new FunderFormModel();
|
||||||
|
this.dmp.extraProperties = new ExtraPropertiesFormModel();
|
||||||
|
this.dmp.fromModel(data);
|
||||||
|
this.formGroup = this.dmp.buildForm();
|
||||||
|
|
||||||
|
this.datasets = this.formGroup.get('datasets') as FormArray;
|
||||||
|
|
||||||
|
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
||||||
|
if (!isNullOrUndefined(this.formGroup.get('profile').value)) {
|
||||||
|
this.dmpProfileService.getSingleBlueprint(this.formGroup.get('profile').value)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
this.selectedDmpBlueprintDefinition = result.definition;
|
||||||
|
this.checkForGrant();
|
||||||
|
this.checkForFunder();
|
||||||
|
this.checkForProject();
|
||||||
|
this.buildExtraFields();
|
||||||
|
this.formGroup.get('profile').setValue(result);
|
||||||
|
this.maxStep = this.selectedDmpBlueprintDefinition.sections.length;
|
||||||
|
this.step = 1;
|
||||||
|
this.sectionTemplates = new Array<Array<DatasetProfileModel>>();
|
||||||
|
this.addProfiles(this.dmp.profiles);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep;
|
||||||
|
|
||||||
|
this.setIsUserOwner();
|
||||||
|
if (!this.isUserOwner) {
|
||||||
|
|
||||||
|
if (this.isUserMember()) {
|
||||||
|
this.router.navigate(['plans', 'overview', itemId]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.isFinalized = true;
|
||||||
|
this.formGroup.disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.dmp.status === DmpStatus.Finalized || lockStatus) {
|
||||||
|
this.isFinalized = true;
|
||||||
|
this.formGroup.disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.authService.current() != null) {
|
||||||
|
if (!lockStatus) {
|
||||||
|
this.lock = new LockModel(data.id, this.getUserFromDMP());
|
||||||
|
|
||||||
|
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
|
||||||
|
this.lock.id = Guid.parse(result);
|
||||||
|
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.associatedUsers = data.associatedUsers;
|
||||||
|
this.people = data.users;
|
||||||
|
this.formGroup.valueChanges.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(x => {
|
||||||
|
this.formChanged();
|
||||||
|
});
|
||||||
|
if (this.lockStatus) {
|
||||||
|
this.dialog.open(PopupNotificationDialogComponent, {
|
||||||
|
data: {
|
||||||
|
title: this.language.instant('DMP-EDITOR.LOCKED.TITLE'),
|
||||||
|
message: this.language.instant('DMP-EDITOR.LOCKED.MESSAGE')
|
||||||
|
}, maxWidth: '30em'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
extraFieldsArray(): FormArray {
|
extraFieldsArray(): FormArray {
|
||||||
return this.formGroup.get('extraFields') as FormArray;
|
return this.formGroup.get('extraFields') as FormArray;
|
||||||
}
|
}
|
||||||
|
@ -437,7 +448,9 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
this.selectedDmpBlueprintDefinition = result.definition;
|
this.selectedDmpBlueprintDefinition = result.definition;
|
||||||
this.formGroup.get('profile').setValue(result);
|
this.formGroup.get('profile').setValue(result);
|
||||||
this.maxStep = this.selectedDmpBlueprintDefinition.sections.length;
|
this.maxStep = this.selectedDmpBlueprintDefinition.sections.length;
|
||||||
|
if (this.formGroup.get('label').valid && this.formGroup.get('description').valid) {
|
||||||
this.nextStep();
|
this.nextStep();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,7 +486,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
}
|
}
|
||||||
|
|
||||||
hasProfile(sectionIndex: number): boolean {
|
hasProfile(sectionIndex: number): boolean {
|
||||||
return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.filter(x => x.data.dmpSectionIndex.includes(sectionIndex)).length > 0;
|
return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.some(x => x.data?.dmpSectionIndex?.includes(sectionIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
addDataset(dmpSectionIndex: number) {
|
addDataset(dmpSectionIndex: number) {
|
||||||
|
@ -509,7 +522,9 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
onSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void {
|
onSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void {
|
||||||
this.scrollTop = document.getElementById('editor-form').scrollTop;
|
this.scrollTop = document.getElementById('editor-form').scrollTop;
|
||||||
// return;
|
// return;
|
||||||
this.dmpService.createDmp(this.formGroup.getRawValue())
|
const rawvalue = this.formGroup.getRawValue();
|
||||||
|
if (rawvalue.profile instanceof Object) rawvalue.profile = rawvalue.profile.id;
|
||||||
|
this.dmpService.createDmp(rawvalue)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => {
|
complete => {
|
||||||
|
@ -576,24 +591,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
this.router.navigate(['/plans', 'edit', dmp.id]);
|
this.router.navigate(['/plans', 'edit', dmp.id]);
|
||||||
}
|
}
|
||||||
let dmpEditorModel: DmpEditorModel;
|
this.getItem(dmp.id);
|
||||||
dmpEditorModel = new DmpEditorModel();
|
|
||||||
dmpEditorModel.grant = new GrantTabModel();
|
|
||||||
dmpEditorModel.project = new ProjectFormModel();
|
|
||||||
dmpEditorModel.funder = new FunderFormModel();
|
|
||||||
dmpEditorModel.extraProperties = new ExtraPropertiesFormModel();
|
|
||||||
dmpEditorModel.fromModel(dmp);
|
|
||||||
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
|
||||||
this.associatedUsers = dmp.associatedUsers;
|
|
||||||
this.people = dmp.users;
|
|
||||||
|
|
||||||
setTimeout(() => { this.formGroup = null; });
|
|
||||||
setTimeout(() => {
|
|
||||||
this.formGroup = dmpEditorModel.buildForm();
|
|
||||||
this.formGroup.valueChanges.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(x => {
|
|
||||||
this.formChanged();
|
|
||||||
});});
|
|
||||||
setTimeout(() => { document.getElementById('editor-form').scrollTop = this.scrollTop; });
|
setTimeout(() => { document.getElementById('editor-form').scrollTop = this.scrollTop; });
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
|
@ -658,6 +656,44 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public removeDataset(datasetId: string, index: number) {
|
||||||
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
|
maxWidth: '300px',
|
||||||
|
restoreFocus: false,
|
||||||
|
data: {
|
||||||
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
||||||
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'),
|
||||||
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
|
||||||
|
isDeleteConfirmation: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
if (datasetId) {
|
||||||
|
this.datasetService.delete(datasetId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
complete => {
|
||||||
|
this.onDeleteCallbackSuccess();
|
||||||
|
},
|
||||||
|
error => this.onDeleteCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.formGroup.get('datasets')['controls'].splice(index, 1);
|
||||||
|
this.step = 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onDeleteCallbackSuccess(): void {
|
||||||
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
|
||||||
|
this.dmp.id != null ? this.router.navigate(['/reload']).then(() => this.router.navigate(['/plans', 'edit', this.dmp.id])) : this.router.navigate(['/plans']);
|
||||||
|
}
|
||||||
|
|
||||||
|
onDeleteCallbackError(error) {
|
||||||
|
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
|
||||||
|
}
|
||||||
|
|
||||||
//checks if the dpm is valid not taking into account the datasets validity
|
//checks if the dpm is valid not taking into account the datasets validity
|
||||||
private _isDMPDescriptionValid(): boolean {
|
private _isDMPDescriptionValid(): boolean {
|
||||||
|
|
||||||
|
@ -830,13 +866,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
}
|
}
|
||||||
|
|
||||||
getExtraFieldIndex(id: string): string {
|
getExtraFieldIndex(id: string): string {
|
||||||
let foundFieldIndex: number;
|
return (this.formGroup.get('extraFields') as FormArray).controls.findIndex((element) => element.value.id == id).toString();
|
||||||
(this.formGroup.get('extraFields') as FormArray).controls.forEach((element, index) => {
|
|
||||||
if(element.value.id === id) {
|
|
||||||
foundFieldIndex = index;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return foundFieldIndex.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkForGrant() {
|
private checkForGrant() {
|
||||||
|
@ -887,13 +917,13 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
}
|
}
|
||||||
const templates: Array<DmpDatasetProfile> = new Array<DmpDatasetProfile>();
|
const templates: Array<DmpDatasetProfile> = new Array<DmpDatasetProfile>();
|
||||||
this.selectedDmpBlueprintDefinition.sections.forEach(section => {
|
this.selectedDmpBlueprintDefinition.sections.forEach(section => {
|
||||||
if (profiles !== undefined) {
|
if (profiles != null) {
|
||||||
profiles.filter(profile => profile.data.dmpSectionIndex.includes(section.ordinal - 1)).forEach(profile => this.sectionTemplates[section.ordinal - 1].push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }));
|
profiles.filter(profile => profile.data.dmpSectionIndex.includes(section.ordinal - 1)).forEach(profile => this.sectionTemplates[section.ordinal - 1].push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
section.descriptionTemplates.forEach(template => {
|
section.descriptionTemplates.forEach(template => {
|
||||||
this.sectionTemplates[section.ordinal - 1].push({ id: template.descriptionTemplateId, label: template.label, description: "" })
|
this.sectionTemplates[section.ordinal - 1].push({ id: template.descriptionTemplateId, label: template.label, description: "" })
|
||||||
let found: DmpDatasetProfile = templates.find(dmpDatasetProfile => dmpDatasetProfile.id == template.descriptionTemplateId);
|
let found: DmpDatasetProfile = templates.find(dmpDatasetProfile => dmpDatasetProfile.descriptionTemplateId == template.descriptionTemplateId);
|
||||||
if (found === undefined) {
|
if (found === undefined) {
|
||||||
let data: DmpDatasetProfileSectionsFormModel = new DmpDatasetProfileSectionsFormModel();
|
let data: DmpDatasetProfileSectionsFormModel = new DmpDatasetProfileSectionsFormModel();
|
||||||
data.dmpSectionIndex.push(section.ordinal - 1);
|
data.dmpSectionIndex.push(section.ordinal - 1);
|
||||||
|
@ -933,6 +963,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
let fields: Array<string> = new Array();
|
let fields: Array<string> = new Array();
|
||||||
var request = new DataTableRequest<DmpBlueprintCriteria>(0, 20, { fields: fields });
|
var request = new DataTableRequest<DmpBlueprintCriteria>(0, 20, { fields: fields });
|
||||||
request.criteria = new DmpBlueprintCriteria();
|
request.criteria = new DmpBlueprintCriteria();
|
||||||
|
request.criteria.like = query;
|
||||||
request.criteria.status = DmpProfileStatus.Finalized;
|
request.criteria.status = DmpProfileStatus.Finalized;
|
||||||
return this.dmpProfileService.getPagedBlueprint(request).pipe(map(x => x.data));
|
return this.dmpProfileService.getPagedBlueprint(request).pipe(map(x => x.data));
|
||||||
}
|
}
|
||||||
|
@ -1059,33 +1090,24 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemoveTemplate(event, sectionIndex: number) {
|
canRemoveItem(item): boolean {
|
||||||
let found = false;
|
let found = false;
|
||||||
let profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[];
|
|
||||||
this.formGroup.get('datasets')['controls'].forEach(element => {
|
this.formGroup.get('datasets')['controls'].forEach(element => {
|
||||||
if ((element.get('profile').value.id === event.id) && (element.get('dmpSectionIndex').value === sectionIndex)) {
|
if ((element.get('profile').value.id === item.id) && (element.get('dmpSectionIndex').value === (this.step - 1))) {
|
||||||
found = true;
|
found = true;
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Success);
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Success);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (found) {
|
if (found) return false
|
||||||
this.formGroup.get('profiles').setValue(profiles);
|
else return true;
|
||||||
this.profilesAutoCompleteConfiguration = {
|
}
|
||||||
filterFn: this.filterProfiles.bind(this),
|
|
||||||
initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
|
||||||
displayFn: (item) => item['label'],
|
|
||||||
titleFn: (item) => item['label'],
|
|
||||||
subtitleFn: (item) => item['description'],
|
|
||||||
popupItemActionIcon: 'visibility'
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
onRemoveTemplate(event, sectionIndex: number) {
|
||||||
else{
|
let profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[];
|
||||||
this.sectionTemplates[sectionIndex] = this.sectionTemplates[sectionIndex].filter(sectionProfile => sectionProfile.id !== event.id);
|
this.sectionTemplates[sectionIndex] = this.sectionTemplates[sectionIndex].filter(sectionProfile => sectionProfile.id !== event.id);
|
||||||
profiles = profiles.filter(sectionProfile => sectionProfile.descriptionTemplateId !== event.id);
|
profiles = profiles.filter(sectionProfile => sectionProfile.descriptionTemplateId !== event.id || !sectionProfile.data.dmpSectionIndex.includes(sectionIndex));
|
||||||
this.formGroup.get('profiles').setValue(profiles);
|
this.formGroup.get('profiles').setValue(profiles);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
addProfile(event, sectionIndex: number) {
|
addProfile(event, sectionIndex: number) {
|
||||||
const profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[];
|
const profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[];
|
||||||
|
@ -1119,14 +1141,9 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.addProfile(event, sectionIndex);
|
this.addProfile(event, sectionIndex);
|
||||||
this.profilesAutoCompleteConfiguration = {
|
const items = this.sectionTemplates[sectionIndex];
|
||||||
filterFn: this.filterProfiles.bind(this),
|
items.push({ id: event.id, label: event.label, description: "" });
|
||||||
initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
this.sectionTemplates[sectionIndex] = [...items];
|
||||||
displayFn: (item) => item['label'],
|
|
||||||
titleFn: (item) => item['label'],
|
|
||||||
subtitleFn: (item) => item['description'],
|
|
||||||
popupItemActionIcon: 'visibility'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="funder-form" *ngIf="type == 1">
|
<div class="funder-form" *ngIf="type == 1">
|
||||||
<div *ngIf="!isCreateNewFunder">
|
<div *ngIf="!isCreateNewFunder">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<app-single-auto-complete [required]="isRequired" [formControl]="funderFormGroup.get('existFunder')" placeholder="{{'DMP-EDITOR.FIELDS.FUNDER' | translate}}" [configuration]="funderAutoCompleteConfiguration">
|
<app-single-auto-complete [required]="isRequired" [formControl]="funderFormGroup.get('existFunder')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.FUNDER' | translate)}}" [configuration]="funderAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<div class="grant-form" *ngIf="type == 2">
|
<div class="grant-form" *ngIf="type == 2">
|
||||||
<div *ngIf="!isCreateNew">
|
<div *ngIf="!isCreateNew">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<app-single-auto-complete [required]="isRequired" [formControl]="grantformGroup.get('existGrant')" placeholder="{{'DMP-EDITOR.FIELDS.GRANT' | translate}}" [configuration]="grantAutoCompleteConfiguration">
|
<app-single-auto-complete [required]="isRequired" [formControl]="grantformGroup.get('existGrant')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.GRANT' | translate)}}" [configuration]="grantAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
<div class="project-form" *ngIf="type == 3">
|
<div class="project-form" *ngIf="type == 3">
|
||||||
<div *ngIf="!isCreateNewProject">
|
<div *ngIf="!isCreateNewProject">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<app-single-auto-complete [formControl]="projectFormGroup.get('existProject')" placeholder="{{'DMP-EDITOR.FIELDS.PROJECT' | translate}}" [configuration]="projectAutoCompleteConfiguration" [required]="isRequired">
|
<app-single-auto-complete [formControl]="projectFormGroup.get('existProject')" placeholder="{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.FIELDS.PROJECT' | translate)}}" [configuration]="projectAutoCompleteConfiguration" [required]="isRequired">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { FunderCriteria } from '@app/core/query/funder/funder-criteria';
|
||||||
import { debounceTime, filter, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
import { debounceTime, filter, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { isNullOrUndefined } from '@swimlane/ngx-datatable';
|
import { isNullOrUndefined } from '@swimlane/ngx-datatable';
|
||||||
|
import { FieldInSection } from '@app/core/model/dmp/dmp-blueprint/dmp-blueprint';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'funding-info',
|
selector: 'funding-info',
|
||||||
templateUrl: './funding-info.component.html',
|
templateUrl: './funding-info.component.html',
|
||||||
|
@ -30,6 +31,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
@Input() isRequired: boolean;
|
@Input() isRequired: boolean;
|
||||||
@Input() type: number;
|
@Input() type: number;
|
||||||
|
@Input() field: FieldInSection;
|
||||||
|
|
||||||
@Input() formGroup: FormGroup;
|
@Input() formGroup: FormGroup;
|
||||||
@Input() grantformGroup: FormGroup;
|
@Input() grantformGroup: FormGroup;
|
||||||
|
|
|
@ -30,14 +30,14 @@
|
||||||
<input class="hidden" #fileInput type="file" onClick="this.form.reset()" (change)="uploadFile($event)" accept="text/xml, application/json">
|
<input class="hidden" #fileInput type="file" onClick="this.form.reset()" (change)="uploadFile($event)" accept="text/xml, application/json">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="upload-form col-sm-12 col-md-12">
|
<!-- <div class="upload-form col-sm-12 col-md-12">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}</mat-label>
|
<mat-label>{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}</mat-label>
|
||||||
<app-multiple-auto-complete [(ngModel)]="dmpProfiles" [configuration]="profilesAutoCompleteConfiguration" (optionActionClicked)="onPreviewTemplate($event)">
|
<app-multiple-auto-complete [(ngModel)]="dmpProfiles" [configuration]="profilesAutoCompleteConfiguration" (optionActionClicked)="onPreviewTemplate($event)">
|
||||||
<!-- <app-multiple-auto-complete required='true' [(ngModel)]="dmpProfiles" placeholder="{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}" [configuration]="profilesAutoCompleteConfiguration" (optionActionClicked)="onPreviewTemplate($event)"> -->
|
<app-multiple-auto-complete required='true' [(ngModel)]="dmpProfiles" placeholder="{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}" [configuration]="profilesAutoCompleteConfiguration" (optionActionClicked)="onPreviewTemplate($event)">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="row mt-3">
|
<div class="row mt-3">
|
||||||
<div class="col-auto ml-auto">
|
<div class="col-auto ml-auto">
|
||||||
|
|
|
@ -332,7 +332,7 @@
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix {
|
:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix {
|
||||||
padding: 0rem 0rem 0.4rem 0rem !important;
|
padding: 0rem 0rem 0.4rem 0rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,54 +1,54 @@
|
||||||
|
import { Location } from '@angular/common';
|
||||||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { FormGroup } from '@angular/forms';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
import { DatasetStatus } from '@app/core/common/enum/dataset-status';
|
import { DatasetStatus } from '@app/core/common/enum/dataset-status';
|
||||||
import { DmpStatus } from '@app/core/common/enum/dmp-status';
|
import { DmpStatus } from '@app/core/common/enum/dmp-status';
|
||||||
|
import { Role } from "@app/core/common/enum/role";
|
||||||
import { Principal } from '@app/core/model/auth/principal';
|
import { Principal } from '@app/core/model/auth/principal';
|
||||||
import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview';
|
import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview';
|
||||||
import { DatasetsToBeFinalized } from '@app/core/model/dataset/datasets-toBeFinalized';
|
import { DatasetsToBeFinalized } from '@app/core/model/dataset/datasets-toBeFinalized';
|
||||||
|
import { DepositConfigurationModel } from '@app/core/model/deposit/deposit-configuration';
|
||||||
|
import { DmpModel } from '@app/core/model/dmp/dmp';
|
||||||
|
import { DmpBlueprintDefinition, SystemFieldType } from '@app/core/model/dmp/dmp-blueprint/dmp-blueprint';
|
||||||
import { DmpOverviewModel } from '@app/core/model/dmp/dmp-overview';
|
import { DmpOverviewModel } from '@app/core/model/dmp/dmp-overview';
|
||||||
|
import { DoiModel } from '@app/core/model/doi/doi';
|
||||||
import { UserInfoListingModel } from '@app/core/model/user/user-info-listing';
|
import { UserInfoListingModel } from '@app/core/model/user/user-info-listing';
|
||||||
|
import { VersionListingModel } from '@app/core/model/version/version-listing.model';
|
||||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
|
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
||||||
|
import { DepositRepositoriesService } from '@app/core/services/deposit-repositories/deposit-repositories.service';
|
||||||
|
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
|
||||||
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
||||||
|
import { LockService } from '@app/core/services/lock/lock.service';
|
||||||
|
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
||||||
import {
|
import {
|
||||||
SnackBarNotificationLevel,
|
SnackBarNotificationLevel,
|
||||||
UiNotificationService
|
UiNotificationService
|
||||||
} from '@app/core/services/notification/ui-notification-service';
|
} from '@app/core/services/notification/ui-notification-service';
|
||||||
import {ConfirmationDialogComponent} from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
|
||||||
import {
|
import {
|
||||||
DmpFinalizeDialogComponent,
|
DmpFinalizeDialogComponent,
|
||||||
DmpFinalizeDialogInput,
|
DmpFinalizeDialogInput,
|
||||||
DmpFinalizeDialogOutput
|
DmpFinalizeDialogOutput
|
||||||
} from '@app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
|
} from '@app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
|
||||||
import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
|
import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
|
||||||
|
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
import { BaseComponent } from '@common/base/base.component';
|
||||||
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import * as FileSaver from 'file-saver';
|
import * as FileSaver from 'file-saver';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
import { map, takeUntil } from 'rxjs/operators';
|
import { map, takeUntil } from 'rxjs/operators';
|
||||||
import {Role} from "@app/core/common/enum/role";
|
|
||||||
import {DmpInvitationDialogComponent} from '../invitation/dmp-invitation-dialog.component';
|
|
||||||
import {ConfigurationService} from '@app/core/services/configuration/configuration.service';
|
|
||||||
import {Location} from '@angular/common';
|
|
||||||
import {FormGroup} from '@angular/forms';
|
|
||||||
import {LockService} from '@app/core/services/lock/lock.service';
|
|
||||||
import {VersionListingModel} from '@app/core/model/version/version-listing.model';
|
|
||||||
import { CloneDialogComponent } from '../clone/clone-dialog/clone-dialog.component';
|
import { CloneDialogComponent } from '../clone/clone-dialog/clone-dialog.component';
|
||||||
import {DmpModel} from '@app/core/model/dmp/dmp';
|
|
||||||
import { DmpEditorModel } from '../editor/dmp-editor.model';
|
import { DmpEditorModel } from '../editor/dmp-editor.model';
|
||||||
import {FunderFormModel} from '../editor/grant-tab/funder-form-model';
|
|
||||||
import {ProjectFormModel} from '../editor/grant-tab/project-form-model';
|
|
||||||
import {GrantTabModel} from '../editor/grant-tab/grant-tab-model';
|
|
||||||
import { ExtraPropertiesFormModel } from '../editor/general-tab/extra-properties-form.model';
|
import { ExtraPropertiesFormModel } from '../editor/general-tab/extra-properties-form.model';
|
||||||
|
import { FunderFormModel } from '../editor/grant-tab/funder-form-model';
|
||||||
|
import { GrantTabModel } from '../editor/grant-tab/grant-tab-model';
|
||||||
|
import { ProjectFormModel } from '../editor/grant-tab/project-form-model';
|
||||||
|
import { DmpInvitationDialogComponent } from '../invitation/dmp-invitation-dialog.component';
|
||||||
import { StartNewDmpDialogComponent } from '../start-new-dmp-dialogue/start-new-dmp-dialog.component';
|
import { StartNewDmpDialogComponent } from '../start-new-dmp-dialogue/start-new-dmp-dialog.component';
|
||||||
import {MatomoService} from '@app/core/services/matomo/matomo-service';
|
|
||||||
import {PopupNotificationDialogComponent} from '@app/library/notification/popup/popup-notification.component';
|
|
||||||
import {DepositRepositoriesService} from '@app/core/services/deposit-repositories/deposit-repositories.service';
|
|
||||||
import {DepositConfigurationModel} from '@app/core/model/deposit/deposit-configuration';
|
|
||||||
import {DoiModel} from '@app/core/model/doi/doi';
|
|
||||||
import {isNullOrUndefined} from '@app/utilities/enhancers/utils';
|
|
||||||
import { DmpBlueprintDefinition, FieldCategory, SystemFieldType } from '@app/core/model/dmp/dmp-blueprint/dmp-blueprint';
|
|
||||||
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-overview',
|
selector: 'app-dmp-overview',
|
||||||
|
@ -662,8 +662,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
if (count < template.minMultiplicity) {
|
if (count < template.minMultiplicity) {
|
||||||
this.dialog.open(PopupNotificationDialogComponent, {
|
this.dialog.open(PopupNotificationDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
title: 'Min(' + template.minMultiplicity + ') datasets needed using this template.',
|
title: this.language.instant('DMP-OVERVIEW.MIN-DESCRIPTIONS-DIALOG.TITLE', { 'minMultiplicity': template.minMultiplicity }),
|
||||||
message: 'Add dataset.'
|
message: this.language.instant('DMP-OVERVIEW.MIN-DESCRIPTIONS-DIALOG.MESSAGE',)
|
||||||
}, maxWidth: '30em'
|
}, maxWidth: '30em'
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@ -858,10 +858,12 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
.subscribe(lockStatus => {
|
.subscribe(lockStatus => {
|
||||||
this.lockStatus = lockStatus
|
this.lockStatus = lockStatus
|
||||||
if (lockStatus) {
|
if (lockStatus) {
|
||||||
this.dialog.open(PopupNotificationDialogComponent,{data:{
|
this.dialog.open(PopupNotificationDialogComponent, {
|
||||||
|
data: {
|
||||||
title: this.language.instant('DMP-OVERVIEW.LOCKED-DIALOG.TITLE'),
|
title: this.language.instant('DMP-OVERVIEW.LOCKED-DIALOG.TITLE'),
|
||||||
message: this.language.instant('DMP-OVERVIEW.LOCKED-DIALOG.MESSAGE')
|
message: this.language.instant('DMP-OVERVIEW.LOCKED-DIALOG.MESSAGE')
|
||||||
}, maxWidth:'30em'});
|
}, maxWidth: '30em'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue