no message
This commit is contained in:
parent
86e54c40bb
commit
651c7bb0f5
|
@ -0,0 +1,9 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public class DataManagementPlanProfileCriteria extends Criteria<DMPProfile> {
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/26/2018.
|
||||
*/
|
||||
public class DynamicFieldsCriteria extends Criteria {
|
||||
public static class DynamicFieldDependencyCriteria {
|
||||
private String property;
|
||||
private String value;
|
||||
|
||||
public DynamicFieldDependencyCriteria() {
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private List<DynamicFieldDependencyCriteria> dynamicFields;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<DynamicFieldDependencyCriteria> getDynamicFields() {
|
||||
return dynamicFields;
|
||||
}
|
||||
|
||||
public void setDynamicFields(List<DynamicFieldDependencyCriteria> dynamicFields) {
|
||||
this.dynamicFields = dynamicFields;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/26/2018.
|
||||
*/
|
||||
public class RequestItem<T> {
|
||||
T criteria;
|
||||
|
||||
public T getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void setCriteria(T criteria) {
|
||||
this.criteria = criteria;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public interface DMPProfileDao extends DatabaseAccessLayer<DMPProfile, UUID> {
|
||||
|
||||
QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria);
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
@Service("dmpProfileDao")
|
||||
public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMPProfileDao {
|
||||
|
||||
@Autowired
|
||||
public DMPProfileDaoImpl(DatabaseService<DMPProfile> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<DMPProfile> createOrUpdateAsync(DMPProfile item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPProfile createOrUpdate(DMPProfile item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DMPProfile.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DMPProfile find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DMPProfile.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPProfile find(UUID id, String hint) {
|
||||
return getDatabaseService().getQueryable(DMPProfile.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DMPProfile item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DMPProfile.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria) {
|
||||
QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%"));
|
||||
return query;
|
||||
}
|
||||
}
|
|
@ -125,6 +125,11 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
@Column(name = "\"Status\"", nullable = false)
|
||||
private Short status;
|
||||
|
||||
@Column(name = "\"Properties\"")
|
||||
private String properties;
|
||||
|
||||
@Column(name = "\"DmpProperties\"")
|
||||
private String dmpProperties;
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
private Date created = null;
|
||||
|
@ -276,16 +281,35 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
this.researchers = researchers;
|
||||
}
|
||||
|
||||
public String getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(String properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getDmpProperties() {
|
||||
return dmpProperties;
|
||||
}
|
||||
|
||||
public void setDmpProperties(String dmpProperties) {
|
||||
this.dmpProperties = dmpProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DMP entity) {
|
||||
this.associatedDmps = entity.associatedDmps;
|
||||
this.label = entity.getLabel();
|
||||
this.profile = entity.getProfile();
|
||||
this.status = entity.getStatus();
|
||||
this.created = entity.created;
|
||||
this.properties = entity.getProperties();
|
||||
this.project = entity.getProject();
|
||||
this.description = entity.getDescription();
|
||||
this.researchers = entity.getResearchers();
|
||||
this.organisations = entity.getOrganisations();
|
||||
this.dmpProperties = entity.getDmpProperties();
|
||||
this.setModified(new Date());
|
||||
if (entity.getUsers() != null) this.users = entity.getUsers();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.data.entities;
|
||||
|
||||
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
|
@ -12,7 +13,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DMPProfile\"")
|
||||
public class DMPProfile {
|
||||
public class DMPProfile implements DataEntity<DMPProfile, UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -34,7 +35,7 @@ public class DMPProfile {
|
|||
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
private Short status;
|
||||
private int status;
|
||||
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
|
@ -43,37 +44,30 @@ public class DMPProfile {
|
|||
@Column(name = "\"Modified\"")
|
||||
private Date modified = new Date();
|
||||
|
||||
|
||||
public Short getStatus() {
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
public void setStatus(Short status) {
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
|
||||
public Date getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
public void setModified(Date modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -106,5 +100,15 @@ public class DMPProfile {
|
|||
this.dmps = dmps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DMPProfile entity) {
|
||||
this.modified = new Date();
|
||||
this.definition = entity.getDefinition();
|
||||
this.label = entity.getLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package eu.eudat.data.query.items.item.dmpprofile;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.data.query.definition.Query;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public class DataManagementPlanProfileCriteriaRequest extends Query<DataManagementPlanProfileCriteria, DMPProfile> {
|
||||
@Override
|
||||
public QueryableList<DMPProfile> applyCriteria() {
|
||||
QueryableList<DMPProfile> query = this.getQuery();
|
||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
|
||||
return query;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package eu.eudat.data.query.items.table.dmpprofile;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.data.query.PaginationService;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public class DataManagementPlanProfileTableRequest extends TableQuery<DataManagementPlanProfileCriteria, DMPProfile, UUID> {
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> applyCriteria() {
|
||||
QueryableList<DMPProfile> query = this.getQuery();
|
||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> applyPaging(QueryableList<DMPProfile> items) throws Exception {
|
||||
return PaginationService.applyPaging(items, this);
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ public abstract class DMPProfile_ {
|
|||
public static volatile SingularAttribute<DMPProfile, String> definition;
|
||||
public static volatile SingularAttribute<DMPProfile, UUID> id;
|
||||
public static volatile SingularAttribute<DMPProfile, String> label;
|
||||
public static volatile SingularAttribute<DMPProfile, Short> status;
|
||||
public static volatile SingularAttribute<DMPProfile, Integer> status;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ public abstract class DMP_ {
|
|||
|
||||
public static volatile SingularAttribute<DMP, UserInfo> creator;
|
||||
public static volatile SetAttribute<DMP, Researcher> researchers;
|
||||
public static volatile SingularAttribute<DMP, String> dmpProperties;
|
||||
public static volatile SingularAttribute<DMP, String> associatedDmps;
|
||||
public static volatile SingularAttribute<DMP, Date> created;
|
||||
public static volatile SingularAttribute<DMP, UUID> groupId;
|
||||
|
@ -26,6 +27,7 @@ public abstract class DMP_ {
|
|||
public static volatile SingularAttribute<DMP, Date> modified;
|
||||
public static volatile SingularAttribute<DMP, UUID> id;
|
||||
public static volatile SetAttribute<DMP, Dataset> dataset;
|
||||
public static volatile SingularAttribute<DMP, String> properties;
|
||||
public static volatile SingularAttribute<DMP, Short> status;
|
||||
|
||||
}
|
||||
|
|
|
@ -90,6 +90,19 @@
|
|||
<version>4.2.3.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- g/a spring -->
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import eu.eudat.queryable.queryableentity.DataEntity;
|
|||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
||||
import javax.persistence.EntityGraph;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.persistence.criteria.*;
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,41 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.dynamicproject.entities.Language;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/28/2018.
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/common"})
|
||||
public class CommonController {
|
||||
|
||||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
|
||||
@Autowired
|
||||
public CommonController(DynamicProjectConfiguration dynamicProjectConfiguration) {
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/language"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<Language>>> getPaged(Principal principal) {
|
||||
try {
|
||||
List<Language> language = this.dynamicProjectConfiguration.getConfiguration().getMainExternalField().getLanguage();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Language>>().status(ApiMessageCode.NO_MESSAGE).payload(language));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Language>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
||||
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||
import eu.eudat.managers.DataManagementProfileManager;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.listingmodels.DataManagementPlanProfileListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/dmpprofile"})
|
||||
public class DMPProfileController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
public DMPProfileController(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMPProfile>> createOrUpdate(@RequestBody DataManagementPlanProfileListingModel dataManagementPlan, Principal principal) {
|
||||
try {
|
||||
DataManagementProfileManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataManagementPlanProfileListingModel>> getSingle(@PathVariable String id, Principal principal) {
|
||||
try {
|
||||
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = new DataManagementProfileManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpProfileDao(), id, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanProfileListingModel));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) {
|
||||
try {
|
||||
DataTableData<DataManagementPlanProfileListingModel> dataTable = new DataManagementProfileManager().getPaged(this.getApiContext(), dataManagementPlanProfileTableRequest, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/get"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<DataManagementPlanProfileListingModel>>> getWithCriteria(@RequestBody DataManagementPlanProfileCriteriaRequest dataManagementPlanCriteria, Principal principal) {
|
||||
try {
|
||||
List<DataManagementPlanProfileListingModel> dataTable = new DataManagementProfileManager().getWithCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpProfileDao(), dataManagementPlanCriteria);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +1,23 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
|
||||
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
|
||||
import eu.eudat.data.dao.criteria.RequestItem;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException;
|
||||
import eu.eudat.managers.DataManagementPlanManager;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.models.helpermodels.Tuple;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import eu.eudat.utilities.interfaces.Applier;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -20,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -29,9 +35,12 @@ import java.util.UUID;
|
|||
@RequestMapping(value = {"/api"})
|
||||
public class DMPs extends BaseController {
|
||||
|
||||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
|
||||
@Autowired
|
||||
public DMPs(ApiContext apiContext) {
|
||||
public DMPs(ApiContext apiContext, DynamicProjectConfiguration dynamicProjectConfiguration) {
|
||||
super(apiContext);
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
|
@ -50,7 +59,7 @@ public class DMPs extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataManagementPlan>> getSingle(@PathVariable String id, Principal principal) {
|
||||
try {
|
||||
eu.eudat.models.dmp.DataManagementPlan dataManagementPlan = new DataManagementPlanManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, principal);
|
||||
eu.eudat.models.dmp.DataManagementPlan dataManagementPlan = new DataManagementPlanManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, principal, this.dynamicProjectConfiguration);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -74,7 +83,7 @@ public class DMPs extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/new/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id,@Valid @RequestBody eu.eudat.models.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) {
|
||||
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @Valid @RequestBody eu.eudat.models.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) {
|
||||
try {
|
||||
DataManagementPlanManager.newVersion(this.getApiContext(), id, dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
||||
|
@ -122,5 +131,18 @@ public class DMPs extends BaseController {
|
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/dynamic"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) {
|
||||
try {
|
||||
List<Tuple<String, String>> dataTable = new DataManagementPlanManager().getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicProjectConfiguration,criteriaRequestItem.getCriteria() );
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ public class FileController extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||
public ResponseEntity<ResponseItem<List<ContentFile>>> handleFileUpload(@RequestParam("file") MultipartFile[] file) {
|
||||
public ResponseEntity<ResponseItem<List<ContentFile>>> handleFileUpload(@RequestParam("file") MultipartFile[] files) {
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(
|
||||
new ResponseItem<List<ContentFile>>().status(ApiMessageCode.NO_MESSAGE).payload(FileManager.saveTempFile(file, getApiContext().getOperationsContext().getFileStorageService())));
|
||||
new ResponseItem<List<ContentFile>>().status(ApiMessageCode.NO_MESSAGE).payload(FileManager.saveTempFile(files, getApiContext().getOperationsContext().getFileStorageService())));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<ContentFile>>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package eu.eudat.dynamicproject;
|
||||
|
||||
import eu.eudat.dynamicproject.entities.Configuration;
|
||||
import eu.eudat.models.dynamicfields.DynamicField;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
public interface DynamicProjectConfiguration {
|
||||
Configuration getConfiguration();
|
||||
|
||||
List<DynamicField> getFields();
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package eu.eudat.dynamicproject;
|
||||
|
||||
import eu.eudat.dynamicproject.entities.Configuration;
|
||||
import eu.eudat.dynamicproject.entities.Property;
|
||||
import eu.eudat.models.dynamicfields.Dependency;
|
||||
import eu.eudat.models.dynamicfields.DynamicField;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
@Service("dynamicProjectConfiguration")
|
||||
public class DynamicProjectConfigurationImpl implements DynamicProjectConfiguration {
|
||||
|
||||
private Configuration configuration;
|
||||
|
||||
private List<DynamicField> fields;
|
||||
|
||||
private Environment environment;
|
||||
|
||||
@Autowired
|
||||
public DynamicProjectConfigurationImpl(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
if (this.configuration != null) return this.configuration;
|
||||
String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl");
|
||||
System.out.println("Loaded also config file: " + fileUrl);
|
||||
String current = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
current = new java.io.File(".").getCanonicalPath();
|
||||
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
|
||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||
is = new URL("file:///C:/Users/ikalyvas/Documents/OpenAIRE-EUDAT-DMP-service-pilot/dmp-backend/web/src/main/resources/ProjectConfiguration.xml").openStream();
|
||||
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.out.println("Cannot find in folder" + current);
|
||||
} finally {
|
||||
try {
|
||||
if (is != null) is.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl);
|
||||
}
|
||||
}
|
||||
return this.configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DynamicField> getFields() {
|
||||
if (this.fields != null) return this.fields;
|
||||
Configuration configuration = this.getConfiguration();
|
||||
List<DynamicField> fields = new LinkedList<>();
|
||||
List<Property> properties = configuration.getConfigurationProperties();
|
||||
properties.stream().forEach(item -> {
|
||||
DynamicField dynamicField = new DynamicField();
|
||||
dynamicField.setId(item.getId());
|
||||
dynamicField.setName(item.getName());
|
||||
dynamicField.setQueryProperty(item.getQueryProperty());
|
||||
dynamicField.setRequired(item.getRequired());
|
||||
List<Dependency> dependencies = new LinkedList<>();
|
||||
item.getDependencies().stream().forEach(dependency -> {
|
||||
Dependency modelDependency = new Dependency();
|
||||
modelDependency.setId(dependency.getId());
|
||||
modelDependency.setQueryProperty(dependency.getQueryProperty());
|
||||
dependencies.add(modelDependency);
|
||||
});
|
||||
dynamicField.setDependencies(dependencies);
|
||||
fields.add(dynamicField);
|
||||
});
|
||||
this.fields = fields;
|
||||
return fields;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package eu.eudat.dynamicproject.entities;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class Configuration {
|
||||
private List<Property> configurationProperties;
|
||||
private MainProperty mainExternalField;
|
||||
|
||||
public MainProperty getMainExternalField() {
|
||||
return mainExternalField;
|
||||
}
|
||||
|
||||
@XmlElement(name = "mainExternalField")
|
||||
public void setMainExternalField(MainProperty mainExternalField) {
|
||||
this.mainExternalField = mainExternalField;
|
||||
}
|
||||
|
||||
public List<Property> getConfigurationProperties() {
|
||||
return configurationProperties;
|
||||
}
|
||||
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name = "property")
|
||||
public void setConfigurationProperties(List<Property> configurationProperties) {
|
||||
this.configurationProperties = configurationProperties;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package eu.eudat.dynamicproject.entities;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
public class Dependency {
|
||||
private String id;
|
||||
private String queryProperty;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getQueryProperty() {
|
||||
return queryProperty;
|
||||
}
|
||||
|
||||
@XmlElement(name = "id")
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlElement(name = "queryProperty")
|
||||
public void setQueryProperty(String queryProperty) {
|
||||
this.queryProperty = queryProperty;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package eu.eudat.dynamicproject.entities;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/28/2018.
|
||||
*/
|
||||
public class Language {
|
||||
private String key;
|
||||
private String languageKey;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@XmlElement(name = "key")
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLanguageKey() {
|
||||
return languageKey;
|
||||
}
|
||||
|
||||
@XmlElement(name = "languageKey")
|
||||
public void setLanguageKey(String languageKey) {
|
||||
this.languageKey = languageKey;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package eu.eudat.dynamicproject.entities;
|
||||
|
||||
import eu.eudat.proxy.config.UrlConfig;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/28/2018.
|
||||
*/
|
||||
public class MainProperty {
|
||||
private String id;
|
||||
private String name;
|
||||
private String queryProperty;
|
||||
private String externalFieldId;
|
||||
private UrlConfig urlConfig;
|
||||
private String externalFieldLabel;
|
||||
private List<Dependency> dependencies;
|
||||
private Boolean required;
|
||||
private List<Language> language;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@XmlElement(name = "id")
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@XmlElement(name = "name")
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getExternalFieldId() {
|
||||
return externalFieldId;
|
||||
}
|
||||
|
||||
@XmlElement(name = "externalFieldId")
|
||||
public void setExternalFieldId(String externalFieldId) {
|
||||
this.externalFieldId = externalFieldId;
|
||||
}
|
||||
|
||||
public String getExternalFieldLabel() {
|
||||
return externalFieldLabel;
|
||||
}
|
||||
|
||||
@XmlElement(name = "externalFieldLabel")
|
||||
public void setExternalFieldLabel(String externalFieldLabel) {
|
||||
this.externalFieldLabel = externalFieldLabel;
|
||||
}
|
||||
|
||||
public List<Dependency> getDependencies() {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name = "dependency")
|
||||
public void setDependencies(List<Dependency> dependencies) {
|
||||
this.dependencies = dependencies;
|
||||
}
|
||||
|
||||
public Boolean getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
@XmlElement(name = "required")
|
||||
public void setRequired(Boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public String getQueryProperty() {
|
||||
return queryProperty;
|
||||
}
|
||||
|
||||
@XmlElement(name = "queryProperty")
|
||||
public void setQueryProperty(String queryProperty) {
|
||||
this.queryProperty = queryProperty;
|
||||
}
|
||||
|
||||
public UrlConfig getUrlConfig() {
|
||||
return urlConfig;
|
||||
}
|
||||
|
||||
@XmlElement(name = "urlConfig")
|
||||
public void setUrlConfig(UrlConfig urlConfig) {
|
||||
this.urlConfig = urlConfig;
|
||||
}
|
||||
|
||||
public List<Language> getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name = "languageProperty")
|
||||
public void setLanguage(List<Language> language) {
|
||||
this.language = language;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package eu.eudat.dynamicproject.entities;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
public class Property {
|
||||
private String id;
|
||||
private String name;
|
||||
private String sourceUrl;
|
||||
private String queryProperty;
|
||||
private String externalFieldId;
|
||||
private String externalFieldLabel;
|
||||
private List<Dependency> dependencies;
|
||||
private Boolean required;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@XmlElement(name = "id")
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@XmlElement(name = "name")
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSourceUrl() {
|
||||
return sourceUrl;
|
||||
}
|
||||
|
||||
@XmlElement(name = "sourceUrl")
|
||||
public void setSourceUrl(String sourceUrl) {
|
||||
this.sourceUrl = sourceUrl;
|
||||
}
|
||||
|
||||
public String getExternalFieldId() {
|
||||
return externalFieldId;
|
||||
}
|
||||
|
||||
@XmlElement(name = "externalFieldId")
|
||||
public void setExternalFieldId(String externalFieldId) {
|
||||
this.externalFieldId = externalFieldId;
|
||||
}
|
||||
|
||||
public String getExternalFieldLabel() {
|
||||
return externalFieldLabel;
|
||||
}
|
||||
|
||||
@XmlElement(name = "externalFieldLabel")
|
||||
public void setExternalFieldLabel(String externalFieldLabel) {
|
||||
this.externalFieldLabel = externalFieldLabel;
|
||||
}
|
||||
|
||||
public List<Dependency> getDependencies() {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name = "dependency")
|
||||
public void setDependencies(List<Dependency> dependencies) {
|
||||
this.dependencies = dependencies;
|
||||
}
|
||||
|
||||
public Boolean getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
@XmlElement(name = "required")
|
||||
public void setRequired(Boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public String getQueryProperty() {
|
||||
return queryProperty;
|
||||
}
|
||||
|
||||
@XmlElement(name = "queryProperty")
|
||||
public void setQueryProperty(String queryProperty) {
|
||||
this.queryProperty = queryProperty;
|
||||
}
|
||||
}
|
|
@ -1,30 +1,34 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.builders.entity.UserInfoBuilder;
|
||||
import eu.eudat.data.dao.entities.*;
|
||||
import eu.eudat.data.entities.*;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.HintedModelFactory;
|
||||
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
|
||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
||||
import eu.eudat.data.dao.criteria.ResearcherCriteria;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.data.dao.entities.*;
|
||||
import eu.eudat.data.entities.*;
|
||||
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.models.dmp.DataManagementPlanNewVersionModel;
|
||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.dynamicproject.entities.Property;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.HintedModelFactory;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.dmp.DataManagementPlanNewVersionModel;
|
||||
import eu.eudat.models.dynamicfields.DynamicFieldWithValue;
|
||||
import eu.eudat.models.helpermodels.Tuple;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -51,12 +55,29 @@ public class DataManagementPlanManager {
|
|||
return dataTable;
|
||||
}
|
||||
|
||||
public eu.eudat.models.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||
public eu.eudat.models.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id, Principal principal, DynamicProjectConfiguration dynamicProjectConfiguration) throws InstantiationException, IllegalAccessException {
|
||||
DMP dataManagementPlanEntity = dmpsRepository.find(UUID.fromString(id));
|
||||
if (dataManagementPlanEntity.getCreator().getId() != principal.getId() && dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||
throw new UnauthorisedException();
|
||||
eu.eudat.models.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.dmp.DataManagementPlan();
|
||||
datamanagementPlan.fromDataModel(dataManagementPlanEntity);
|
||||
Map dmpProperties = dataManagementPlanEntity.getDmpProperties() != null ? new org.json.JSONObject(dataManagementPlanEntity.getDmpProperties()).toMap() : null;
|
||||
datamanagementPlan.setDynamicFields(dynamicProjectConfiguration.getFields().stream().map(item -> {
|
||||
DynamicFieldWithValue fieldWithValue = new DynamicFieldWithValue();
|
||||
fieldWithValue.setId(item.getId());
|
||||
fieldWithValue.setDependencies(item.getDependencies());
|
||||
fieldWithValue.setName(item.getName());
|
||||
fieldWithValue.setQueryProperty(item.getQueryProperty());
|
||||
fieldWithValue.setRequired(item.getRequired());
|
||||
return fieldWithValue;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
if (dmpProperties != null && datamanagementPlan.getDynamicFields() != null)
|
||||
datamanagementPlan.getDynamicFields().forEach(item -> {
|
||||
Map<String, String> properties = (Map<String, String>) dmpProperties.get(item.getId());
|
||||
if (properties != null)
|
||||
item.setValue(new Tuple<String, String>(properties.get("id"), properties.get("label")));
|
||||
});
|
||||
return datamanagementPlan;
|
||||
}
|
||||
|
||||
|
@ -66,6 +87,49 @@ public class DataManagementPlanManager {
|
|||
return datamanagementPlans;
|
||||
}
|
||||
|
||||
public List<Tuple<String, String>> getDynamicFields(String id, DynamicProjectConfiguration dynamicProjectConfiguration, DynamicFieldsCriteria criteria) throws IllegalAccessException, InstantiationException {
|
||||
List<Tuple<String, String>> result = new LinkedList<>();
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
|
||||
|
||||
Property property = dynamicProjectConfiguration.getConfiguration().getConfigurationProperties().stream()
|
||||
.filter(item -> item.getId().equals(id)).findFirst().orElse(null);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (criteria.getLike() != null) stringBuilder.append("?search=" + criteria.getLike());
|
||||
if (property.getDependencies() != null && !property.getDependencies().isEmpty() && criteria.getDynamicFields() != null && !criteria.getDynamicFields().isEmpty()) {
|
||||
property.getDependencies().stream().forEach(item -> {
|
||||
DynamicFieldsCriteria.DynamicFieldDependencyCriteria dependencyCriteria = criteria.getDynamicFields().stream().filter(dfield -> dfield.getProperty().equals(item.getId()))
|
||||
.findFirst().orElse(null);
|
||||
if (dependencyCriteria != null) {
|
||||
if (criteria.getLike() != null || property.getDependencies().indexOf(item) > 0)
|
||||
stringBuilder.append("&");
|
||||
stringBuilder.append(item.getQueryProperty() + "=" + dependencyCriteria.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
ResponseEntity<ArrayList> response = restTemplate.exchange(property.getSourceUrl() + stringBuilder.toString(), HttpMethod.GET, entity, ArrayList.class);
|
||||
response.getBody().forEach(item -> {
|
||||
Tuple<String, String> tuple = new Tuple<>();
|
||||
tuple.setId((String) (((Map<String, Object>) item).get(property.getExternalFieldId())));
|
||||
tuple.setLabel((String) (((Map<String, Object>) item).get(property.getExternalFieldLabel())));
|
||||
result.add(tuple);
|
||||
});
|
||||
|
||||
} else {
|
||||
ResponseEntity<ArrayList> response = restTemplate.exchange(property.getSourceUrl() + stringBuilder.toString(), HttpMethod.GET, entity, ArrayList.class);
|
||||
response.getBody().forEach(item -> {
|
||||
Tuple<String, String> tuple = new Tuple<>();
|
||||
tuple.setId((String) (((Map<String, Object>) item).get(property.getExternalFieldId())));
|
||||
tuple.setLabel((String) (((Map<String, Object>) item).get(property.getExternalFieldLabel())));
|
||||
result.add(tuple);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void createOrUpdate(ApiContext apiContext, DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
|
@ -129,7 +193,7 @@ public class DataManagementPlanManager {
|
|||
ResearcherCriteria criteria = new ResearcherCriteria();
|
||||
criteria.setLike(researcher.getReference());
|
||||
List<eu.eudat.data.entities.Researcher> entries = researcherRepository.getWithCriteria(criteria).toList();
|
||||
if (entries != null && !entries.isEmpty()) researcher.setId(entries.get(0).getId ());
|
||||
if (entries != null && !entries.isEmpty()) researcher.setId(entries.get(0).getId());
|
||||
else researcher = researcherRepository.createOrUpdate(researcher);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.data.dao.entities.DMPProfileDao;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
||||
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||
import eu.eudat.models.HintedModelFactory;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
|
||||
import eu.eudat.models.listingmodels.DataManagementPlanProfileListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.services.ApiContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public class DataManagementProfileManager {
|
||||
|
||||
public DataTableData<DataManagementPlanProfileListingModel> getPaged(ApiContext apiContext, DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception {
|
||||
|
||||
QueryableList<DMPProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().getWithCriteria(dataManagementPlanProfileTableRequest.getCriteria());
|
||||
QueryableList<DMPProfile> pagedItems = PaginationManager.applyPaging(items, dataManagementPlanProfileTableRequest);
|
||||
|
||||
DataTableData<DataManagementPlanProfileListingModel> dataTable = new DataTableData<DataManagementPlanProfileListingModel>();
|
||||
|
||||
CompletableFuture itemsFuture = pagedItems
|
||||
.selectAsync(item -> new DataManagementPlanProfileListingModel().fromDataModel(item)).whenComplete((resultList, throwable) -> {
|
||||
dataTable.setData(resultList);
|
||||
});
|
||||
|
||||
CompletableFuture countFuture = items.countAsync().whenComplete((count, throwable) -> {
|
||||
dataTable.setTotalCount(count);
|
||||
});
|
||||
CompletableFuture.allOf(itemsFuture, countFuture).join();
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataManagementPlanProfileListingModel getSingle(DMPProfileDao dmpProfileDao, String id, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||
DMPProfile dmpProfile = dmpProfileDao.find(UUID.fromString(id));
|
||||
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = new DataManagementPlanProfileListingModel();
|
||||
dataManagementPlanProfileListingModel.fromDataModel(dmpProfile);
|
||||
return dataManagementPlanProfileListingModel;
|
||||
}
|
||||
|
||||
public List<DataManagementPlanProfileListingModel> getWithCriteria(DMPProfileDao dmpProfileDao, DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException {
|
||||
QueryableList<DMPProfile> items = dmpProfileDao.getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria());
|
||||
List<DataManagementPlanProfileListingModel> datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item));
|
||||
return datamanagementPlans;
|
||||
}
|
||||
|
||||
public static void createOrUpdate(ApiContext apiContext, DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel, Principal principal) throws Exception {
|
||||
DMPProfile dmpProfile = dataManagementPlanProfileListingModel.toDataModel();
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
|
||||
}
|
||||
}
|
|
@ -1,10 +1,15 @@
|
|||
package eu.eudat.models.dmp;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.dynamicfields.DynamicFieldWithValue;
|
||||
import eu.eudat.models.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
||||
import eu.eudat.models.helpermodels.Tuple;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.userinfo.UserInfo;
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
import net.minidev.json.JSONObject;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
@ -17,6 +22,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
private UUID id;
|
||||
private String label;
|
||||
private UUID groupId;
|
||||
private Tuple<UUID, String> profile;
|
||||
private int version;
|
||||
private int status;
|
||||
private String description;
|
||||
|
@ -25,8 +31,11 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
private List<Organisation> organisations;
|
||||
private List<Researcher> researchers;
|
||||
private List<UserInfo> associatedUsers;
|
||||
private DataManagementPlanProfile definition;
|
||||
private eu.eudat.models.userinfo.UserInfo creator;
|
||||
private Date created;
|
||||
private List<DynamicFieldWithValue> dynamicFields;
|
||||
private Map<String, Object> properties;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -36,6 +45,14 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public Tuple<UUID, String> getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(Tuple<UUID, String> profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
@ -132,18 +149,51 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public DataManagementPlanProfile getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(DataManagementPlanProfile definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public List<DynamicFieldWithValue> getDynamicFields() {
|
||||
return dynamicFields;
|
||||
}
|
||||
|
||||
public void setDynamicFields(List<DynamicFieldWithValue> dynamicFields) {
|
||||
this.dynamicFields = dynamicFields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataManagementPlan fromDataModel(DMP entity) {
|
||||
this.id = entity.getId();
|
||||
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
||||
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.version = entity.getVersion();
|
||||
this.groupId = this.groupId == null ? null : this.groupId;
|
||||
this.label = entity.getLabel();
|
||||
this.project = new Project();
|
||||
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
||||
this.project.fromDataModel(entity.getProject());
|
||||
this.creator = new eu.eudat.models.userinfo.UserInfo();
|
||||
this.groupId = entity.getGroupId();
|
||||
this.definition = entity.getProfile() == null ? null : new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getProfile().getDefinition()).getDocumentElement());
|
||||
if (this.definition != null && this.definition.getFields() != null && !this.definition.getFields().isEmpty() && this.properties != null) {
|
||||
this.definition.getFields().forEach(item -> {
|
||||
Optional<Map<String, Object>> fieldOptional = ((List<Map<String, Object>>) this.properties.get("fields")).stream().filter(field -> field.get("id").equals(item.getId().toString())).findFirst();
|
||||
item.setValue(fieldOptional.orElse(null).get("value"));
|
||||
});
|
||||
}
|
||||
if (entity.getCreator() != null) this.creator.fromDataModel(entity.getCreator());
|
||||
|
||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||
|
@ -169,6 +219,11 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
@Override
|
||||
public DMP toDataModel() throws Exception {
|
||||
DMP dataManagementPlanEntity = new DMP();
|
||||
if (this.profile != null) {
|
||||
DMPProfile dmpProfile = new DMPProfile();
|
||||
dmpProfile.setId(this.profile.getId());
|
||||
dataManagementPlanEntity.setProfile(dmpProfile);
|
||||
}
|
||||
dataManagementPlanEntity.setId(this.id);
|
||||
if (this.organisations != null && !this.organisations.isEmpty())
|
||||
dataManagementPlanEntity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
|
@ -189,8 +244,11 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
associatedProfileDoc.appendChild(associatedProfilesElement);
|
||||
dataManagementPlanEntity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));
|
||||
}
|
||||
dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
|
||||
dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
|
||||
dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
||||
dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
|
||||
dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
|
||||
dataManagementPlanEntity.setUsers(new HashSet<>(this.associatedUsers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
return dataManagementPlanEntity;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package eu.eudat.models.dynamicfields;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
public class Dependency {
|
||||
private String id;
|
||||
private String queryProperty;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getQueryProperty() {
|
||||
return queryProperty;
|
||||
}
|
||||
|
||||
public void setQueryProperty(String queryProperty) {
|
||||
this.queryProperty = queryProperty;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package eu.eudat.models.dynamicfields;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
public class DynamicField {
|
||||
private String id;
|
||||
private String name;
|
||||
private boolean required;
|
||||
private String queryProperty;
|
||||
private List<Dependency> dependencies;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getQueryProperty() {
|
||||
return queryProperty;
|
||||
}
|
||||
|
||||
public void setQueryProperty(String queryProperty) {
|
||||
this.queryProperty = queryProperty;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public List<Dependency> getDependencies() {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
public void setDependencies(List<Dependency> dependencies) {
|
||||
this.dependencies = dependencies;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package eu.eudat.models.dynamicfields;
|
||||
|
||||
import eu.eudat.models.helpermodels.Tuple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/27/2018.
|
||||
*/
|
||||
public class DynamicFieldWithValue {
|
||||
private String id;
|
||||
private String name;
|
||||
private boolean required;
|
||||
private String queryProperty;
|
||||
private Tuple<String,String> value;
|
||||
private List<Dependency> dependencies;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getQueryProperty() {
|
||||
return queryProperty;
|
||||
}
|
||||
|
||||
public void setQueryProperty(String queryProperty) {
|
||||
this.queryProperty = queryProperty;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public List<Dependency> getDependencies() {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
public void setDependencies(List<Dependency> dependencies) {
|
||||
this.dependencies = dependencies;
|
||||
}
|
||||
|
||||
public Tuple<String, String> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Tuple<String, String> value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package eu.eudat.models.entities.xmlmodels.dmpprofiledefinition;
|
||||
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
import eu.eudat.utilities.interfaces.XmlSerializable;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public class DataManagementPlanProfile implements XmlSerializable<DataManagementPlanProfile> {
|
||||
|
||||
private List<Field> fields;
|
||||
|
||||
public List<Field> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(List<Field> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = doc.createElement("root");
|
||||
Element fields = doc.createElement("fields");
|
||||
for (Field field : this.fields) {
|
||||
fields.appendChild(field.toXml(doc));
|
||||
}
|
||||
root.appendChild(fields);
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataManagementPlanProfile fromXml(Element item) {
|
||||
this.fields = new LinkedList();
|
||||
Element fields = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "fields");
|
||||
if (fields != null) {
|
||||
NodeList fieldElements = fields.getChildNodes();
|
||||
for (int temp = 0; temp < fieldElements.getLength(); temp++) {
|
||||
Node fieldElement = fieldElements.item(temp);
|
||||
if (fieldElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||
this.fields.add(new Field().fromXml((Element) fieldElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package eu.eudat.models.entities.xmlmodels.dmpprofiledefinition;
|
||||
|
||||
import eu.eudat.models.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileFieldDataType;
|
||||
import eu.eudat.models.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileType;
|
||||
import eu.eudat.utilities.interfaces.XmlSerializable;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public class Field implements XmlSerializable<Field> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private DMPProfileType type;
|
||||
|
||||
private DMPProfileFieldDataType dataType;
|
||||
|
||||
private Boolean required;
|
||||
|
||||
private String label;
|
||||
|
||||
private Object value;
|
||||
|
||||
public UUID getId() {
|
||||
if (this.id == null) this.id = UUID.randomUUID();
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type.getValue();
|
||||
}
|
||||
|
||||
public void setType(DMPProfileType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getDataType() {
|
||||
return dataType.getValue();
|
||||
}
|
||||
|
||||
public void setDataType(DMPProfileFieldDataType dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
public Boolean getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(Boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element rootElement = doc.createElement("field");
|
||||
rootElement.setAttribute("id", this.getId().toString());
|
||||
rootElement.setAttribute("type", this.type.getValue().toString());
|
||||
rootElement.setAttribute("datatype", "" + this.dataType.getValue().toString());
|
||||
rootElement.setAttribute("required", this.required.toString());
|
||||
rootElement.setAttribute("label", this.label);
|
||||
return rootElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public eu.eudat.models.entities.xmlmodels.dmpprofiledefinition.Field fromXml(Element item) {
|
||||
this.id = UUID.fromString(item.getAttribute("id"));
|
||||
this.label = item.getAttribute("label");
|
||||
this.dataType = DMPProfileFieldDataType.fromInteger(Integer.parseInt(item.getAttribute("datatype")));
|
||||
this.required = Boolean.valueOf(item.getAttribute("required"));
|
||||
this.type = DMPProfileType.fromInteger(Integer.parseInt(item.getAttribute("type")));
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package eu.eudat.models.entities.xmlmodels.dmpprofiledefinition;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/22/2018.
|
||||
*/
|
||||
public class FieldValues {
|
||||
private String id;
|
||||
private String value;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package eu.eudat.models.entities.xmlmodels.dmpprofiledefinition.types;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public enum DMPProfileFieldDataType {
|
||||
DATE(0), NUMBER(1), TEXT(2);
|
||||
|
||||
private Integer value;
|
||||
|
||||
private DMPProfileFieldDataType(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DMPProfileFieldDataType fromInteger(Integer value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return DATE;
|
||||
case 1:
|
||||
return NUMBER;
|
||||
case 2:
|
||||
return TEXT;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported DMPProfileFieldData Type");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package eu.eudat.models.entities.xmlmodels.dmpprofiledefinition.types;
|
||||
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public enum DMPProfileType {
|
||||
INPUT(0);
|
||||
|
||||
private Integer value;
|
||||
|
||||
DMPProfileType(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DMPProfileType fromInteger(Integer value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return INPUT;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported DMPProfile Type");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package eu.eudat.models.helpermodels;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/28/2018.
|
||||
*/
|
||||
public class Pair {
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package eu.eudat.models.helpermodels;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/23/2018.
|
||||
*/
|
||||
public class Tuple<L, R> {
|
||||
private L id;
|
||||
private R label;
|
||||
|
||||
public Tuple() {
|
||||
}
|
||||
|
||||
public Tuple(L id, R label) {
|
||||
this.id = id;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public L getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(L id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public R getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(R label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Tuple<?, ?> tuple = (Tuple<?, ?>) o;
|
||||
|
||||
if (id != null ? !id.equals(tuple.getId()) : tuple.id != null) return false;
|
||||
return label != null ? label.equals(tuple.label) : tuple.label == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (label != null ? label.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package eu.eudat.models.listingmodels;
|
||||
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public class DataManagementPlanProfileListingModel implements DataModel<DMPProfile, DataManagementPlanProfileListingModel> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String label;
|
||||
|
||||
private DataManagementPlanProfile definition;
|
||||
|
||||
private int status;
|
||||
|
||||
private Date created = null;
|
||||
|
||||
private Date modified = new Date();
|
||||
|
||||
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 DataManagementPlanProfile getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(DataManagementPlanProfile definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Date getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void setModified(Date modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataManagementPlanProfileListingModel fromDataModel(DMPProfile entity) {
|
||||
this.id = entity.getId();
|
||||
this.created = entity.getCreated();
|
||||
this.definition = new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getDefinition()).getDocumentElement());
|
||||
this.modified = entity.getModified();
|
||||
this.label = entity.getLabel();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPProfile toDataModel() throws Exception {
|
||||
Document document = XmlBuilder.getDocument();
|
||||
document.appendChild(this.definition.toXml(document));
|
||||
DMPProfile dmpProfile = new DMPProfile();
|
||||
dmpProfile.setCreated(this.created == null ? new Date() : this.created);
|
||||
dmpProfile.setDefinition(XmlBuilder.generateXml(document));
|
||||
dmpProfile.setId(this.id);
|
||||
dmpProfile.setLabel(this.label);
|
||||
dmpProfile.setStatus(this.status);
|
||||
dmpProfile.setModified(this.modified == null ? new Date() : this.modified);
|
||||
return dmpProfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -3,9 +3,6 @@ package eu.eudat.proxy.config;
|
|||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
//private static String DATAPATH = "$['data'][*]['attributes']['pid','name','uri','description']";
|
||||
//private static String PAGINATIONPATH = "$['meta']['pagination']['page','pages','count']";
|
||||
|
||||
public class UrlConfig {
|
||||
|
||||
private Integer ordinal;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class DevelConfigLoader implements ConfigLoader {
|
|||
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class);
|
||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||
is = new URL("file:///C:/Users/ikalyvas/Documents/Projects/OpenAIRE-EUDAT-DMP-service-pilot/dmp-backend/src/main/resources/ExternalUrls.xml").openStream();
|
||||
is = new URL("file:///C:/Users/ikalyvas/Documents/OpenAIRE-EUDAT-DMP-service-pilot/dmp-backend/src/main/resources/ExternalUrls.xml").openStream();
|
||||
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(is);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.proxy.fetching;
|
|||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import eu.eudat.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.proxy.config.FetchStrategy;
|
||||
import eu.eudat.proxy.config.UrlConfig;
|
||||
import eu.eudat.proxy.config.configloaders.ConfigLoader;
|
||||
|
@ -20,12 +21,15 @@ import java.util.*;
|
|||
@Service
|
||||
public class RemoteFetcher {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ConfigLoader configLoader;
|
||||
|
||||
// private static int MAX_RESULTS = 30;
|
||||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
|
||||
@Autowired
|
||||
public RemoteFetcher(ConfigLoader configLoader, DynamicProjectConfiguration dynamicProjectConfiguration) {
|
||||
this.configLoader = configLoader;
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
}
|
||||
|
||||
@Cacheable("repositories")
|
||||
public List<Map<String, String>> getRepositories(String query) throws NoURLFound, HugeResultSet {
|
||||
|
@ -36,7 +40,7 @@ public class RemoteFetcher {
|
|||
|
||||
@Cacheable("projects")
|
||||
public List<Map<String, String>> getProjects(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getProjects().getUrls();
|
||||
List<UrlConfig> urlConfigs = Arrays.asList(this.dynamicProjectConfiguration.getConfiguration().getMainExternalField().getUrlConfig());
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getProjects().getFetchMode();
|
||||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
@ -82,7 +86,7 @@ public class RemoteFetcher {
|
|||
if (urlConfigs == null || urlConfigs.isEmpty())
|
||||
throw new NoURLFound("No Repository urls found in configuration");
|
||||
|
||||
Collections.sort(urlConfigs, (config1, config2) -> config1.getOrdinal().compareTo(config2.getOrdinal()));
|
||||
Collections.sort(urlConfigs, Comparator.comparing(UrlConfig::getOrdinal));
|
||||
|
||||
return getAllResultsFromUrl(urlConfigs.get(0).getUrl(), fetchStrategy, urlConfigs.get(0).getDataPath(), urlConfigs.get(0).getPaginationPath(), query);
|
||||
|
||||
|
|
|
@ -39,4 +39,6 @@ public interface DatabaseRepository {
|
|||
UserDmpDao getUserDmpDao();
|
||||
|
||||
ContentDao getContentDao();
|
||||
|
||||
DMPProfileDao getDmpProfileDao();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
|||
private UserRoleDao userRoleDao;
|
||||
private UserDmpDao userDmpDao;
|
||||
private ContentDao contentDao;
|
||||
private DMPProfileDao dmpProfileDao;
|
||||
|
||||
private EntityManager entityManager;
|
||||
|
||||
|
@ -206,4 +207,14 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
|||
public void setContentDao(ContentDao contentDao) {
|
||||
this.contentDao = contentDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPProfileDao getDmpProfileDao() {
|
||||
return dmpProfileDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setDmpProfileDao(DMPProfileDao dmpProfileDao) {
|
||||
this.dmpProfileDao = dmpProfileDao;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
<configuration>
|
||||
<configurationProperties>
|
||||
<property>
|
||||
<id>field1</id>
|
||||
<name>DMP-EDITOR.FIELDS.PROJECT</name>
|
||||
<sourceUrl>http://localhost:9091/api/project/</sourceUrl>
|
||||
<queryProperty>search</queryProperty>
|
||||
<externalFieldId>id</externalFieldId>
|
||||
<externalFieldLabel>name</externalFieldLabel>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<id>field2</id>
|
||||
<queryProperty>funder</queryProperty>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<required>false</required>
|
||||
</property>
|
||||
<property>
|
||||
<id>field2</id>
|
||||
<name>DMP-EDITOR.FIELDS.FUNDER</name>
|
||||
<sourceUrl>http://localhost:9091/api/funder/</sourceUrl>
|
||||
<queryProperty>search</queryProperty>
|
||||
<externalFieldId>id</externalFieldId>
|
||||
<externalFieldLabel>name</externalFieldLabel>
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
<required>false</required>
|
||||
</property>
|
||||
<property>
|
||||
<id>field3</id>
|
||||
<name>DMP-EDITOR.FIELDS.GRANT</name>
|
||||
<sourceUrl>http://localhost:9091/api/grant/</sourceUrl>
|
||||
<queryProperty>search</queryProperty>
|
||||
<externalFieldId>id</externalFieldId>
|
||||
<externalFieldLabel>name</externalFieldLabel>
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
<required>false</required>
|
||||
</property>
|
||||
</configurationProperties>
|
||||
<mainExternalField>
|
||||
<id>field3</id>
|
||||
<name>project.configuration.grant.name</name>
|
||||
<urlConfig>
|
||||
<ordinal>1</ordinal>
|
||||
<url>https://eestore.paas2.uninett.no/api/projectrepo/</url>
|
||||
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
|
||||
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
||||
</urlConfig>
|
||||
<externalFieldId>pid</externalFieldId>
|
||||
<externalFieldLabel>name</externalFieldLabel>
|
||||
<language>
|
||||
<languageProperty>
|
||||
<key>navbar</key>
|
||||
<languageKey>NAV-BAR.PROJECTS</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>listingTitle</key>
|
||||
<languageKey>PROJECT-LISTING.TITLE</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>editorTitle</key>
|
||||
<languageKey>PROJECT-EDITOR.TITLE.NEW</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>editorLogo</key>
|
||||
<languageKey>PROJECT-EDITOR.FIELDS.LOGO</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>dmpEditor</key>
|
||||
<languageKey>DMP-EDITOR.FIELDS.PROJECT</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>criteriaStart</key>
|
||||
<languageKey>CRITERIA.PROJECTS.PERIOD-FROM</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>criteriaEnd</key>
|
||||
<languageKey>CRITERIA.PROJECTS.PERIOD-TO</languageKey>
|
||||
</languageProperty>
|
||||
<languageProperty>
|
||||
<key>dmpCriteria</key>
|
||||
<languageKey>CRITERIA.DMP.PROJECTS</languageKey>
|
||||
</languageProperty>
|
||||
</language>
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
<required></required>
|
||||
</mainExternalField>
|
||||
</configuration>
|
|
@ -59,4 +59,8 @@ b2access.externallogin.clientSecret=A3b*1*92
|
|||
#################################################################################
|
||||
pdf.converter.url=http://localhost/
|
||||
files.storage.temp = temp
|
||||
files.storage.final = final
|
||||
files.storage.final = final
|
||||
#################################################################################
|
||||
project.configuration.project.name = Project
|
||||
project.configuration.funder.name = Funder
|
||||
project.configuration.grant.name = Grant
|
|
@ -0,0 +1,51 @@
|
|||
import { BaseHttpService } from "../utilities/cite-http-service-module/base-http.service";
|
||||
import { HttpClient, HttpClientModule } from "@angular/common/http";
|
||||
import { TranslateLoader } from "@ngx-translate/core";
|
||||
import { TranslateModule } from "@ngx-translate/core";
|
||||
import { SharedModule } from "../shared/shared.module";
|
||||
import { FormsModule } from "@angular/forms";
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { NgModule } from "@angular/core";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
|
||||
import { AboutRoutes } from "./about.routes";
|
||||
import { AboutComponent } from "./components/about.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
SharedModule,
|
||||
HttpClientModule,
|
||||
AboutRoutes,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
],
|
||||
|
||||
declarations: [
|
||||
AboutComponent
|
||||
],
|
||||
|
||||
exports: [
|
||||
AboutComponent
|
||||
],
|
||||
providers: [
|
||||
BaseHttpService
|
||||
]
|
||||
})
|
||||
|
||||
export class AboutModule {
|
||||
constructor(private translate: TranslateService) {
|
||||
translate.setDefaultLang('en');
|
||||
translate.use('en');
|
||||
}
|
||||
}
|
||||
|
||||
export function HttpLoaderFactory(httpClient: HttpClient) {
|
||||
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import { AboutComponent } from "./components/about.component";
|
||||
import { Routes, RouterModule } from "@angular/router";
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: AboutComponent },
|
||||
];
|
||||
|
||||
export const AboutRoutes = RouterModule.forChild(routes);
|
|
@ -0,0 +1 @@
|
|||
about
|
|
@ -0,0 +1,22 @@
|
|||
import { Component, ViewEncapsulation, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
||||
@Component({
|
||||
selector: 'app-about',
|
||||
templateUrl: './about.component.html',
|
||||
styleUrls: ['./about.component.scss'],
|
||||
providers: [],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class AboutComponent implements OnInit {
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,8 +10,10 @@ import { B2AccessLoginComponent } from './user-management/login/b2access/b2acces
|
|||
|
||||
const appRoutes: Routes = [
|
||||
{ path: 'datasets', loadChildren: './datasets/dataset.module#DatasetModule', canActivate: [AuthGuard] },
|
||||
{ path: 'about', loadChildren: './about/about.module#AboutModule', canActivate: [AuthGuard] },
|
||||
{ path: 'projects', loadChildren: './projects/projects.module#ProjectsModule', canActivate: [AuthGuard] },
|
||||
{ path: "dmps", loadChildren: './dmps/dmps.module#DataManagementPlanModule', canActivate: [AuthGuard] },
|
||||
{ path: "dmp-profiles", loadChildren: './dmp-profiles/dmp-profile.module#DataManagamentPlanProfileModule', canActivate: [AuthGuard] },
|
||||
{ path: 'form', loadChildren: './dataset-profile-form/dataset-profile.module#DatasetProfileModule', canActivate: [AuthGuard] },
|
||||
{ path: 'home', component: HomepageComponent, canActivate: [AuthGuard] },
|
||||
{ path: '', redirectTo: '/welcome', pathMatch: 'full' },
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute, NavigationExtras } from '@angular/router';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { LanguageResolverService } from './services/language-resolver/language-resolver.service';
|
||||
|
||||
|
||||
declare const gapi: any;
|
||||
|
@ -15,7 +16,7 @@ declare var $: any;
|
|||
})
|
||||
export class AppComponent implements OnInit {
|
||||
|
||||
constructor(private router: Router, private route: ActivatedRoute, private translate: TranslateService) {
|
||||
constructor(private router: Router, private route: ActivatedRoute, private translate: TranslateService, private languageService: LanguageResolverService) {
|
||||
// this language will be used as a fallback when a translation isn't found in the current language
|
||||
translate.setDefaultLang('en');
|
||||
// the lang to use, if the lang isn't available, it will use the current loader to get them
|
||||
|
|
|
@ -35,6 +35,8 @@ import { HelpContentService } from './services/help-content/help-content.service
|
|||
import { HelpContentComponent } from './help-content/help-content.component';
|
||||
import { B2AccessLoginComponent } from './user-management/login/b2access/b2access-login.component';
|
||||
import { RecentActivityComponent } from '@app/users/activity/recent-activity.component';
|
||||
import { LanguageResolverService } from './services/language-resolver/language-resolver.service';
|
||||
import { LanguageService } from './services/language/language.service';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -96,7 +98,9 @@ import { RecentActivityComponent } from '@app/users/activity/recent-activity.com
|
|||
AuthService,
|
||||
DashboardService,
|
||||
BaseHttpService,
|
||||
HelpContentService
|
||||
HelpContentService,
|
||||
LanguageService,
|
||||
LanguageResolverService
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
|
||||
<div class="dmp-profile-editor">
|
||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
||||
<mat-card>
|
||||
<mat-card-header>
|
||||
<mat-card-title *ngIf="isNew">{{'DMP-PROFILE-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
|
||||
<mat-card-title *ngIf="!isNew">{{formGroup.get('label').value}}</mat-card-title>
|
||||
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
|
||||
<mat-form-field class="full-width">
|
||||
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label"
|
||||
required>
|
||||
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div formGroupName="definition">
|
||||
<mat-list formArrayName="fields">
|
||||
<mat-list-item *ngFor="let field of formGroup.controls.definition.controls.fields.controls;let i=index">
|
||||
<div [formGroupName]="i">
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label"
|
||||
required>
|
||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('label').errors?.required">{{baseErrorModel.label}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('label').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.TYPE' | translate}}" formControlName="type">
|
||||
<mat-option *ngFor="let fieldType of getDMPProfileFieldTypeValues()" [value]="fieldType">{{ getDMPProfileFieldTypeWithLanguage(fieldType) | translate}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.required">{{baseErrorModel.type}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.DATATYPE' | translate}}" formControlName="dataType">
|
||||
<mat-option *ngFor="let fieldDataType of getDMPProfileFieldDataTypeValues()" [value]="fieldDataType">{{ getDMPProfileFieldDataTypeWithLanguage(fieldDataType) | translate}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.required">{{baseErrorModel.dataType}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-checkbox formControlName="required">
|
||||
{{'DMP-PROFILE-EDITOR.FIELDS.REQUIRED' | translate}}
|
||||
</mat-checkbox>
|
||||
</div>
|
||||
</mat-list-item>
|
||||
<button mat-fab class="mat-fab-bottom-right" color="primary" type="button" (click)="addField()">
|
||||
<mat-icon class="mat-24">add</mat-icon>
|
||||
</button>
|
||||
</mat-list>
|
||||
</div>
|
||||
<div layout="row" class="full-width text-right" align="end">
|
||||
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
||||
<button mat-raised-button color="primary" type="submit">{{'DMP-PROFILE-EDITOR.ACTIONS.SAVE' | translate}}</button>
|
||||
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="delete()">{{'DMP-PROFILE-EDITOR.ACTIONS.DELETE' | translate}}</button>
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</form>
|
||||
</div>
|
|
@ -0,0 +1,39 @@
|
|||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input-table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.table-card .mat-grid-tile {
|
||||
background: rgba(0, 0, 0, 0.32);
|
||||
}
|
||||
|
||||
.dmp-profile-editor {
|
||||
|
||||
.mat-form-field-full-width{
|
||||
mat-form-field {
|
||||
width: 100%;
|
||||
padding: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.mat-card {
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 16px;
|
||||
}
|
||||
|
||||
.left-button {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.description-area {
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
|
||||
import { ProjectModel } from "../../models/projects/ProjectModel";
|
||||
import { ProjectService } from "../../services/project/project.service";
|
||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||
import { FormGroup, AbstractControl, FormControl, FormArray } from "@angular/forms";
|
||||
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
|
||||
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
|
||||
import { TdDialogService } from "@covalent/core";
|
||||
import { HostConfiguration } from "@app/app.constants";
|
||||
import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service";
|
||||
import { DataManagementPlanProfileModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileModel";
|
||||
import { DMPProfileFieldDataType, DMPProfileType, DataManagementProfileField } from "../../models/data-management-plan-profile/DataManagementProfileField";
|
||||
import { Utilities } from "../../utilities/utilities";
|
||||
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-profile-editor-component',
|
||||
templateUrl: 'dmp-profile-editor.component.html',
|
||||
styleUrls: ['./dmp-profile-editor.component.scss'],
|
||||
providers: [DataManagementPlanProfileService],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DataManagementPlanProfileEditorComponent implements AfterViewInit {
|
||||
|
||||
isNew = true;
|
||||
dataManagementPlanProfileModel: DataManagementPlanProfileModel;
|
||||
formGroup: FormGroup = null;
|
||||
host = HostConfiguration.Server;
|
||||
baseErrorModel: BaseErrorModel;
|
||||
constructor(
|
||||
private dmpProfileService: DataManagementPlanProfileService,
|
||||
private route: ActivatedRoute,
|
||||
public snackBar: MatSnackBar,
|
||||
public router: Router,
|
||||
public language: TranslateService,
|
||||
private dialogService: TdDialogService
|
||||
) {
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.route.params.subscribe((params: Params) => {
|
||||
const itemId = params['id'];
|
||||
|
||||
if (itemId != null) {
|
||||
this.isNew = false;
|
||||
this.dmpProfileService.getSingle(itemId).map(data => data as DataManagementPlanProfileModel)
|
||||
.subscribe(data => {
|
||||
this.dataManagementPlanProfileModel = JsonSerializer.fromJSONObject(data, DataManagementPlanProfileModel);
|
||||
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
|
||||
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
|
||||
});
|
||||
} else {
|
||||
this.dataManagementPlanProfileModel = new DataManagementPlanProfileModel();
|
||||
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
|
||||
|
||||
setTimeout(() => {
|
||||
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
formSubmit(): void {
|
||||
this.touchAllFormFields(this.formGroup);
|
||||
if (!this.isFormValid()) { return; }
|
||||
this.onSubmit();
|
||||
}
|
||||
|
||||
public isFormValid() {
|
||||
return this.formGroup.valid;
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
this.dmpProfileService.createDataManagementPlan(this.formGroup.value).subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
|
||||
onCallbackSuccess(): void {
|
||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||
duration: 3000,
|
||||
extraClasses: ['snackbar-success']
|
||||
})
|
||||
this.router.navigate(['/dmp-profiles']);
|
||||
}
|
||||
|
||||
onCallbackError(errorResponse: any) {
|
||||
this.setErrorModel(errorResponse.error);
|
||||
this.validateAllFormFields(this.formGroup);
|
||||
}
|
||||
|
||||
public setErrorModel(errorModel: BaseErrorModel) {
|
||||
Object.keys(errorModel).forEach(item => {
|
||||
(<any>this.dataManagementPlanProfileModel.errorModel)[item] = (<any>errorModel)[item];
|
||||
})
|
||||
}
|
||||
|
||||
public cancel(): void {
|
||||
this.router.navigate(['/dmp-profiles']);
|
||||
}
|
||||
|
||||
|
||||
public touchAllFormFields(formControl: AbstractControl) {
|
||||
if (formControl instanceof FormControl) {
|
||||
formControl.markAsTouched();
|
||||
} else if (formControl instanceof FormGroup) {
|
||||
Object.keys(formControl.controls).forEach(item => {
|
||||
const control = formControl.get(item);
|
||||
this.touchAllFormFields(control);
|
||||
})
|
||||
}
|
||||
else if (formControl instanceof FormArray) {
|
||||
formControl.controls.forEach(item => {
|
||||
this.touchAllFormFields(item);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public validateAllFormFields(formControl: AbstractControl) {
|
||||
if (formControl instanceof FormControl) {
|
||||
formControl.updateValueAndValidity({ emitEvent: false })
|
||||
} else if (formControl instanceof FormGroup) {
|
||||
Object.keys(formControl.controls).forEach(item => {
|
||||
const control = formControl.get(item);
|
||||
this.validateAllFormFields(control);
|
||||
})
|
||||
}
|
||||
else if (formControl instanceof FormArray) {
|
||||
formControl.controls.forEach(item => {
|
||||
this.validateAllFormFields(item);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
addField() {
|
||||
(<FormArray>this.formGroup.get("definition").get("fields")).push(new DataManagementProfileField().buildForm())
|
||||
}
|
||||
|
||||
getDMPProfileFieldDataTypeValues(): Number[] {
|
||||
let keys: string[] = Object.keys(DMPProfileFieldDataType);
|
||||
keys = keys.slice(0, keys.length / 2);
|
||||
const values: Number[] = keys.map(Number);
|
||||
return values;
|
||||
}
|
||||
|
||||
getDMPProfileFieldDataTypeWithLanguage(role: DMPProfileFieldDataType): string {
|
||||
let result = '';
|
||||
this.language.get(new Utilities().convertFromDMPProfileDataType(role)).subscribe((value: string) => {
|
||||
result = value;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
getDMPProfileFieldTypeValues(): Number[] {
|
||||
let keys: string[] = Object.keys(DMPProfileType);
|
||||
keys = keys.slice(0, keys.length / 2);
|
||||
const values: Number[] = keys.map(Number);
|
||||
return values;
|
||||
}
|
||||
|
||||
getDMPProfileFieldTypeWithLanguage(role: DMPProfileType): string {
|
||||
let result = '';
|
||||
this.language.get(new Utilities().convertFromDMPProfileType(role)).subscribe((value: string) => {
|
||||
result = value;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<div class="container-fluid">
|
||||
<h3>{{titlePrefix}} {{'DATASET-LISTING.TITLE' | translate}}</h3>
|
||||
|
||||
|
||||
<app-dmp-profile-criteria-component></app-dmp-profile-criteria-component>
|
||||
<mat-card class="mat-card">
|
||||
<mat-card-header>
|
||||
<mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
|
||||
</mat-card-header>
|
||||
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
|
||||
|
||||
<!-- Column Definition: Name -->
|
||||
<ng-container cdkColumnDef="label">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header="label">{{'DATASET-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Column Definition: status -->
|
||||
<ng-container cdkColumnDef="status">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header="status">{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.status}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Column Definition: Created -->
|
||||
<ng-container cdkColumnDef="created">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DATASET-LISTING.COLUMNS.CREATED' | translate}}</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.created | date:'shortDate'}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Column Definition: Submission Time -->
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
|
||||
<!-- (click)="rowClick(row.id)" -->
|
||||
|
||||
</mat-table>
|
||||
<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
|
||||
</mat-paginator>
|
||||
</mat-card>
|
||||
|
||||
<button mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]="['/dmp-profiles/new'] ">
|
||||
<mat-icon class="mat-24">add</mat-icon>
|
||||
</button>
|
||||
</div>
|
|
@ -0,0 +1,35 @@
|
|||
.mat-table {
|
||||
margin: 24px;
|
||||
}
|
||||
|
||||
.mat-fab-bottom-right {
|
||||
top: auto !important;
|
||||
right: 20px !important;
|
||||
bottom: 10px !important;
|
||||
left: auto !important;
|
||||
position: fixed !important;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mat-card {
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.mat-row {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
mat-row:hover {
|
||||
background-color: lightgray;
|
||||
}
|
||||
|
||||
// mat-row:nth-child(even){
|
||||
// background-color:red;
|
||||
// }
|
||||
|
||||
mat-row:nth-child(odd){
|
||||
background-color:#eef0fb;
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
import { Component, ViewChild, OnInit } from "@angular/core";
|
||||
import { MatPaginator, MatSort, PageEvent, MatSnackBar } from "@angular/material";
|
||||
import { DataManagementPlanProfileCriteriaComponent } from "../../shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component";
|
||||
import { ActivatedRoute, Router, Params } from "@angular/router";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria";
|
||||
import { Observable } from "rxjs";
|
||||
import { DataTableRequest } from "../../models/data-table/DataTableRequest";
|
||||
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
|
||||
import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-profile-listing-component',
|
||||
templateUrl: 'dmp-profile-listing.component.html',
|
||||
styleUrls: ['./dmp-profile-listing.component.scss'],
|
||||
providers: [DataManagementPlanProfileService]
|
||||
})
|
||||
export class DataManagementPlanProfileListingComponent implements OnInit {
|
||||
|
||||
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
@ViewChild(DataManagementPlanProfileCriteriaComponent) criteria: DataManagementPlanProfileCriteriaComponent;
|
||||
|
||||
|
||||
dataSource: DatasetDataSource | null;
|
||||
displayedColumns: String[] = ['label', 'status', 'created'];
|
||||
pageEvent: PageEvent;
|
||||
titlePrefix: String;
|
||||
dmpId: String;
|
||||
|
||||
statuses = [
|
||||
{ value: '0', viewValue: 'Active' },
|
||||
{ value: '1', viewValue: 'Inactive' }
|
||||
];
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private languageService: TranslateService,
|
||||
public snackBar: MatSnackBar,
|
||||
public route: ActivatedRoute,
|
||||
public dataManagementPlanService: DataManagementPlanProfileService
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe((params: Params) => {
|
||||
this.dmpId = params['dmpId'];
|
||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||
this.refresh();
|
||||
this.criteria.setRefreshCallback(() => this.refresh());
|
||||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.dataSource = new DatasetDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
|
||||
}
|
||||
|
||||
rowClick(rowId: String) {
|
||||
this.router.navigate(['dmp-profiles/' + rowId]);
|
||||
}
|
||||
|
||||
getDefaultCriteria(): DataManagementPlanProfileCriteria {
|
||||
const defaultCriteria = new DataManagementPlanProfileCriteria();
|
||||
return defaultCriteria;
|
||||
}
|
||||
|
||||
// makeItPublic(id: String) {
|
||||
// debugger;
|
||||
// this.datasetService.makeDatasetPublic(id).subscribe();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
export class DatasetDataSource extends DataSource<DataManagementPlanProfileListingModel> {
|
||||
|
||||
totalCount = 0;
|
||||
isLoadingResults = false;
|
||||
|
||||
constructor(
|
||||
private _service: DataManagementPlanProfileService,
|
||||
private _paginator: MatPaginator,
|
||||
private _sort: MatSort,
|
||||
private _languageService: TranslateService,
|
||||
private _snackBar: MatSnackBar,
|
||||
private _criteria: DataManagementPlanProfileCriteriaComponent
|
||||
) {
|
||||
super();
|
||||
|
||||
}
|
||||
|
||||
connect(): Observable<DataManagementPlanProfileListingModel[]> {
|
||||
const displayDataChanges = [
|
||||
this._paginator.page
|
||||
//this._sort.matSortChange
|
||||
];
|
||||
|
||||
|
||||
return Observable.merge(...displayDataChanges)
|
||||
.startWith(null)
|
||||
.switchMap(() => {
|
||||
setTimeout(() => {
|
||||
this.isLoadingResults = true;
|
||||
});
|
||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||
let fields: Array<string> = new Array()
|
||||
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
|
||||
const request = new DataTableRequest<DataManagementPlanProfileCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||
request.criteria = this._criteria.criteria;
|
||||
return this._service.getPaged(request);
|
||||
})
|
||||
/*.catch((error: any) => {
|
||||
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
||||
duration: 3000,
|
||||
extraClasses: ['snackbar-warning']
|
||||
});
|
||||
//this._criteria.criteria.onCallbackError(error);
|
||||
return Observable.of(null);
|
||||
})*/
|
||||
.map(result => {
|
||||
setTimeout(() => {
|
||||
this.isLoadingResults = false;
|
||||
});
|
||||
return result;
|
||||
})
|
||||
.map(result => {
|
||||
if (!result) { return []; }
|
||||
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
||||
return result.data;
|
||||
});
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
// No-op
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
import { RouterModule } from '@angular/router';
|
||||
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
||||
import { DatasetService } from '../services/dataset/dataset.service';
|
||||
import { DynamicFormModule } from '../form/dynamic-form.module';
|
||||
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
import { SharedModule } from '../shared/shared.module'
|
||||
import { DataManagementPlanProfileRoutes } from './dmp-profile.routes';
|
||||
import { DataManagementPlanProfileEditorComponent } from './dmp-profile-editor/dmp-profile-editor.component';
|
||||
import { DataManagementPlanProfileListingComponent } from './dmp-profile-listing/dmp-profile-listing.component';
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
HttpClientModule,
|
||||
SharedModule,
|
||||
RouterModule.forChild(DataManagementPlanProfileRoutes),
|
||||
ReactiveFormsModule,
|
||||
DynamicFormModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
],
|
||||
|
||||
declarations: [
|
||||
DataManagementPlanProfileEditorComponent,
|
||||
DataManagementPlanProfileListingComponent
|
||||
],
|
||||
|
||||
exports: [
|
||||
DataManagementPlanProfileEditorComponent,
|
||||
DataManagementPlanProfileListingComponent,
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
DatasetService
|
||||
]
|
||||
})
|
||||
|
||||
export class DataManagamentPlanProfileModule {
|
||||
constructor(private translate: TranslateService) {
|
||||
translate.setDefaultLang('en');
|
||||
translate.use('en');
|
||||
}
|
||||
}
|
||||
|
||||
export function HttpLoaderFactory(httpClient: HttpClient) {
|
||||
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import { AuthGuard } from '../guards/auth.guard';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { DataManagementPlanProfileListingComponent } from './dmp-profile-listing/dmp-profile-listing.component';
|
||||
import { DataManagementPlanProfileEditorComponent } from './dmp-profile-editor/dmp-profile-editor.component';
|
||||
|
||||
export const DataManagementPlanProfileRoutes: Routes = [
|
||||
{ path: '', component: DataManagementPlanProfileListingComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'new', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
|
||||
{ path: ':id', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
|
||||
];
|
|
@ -18,6 +18,9 @@ import { CovalentDialogsModule } from '@covalent/core';
|
|||
import { SharedModule } from '../shared/shared.module'
|
||||
import { NgModule } from '@angular/core';
|
||||
import { AvailableProfilesComponent } from '@app/available-profiles/available-profiles.component';
|
||||
import { DynamicDmpFieldResolver } from './editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component';
|
||||
import { DynamicFieldsProjectComponent } from './editor/dynamic-fields-project/dynamic-fields-project.component';
|
||||
import { DynamicFieldProjectComponent } from './editor/dynamic-fields-project/dynamic-field-project/dynamic-field-project.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -46,7 +49,10 @@ import { AvailableProfilesComponent } from '@app/available-profiles/available-pr
|
|||
DataManagementPlanWizardEditorComponent,
|
||||
DatasetWizardListingComponent,
|
||||
AddResearchersComponent,
|
||||
AvailableProfilesComponent
|
||||
AvailableProfilesComponent,
|
||||
DynamicDmpFieldResolver,
|
||||
DynamicFieldsProjectComponent,
|
||||
DynamicFieldProjectComponent
|
||||
],
|
||||
|
||||
exports: [
|
||||
|
@ -57,9 +63,11 @@ import { AvailableProfilesComponent } from '@app/available-profiles/available-pr
|
|||
DataManagementPlanWizardComponent,
|
||||
DataManagementPlanWizardEditorComponent,
|
||||
DatasetWizardListingComponent,
|
||||
AddResearchersComponent,
|
||||
AvailableProfilesComponent
|
||||
|
||||
AddResearchersComponent,
|
||||
AvailableProfilesComponent,
|
||||
DynamicFieldsProjectComponent,
|
||||
DynamicFieldProjectComponent
|
||||
|
||||
],
|
||||
entryComponents: [
|
||||
InvitationComponent,
|
||||
|
@ -76,7 +84,7 @@ export class DataManagementPlanModule {
|
|||
translate.setDefaultLang('en');
|
||||
translate.use('en');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function HttpLoaderFactory(httpClient: HttpClient) {
|
||||
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
<div class="data-management-plan-editor">
|
||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
||||
<mat-card>
|
||||
<mat-form-field class="full-width">
|
||||
<input type="text" placeholder="{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}" [formControl]="textCtrl" matInput [matAutocomplete]="auto">
|
||||
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayWith">
|
||||
<mat-option *ngFor="let option of filteredOptions | async" [value]="option" (click)="selectOption(option)">
|
||||
{{ option.label }}
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
</mat-form-field>
|
||||
<mat-card-title *ngIf="isNew">{{'DMP-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
|
||||
<mat-card-title *ngIf="!isNew">{{formGroup.get('label').value}}</mat-card-title>
|
||||
<mat-card-content>
|
||||
|
@ -18,10 +26,12 @@
|
|||
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<auto-complete class="mat-form-field-full-width" placeholder="{{'DMP-EDITOR.FIELDS.PROJECT' | translate}}" [configuration]="projectAutoCompleteConfiguration"
|
||||
<auto-complete class="mat-form-field-full-width" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}" [configuration]="projectAutoCompleteConfiguration"
|
||||
titleKey="label" [control]="formGroup.get('project')" [required]="true">
|
||||
</auto-complete>
|
||||
|
||||
<app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project>
|
||||
|
||||
<td-chips color="accent" [items]="filteredProfiles" formControlName="profiles" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
|
||||
(inputChange)="filterProfiles($event)" requireMatch required>
|
||||
<ng-template td-chip let-chip="chip">
|
||||
|
@ -79,6 +89,7 @@
|
|||
<mat-icon aria-label="Example icon-button with a heart icon">add_circle</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
<app-dynamic-dmp-field-resolver class="full-width" *ngIf="dataManagementPlan.definition" [formGroup]="formGroup" [dataManagementPlanProfile]="dataManagementPlan.definition"></app-dynamic-dmp-field-resolver>
|
||||
|
||||
<mat-form-field class="full-width">
|
||||
<input matInput placeholder="Version" disabled [value]="formGroup.get('version').value== undefined ?0 :formGroup.get('version').value">
|
||||
|
@ -101,6 +112,7 @@
|
|||
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)">{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}</button>
|
||||
</div>
|
||||
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</form>
|
||||
|
|
|
@ -5,7 +5,7 @@ import { TranslateService } from "@ngx-translate/core";
|
|||
import { DataSource } from "@angular/cdk/table";
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { FormGroup, FormControl } from "@angular/forms";
|
||||
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
|
||||
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
|
||||
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
|
||||
|
@ -26,18 +26,24 @@ import { TdDialogService } from '@covalent/core';
|
|||
import { AvailableProfilesComponent } from "@app/available-profiles/available-profiles.component";
|
||||
import { AutoCompleteChipConfiguration } from "@app/shared/components/autocompleteChips/AutoCompleteChipConfiguration";
|
||||
import { BaseCriteria } from "@app/models/criteria/BaseCriteria";
|
||||
import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service";
|
||||
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
|
||||
import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria";
|
||||
import { DataManagementPlanProfile } from "../../models/data-management-plan-profile/DataManagementPlanProfile";
|
||||
import { LanguageResolverService } from "../../services/language-resolver/language-resolver.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-editor-component',
|
||||
templateUrl: 'dmp-editor.component.html',
|
||||
styleUrls: ['./dmp-editor.component.scss'],
|
||||
providers: [DataManagementPlanService, ExternalSourcesService, ProjectService],
|
||||
providers: [DataManagementPlanService, ExternalSourcesService, ProjectService, DataManagementPlanProfileService],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DataManagementPlanEditorComponent implements AfterViewInit {
|
||||
|
||||
|
||||
isNew = true;
|
||||
textCtrl = new FormControl();
|
||||
dataManagementPlan: DataManagementPlanModel;
|
||||
formGroup: FormGroup = null;
|
||||
|
||||
|
@ -52,8 +58,10 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
organisationsAutoCompleteConfiguration: AutoCompleteChipConfiguration;
|
||||
createNewVersion;
|
||||
associatedUsers: Array<DmpUsersModel>
|
||||
filteredOptions: Observable<DataManagementPlanProfileListingModel>
|
||||
|
||||
constructor(
|
||||
private dmpProfileService: DataManagementPlanProfileService,
|
||||
private dataManagementPlanService: DataManagementPlanService,
|
||||
private projectService: ProjectService,
|
||||
private externalSourcesService: ExternalSourcesService,
|
||||
|
@ -64,8 +72,10 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
private _service: DataManagementPlanService,
|
||||
public dialog: MatDialog,
|
||||
private _dialogService: TdDialogService,
|
||||
private _viewContainerRef: ViewContainerRef
|
||||
private _viewContainerRef: ViewContainerRef,
|
||||
private languageResolverService: LanguageResolverService
|
||||
) {
|
||||
this.filteredOptions = dmpProfileService.getAll({ criteria: new DataManagementPlanProfileCriteria() });
|
||||
|
||||
}
|
||||
|
||||
|
@ -86,16 +96,22 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
.subscribe(data => {
|
||||
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
|
||||
this.formGroup = this.dataManagementPlan.buildForm();
|
||||
if (this.formGroup.get("profile") && this.formGroup.get("profile").value) {
|
||||
this.textCtrl.patchValue(this.formGroup.get("profile").value);
|
||||
}
|
||||
this.associatedUsers = data.associatedUsers;
|
||||
});
|
||||
} else {
|
||||
this.dataManagementPlan = new DataManagementPlanModel();
|
||||
setTimeout(() => {
|
||||
this.formGroup = this.dataManagementPlan.buildForm();
|
||||
if (this.formGroup.get("profile") && this.formGroup.get("profile").value) {
|
||||
this.textCtrl.patchValue(this.formGroup.get("profile").value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
// let clone = this.route.snapshot.data.clone; ginetai kai esti ikalyvas
|
||||
this.route
|
||||
.queryParams
|
||||
.subscribe(params => {
|
||||
|
@ -259,4 +275,17 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
selectOption(option: any) {
|
||||
this.dataManagementPlan.definition = null;
|
||||
this.formGroup.get("profile").patchValue(option, { emitEvent: false })
|
||||
this.dmpProfileService.getSingle(option.id).subscribe(result => {
|
||||
this.dataManagementPlan.definition = result.definition;
|
||||
})
|
||||
}
|
||||
|
||||
displayWith(item: any) {
|
||||
if (!item) return null;
|
||||
return item["label"];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<div *ngFor="let field of dataManagementPlanProfile.fields; let i = index">
|
||||
<div *ngIf="field.type == DMPProfileType.INPUT">
|
||||
<mat-form-field class="full-width" *ngIf="field.dataType == DMPProfileFieldDataType.DATE">
|
||||
<input matInput [matDatepicker]="picker" [placeholder]="field.label" [formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')">
|
||||
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #picker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="full-width" *ngIf="field.dataType == DMPProfileFieldDataType.TEXT">
|
||||
<input matInput [placeholder]="field.label" [formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')">
|
||||
</mat-form-field>
|
||||
<mat-form-field class="full-width" *ngIf="field.dataType == DMPProfileFieldDataType.NUMBER">
|
||||
<input matInput type="number" [placeholder]="field.label" [formControl]="formGroup.get('properties').get('fields').get(''+i).get('value')">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,12 @@
|
|||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input-table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.table-card .mat-grid-tile {
|
||||
background: rgba(0, 0, 0, 0.32);
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import { Component, ViewEncapsulation, AfterViewInit, Input, OnInit, OnDestroy } from "@angular/core";
|
||||
import { DataManagementPlanProfile } from "../../../models/data-management-plan-profile/DataManagementPlanProfile";
|
||||
import { DMPProfileFieldDataType, DMPProfileType } from "../../../models/data-management-plan-profile/DataManagementProfileField";
|
||||
import { FormGroup, FormBuilder, FormArray } from "@angular/forms";
|
||||
import { LanguageResolverService } from "../../../services/language-resolver/language-resolver.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-dynamic-dmp-field-resolver',
|
||||
templateUrl: 'dynamic-dmp-field-resolver.component.html',
|
||||
styleUrls: ['./dynamic-dmp-field-resolver.component.scss'],
|
||||
providers: [],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DynamicDmpFieldResolver implements OnInit, OnDestroy {
|
||||
|
||||
|
||||
DMPProfileFieldDataType = DMPProfileFieldDataType;
|
||||
DMPProfileType = DMPProfileType;
|
||||
|
||||
@Input()
|
||||
dataManagementPlanProfile: DataManagementPlanProfile;
|
||||
|
||||
@Input()
|
||||
formGroup: FormGroup
|
||||
|
||||
ngOnInit(): void {
|
||||
this.formGroup.addControl("properties", new FormBuilder().group([]));
|
||||
(<FormGroup>this.formGroup.get("properties")).addControl("fields", new FormBuilder().array([]))
|
||||
|
||||
this.dataManagementPlanProfile.fields.forEach(item => {
|
||||
(<FormArray>this.formGroup.get("properties").get("fields")).push(new FormBuilder().group({
|
||||
id: [item.id],
|
||||
value: [item.value]
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.formGroup.removeControl("properties")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<app-auto-complete class="mat-form-field-full-width" placeholder="{{ formGroup.get('name').value | translate }}" [inputData]="autoCompleteConfiguration"
|
||||
titleKey="label" [formCtrl]="formGroup.get('value')" [displayFunction]="displayFunction" [disabled]="hasUnResolvedDependencies()">
|
||||
</app-auto-complete>
|
|
@ -0,0 +1,85 @@
|
|||
import { Component, ViewEncapsulation, OnInit, Input, ViewChild } from "@angular/core";
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { DataManagementPlanService } from "../../../../services/data-management-plan/data-management-plan.service";
|
||||
import { AutoCompleteConfiguration } from "../../../../shared/components/autocomplete/AutoCompleteConfiguration";
|
||||
import { RequestItem } from "../../../../models/criteria/RequestItem";
|
||||
import { DynamicFieldProjectCriteria, DynamicFieldProjectCriteriaDependencies } from "../../../../models/dynamic-field-project/DynamicFieldProjectCriteria";
|
||||
import { AutoCompleteComponent } from "../../../../shared/components/auto-complete/auto-complete.component";
|
||||
import { DynamicFieldDependency } from "../../../../models/data-managemnt-plans/DynamicFieldDependency";
|
||||
import { LanguageResolverService } from "../../../../services/language-resolver/language-resolver.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-dynamic-field-project',
|
||||
templateUrl: 'dynamic-field-project.component.html',
|
||||
styleUrls: ['./dynamic-field-project.component.scss'],
|
||||
providers: [DataManagementPlanService],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DynamicFieldProjectComponent implements OnInit {
|
||||
|
||||
constructor(private languageResolverService: LanguageResolverService, private dmpService: DataManagementPlanService) { }
|
||||
|
||||
@Input()
|
||||
dependencies: Array<FormGroup>
|
||||
|
||||
@Input()
|
||||
formGroup: FormGroup;
|
||||
|
||||
@ViewChild(AutoCompleteComponent)
|
||||
autocomplete: AutoCompleteComponent
|
||||
|
||||
autoCompleteConfiguration: AutoCompleteConfiguration
|
||||
|
||||
ngOnInit(): void {
|
||||
let requestItem = new RequestItem<DynamicFieldProjectCriteria>()
|
||||
requestItem.criteria = { id: this.formGroup.get("id").value, dynamicFields: this.buildDependencies() }
|
||||
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
|
||||
}
|
||||
|
||||
hasUnResolvedDependencies() {
|
||||
if (this.dependencies == null || this.dependencies.length == 0) {
|
||||
if (this.formGroup.get("value").disabled) {
|
||||
this.updateConfiguration();
|
||||
this.formGroup.get("value").enable({ onlySelf: true, emitEvent: false })
|
||||
}
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < this.dependencies.length; i++) {
|
||||
if (!this.dependencies[i].get("value").value) {
|
||||
this.formGroup.get("value").disable({ onlySelf: true, emitEvent: false })
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (this.formGroup.get("value").disabled) {
|
||||
this.updateConfiguration();
|
||||
this.formGroup.get("value").enable({ onlySelf: true, emitEvent: false })
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
updateConfiguration() {
|
||||
let requestItem = new RequestItem<DynamicFieldProjectCriteria>()
|
||||
requestItem.criteria = { id: this.formGroup.get("id").value, dynamicFields: this.buildDependencies() }
|
||||
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
|
||||
this.autocomplete.inputData = this.autoCompleteConfiguration;
|
||||
}
|
||||
|
||||
buildDependencies(): Array<DynamicFieldProjectCriteriaDependencies> {
|
||||
if (!this.dependencies || this.dependencies.length == 0) return []
|
||||
let dependencies = new Array<DynamicFieldProjectCriteriaDependencies>();
|
||||
for (let i = 0; i < this.dependencies.length; i++) {
|
||||
dependencies.push({ property: this.dependencies[i].get("id").value, value: this.assignFunction(this.dependencies[i].get("value").value) })
|
||||
}
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
displayFunction(item: any): any {
|
||||
if(!item) return null;
|
||||
return item["label"];
|
||||
}
|
||||
|
||||
assignFunction(item: any): any {
|
||||
if(!item) return null;
|
||||
return item["id"];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<div *ngIf="formGroup" [formGroup]="formGroup">
|
||||
<div formArrayName="dynamicFields">
|
||||
<div *ngFor="let control of formGroup.get('dynamicFields').controls;let i = index;">
|
||||
<app-dynamic-field-project [formGroup]="control" [dependencies]="findDependencies(i)"></app-dynamic-field-project>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,35 @@
|
|||
import { Component, ViewEncapsulation, OnInit, OnDestroy, Input } from "@angular/core";
|
||||
import { FormGroup, FormArray } from "@angular/forms";
|
||||
import { DynamicFieldDependency } from "../../../models/data-managemnt-plans/DynamicFieldDependency";
|
||||
|
||||
@Component({
|
||||
selector: 'app-dynamic-fields-project',
|
||||
templateUrl: 'dynamic-fields-project.component.html',
|
||||
styleUrls: ['./dynamic-fields-project.component.scss'],
|
||||
providers: [],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DynamicFieldsProjectComponent implements OnInit {
|
||||
|
||||
@Input()
|
||||
formGroup: FormGroup;
|
||||
|
||||
ngOnInit(): void {
|
||||
console.log(this.formGroup)
|
||||
}
|
||||
|
||||
findDependencies(id: number) {
|
||||
let formGroupDependencies: Array<FormGroup> = new Array<FormGroup>();
|
||||
let dynamicFieldDependency: DynamicFieldDependency[] = (<FormArray>this.formGroup.get("dynamicFields")).at(id).get("dependencies").value
|
||||
if (dynamicFieldDependency.length > 0) {
|
||||
dynamicFieldDependency.forEach(item => {
|
||||
let length = (<FormArray>this.formGroup.get("dynamicFields")).length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
let formGroup = (<FormArray>this.formGroup.get("dynamicFields")).at(i);
|
||||
if (formGroup.get("id").value === item.id) formGroupDependencies.push(<FormGroup>formGroup);
|
||||
}
|
||||
})
|
||||
}
|
||||
return formGroupDependencies;
|
||||
}
|
||||
}
|
|
@ -59,6 +59,8 @@ export class DataManagementPlanListingComponent implements OnInit {
|
|||
this.criteria.setRefreshCallback(() => this.refresh());
|
||||
} else {
|
||||
this.itemId = params['groupId'];
|
||||
this.showProject = true;
|
||||
|
||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||
this.refresh();
|
||||
this.criteria.setRefreshCallback(() => this.refresh());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div [formGroup]="form">
|
||||
<mat-form-field>
|
||||
<input matInput [matAutocomplete]="auto" formControlName="value" [required]="required">
|
||||
<input matInput [matAutocomplete]="auto" formControlName="value" [required]="required" [disabled]="disabled">
|
||||
<mat-progress-spinner matSuffix mode="indeterminate" *ngIf="loading" [diameter]="22"></mat-progress-spinner>
|
||||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="this.optionSelected($event)">
|
||||
<mat-option *ngFor="let item of filteredItems " [value]="item">
|
||||
|
|
|
@ -20,6 +20,7 @@ export class AutocompleteRemoteComponent implements OnInit/* , ControlValueAcces
|
|||
|
||||
|
||||
@Input() field: Field;
|
||||
@Input() disabled = false
|
||||
@Input() form: FormGroup;
|
||||
|
||||
private loading: boolean;
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<div class="main-panel" id="main-panel">
|
||||
<div class="container">
|
||||
<div class="row" style="margin-top: 30px">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 col-md-offset-1">
|
||||
<h3 *ngIf="!this.isAuthenticated()">{{ 'HOMEPAGE.OPEN-DMPS.STATS' | translate }}</h3>
|
||||
<h3 *ngIf="this.isAuthenticated()">{{ 'HOMEPAGE.MY-DMPS.STATS' | translate }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-top: 30px">
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 col-md-offset-1">
|
||||
<app-figurecard title={{dashboardStatisticsData.totalProjectCount}} headerIcon="list" [category]="this.isAuthenticated() ? 'My Projects' : 'Projects'"
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
import { BaseCriteria } from '../BaseCriteria';
|
||||
export class DataManagementPlanProfileCriteria extends BaseCriteria {
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
import { BaseCriteriaErrorModel } from '../BaseCriteriaErrorModel';
|
||||
export class DataManagementPlanProfileCriteriaErrorModel extends BaseCriteriaErrorModel {
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import { DataManagementProfileField } from "./DataManagementProfileField";
|
||||
import { Serializable } from "../interfaces/Serializable";
|
||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||
import { FormGenerator } from "../interfaces/FormGenerator";
|
||||
import { FormGroup, FormBuilder } from "@angular/forms";
|
||||
|
||||
export class DataManagementPlanProfile implements Serializable<DataManagementPlanProfile>, FormGenerator<FormGroup>{
|
||||
|
||||
public fields: DataManagementProfileField[] = new Array<DataManagementProfileField>()
|
||||
|
||||
fromJSONObject(item: any): DataManagementPlanProfile {
|
||||
this.fields = JsonSerializer.fromJSONArray(item.fields, DataManagementProfileField);
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(): FormGroup {
|
||||
let formBuilder = new FormBuilder();
|
||||
let formGroup = formBuilder.group({});
|
||||
let fieldsFormArray = new Array<FormGroup>();
|
||||
this.fields.forEach(item => {
|
||||
let form: FormGroup = item.buildForm();
|
||||
fieldsFormArray.push(form)
|
||||
})
|
||||
formGroup.addControl('fields', formBuilder.array(fieldsFormArray));
|
||||
return formGroup;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
export class DataManagementPlanProfileListingModel {
|
||||
public id: string;
|
||||
|
||||
public label: string;
|
||||
|
||||
public status: number;
|
||||
|
||||
public created: Date;
|
||||
|
||||
public modified: Date;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
import { DataManagementProfileField } from "./DataManagementProfileField";
|
||||
import { Serializable } from "../interfaces/Serializable";
|
||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||
import { DataManagementPlanProfile } from "./DataManagementPlanProfile";
|
||||
import { FormGenerator } from "../interfaces/FormGenerator";
|
||||
import { FormGroup, FormBuilder } from "@angular/forms";
|
||||
import { BaseErrorModel } from "../error/BaseErrorModel";
|
||||
|
||||
export class DataManagementPlanProfileModel implements Serializable<DataManagementPlanProfileModel>, FormGenerator<FormGroup>{
|
||||
|
||||
|
||||
public id: string;
|
||||
public label: string;
|
||||
public definition: DataManagementPlanProfile = new DataManagementPlanProfile();
|
||||
public status: number;
|
||||
public created: Date;
|
||||
public modified: Date;
|
||||
public errorModel: BaseErrorModel = new BaseErrorModel();
|
||||
|
||||
|
||||
fromJSONObject(item: any): DataManagementPlanProfileModel {
|
||||
this.id = item.id;
|
||||
this.label = item.label;
|
||||
this.definition = JsonSerializer.fromJSONObject(item.definition, DataManagementPlanProfile);
|
||||
this.status = item.status;
|
||||
this.created = item.created;
|
||||
this.modified = item.modified;
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(): FormGroup {
|
||||
let formGroup = new FormBuilder().group({
|
||||
id: [this.id],
|
||||
label: [this.label],
|
||||
status: [this.status],
|
||||
created: [this.created],
|
||||
modified: [this.modified]
|
||||
})
|
||||
formGroup.addControl("definition", this.definition.buildForm());
|
||||
return formGroup;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
import { Serializable } from "../Serializable";
|
||||
import { FormGenerator } from "../interfaces/FormGenerator";
|
||||
import { FormGroup, FormBuilder } from "@angular/forms";
|
||||
|
||||
export enum DMPProfileType {
|
||||
INPUT = 0
|
||||
}
|
||||
|
||||
export enum DMPProfileFieldDataType {
|
||||
DATE = 0,
|
||||
NUMBER = 1,
|
||||
TEXT = 2
|
||||
}
|
||||
|
||||
export class DataManagementProfileField implements Serializable<DataManagementProfileField>, FormGenerator<FormGroup>{
|
||||
|
||||
|
||||
public type: DMPProfileType;
|
||||
|
||||
public dataType: DMPProfileFieldDataType;
|
||||
|
||||
public required: boolean = false;
|
||||
|
||||
public label: string;
|
||||
|
||||
public id: string
|
||||
|
||||
public value:any
|
||||
|
||||
fromJSONObject(item: any): DataManagementProfileField {
|
||||
this.type = item.type;
|
||||
this.dataType = item.dataType;
|
||||
this.required = item.required;
|
||||
this.label = item.label;
|
||||
this.id = item.id
|
||||
this.value = item.value
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(): FormGroup {
|
||||
return new FormBuilder().group({
|
||||
type: [this.type],
|
||||
id: [this.id],
|
||||
dataType: [this.dataType],
|
||||
required: [this.required],
|
||||
label: [this.label]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -11,11 +11,14 @@ import { JsonSerializer } from "../../utilities/JsonSerializer";
|
|||
import { ProfileModel } from "../profile/ProfileModel";
|
||||
import { Status } from "../Status";
|
||||
import { DmpUsersModel } from "@app/models/dmpUsers/DmpUsersModel";
|
||||
import { DataManagementPlanProfile } from "../data-management-plan-profile/DataManagementPlanProfile";
|
||||
import { DynamicField } from "./DynamicField";
|
||||
|
||||
export class DataManagementPlanModel implements Serializable<DataManagementPlanModel> {
|
||||
public id: String;
|
||||
public label: String;
|
||||
public groupId: String;
|
||||
public profile: String
|
||||
public version: number;
|
||||
public status: Status = Status.Active;
|
||||
public description: String;
|
||||
|
@ -24,11 +27,13 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
|
|||
public researchers: ResearcherModel[] = [];
|
||||
public profiles: ProfileModel[] = [];
|
||||
public associatedUsers: DmpUsersModel[] = [];
|
||||
|
||||
public definition: DataManagementPlanProfile
|
||||
public dynamicFields: Array<DynamicField>;
|
||||
public errorModel: BaseErrorModel = new BaseErrorModel();
|
||||
|
||||
fromJSONObject(item: any): DataManagementPlanModel {
|
||||
this.id = item.id;
|
||||
this.profile = item.profile;
|
||||
this.label = item.label;
|
||||
this.groupId = item.groupId;
|
||||
this.version = item.version;
|
||||
|
@ -39,7 +44,8 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
|
|||
this.researchers = JsonSerializer.fromJSONArray(item.researchers, ResearcherModel);
|
||||
this.profiles = JsonSerializer.fromJSONArray(item.profiles, ProfileModel);
|
||||
this.associatedUsers = JsonSerializer.fromJSONArray(item.associatedUsers, DmpUsersModel);
|
||||
|
||||
this.definition = JsonSerializer.fromJSONObject(item.definition, DataManagementPlanProfile);
|
||||
this.dynamicFields = JsonSerializer.fromJSONArray(item.dynamicFields, DynamicField);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -47,7 +53,8 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
|
|||
if (context == null) { context = this.createValidationContext(); }
|
||||
|
||||
const formGroup = new FormBuilder().group({
|
||||
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
||||
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
||||
profile: [{ value: this.profile, disabled: disabled }, context.getValidation('profile').validators],
|
||||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
groupId: [{ value: this.groupId, disabled: disabled }, context.getValidation('groupId').validators],
|
||||
version: [{ value: this.version, disabled: disabled }, context.getValidation('version').validators],
|
||||
|
@ -57,24 +64,30 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
|
|||
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('organisations').validators],
|
||||
researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators],
|
||||
profiles: [{ value: this.profiles, disabled: disabled }, context.getValidation('profiles').validators],
|
||||
associatedUsers: [{ value: this.associatedUsers, disabled: disabled }, context.getValidation('associatedUsers').validators]
|
||||
associatedUsers: [{ value: this.associatedUsers, disabled: disabled }, context.getValidation('associatedUsers').validators],
|
||||
});
|
||||
|
||||
let dynamicFields = new Array<FormGroup>();
|
||||
if (this.dynamicFields) this.dynamicFields.forEach(item => dynamicFields.push(item.buildForm()));
|
||||
|
||||
formGroup.addControl("dynamicFields", new FormBuilder().array(dynamicFields));
|
||||
|
||||
return formGroup;
|
||||
}
|
||||
|
||||
createValidationContext(): ValidationContext {
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
baseContext.validation.push({ key: 'id', validators: [ BackendErrorValidator(this.errorModel, 'id')] });
|
||||
baseContext.validation.push({ key: 'id', validators: [BackendErrorValidator(this.errorModel, 'id')] });
|
||||
baseContext.validation.push({ key: 'profile', validators: [BackendErrorValidator(this.errorModel, 'profile')] });
|
||||
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'label')] });
|
||||
baseContext.validation.push({ key: 'groupId', validators: [BackendErrorValidator(this.errorModel, 'groupId')] });
|
||||
baseContext.validation.push({ key: 'version', validators: [BackendErrorValidator(this.errorModel, 'version')] });
|
||||
baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'status')] });
|
||||
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'description')] });
|
||||
baseContext.validation.push({ key: 'project', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'project')] });
|
||||
baseContext.validation.push({ key: 'organisations', validators: [Validators.required,BackendErrorValidator(this.errorModel, 'organisations')] });
|
||||
baseContext.validation.push({ key: 'organisations', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'organisations')] });
|
||||
baseContext.validation.push({ key: 'researchers', validators: [BackendErrorValidator(this.errorModel, 'researchers')] });
|
||||
baseContext.validation.push({ key: 'profiles', validators: [Validators.required,BackendErrorValidator(this.errorModel, 'profiles')] });
|
||||
baseContext.validation.push({ key: 'profiles', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'profiles')] });
|
||||
baseContext.validation.push({ key: 'associatedUsers', validators: [BackendErrorValidator(this.errorModel, 'associatedUsers')] });
|
||||
|
||||
return baseContext;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
import { DynamicFieldDependency } from "./DynamicFieldDependency";
|
||||
import { Serializable } from "../Serializable";
|
||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||
import { FormGroup, FormBuilder } from "@angular/forms";
|
||||
import { FormGenerator } from "../interfaces/FormGenerator";
|
||||
|
||||
export class DynamicField implements Serializable<DynamicField>, FormGenerator<FormGroup>{
|
||||
|
||||
public id: string;
|
||||
public name: string;
|
||||
public required: boolean;
|
||||
public queryProperty;
|
||||
public value: string;
|
||||
public dependencies: Array<DynamicFieldDependency>;
|
||||
|
||||
fromJSONObject(item: any): DynamicField {
|
||||
this.id = item.id;
|
||||
this.name = item.name;
|
||||
this.required = item.required;
|
||||
this.value = item.value;
|
||||
this.queryProperty = item.queryProperty;
|
||||
this.dependencies = JsonSerializer.fromJSONArray(item.dependencies, DynamicFieldDependency);
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(): FormGroup {
|
||||
let builder = new FormBuilder();
|
||||
let formGroup = builder.group({
|
||||
id: [this.id],
|
||||
name: [this.name],
|
||||
required: [this.required],
|
||||
value: [this.value],
|
||||
queryProperty: [this.queryProperty],
|
||||
dependencies: [this.dependencies]
|
||||
})
|
||||
return formGroup;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
import { Serializable } from "../Serializable";
|
||||
import { FormGenerator } from "../interfaces/FormGenerator";
|
||||
import { FormGroup, FormBuilder } from "@angular/forms";
|
||||
|
||||
export class DynamicFieldDependency implements Serializable<DynamicFieldDependency>, FormGenerator<FormGroup>{
|
||||
public id: string
|
||||
public queryProperty: string
|
||||
|
||||
fromJSONObject(item: any): DynamicFieldDependency {
|
||||
this.id = item.id;
|
||||
this.queryProperty = item.queryProperty;
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(): FormGroup {
|
||||
return new FormBuilder().group({
|
||||
id: [this.id],
|
||||
queryProperty: [this.queryProperty]
|
||||
})
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
export class DynamicFieldProjectCriteria {
|
||||
public id: string;
|
||||
public dynamicFields: DynamicFieldProjectCriteriaDependencies[]
|
||||
}
|
||||
|
||||
export class DynamicFieldProjectCriteriaDependencies {
|
||||
public value;
|
||||
public property;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export class Language {
|
||||
public key: string;
|
||||
public languageKey: string
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
<mat-card-content>
|
||||
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="{{'PROJECT-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label"
|
||||
<input matInput placeholder="{{'PROJECT-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label"
|
||||
required>
|
||||
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
|
@ -59,7 +59,7 @@
|
|||
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<p>{{'PROJECT-EDITOR.FIELDS.LOGO' | translate}}</p>
|
||||
<p>{{this.languageResolverService.getBy('editorLogo') | translate}}</p>
|
||||
|
||||
<table class="logo-table full-width">
|
||||
<tr>
|
||||
|
|
|
@ -14,6 +14,7 @@ import { BaseErrorModel } from "../../models/error/BaseErrorModel";
|
|||
import { TdDialogService } from "@covalent/core";
|
||||
import { ProjectFileUploaderService } from "@app/services/files/project-file-uploader.service";
|
||||
import { HostConfiguration } from "@app/app.constants";
|
||||
import { LanguageResolverService } from "../../services/language-resolver/language-resolver.service";
|
||||
|
||||
|
||||
|
||||
|
@ -37,7 +38,8 @@ export class ProjectEditorComponent implements AfterViewInit {
|
|||
public router: Router,
|
||||
public language: TranslateService,
|
||||
private dialogService: TdDialogService,
|
||||
private uploaderService: ProjectFileUploaderService
|
||||
private uploaderService: ProjectFileUploaderService,
|
||||
private languageResolverService: LanguageResolverService
|
||||
) {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="container-fluid">
|
||||
<h3>{{'PROJECT-LISTING.TITLE' | translate}}</h3>
|
||||
<h3>{{languageResolverService.getBy('listingTitle') | translate}}</h3>
|
||||
|
||||
<app-projects-criteria-component></app-projects-criteria-component>
|
||||
<mat-card class="mat-card">
|
||||
|
|
|
@ -10,6 +10,8 @@ import { DataSource } from "@angular/cdk/table";
|
|||
import { Observable } from "rxjs/Observable";
|
||||
import { ProjectCriteriaComponent } from '@app/shared/components/criteria/projects/projects-criteria.component';
|
||||
import { HostConfiguration } from '@app/app.constants';
|
||||
import { LanguageService } from '../../services/language/language.service';
|
||||
import { LanguageResolverService } from '../../services/language-resolver/language-resolver.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-project-listing-component',
|
||||
|
@ -33,6 +35,7 @@ export class ProjectListingComponent implements OnInit {
|
|||
private router: Router,
|
||||
private languageService: TranslateService,
|
||||
public snackBar: MatSnackBar,
|
||||
private languageResolverService: LanguageResolverService
|
||||
) {
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { HttpHeaders } from "@angular/common/http";
|
||||
import { BaseHttpService } from "../../utilities/cite-http-service-module/base-http.service";
|
||||
import { HostConfiguration } from "../../app.constants";
|
||||
import { DataTableRequest } from "../../models/data-table/DataTableRequest";
|
||||
import { DataTableData } from "../../models/data-table/DataTableData";
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria";
|
||||
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
|
||||
import { DataManagementPlanProfileModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileModel";
|
||||
import { RequestItem } from "../../models/criteria/RequestItem";
|
||||
|
||||
@Injectable()
|
||||
export class DataManagementPlanProfileService {
|
||||
|
||||
private actionUrl: string;
|
||||
private headers: HttpHeaders;
|
||||
|
||||
constructor(private http: BaseHttpService) {
|
||||
|
||||
this.actionUrl = HostConfiguration.Server + 'dmpprofile/';
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
this.headers = this.headers.set('Content-Type', 'application/json');
|
||||
this.headers = this.headers.set('Accept', 'application/json');
|
||||
}
|
||||
|
||||
getPaged(dataTableRequest: DataTableRequest<DataManagementPlanProfileCriteria>): Observable<DataTableData<DataManagementPlanProfileListingModel>> {
|
||||
return this.http.post<DataTableData<DataManagementPlanProfileListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers });
|
||||
}
|
||||
|
||||
getSingle(id: String): Observable<DataManagementPlanProfileModel> {
|
||||
return this.http.get<DataManagementPlanProfileModel>(this.actionUrl + 'getSingle/' + id, { headers: this.headers });
|
||||
}
|
||||
|
||||
createDataManagementPlan(dataManagementPlanModel: DataManagementPlanProfileModel): Observable<DataManagementPlanProfileModel> {
|
||||
return this.http.post<DataManagementPlanProfileModel>(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers });
|
||||
}
|
||||
|
||||
getAll(criteria: RequestItem<DataManagementPlanProfileCriteria>): Observable<DataManagementPlanProfileListingModel> {
|
||||
return this.http.post<DataManagementPlanProfileModel>(this.actionUrl + 'get/' ,criteria, { headers: this.headers });
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ export class DataManagementPlanService {
|
|||
}
|
||||
|
||||
createDataManagementPlan(dataManagementPlanModel: DataManagementPlanModel): Observable<DataManagementPlanModel> {
|
||||
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers });
|
||||
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers });
|
||||
}
|
||||
|
||||
inactivate(id: String): Observable<DataManagementPlanModel> {
|
||||
|
@ -49,15 +49,19 @@ export class DataManagementPlanService {
|
|||
return this.http.post<DatasetProfileModel[]>(this.actionUrl + "datasetprofiles/get", dataSetProfileRequest, { headers: this.headers });
|
||||
}
|
||||
|
||||
newVersion(dataManagementPlanModel: DataManagementPlanModel, id:String): Observable<DataManagementPlanModel> {
|
||||
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'new/' + id , dataManagementPlanModel, { headers: this.headers });
|
||||
newVersion(dataManagementPlanModel: DataManagementPlanModel, id: String): Observable<DataManagementPlanModel> {
|
||||
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'new/' + id, dataManagementPlanModel, { headers: this.headers });
|
||||
}
|
||||
|
||||
clone(dataManagementPlanModel: DataManagementPlanModel, id:String): Observable<DataManagementPlanModel> {
|
||||
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'clone/' + id , dataManagementPlanModel, { headers: this.headers });
|
||||
clone(dataManagementPlanModel: DataManagementPlanModel, id: String): Observable<DataManagementPlanModel> {
|
||||
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'clone/' + id, dataManagementPlanModel, { headers: this.headers });
|
||||
}
|
||||
|
||||
delete(id: String): Observable<DataManagementPlanModel> {
|
||||
return this.http.delete<DataManagementPlanModel>(this.actionUrl + 'delete/' + id, { headers: this.headers });
|
||||
}
|
||||
|
||||
getDynamicField(requestItem: RequestItem<DatasetProfileCriteria>): any {
|
||||
return this.http.post<any>(this.actionUrl + "dynamic", requestItem, { headers: this.headers })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { LanguageService } from "../language/language.service";
|
||||
|
||||
@Injectable()
|
||||
export class LanguageResolverService {
|
||||
|
||||
private languageData = {};
|
||||
|
||||
constructor(private language: LanguageService) {
|
||||
if (Object.keys(this.languageData).length == 0) {
|
||||
this.language.getLang().subscribe(result => {
|
||||
result.forEach(item => {
|
||||
this.languageData[item.key] = item.languageKey;
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public getBy(key: string): string {
|
||||
return this.languageData[key];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { HttpHeaders } from "@angular/common/http";
|
||||
import { BaseHttpService } from "../../utilities/cite-http-service-module/base-http.service";
|
||||
import { HostConfiguration } from "../../app.constants";
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { Invitation } from "../../models/invitation/Invitation";
|
||||
import { User } from "../../models/invitation/User";
|
||||
import { RequestItem } from "../../models/criteria/RequestItem";
|
||||
import { UserInvitationCriteria } from "../../models/criteria/invitation/UserInvitationCriteria";
|
||||
import { Language } from "../../models/language/Language";
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class LanguageService {
|
||||
private actionUrl: string;
|
||||
private headers: HttpHeaders;
|
||||
|
||||
constructor(private http: BaseHttpService) {
|
||||
|
||||
this.actionUrl = HostConfiguration.Server + 'common/';
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
this.headers = this.headers.set('Content-Type', 'application/json');
|
||||
this.headers = this.headers.set('Accept', 'application/json');
|
||||
}
|
||||
|
||||
public getLang(): Observable<Language[]> {
|
||||
return this.http.get<Language[]>(this.actionUrl + "language", { headers: this.headers });
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<div class="auto-complete">
|
||||
<mat-form-field>
|
||||
<input matInput
|
||||
type="text"
|
||||
[placeholder]="placeholder"
|
||||
[formControl]="textFormCtrl"
|
||||
[matAutocomplete]="auto"
|
||||
[required]="required"
|
||||
[errorStateMatcher]="this">
|
||||
<mat-error *ngIf="validationErrorString">{{validationErrorString}}</mat-error>
|
||||
<mat-error *ngIf="formCtrl && formCtrl.errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
<mat-progress-spinner matSuffix mode="indeterminate" *ngIf="loading" [diameter]="22"></mat-progress-spinner>
|
||||
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFunction" (optionSelected)="this.optionSelected($event)">
|
||||
<mat-option *ngFor="let option of options" [value]="option">
|
||||
{{ this.printText(option) }}
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
</mat-form-field>
|
||||
</div>
|
|
@ -0,0 +1,7 @@
|
|||
.auto-complete {
|
||||
.mat-form-field {
|
||||
width: 100%;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
import { Input, OnInit, Component, AfterViewInit, Output, EventEmitter, OnChanges } from '@angular/core';
|
||||
import { FormGroup, FormControl, FormGroupDirective, NgForm } from '@angular/forms';
|
||||
import { ErrorStateMatcher } from '@angular/material';
|
||||
import { AutoCompleteConfiguration } from '../autocomplete/AutoCompleteConfiguration';
|
||||
|
||||
@Component({
|
||||
selector: 'app-auto-complete',
|
||||
templateUrl: './auto-complete.component.html',
|
||||
styleUrls: ['./auto-complete.component.scss']
|
||||
})
|
||||
export class AutoCompleteComponent implements OnInit, ErrorStateMatcher {
|
||||
|
||||
@Input() placeholder: String;
|
||||
@Input() disabled: boolean;
|
||||
|
||||
@Input() typeaheadMS: number;
|
||||
@Input() formCtrl: FormControl;
|
||||
@Input() required = false;
|
||||
@Input() displayFunction: Function;
|
||||
@Input() assignValueFunction: Function;
|
||||
@Input() inputData: AutoCompleteConfiguration;
|
||||
@Input() validationErrorString: String;
|
||||
|
||||
@Output() onItemChange = new EventEmitter<any>();
|
||||
|
||||
public textFormCtrl: FormControl;
|
||||
public options: any[];
|
||||
|
||||
loading = false;
|
||||
hasSelectedItem = false;
|
||||
isUnchanged = true;
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.textFormCtrl = new FormControl();
|
||||
this.formCtrl.registerOnDisabledChange(isDisabled => {
|
||||
if (isDisabled) this.textFormCtrl.disable({ onlySelf: true, emitEvent: false });
|
||||
else this.textFormCtrl.enable({ onlySelf: true, emitEvent: false });
|
||||
})
|
||||
if (this.formCtrl && this.formCtrl.value) {
|
||||
this.textFormCtrl.patchValue(this.formCtrl.value, { emitEvent: false });
|
||||
this.hasSelectedItem = true;
|
||||
}
|
||||
|
||||
const valueChanges = this.textFormCtrl.valueChanges.share();
|
||||
|
||||
valueChanges.subscribe(searchTerm => { // reset value of input control every time the user starts typing
|
||||
if (this.hasSelectedItem) {
|
||||
this.hasSelectedItem = false;
|
||||
this.onItemChange.emit(null);
|
||||
if (this.formCtrl && this.formCtrl.value) {
|
||||
this.formCtrl.patchValue(null, { emitEvent: false });
|
||||
}
|
||||
}
|
||||
this.isUnchanged = false;
|
||||
this.loading = true;
|
||||
});
|
||||
|
||||
valueChanges.debounceTime(this.typeaheadMS)
|
||||
.do(value => {
|
||||
if (this.hasSelectedItem) { this.loading = false; }
|
||||
if (typeof value === 'string') {
|
||||
this.inputData.requestItem.criteria["like"] = value;
|
||||
this.inputData.callback(this.inputData.requestItem).map(res => {
|
||||
this.options = res;
|
||||
this.loading = false;
|
||||
}).subscribe();
|
||||
}
|
||||
})
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
printText(item: any): string {
|
||||
if (this.displayFunction) return this.displayFunction(item);
|
||||
else return item;
|
||||
}
|
||||
|
||||
getValue(item: any): string {
|
||||
if (this.assignValueFunction) return this.assignValueFunction(item);
|
||||
else return item;
|
||||
}
|
||||
|
||||
optionSelected(event: any) {
|
||||
if (this.formCtrl) { this.formCtrl.patchValue(this.assignValueFunction ? this.assignValueFunction(event.option.value) : event.option.value, { emitEvent: false }); }
|
||||
this.hasSelectedItem = true;
|
||||
this.onItemChange.emit(this.assignValueFunction ? this.assignValueFunction(event.option.value) : event.option.value);
|
||||
}
|
||||
|
||||
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
||||
const isFormSubmitted = form && form.submitted;
|
||||
const isControlInvalid = (control && control.invalid && (control.dirty || control.touched || isFormSubmitted)) || (!this.hasSelectedItem && !this.isUnchanged);
|
||||
const isFormInvalid = form && form.enabled && form.invalid && (form.dirty || form.touched || isFormSubmitted);
|
||||
return !!(isControlInvalid || isFormInvalid);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue