no message
This commit is contained in:
parent
e437ae354e
commit
5692b2072f
|
@ -7,11 +7,11 @@ import org.springframework.boot.SpringApplication;
|
|||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.support.SpringBootServletInitializer;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
public class EuDatApplication extends SpringBootServletInitializer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EuDatApplication.class);
|
||||
|
|
|
@ -8,13 +8,14 @@ import org.springframework.boot.web.servlet.ErrorPage;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@EnableAsync
|
||||
@Configuration
|
||||
public class WebMVCConfiguration extends WebMvcConfigurerAdapter {
|
||||
|
||||
|
|
|
@ -5,9 +5,11 @@ import java.util.UUID;
|
|||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.managers.DashBoardManager;
|
||||
import eu.eudat.models.dashboard.DashBoardStatistics;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import eu.eudat.types.Authorities;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -52,7 +54,7 @@ public class Admin extends BaseController {
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<Object> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
try {
|
||||
eu.eudat.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile);
|
||||
|
||||
|
@ -60,23 +62,23 @@ public class Admin extends BaseController {
|
|||
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
||||
this.getApiContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(null);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"reason\":\"" + ex.getMessage() + "\"}");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<UUID>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/admin/get/{id}"}, produces = "application/json")
|
||||
public ResponseEntity<Object> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
public ResponseEntity<ResponseItem<DatasetProfile>> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
try {
|
||||
eu.eudat.entities.DatasetProfile profile = this.getApiContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
datasetprofile.setLabel(profile.getLabel());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"reason\":\"" + ex.getMessage() + "\"}");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@ package eu.eudat.controllers;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||
|
@ -19,6 +19,8 @@ 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.scheduling.annotation.Async;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import eu.eudat.managers.DataManagementPlanManager;
|
||||
|
@ -74,12 +76,11 @@ public class DMPs extends BaseController {
|
|||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/new/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> createOrUpdate(@PathVariable UUID id, @RequestBody eu.eudat.models.dmp.DataManagementPlan dataManagementPlan, Principal principal) {
|
||||
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @RequestBody eu.eudat.models.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) {
|
||||
try {
|
||||
DataManagementPlanManager.clone(this.getApiContext(), id, dataManagementPlan, principal);
|
||||
DataManagementPlanManager.newVersion(this.getApiContext(), id, dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
@ -101,5 +102,19 @@ public class DMPs extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/dmps/delete/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> delete(@PathVariable UUID id, Principal principal) {
|
||||
try {
|
||||
DataManagementPlanManager.delete(this.getApiContext(), id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Dataset"));
|
||||
} catch (DMPWithDatasetsException ex){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class DatasetProfiles extends BaseController {
|
|||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/datasetprofiles/get"}, produces = "application/json")
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/admin/datasetprofiles/get"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<DatasetProfileAutocompleteItem>>> get(@RequestBody DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) {
|
||||
try {
|
||||
|
@ -42,7 +42,7 @@ public class DatasetProfiles extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/datasetprofiles/getPaged"}, produces = "application/json")
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/admin/datasetprofiles/getPaged"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) {
|
||||
try {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.managers.UserManager;
|
||||
import eu.eudat.models.login.Credentials;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
|
|
|
@ -3,19 +3,19 @@ package eu.eudat.controllers;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.managers.ResearcherManager;
|
||||
import eu.eudat.models.dmp.Researcher;
|
||||
import eu.eudat.models.external.ResearchersExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
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.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
||||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
||||
|
@ -47,5 +47,21 @@ public class Researchers extends BaseController{
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/researchers/create" }, consumes = "application/json",produces="application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Researcher>> create(@RequestBody eu.eudat.models.researcher.Researcher researcher, Principal principal) {
|
||||
try {
|
||||
ResearcherManager.create(this.getApiContext(),researcher);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Researcher>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
}catch (UnauthorisedException e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Researcher>().status(ApiMessageCode.SUCCESS_MESSAGE).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.managers.InvitationsManager;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.invitation.Invitation;
|
||||
|
|
|
@ -5,9 +5,9 @@ import eu.eudat.queryable.QueryableList;
|
|||
import eu.eudat.queryable.hibernatequeryablelist.QueryableHibernateList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
@ -17,14 +17,22 @@ import java.util.UUID;
|
|||
|
||||
@Repository("databaseCtx")
|
||||
public class DatabaseContext<T extends DataEntity<T>> {
|
||||
@Autowired
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
public DatabaseContext(EntityManagerFactory entityManagerFactory) {
|
||||
this.entityManager = entityManagerFactory.createEntityManager();
|
||||
}
|
||||
|
||||
public QueryableList<T> getQueryable(Class<T> type) {
|
||||
return new QueryableHibernateList<>(this.entityManager, type).setEntity(type);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public T createOrUpdate(T item, Class<T> type) {
|
||||
EntityManager entityManager = this.entityManager;
|
||||
if (item.getKeys()[0] != null) {
|
||||
T oldItem = entityManager.find(type, item.getKeys()[0]);
|
||||
if(oldItem!=null) {
|
||||
|
@ -39,6 +47,7 @@ public class DatabaseContext<T extends DataEntity<T>> {
|
|||
}
|
||||
|
||||
public long count(Class<T> entityClass) {
|
||||
EntityManager entityManager = this.entityManager;
|
||||
return ((Number) entityManager.createQuery("select count(e) from " + entityClass.getSimpleName() + " e").getSingleResult()).longValue();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.entities.DataEntity;
|
|||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package eu.eudat.dao.entities;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
import eu.eudat.dao.DatabaseAccess;
|
||||
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.DatasetProfile;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.criteria.DataManagementPlanCriteria;
|
||||
|
@ -34,6 +36,8 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||
if (criteria.getProjects() != null && !criteria.getProjects().isEmpty())
|
||||
query.where(((builder, root) -> root.get("project").in(criteria.getProjectEntities())));
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
||||
query.where((builder, root) -> builder.not(root.get("id").in(query.subQuery((builder1, root1) -> root1.get("previous").isNotNull(), Arrays.asList("previous")))));
|
||||
return query;
|
||||
}
|
||||
|
||||
|
@ -61,11 +65,6 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count() {
|
||||
return this.getDatabaseService().count(DMP.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DMP item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
|
@ -75,4 +74,9 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
public QueryableList<DMP> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DMP.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count() {
|
||||
return this.getDatabaseService().count(DMP.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.dao.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import eu.eudat.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.entities.DataRepository;
|
||||
|
@ -8,6 +9,7 @@ import eu.eudat.entities.Dataset;
|
|||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.criteria.DatasetCriteria;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface DatasetDao extends DatabaseAccessLayer<Dataset,UUID> {
|
||||
|
||||
|
@ -15,5 +17,9 @@ public interface DatasetDao extends DatabaseAccessLayer<Dataset,UUID> {
|
|||
|
||||
QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal);
|
||||
|
||||
CompletableFuture<Dataset> createOrUpdateAsync(Dataset item);
|
||||
|
||||
Dataset find(UUID id,String hint);
|
||||
|
||||
Long count();
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.dao.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import eu.eudat.dao.DatabaseAccess;
|
||||
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||
|
@ -11,6 +12,7 @@ import eu.eudat.models.criteria.DatasetCriteria;
|
|||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Component("datasetDao")
|
||||
public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao {
|
||||
|
@ -21,18 +23,23 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
|||
|
||||
@Override
|
||||
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
|
||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(),Dataset.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%"));
|
||||
if (criteria.getStatus() != null) query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus()));
|
||||
if (criteria.getPeriodEnd() != null) query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||
if (criteria.getPeriodStart() != null) query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||
if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty()) query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds()));
|
||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%"));
|
||||
if (criteria.getStatus() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus()));
|
||||
if (criteria.getPeriodEnd() != null)
|
||||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||
if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
|
||||
query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset createOrUpdate(Dataset item) {
|
||||
return getDatabaseService().createOrUpdate(item,Dataset.class);
|
||||
return getDatabaseService().createOrUpdate(item, Dataset.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,6 +47,11 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
|||
return getDatabaseService().getQueryable(Dataset.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset find(UUID id,String hint) {
|
||||
return getDatabaseService().getQueryable(Dataset.getHints(),Dataset.class).withHint(hint).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
|
||||
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.isMember(principal, root.get("dmp").get("users"))
|
||||
|
@ -61,4 +73,8 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
|||
public QueryableList<Dataset> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Dataset.class);
|
||||
}
|
||||
|
||||
public CompletableFuture<Dataset> createOrUpdateAsync(Dataset item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package eu.eudat.dao.entities;
|
||||
|
||||
import eu.eudat.dao.DatabaseAccess;
|
||||
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.entities.DMP;
|
||||
|
@ -13,7 +14,7 @@ import java.util.UUID;
|
|||
|
||||
|
||||
@Service("invitationDao")
|
||||
public class InvitationDaoImpl extends DatabaseAccess<Invitation> implements InvitationDao{
|
||||
public class InvitationDaoImpl extends DatabaseAccess<Invitation> implements InvitationDao {
|
||||
|
||||
@Autowired
|
||||
public InvitationDaoImpl(DatabaseService<Invitation> databaseService) {
|
||||
|
@ -27,12 +28,12 @@ public class InvitationDaoImpl extends DatabaseAccess<Invitation> implements Inv
|
|||
|
||||
@Override
|
||||
public Invitation createOrUpdate(Invitation item) {
|
||||
return this.getDatabaseService().createOrUpdate(item,Invitation.class);
|
||||
return this.getDatabaseService().createOrUpdate(item, Invitation.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Invitation find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(Invitation.class).where((builder, root) -> builder.equal(root.get("id"),id)).getSingle();
|
||||
return this.getDatabaseService().getQueryable(Invitation.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,5 +13,6 @@ import java.util.UUID;
|
|||
public interface UserRoleDao extends DatabaseAccessLayer<UserRole, UUID> {
|
||||
|
||||
QueryableList<UserRole> getWithCriteria(UserRoleCriteria criteria);
|
||||
|
||||
List<UserRole> getUserRoles(UserInfo userInfo);
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ public class UserTokenDaoImpl extends DatabaseAccess<UserToken> implements UserT
|
|||
|
||||
@Override
|
||||
public UserToken createOrUpdate(UserToken item) {
|
||||
return this.getDatabaseService().createOrUpdate(item,UserToken.class);
|
||||
return this.getDatabaseService().createOrUpdate(item, UserToken.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserToken find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(UserToken.class).where((builder, root) -> builder.equal(root.get("token"),id)).getSingleOrDefault();
|
||||
return this.getDatabaseService().getQueryable(UserToken.class).where((builder, root) -> builder.equal(root.get("token"), id)).getSingleOrDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.*;
|
|||
|
||||
import javax.persistence.*;
|
||||
|
||||
import eu.eudat.types.Authorities;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
|
@ -19,7 +20,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
|||
@NamedEntityGraph(
|
||||
name = "dataManagementPlanListingModel",
|
||||
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"),
|
||||
@NamedAttributeNode("project"), @NamedAttributeNode("profile"),@NamedAttributeNode("dataset")}
|
||||
@NamedAttributeNode("project"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")}
|
||||
),
|
||||
@NamedEntityGraph(
|
||||
name = "fullyDetailed",
|
||||
|
@ -29,6 +30,31 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
|||
})
|
||||
public class DMP implements Serializable, DataEntity<DMP> {
|
||||
|
||||
public enum DMPStatus {
|
||||
ACTIVE((short) 0), DELETED((short) 1);
|
||||
|
||||
private short value;
|
||||
|
||||
private DMPStatus(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DMPStatus fromInteger(short value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return ACTIVE;
|
||||
case 1:
|
||||
return DELETED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported DMP Status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getHints() {
|
||||
return hints;
|
||||
}
|
||||
|
|
|
@ -15,305 +15,307 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
|||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
|
||||
@Entity
|
||||
@Table(name="\"Dataset\"")
|
||||
@Table(name = "\"Dataset\"")
|
||||
@NamedEntityGraphs({
|
||||
@NamedEntityGraph(
|
||||
name = "datasetListingModel",
|
||||
attributeNodes = {@NamedAttributeNode("services"),@NamedAttributeNode("dataRepositories"),@NamedAttributeNode("registries"),
|
||||
@NamedAttributeNode("dmp"),@NamedAttributeNode("profile"),@NamedAttributeNode("creator")})
|
||||
@NamedEntityGraph(
|
||||
name = "datasetListingModel",
|
||||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("dataRepositories"), @NamedAttributeNode("externalDatasets"), @NamedAttributeNode("registries"),
|
||||
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")})
|
||||
})
|
||||
public class Dataset implements DataEntity<Dataset> {
|
||||
|
||||
public static Set<String> getHints() {
|
||||
return hints;
|
||||
}
|
||||
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
|
||||
public static Set<String> getHints() {
|
||||
return hints;
|
||||
}
|
||||
|
||||
public enum Status {
|
||||
SAVED((short) 0), FINALISED((short) 1), DELETED((short) 99);
|
||||
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
|
||||
|
||||
private short value;
|
||||
public enum Status {
|
||||
SAVED((short) 0), FINALISED((short) 1), DELETED((short) 99);
|
||||
|
||||
private Status(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
private short value;
|
||||
|
||||
public short getValue() {
|
||||
return value;
|
||||
}
|
||||
private Status(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static Dataset.Status fromInteger(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return SAVED;
|
||||
case 1:
|
||||
return FINALISED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Project Status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
public short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Dataset.Status fromInteger(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return SAVED;
|
||||
case 1:
|
||||
return FINALISED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Project Status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
@Column(name = "\"Label\"")
|
||||
private String label;
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private UUID id;
|
||||
|
||||
@Column(name = "\"Label\"")
|
||||
private String label;
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||
@JoinColumn(name = "\"DMP\"", nullable = true)
|
||||
private DMP dmp;
|
||||
|
||||
private DMP dmp;
|
||||
|
||||
@Column(name = "\"Uri\"")
|
||||
private String uri;
|
||||
|
||||
@Type(type="eu.eudat.typedefinition.XMLType")
|
||||
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
||||
private String properties;
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||
@Column(name = "\"Uri\"")
|
||||
private String uri;
|
||||
|
||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
||||
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
||||
private String properties;
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||
@JoinColumn(name = "\"Profile\"", nullable = true)
|
||||
private DatasetProfile profile;
|
||||
|
||||
@Type(type="eu.eudat.typedefinition.XMLType")
|
||||
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
||||
private String reference;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"DatasetDataRepository\"",
|
||||
joinColumns={@JoinColumn(name="\"Dataset\"", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="\"DataRepository\"", referencedColumnName="\"ID\"")}
|
||||
)
|
||||
private DatasetProfile profile;
|
||||
|
||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
||||
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
||||
private String reference;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetDataRepository\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"DataRepository\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<DataRepository> dataRepositories;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"DatasetRegistry\"",
|
||||
joinColumns={@JoinColumn(name="\"Dataset\"", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="\"Registry\"", referencedColumnName="\"ID\"")}
|
||||
)
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetRegistry\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<Registry> registries;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"DatasetService\"",
|
||||
joinColumns={@JoinColumn(name="\"Dataset\"", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="\"Service\"", referencedColumnName="\"ID\"")}
|
||||
)
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetService\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"Service\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<Service> services;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name="\"DatasetExternalDataset\"",
|
||||
joinColumns={@JoinColumn(name="\"Dataset\"", referencedColumnName="\"ID\"")},
|
||||
inverseJoinColumns={@JoinColumn(name="\"ExternalDataset\"", referencedColumnName="\"Id\"")}
|
||||
)
|
||||
private Set<ExternalDataset> externalDatasets;
|
||||
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
private Short status;
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetExternalDataset\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"ExternalDataset\"", referencedColumnName = "\"Id\"")}
|
||||
)
|
||||
private Set<ExternalDataset> externalDatasets;
|
||||
|
||||
@Column(name = "\"IsPublic\"", nullable = false)
|
||||
private boolean isPublic;
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
private Date created = null;
|
||||
|
||||
@Column(name = "\"Modified\"")
|
||||
private Date modified = new Date();
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
private Short status;
|
||||
|
||||
@Column(name = "\"IsPublic\"", nullable = false)
|
||||
private boolean isPublic;
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
private Date created = null;
|
||||
|
||||
@Column(name = "\"Modified\"")
|
||||
private Date modified = new Date();
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"Creator\"", nullable = true)
|
||||
private UserInfo creator;
|
||||
|
||||
@Column(name = "\"Description\"")
|
||||
private String description;
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private UserInfo creator;
|
||||
|
||||
public UserInfo getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(UserInfo creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
@Column(name = "\"Description\"")
|
||||
private String description;
|
||||
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
public UserInfo getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(UserInfo creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public Date getModified() {
|
||||
return modified;
|
||||
}
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
public void setModified(Date modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
|
||||
public Set<Registry> getRegistries() {
|
||||
return registries;
|
||||
}
|
||||
public Date getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
public void setRegistries(Set<Registry> registries) {
|
||||
this.registries = registries;
|
||||
}
|
||||
public void setModified(Date modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
|
||||
public Set<Service> getServices() {
|
||||
return services;
|
||||
}
|
||||
public Set<Registry> getRegistries() {
|
||||
return registries;
|
||||
}
|
||||
|
||||
|
||||
public void setServices(Set<Service> services) {
|
||||
this.services = services;
|
||||
}
|
||||
public void setRegistries(Set<Registry> registries) {
|
||||
this.registries = registries;
|
||||
}
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
public Set<Service> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setServices(Set<Service> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
public DMP getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public void setDmp(DMP dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
public DMP getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
|
||||
|
||||
public String getProperties() {
|
||||
return properties;
|
||||
}
|
||||
public void setDmp(DMP dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
|
||||
public void setProperties(String properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
|
||||
public DatasetProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
|
||||
public void setProfile(DatasetProfile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
public String getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
public Set<DataRepository> getDataRepositories() {
|
||||
return dataRepositories;
|
||||
}
|
||||
public void setProperties(String properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
||||
public void setDataRepositories(Set<DataRepository> dataRepositories) {
|
||||
this.dataRepositories = dataRepositories;
|
||||
}
|
||||
public DatasetProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
public void setProfile(DatasetProfile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
public Set<DataRepository> getDataRepositories() {
|
||||
return dataRepositories;
|
||||
}
|
||||
|
||||
public Set<ExternalDataset> getExternalDatasets() {
|
||||
return externalDatasets;
|
||||
}
|
||||
|
||||
public void setExternalDatasets(Set<ExternalDataset> externalDatasets) {
|
||||
this.externalDatasets = externalDatasets;
|
||||
}
|
||||
public void setDataRepositories(Set<DataRepository> dataRepositories) {
|
||||
this.dataRepositories = dataRepositories;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public void setPublic(boolean aPublic) {
|
||||
isPublic = aPublic;
|
||||
}
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Dataset entity) {
|
||||
this.setRegistries(entity.getRegistries());
|
||||
this.setDataRepositories(entity.getDataRepositories());
|
||||
this.setDescription(entity.getDescription());
|
||||
this.setLabel(entity.getLabel());
|
||||
this.setProperties(entity.getProperties());
|
||||
this.setExternalDatasets(entity.getExternalDatasets());
|
||||
this.setStatus(entity.getStatus());
|
||||
if(entity.getCreator()!=null) this.creator = entity.getCreator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
}
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public Set<ExternalDataset> getExternalDatasets() {
|
||||
return externalDatasets;
|
||||
}
|
||||
|
||||
public void setExternalDatasets(Set<ExternalDataset> externalDatasets) {
|
||||
this.externalDatasets = externalDatasets;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public void setPublic(boolean aPublic) {
|
||||
isPublic = aPublic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Dataset entity) {
|
||||
this.setRegistries(entity.getRegistries());
|
||||
this.setDataRepositories(entity.getDataRepositories());
|
||||
this.setDescription(entity.getDescription());
|
||||
this.setLabel(entity.getLabel());
|
||||
this.setProperties(entity.getProperties());
|
||||
this.setExternalDatasets(entity.getExternalDatasets());
|
||||
this.setStatus(entity.getStatus());
|
||||
this.setProfile(entity.getProfile());
|
||||
if (entity.getCreator() != null) this.creator = entity.getCreator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package eu.eudat.exceptions.datamanagementplan;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/5/2018.
|
||||
*/
|
||||
public class DMPWithDatasetsException extends RuntimeException {
|
||||
public DMPWithDatasetsException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DMPWithDatasetsException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DMPWithDatasetsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DMPWithDatasetsException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.exceptions;
|
||||
package eu.eudat.exceptions.security;
|
||||
|
||||
public class NonValidTokenException extends Exception {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.exceptions;
|
||||
package eu.eudat.exceptions.security;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.handlers;
|
||||
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.services.AuthenticationService;
|
||||
|
@ -14,8 +14,6 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
|||
import java.lang.annotation.Annotation;
|
||||
import java.util.*;
|
||||
|
||||
import static eu.eudat.types.Authorities.USER;
|
||||
|
||||
|
||||
public final class PrincipalArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
|
|
|
@ -1,27 +1,29 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.Project;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.entities.*;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.HintedModelFactory;
|
||||
import eu.eudat.models.criteria.OrganisationCriteria;
|
||||
import eu.eudat.models.criteria.ProjectCriteria;
|
||||
import eu.eudat.models.criteria.ResearcherCriteria;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.models.dmp.DataManagementPlanNewVersionModel;
|
||||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||
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 eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
public class DataManagementPlanManager {
|
||||
|
||||
|
@ -32,10 +34,17 @@ public class DataManagementPlanManager {
|
|||
QueryableList<DMP> authItems = apiContext.getDatabaseRepository().getDmpDao().getAuthenticated(items, userInfo);
|
||||
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
||||
|
||||
List<DataManagementPlanListingModel> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, DataManagementPlanListingModel>().fromDataModel(pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)).toList(), DataManagementPlanListingModel.class);
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<DataManagementPlanListingModel>();
|
||||
dataTable.setData(datamanagementPlans);
|
||||
dataTable.setTotalCount(items.count());
|
||||
|
||||
CompletableFuture itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)).toListAsync().whenComplete((resultList, throwable) -> {
|
||||
List<DataManagementPlanListingModel> datamanagementPlans = new DomainModelConverter<DMP, DataManagementPlanListingModel>().fromDataModel(resultList, DataManagementPlanListingModel.class);
|
||||
dataTable.setData(datamanagementPlans);
|
||||
});
|
||||
|
||||
CompletableFuture countFuture = items.countAsync().whenComplete((count, throwable) -> {
|
||||
dataTable.setTotalCount(count);
|
||||
});
|
||||
CompletableFuture.allOf(itemsFuture, countFuture).join();
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
|
@ -65,17 +74,29 @@ public class DataManagementPlanManager {
|
|||
|
||||
}
|
||||
|
||||
public static void clone(ApiContext apiContext, UUID uuid, DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP oldDmp = new DMP();
|
||||
oldDmp.setId(uuid);
|
||||
public static void newVersion(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP oldDmp = apiContext.getDatabaseRepository().getDmpDao().find(uuid);
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getResearcherDao());
|
||||
UserInfo user = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
createProjectIfItDoesntExist(newDmp, apiContext.getDatabaseRepository().getProjectDao(), user);
|
||||
newDmp.setCreator(user);
|
||||
newDmp.setPrevious(oldDmp);
|
||||
apiContext.getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||
newDmp.setVersion(oldDmp.getVersion() + 1);
|
||||
newDmp.setId(null);
|
||||
newDmp = apiContext.getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||
copyDatasets(newDmp, apiContext.getDatabaseRepository().getDatasetDao());
|
||||
|
||||
}
|
||||
|
||||
public static void delete(ApiContext apiContext, UUID uuid) throws DMPWithDatasetsException {
|
||||
DMP oldDmp = apiContext.getDatabaseRepository().getDmpDao().find(uuid);
|
||||
if (oldDmp.getDataset().size() > 0)
|
||||
throw new DMPWithDatasetsException("You cannot Remove Datamanagement Plan with Datasets");
|
||||
oldDmp.setStatus(DMP.DMPStatus.DELETED.getValue());
|
||||
apiContext.getDatabaseRepository().getDmpDao().createOrUpdate(oldDmp);
|
||||
}
|
||||
|
||||
private static void createResearchersIfTheyDontExist(DMP newDmp, ResearcherDao researcherRepository) {
|
||||
|
@ -115,4 +136,54 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
private static void copyDatasets(DMP newDmp, DatasetDao datasetDao) {
|
||||
List<CompletableFuture<Dataset>> futures = new LinkedList<>();
|
||||
for (Dataset dataset : newDmp.getDataset()) {
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
Dataset entityDataset = datasetDao.find(dataset.getId(), HintedModelFactory.getHint(DatasetListingModel.class));
|
||||
Dataset newDataset = new Dataset();
|
||||
newDataset.update(entityDataset);
|
||||
newDataset.setDmp(newDmp);
|
||||
if (newDataset.getDataRepositories() != null) {
|
||||
newDataset.setDataRepositories(newDataset.getDataRepositories().stream().map(item -> {
|
||||
DataRepository dataRepository = new DataRepository();
|
||||
dataRepository.setId(item.getId());
|
||||
return dataRepository;
|
||||
}).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
if (newDataset.getExternalDatasets() != null) {
|
||||
newDataset.setExternalDatasets(newDataset.getExternalDatasets().stream().map(item -> {
|
||||
ExternalDataset externalDataset = new ExternalDataset();
|
||||
externalDataset.setId(item.getId());
|
||||
return externalDataset;
|
||||
}).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
if (newDataset.getRegistries() != null) {
|
||||
newDataset.setRegistries(newDataset.getRegistries().stream().map(item -> {
|
||||
Registry registry = new Registry();
|
||||
registry.setId(item.getId());
|
||||
return registry;
|
||||
}).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
if (newDataset.getServices() != null) {
|
||||
newDataset.setServices(newDataset.getServices().stream().map(item -> {
|
||||
Service service = new Service();
|
||||
service.setId(item.getId());
|
||||
return service;
|
||||
}).collect(Collectors.toSet()));
|
||||
}
|
||||
newDataset.setCreated(new Date());
|
||||
return newDataset;
|
||||
}).thenApplyAsync(item -> {
|
||||
futures.add(datasetDao.createOrUpdateAsync(item));
|
||||
return futures;
|
||||
}).join();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.HintedModelFactory;
|
||||
import eu.eudat.models.criteria.DataRepositoryCriteria;
|
||||
|
@ -23,6 +24,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
public class DatasetManager {
|
||||
|
@ -33,10 +35,18 @@ public class DatasetManager {
|
|||
QueryableList<eu.eudat.entities.Dataset> items = apiContext.getDatabaseRepository().getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.entities.Dataset> authItems = apiContext.getDatabaseRepository().getDatasetDao().getAuthenticated(items, userInfo);
|
||||
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
|
||||
List<DatasetListingModel> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, DatasetListingModel>().fromDataModel(pagedItems.withHint(HintedModelFactory.getHint(DatasetListingModel.class)).toList(), DatasetListingModel.class);
|
||||
DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>();
|
||||
dataTable.setData(datasets);
|
||||
dataTable.setTotalCount(items.count());
|
||||
|
||||
CompletableFuture<List<Dataset>> itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DatasetListingModel.class)).toListAsync().whenComplete((resultList,throwable)->{
|
||||
List<DatasetListingModel> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, DatasetListingModel>().fromDataModel(resultList, DatasetListingModel.class);
|
||||
dataTable.setData(datasets);
|
||||
});
|
||||
|
||||
CompletableFuture countFuture = items.countAsync().whenComplete((count, throwable) -> {
|
||||
dataTable.setTotalCount(count);
|
||||
});
|
||||
|
||||
CompletableFuture.allOf(itemsFuture,countFuture).join();
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.managers;
|
|||
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.invitation.Invitation;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.models.userinfo.UserInfoInvitationModel;
|
||||
|
@ -11,8 +11,6 @@ import eu.eudat.queryable.QueryableList;
|
|||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.text.ParseException;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import eu.eudat.dao.entities.ProjectDao;
|
||||
import eu.eudat.dao.entities.UserInfoDao;
|
||||
|
@ -26,10 +27,16 @@ public class ProjectManager {
|
|||
public DataTableData<eu.eudat.models.project.ProjectListingModel> getPaged(ProjectDao projectRepository, ProjectTableRequest projectTableRequest) throws Exception {
|
||||
QueryableList<eu.eudat.entities.Project> items = projectRepository.getWithCriteria(projectTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.entities.Project> pagedItems = PaginationManager.applyPaging(items, projectTableRequest);
|
||||
List<eu.eudat.models.project.ProjectListingModel> projects = new DomainModelConverter<eu.eudat.entities.Project, ProjectListingModel>().fromDataModel(pagedItems.toList(), eu.eudat.models.project.ProjectListingModel.class);
|
||||
DataTableData<eu.eudat.models.project.ProjectListingModel> dataTable = new DataTableData<eu.eudat.models.project.ProjectListingModel>();
|
||||
dataTable.setData(projects);
|
||||
dataTable.setTotalCount(items.count());
|
||||
|
||||
CompletableFuture projectsFuture = pagedItems.toListAsync().whenComplete((results, throwable) -> {
|
||||
List<eu.eudat.models.project.ProjectListingModel> projects = new DomainModelConverter<eu.eudat.entities.Project, ProjectListingModel>().fromDataModel(results, eu.eudat.models.project.ProjectListingModel.class);
|
||||
dataTable.setData(projects);
|
||||
});
|
||||
|
||||
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
||||
|
||||
CompletableFuture.allOf(projectsFuture,countFuture).join();
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.entities.Researcher;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/5/2018.
|
||||
*/
|
||||
public class ResearcherManager {
|
||||
|
||||
public static Researcher create(ApiContext apiContext, eu.eudat.models.researcher.Researcher researcher) throws Exception {
|
||||
Researcher researcherEntity = new DomainModelConverter<Researcher, eu.eudat.models.researcher.Researcher>().toDataModel(Arrays.asList(researcher)).get(0);
|
||||
return apiContext.getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity);
|
||||
}
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.dao.entities.UserInfoDao;
|
||||
import eu.eudat.dao.entities.UserRoleDao;
|
||||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.UserRole;
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
import eu.eudat.models.login.Credentials;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.models.userinfo.UserInfo;
|
||||
import eu.eudat.models.userinfo.UserInfoTableRequestItem;
|
||||
import eu.eudat.models.userinfo.UserListingModel;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
@ -20,7 +17,6 @@ import org.w3c.dom.Element;
|
|||
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class UserManager {
|
||||
|
|
|
@ -0,0 +1,193 @@
|
|||
package eu.eudat.models.dmp;
|
||||
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.dataset.Dataset;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.userinfo.UserInfo;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/5/2018.
|
||||
*/
|
||||
public class DataManagementPlanNewVersionModel implements DataModel<DMP> {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private DataManagementPlan previous;
|
||||
private int version;
|
||||
private int status;
|
||||
private String description;
|
||||
private List<AssociatedProfile> profiles;
|
||||
private eu.eudat.models.project.Project project;
|
||||
private List<Organisation> organisations;
|
||||
private List<Researcher> researchers;
|
||||
private List<UserInfo> associatedUsers;
|
||||
private eu.eudat.models.userinfo.UserInfo creator;
|
||||
private Date created;
|
||||
private List<Dataset> datasets;
|
||||
|
||||
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 DataManagementPlan getPrevious() {
|
||||
return previous;
|
||||
}
|
||||
|
||||
public void setPrevious(DataManagementPlan previous) {
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<AssociatedProfile> getProfiles() {
|
||||
return profiles;
|
||||
}
|
||||
|
||||
public void setProfiles(List<AssociatedProfile> profiles) {
|
||||
this.profiles = profiles;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public List<Organisation> getOrganisations() {
|
||||
return organisations;
|
||||
}
|
||||
|
||||
public void setOrganisations(List<Organisation> organisations) {
|
||||
this.organisations = organisations;
|
||||
}
|
||||
|
||||
public List<Researcher> getResearchers() {
|
||||
return researchers;
|
||||
}
|
||||
|
||||
public void setResearchers(List<Researcher> researchers) {
|
||||
this.researchers = researchers;
|
||||
}
|
||||
|
||||
public List<UserInfo> getAssociatedUsers() {
|
||||
return associatedUsers;
|
||||
}
|
||||
|
||||
public void setAssociatedUsers(List<UserInfo> associatedUsers) {
|
||||
this.associatedUsers = associatedUsers;
|
||||
}
|
||||
|
||||
public UserInfo getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(UserInfo creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public List<Dataset> getDatasets() {
|
||||
return datasets;
|
||||
}
|
||||
|
||||
public void setDatasets(List<Dataset> datasets) {
|
||||
this.datasets = datasets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMP toDataModel() throws Exception {
|
||||
DMP entity = new DMP();
|
||||
entity.setId(this.id);
|
||||
entity.setUsers(new HashSet<>(new DomainModelConverter<eu.eudat.entities.UserInfo, UserInfo>().toDataModel(this.associatedUsers)));
|
||||
entity.setDescription(this.description);
|
||||
entity.setStatus((short) this.status);
|
||||
entity.setPrevious(this.previous == null ? null : new DomainModelConverter<DMP, DataManagementPlan>().toDataModel(Arrays.asList(this.previous)).get(0));
|
||||
entity.setCreated(new Date());
|
||||
entity.setLabel(this.label);
|
||||
entity.setModified(new Date());
|
||||
List<eu.eudat.entities.Dataset> datasets = new LinkedList<>();
|
||||
if(this.datasets!=null){
|
||||
for (Dataset dataset :this.datasets){
|
||||
eu.eudat.entities.Dataset entityDataset = new eu.eudat.entities.Dataset();
|
||||
entityDataset.setId(dataset.getId());
|
||||
datasets.add(entityDataset);
|
||||
}
|
||||
entity.setDataset(new HashSet<>(datasets));
|
||||
}
|
||||
if (this.organisations != null && !this.organisations.isEmpty())
|
||||
entity.setOrganisations(new HashSet<eu.eudat.entities.Organisation>(new DomainModelConverter<eu.eudat.entities.Organisation, Organisation>().toDataModel(this.organisations)));
|
||||
if (this.researchers != null && !this.researchers.isEmpty())
|
||||
entity.setResearchers(new HashSet<eu.eudat.entities.Researcher>(new DomainModelConverter<eu.eudat.entities.Researcher, Researcher>().toDataModel(this.researchers)));
|
||||
if (this.project != null) entity.setProject(this.project.toDataModel());
|
||||
if (this.profiles != null) {
|
||||
Document associatedProfileDoc = XmlBuilder.getDocument();
|
||||
Element associatedProfilesElement = associatedProfileDoc.createElement("profiles");
|
||||
for (AssociatedProfile associatedProfile : this.profiles) {
|
||||
associatedProfilesElement.appendChild(associatedProfile.toXml(associatedProfileDoc));
|
||||
}
|
||||
associatedProfileDoc.appendChild(associatedProfilesElement);
|
||||
entity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package eu.eudat.models.researcher;
|
||||
|
||||
import eu.eudat.models.DataModel;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/5/2018.
|
||||
*/
|
||||
public class Researcher implements DataModel<eu.eudat.entities.Researcher> {
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(eu.eudat.entities.Researcher entity) throws InstantiationException, IllegalAccessException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public eu.eudat.entities.Researcher toDataModel() throws Exception {
|
||||
eu.eudat.entities.Researcher researcher = new eu.eudat.entities.Researcher();
|
||||
researcher.setCreated(new Date());
|
||||
researcher.setLabel(this.firstName+" "+this.lastName);
|
||||
researcher.setModified(new Date());
|
||||
researcher.setReference("dmp:"+researcher.getLabel());
|
||||
researcher.setStatus((short)0);
|
||||
return researcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.models.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.types.Authorities;
|
||||
|
||||
import java.util.*;
|
||||
|
|
|
@ -6,9 +6,10 @@ import eu.eudat.queryable.predicates.OrderByPredicate;
|
|||
import eu.eudat.queryable.predicates.SelectPredicate;
|
||||
import eu.eudat.queryable.predicates.SinglePredicate;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.persistence.criteria.Subquery;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface QueryableList<T extends DataEntity<T>> {
|
||||
QueryableList<T> where(SinglePredicate<T> predicate);
|
||||
|
@ -17,10 +18,16 @@ public interface QueryableList<T extends DataEntity<T>> {
|
|||
|
||||
List<T> toList();
|
||||
|
||||
CompletableFuture<List<T>> toListAsync();
|
||||
|
||||
T getSingle();
|
||||
|
||||
CompletableFuture<T> getSingleAsync();
|
||||
|
||||
T getSingleOrDefault();
|
||||
|
||||
CompletableFuture<T> getSingleOrDefaultAsync();
|
||||
|
||||
QueryableList<T> skip(Integer offset);
|
||||
|
||||
QueryableList<T> take(Integer length);
|
||||
|
@ -35,4 +42,8 @@ public interface QueryableList<T extends DataEntity<T>> {
|
|||
|
||||
Long count();
|
||||
|
||||
CompletableFuture<Long> countAsync();
|
||||
|
||||
Subquery<T> subQuery(SinglePredicate<T> predicate,List<String> fields);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import eu.eudat.queryable.exceptions.NotSingleResultException;
|
|||
import eu.eudat.queryable.predicates.OrderByPredicate;
|
||||
import eu.eudat.queryable.predicates.SelectPredicate;
|
||||
import eu.eudat.queryable.predicates.SinglePredicate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
@ -14,6 +16,7 @@ import javax.persistence.criteria.*;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class QueryableHibernateList<T extends DataEntity<T>> implements QueryableList<T> {
|
||||
|
@ -22,6 +25,7 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
private CriteriaQuery<T> query;
|
||||
private Class<T> tClass;
|
||||
private Root<T> root;
|
||||
private Subquery<T> subquery;
|
||||
private List<SinglePredicate<T>> predicates = new LinkedList<>();
|
||||
private List<OrderByPredicate<T>> orderings = new LinkedList<>();
|
||||
private List<Selection> fields = new LinkedList<>();
|
||||
|
@ -107,6 +111,15 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
return this.manager.createQuery(criteriaQuery).getSingleResult();
|
||||
}
|
||||
|
||||
public CompletableFuture<Long> countAsync() {
|
||||
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
|
||||
CriteriaQuery<Long> criteriaQuery = criteriaBuilder.createQuery(Long.class);
|
||||
Root<T> root = criteriaQuery.from(tClass);
|
||||
criteriaQuery.select(criteriaBuilder.count(root));
|
||||
criteriaQuery.where(this.generateWherePredicates(this.predicates, root));
|
||||
return CompletableFuture.supplyAsync(() -> this.manager.createQuery(criteriaQuery).getSingleResult());
|
||||
}
|
||||
|
||||
private Predicate[] generateWherePredicates(List<SinglePredicate<T>> singlePredicates, Root<T> root) {
|
||||
List<Predicate> predicates = new LinkedList<>();
|
||||
for (SinglePredicate<T> singlePredicate : singlePredicates) {
|
||||
|
@ -137,32 +150,81 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
return typedQuery.getResultList();
|
||||
}
|
||||
|
||||
public CompletableFuture<List<T>> toListAsync() {
|
||||
this.query.where(this.generateWherePredicates(this.predicates, this.root));
|
||||
if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root));
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||
if (this.offset != null) typedQuery.setFirstResult(this.offset);
|
||||
if (this.length != null) typedQuery.setMaxResults(this.length);
|
||||
if (this.hint != null && this.hints.contains(hint)) {
|
||||
List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()[0]).collect(Collectors.toList());
|
||||
if (ids != null && !ids.isEmpty()) typedQuery = queryWithHint(ids);
|
||||
}
|
||||
TypedQuery<T> finalQuery = typedQuery;
|
||||
return CompletableFuture.supplyAsync(() -> finalQuery.getResultList());
|
||||
}
|
||||
|
||||
public T getSingle() {
|
||||
this.query.where(this.generateWherePredicates(this.predicates, this.root));
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||
if (this.hint != null)
|
||||
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
|
||||
return typedQuery.getSingleResult();
|
||||
}
|
||||
|
||||
public CompletableFuture<T> getSingleAsync() {
|
||||
this.query.where(this.generateWherePredicates(this.predicates, this.root));
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||
if (this.hint != null)
|
||||
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
|
||||
return CompletableFuture.supplyAsync(() -> typedQuery.getSingleResult());
|
||||
}
|
||||
|
||||
public T getSingleOrDefault() {
|
||||
this.query.where(this.generateWherePredicates(this.predicates, this.root));
|
||||
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||
if (this.hint != null)
|
||||
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
|
||||
List<T> results = typedQuery.getResultList();
|
||||
if (results.size() == 0) return null;
|
||||
if (results.size() == 1) return results.get(0);
|
||||
else throw new NotSingleResultException("Query returned more than one items");
|
||||
}
|
||||
|
||||
public CompletableFuture<T> getSingleOrDefaultAsync() {
|
||||
this.query.where(this.generateWherePredicates(this.predicates, this.root));
|
||||
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||
if (this.hint != null)
|
||||
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
|
||||
return CompletableFuture.supplyAsync(() -> typedQuery.getResultList()).thenApply(list -> {
|
||||
if (list.size() == 0) return null;
|
||||
if (list.size() == 1) return list.get(0);
|
||||
else throw new NotSingleResultException("Query returned more than one items");
|
||||
});
|
||||
}
|
||||
|
||||
private TypedQuery<T> queryWithHint(List ids) {
|
||||
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
|
||||
CriteriaQuery<T> criteriaQuery = criteriaBuilder.createQuery(tClass);
|
||||
Root<T> criteriaRoot = criteriaQuery.from(this.tClass);
|
||||
|
||||
criteriaQuery.where(criteriaRoot.get("id").in(ids));
|
||||
if (!this.orderings.isEmpty()) criteriaQuery.orderBy(this.generateOrderPredicates(this.orderings, criteriaRoot));
|
||||
if (!this.orderings.isEmpty())
|
||||
criteriaQuery.orderBy(this.generateOrderPredicates(this.orderings, criteriaRoot));
|
||||
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(criteriaQuery);
|
||||
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
|
||||
return typedQuery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subquery<T> subQuery(SinglePredicate<T> predicate, List<String> fields) {
|
||||
Subquery<T> subquery = this.manager.getCriteriaBuilder().createQuery().subquery(this.tClass);
|
||||
Root<T> root = subquery.from(this.tClass);
|
||||
subquery.where(predicate.applyPredicate(this.manager.getCriteriaBuilder(), root));
|
||||
subquery.select(root.get(fields.get(0)));
|
||||
return subquery;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,14 @@ package eu.eudat.security;
|
|||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.login.LoginInfo;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.security.validators.TokenValidatorFactory;
|
||||
import eu.eudat.security.validators.TokenValidatorFactoryImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.eudat.dao.entities.UserInfoDao;
|
||||
import eu.eudat.exceptions.NonValidTokenException;
|
||||
import eu.eudat.security.validators.google.GoogleTokenValidator;
|
||||
import eu.eudat.exceptions.security.NonValidTokenException;
|
||||
|
||||
@Component
|
||||
public class CustomAuthenticationProvider {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.security.validators;
|
||||
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.exceptions.NonValidTokenException;
|
||||
import eu.eudat.exceptions.security.NonValidTokenException;
|
||||
import eu.eudat.models.login.LoginInfo;
|
||||
import eu.eudat.models.security.Principal;
|
||||
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
package eu.eudat.security.validators.facebook;
|
||||
|
||||
import eu.eudat.dao.entities.UserInfoDao;
|
||||
import eu.eudat.dao.entities.security.CredentialDao;
|
||||
import eu.eudat.dao.entities.security.UserTokenDao;
|
||||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.entities.UserToken;
|
||||
import eu.eudat.exceptions.NonValidTokenException;
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.models.criteria.UserInfoCriteria;
|
||||
import eu.eudat.exceptions.security.NonValidTokenException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.login.LoginInfo;
|
||||
import eu.eudat.models.loginprovider.LoginProviderUser;
|
||||
import eu.eudat.models.security.Principal;
|
||||
|
@ -18,14 +11,8 @@ import eu.eudat.services.ApiContext;
|
|||
import eu.eudat.services.AuthenticationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.social.connect.Connection;
|
||||
import org.springframework.social.connect.ConnectionKey;
|
||||
import org.springframework.social.facebook.api.Facebook;
|
||||
import org.springframework.social.facebook.api.User;
|
||||
import org.springframework.social.facebook.connect.FacebookConnectionFactory;
|
||||
import org.springframework.social.facebook.connect.FacebookServiceProvider;
|
||||
import org.springframework.social.oauth2.AccessGrant;
|
||||
import org.springframework.social.oauth2.OAuth2Operations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
package eu.eudat.security.validators.google;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.Principal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.api.client.googleapis.auth.oauth2.*;
|
||||
import eu.eudat.dao.entities.security.CredentialDao;
|
||||
import eu.eudat.dao.entities.security.UserTokenDao;
|
||||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.UserToken;
|
||||
import eu.eudat.models.criteria.UserInfoCriteria;
|
||||
import eu.eudat.models.login.LoginInfo;
|
||||
import eu.eudat.models.loginprovider.LoginProviderUser;
|
||||
import eu.eudat.security.validators.TokenValidator;
|
||||
|
@ -27,14 +18,9 @@ import com.google.api.client.http.HttpTransport;
|
|||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
|
||||
import eu.eudat.dao.entities.UserInfoDao;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.exceptions.NonValidTokenException;
|
||||
import eu.eudat.exceptions.security.NonValidTokenException;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static com.sun.org.apache.xalan.internal.xsltc.compiler.Constants.REDIRECT_URI;
|
||||
|
||||
@Component("googleTokenValidator")
|
||||
public class GoogleTokenValidator implements TokenValidator {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.security.validators.linkedin;
|
||||
|
||||
import eu.eudat.exceptions.NonValidTokenException;
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.exceptions.security.NonValidTokenException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.login.LoginInfo;
|
||||
import eu.eudat.models.loginprovider.LoginProviderUser;
|
||||
import eu.eudat.models.security.Principal;
|
||||
|
@ -11,7 +11,6 @@ import eu.eudat.services.ApiContext;
|
|||
import eu.eudat.services.AuthenticationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.social.facebook.connect.FacebookServiceProvider;
|
||||
import org.springframework.social.linkedin.api.LinkedIn;
|
||||
import org.springframework.social.linkedin.api.LinkedInProfile;
|
||||
import org.springframework.social.linkedin.connect.LinkedInServiceProvider;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.security.validators.twitter;
|
||||
|
||||
import eu.eudat.exceptions.NonValidTokenException;
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.exceptions.security.NonValidTokenException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.login.LoginInfo;
|
||||
import eu.eudat.models.loginprovider.LoginProviderUser;
|
||||
import eu.eudat.models.security.Principal;
|
||||
|
@ -11,12 +11,8 @@ import eu.eudat.services.ApiContext;
|
|||
import eu.eudat.services.AuthenticationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.social.linkedin.api.LinkedIn;
|
||||
import org.springframework.social.linkedin.api.LinkedInProfile;
|
||||
import org.springframework.social.linkedin.connect.LinkedInServiceProvider;
|
||||
import org.springframework.social.oauth1.AuthorizedRequestToken;
|
||||
import org.springframework.social.oauth1.OAuthToken;
|
||||
import org.springframework.social.oauth2.AccessGrant;
|
||||
import org.springframework.social.twitter.api.TwitterProfile;
|
||||
import org.springframework.social.twitter.api.impl.TwitterTemplate;
|
||||
import org.springframework.social.twitter.connect.TwitterServiceProvider;
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import javax.xml.ws.ServiceMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service("authenticationService ")
|
||||
|
@ -56,7 +57,7 @@ public class AuthenticationService {
|
|||
principal.setExpiresAt(token.getExpiresAt());
|
||||
principal.setName(user.getName());
|
||||
|
||||
List<UserRole> userRoles = this.apiContext.getDatabaseRepository().getUserRoleDao().getUserRoles(user);
|
||||
List<UserRole> userRoles = user.getUserRoles().stream().collect(Collectors.toList());
|
||||
for (UserRole item : userRoles) {
|
||||
if (principal.getAuthz() == null) principal.setAuthorities(new HashSet<>());
|
||||
principal.getAuthz().add(Authorities.fromInteger(item.getRole()));
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package eu.eudat.utilities;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/5/2018.
|
||||
*/
|
||||
public interface Cloneable<T> {
|
||||
T clone();
|
||||
}
|
|
@ -18,11 +18,18 @@ public class DomainModelConverter<T extends DataEntity,U extends DataModel<T>> {
|
|||
return entities;
|
||||
}
|
||||
|
||||
public List<U> fromDataModel(List<T> entities,Class<U> clazz) throws IllegalAccessException, InstantiationException {
|
||||
public List<U> fromDataModel(List<T> entities,Class<U> clazz) {
|
||||
List<U> models = new LinkedList<>();
|
||||
for(T entity:entities){
|
||||
U model = clazz.newInstance();
|
||||
model.fromDataModel(entity);
|
||||
U model = null;
|
||||
try {
|
||||
model = clazz.newInstance();
|
||||
model.fromDataModel(entity);
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
models.add(model);
|
||||
}
|
||||
return models;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export const HostConfiguration = {
|
||||
Server: 'http://192.168.32.67:8080/', //'http://dl043.madgik.di.uoa.gr:8080/'
|
||||
Server: 'http://192.168.32.64:8080/', //'http://dl043.madgik.di.uoa.gr:8080/'
|
||||
App: 'localhost:4200/' // 'http://dl043.madgik.di.uoa.gr:8080/'
|
||||
//CASHost: 'https://login-devel.uoa.gr/login',
|
||||
//Service: 'http://elkefinman/login'
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import { DatasetWizardListingComponent } from './wizard/listing/dataset-wizard-listing.component';
|
||||
import { DataManagementPlanWizardEditorComponent } from './wizard/editor/dmp-wizard-editor.component';
|
||||
import { DataManagementPlanWizardComponent } from './wizard/dmp-wizard.component';
|
||||
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
||||
import { BaseHttpService } from '../utilities/cite-http-service-module/base-http.service';
|
||||
import { InvitationAcceptedComponent } from '../invitation-accepted/invitation-accepted.component';
|
||||
|
@ -35,6 +38,9 @@ import { NgModule } from '@angular/core';
|
|||
DataManagementPlanEditorComponent,
|
||||
InvitationComponent,
|
||||
InvitationAcceptedComponent,
|
||||
DataManagementPlanWizardComponent,
|
||||
DataManagementPlanWizardEditorComponent,
|
||||
DatasetWizardListingComponent
|
||||
],
|
||||
|
||||
exports: [
|
||||
|
@ -42,7 +48,9 @@ import { NgModule } from '@angular/core';
|
|||
DataManagementPlanEditorComponent,
|
||||
InvitationComponent,
|
||||
InvitationAcceptedComponent,
|
||||
|
||||
DataManagementPlanWizardComponent,
|
||||
DataManagementPlanWizardEditorComponent,
|
||||
DatasetWizardListingComponent
|
||||
],
|
||||
entryComponents: [
|
||||
InvitationComponent
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { DataManagementPlanWizardComponent } from './wizard/dmp-wizard.component';
|
||||
import { DataManagementPlanEditorComponent } from './editor/dmp-editor.component';
|
||||
import { DataManagementPlanListingComponent } from './listing/dmp-listing.component';
|
||||
import { DatasetListingComponent } from '../datasets/listing/dataset-listing.component';
|
||||
|
@ -7,7 +8,7 @@ const routes: Routes = [
|
|||
{ path: '', component: DataManagementPlanListingComponent },
|
||||
{ path: 'edit/:id', component: DataManagementPlanEditorComponent },
|
||||
{ path: 'new', component: DataManagementPlanEditorComponent },
|
||||
{ path: 'new_version/:id', component: DataManagementPlanEditorComponent, data: { clone: "clone" } },
|
||||
{ path: 'new_version/:id', component: DataManagementPlanWizardComponent, data: { clone: "clone" } },
|
||||
];
|
||||
|
||||
export const DataManagementPlanRoutes = RouterModule.forChild(routes);
|
||||
|
|
|
@ -86,10 +86,10 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
});
|
||||
// let clone = this.route.snapshot.data.clone; ginetai kai esti ikalyvas
|
||||
this.route
|
||||
.queryParams
|
||||
.subscribe(params => {
|
||||
this.createNewVersion = params["clone"];
|
||||
});
|
||||
.queryParams
|
||||
.subscribe(params => {
|
||||
this.createNewVersion = params["clone"];
|
||||
});
|
||||
}
|
||||
|
||||
formSubmit(): void {
|
||||
|
@ -102,19 +102,12 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
return this.formGroup.valid;
|
||||
}
|
||||
|
||||
onSubmit(): void {debugger;
|
||||
if(this.createNewVersion =="true"){
|
||||
this.formGroup.value.id = null;
|
||||
this.dataManagementPlanService.createDataManagementPlanClone(this.formGroup.value, this.formGroup.get("id").value).subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
else
|
||||
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
onSubmit(): void {
|
||||
debugger;
|
||||
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
error => this.onCallbackError(error)
|
||||
)
|
||||
}
|
||||
|
||||
onCallbackSuccess(): void {
|
||||
|
@ -142,7 +135,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
}
|
||||
|
||||
public invite(): void {
|
||||
this.router.navigate(['/invite/'+this.dataManagementPlan.id]);
|
||||
this.router.navigate(['/invite/' + this.dataManagementPlan.id]);
|
||||
}
|
||||
|
||||
filterOrganisations(value: string): void {
|
||||
|
|
|
@ -64,7 +64,7 @@ export class DataManagementPlanListingComponent implements OnInit {
|
|||
}
|
||||
|
||||
newVersion(rowId: String) {
|
||||
this.router.navigate(['/dmps/new_version/' + rowId], { queryParams: { clone: 'true' } });
|
||||
this.router.navigate(['/dmps/new_version/' + rowId]);
|
||||
}
|
||||
|
||||
getDefaultCriteria(): DataManagementPlanCriteria {
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<div class="dmp-wizard">
|
||||
<mat-horizontal-stepper [linear]="isLinear" #stepper>
|
||||
<mat-step>
|
||||
<ng-template matStepLabel>{{'DMP-WIZARD.FIRST-STEP.TITLE' | translate}}</ng-template>
|
||||
<app-dmp-wizard-editor-component [formGroup]="formGroup" *ngIf="formGroup"></app-dmp-wizard-editor-component>
|
||||
<div class="navigation-buttons-container">
|
||||
<button style="float:right;" matStepperNext mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.NEXT' | translate}}</button>
|
||||
</div>
|
||||
</mat-step>
|
||||
<mat-step>
|
||||
<ng-template matStepLabel>{{'DMP-WIZARD.FIRST-STEP.TITLE' | translate}}</ng-template>
|
||||
<app-dataset-wizard-listing-component [formGroup]="formGroup" [dmpId]="formGroup.get('id').value" *ngIf="formGroup"></app-dataset-wizard-listing-component>
|
||||
<div class="navigation-buttons-container">
|
||||
<button matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button>
|
||||
<button style="float:right;" matStepperNext mat-raised-button (click)='submit()' color="primary">{{'DATASET-WIZARD.ACTIONS.SAVE' | translate}}</button>
|
||||
</div>
|
||||
</mat-step>
|
||||
</mat-horizontal-stepper>
|
||||
</div>
|
|
@ -0,0 +1,46 @@
|
|||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input-table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.table-card .mat-grid-tile {
|
||||
background: rgba(0, 0, 0, 0.32);
|
||||
}
|
||||
|
||||
.dmp-wizard {
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
mat-form-field {
|
||||
width: 100%;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
td-chips {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.navigation-buttons-container {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.mat-card {
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 16px;
|
||||
}
|
||||
|
||||
.left-button {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.description-area {
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
|
||||
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
|
||||
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||
import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel';
|
||||
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { MatSnackBar } from '@angular/material';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
@Component({
|
||||
selector: 'app-dmp-wizard-component',
|
||||
templateUrl: 'dmp-wizard.component.html',
|
||||
styleUrls: ['./dmp-wizard.component.scss'],
|
||||
providers: [DataManagementPlanService]
|
||||
})
|
||||
export class DataManagementPlanWizardComponent implements OnInit {
|
||||
constructor(
|
||||
private dataManagementPlanService: DataManagementPlanService,
|
||||
private language: TranslateService,
|
||||
public snackBar: MatSnackBar,
|
||||
public route: ActivatedRoute,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
itemId: string
|
||||
dataManagementPlan: DataManagementPlanModel;
|
||||
formGroup: FormGroup
|
||||
ngOnInit(): void {
|
||||
this.route.params.subscribe((params: Params) => {
|
||||
this.itemId = params['id'];
|
||||
this.dataManagementPlanService.getSingle(this.itemId).map(data => data as DataManagementPlanModel)
|
||||
.subscribe(data => {
|
||||
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
|
||||
this.formGroup = this.dataManagementPlan.buildForm();
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
submit() {
|
||||
debugger;
|
||||
this.dataManagementPlanService.newVersion(this.formGroup.value, this.itemId).subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
|
||||
onCallbackSuccess(): void {
|
||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||
duration: 3000,
|
||||
extraClasses: ['snackbar-success']
|
||||
})
|
||||
this.router.navigate(['/dmps']);
|
||||
}
|
||||
|
||||
onCallbackError(error: any) {
|
||||
this.setErrorModel(error.error);
|
||||
//this.validateAllFormFields(this.formGroup);
|
||||
}
|
||||
|
||||
public setErrorModel(errorModel: BaseErrorModel) {
|
||||
Object.keys(errorModel).forEach(item => {
|
||||
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<div class="data-management-plan-wizard-editor">
|
||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<mat-form-field class="full-width">
|
||||
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | 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>
|
||||
|
||||
<mat-form-field class="full-width">
|
||||
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
|
||||
required></textarea>
|
||||
<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>
|
||||
|
||||
<auto-complete class="mat-form-field-full-width" placeholder="{{'DMP-EDITOR.FIELDS.PROJECT' | translate}}" [configuration]="projectAutoCompleteConfiguration"
|
||||
titleKey="label" [control]="formGroup.get('project')" [required]="true">
|
||||
</auto-complete>
|
||||
|
||||
<td-chips color="accent" [items]="filteredProfiles" formControlName="profiles" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
|
||||
(inputChange)="filterProfiles($event)" requireMatch>
|
||||
<ng-template td-chip let-chip="chip">
|
||||
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.label.substring(0, 1).toUpperCase()}}</div>
|
||||
{{chip.label}}
|
||||
</ng-template>
|
||||
<ng-template td-autocomplete-option let-option="option">
|
||||
<div layout="row" layout-align="start center">
|
||||
{{option.label}}
|
||||
</div>
|
||||
</ng-template>
|
||||
<mat-progress-bar [style.height.px]="2" *ngIf="filteredProfilesAsync" mode="indeterminate"></mat-progress-bar>
|
||||
<mat-error style="font-size:10.5px" *ngIf="formGroup.get('profiles').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</td-chips>
|
||||
|
||||
|
||||
<td-chips color="accent" [items]="filteredOrganisations" formControlName="organisations" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
|
||||
(inputChange)="filterOrganisations($event)" requireMatch>
|
||||
<ng-template td-chip let-chip="chip">
|
||||
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.name.substring(0, 1).toUpperCase()}}</div>
|
||||
{{chip.name}}
|
||||
</ng-template>
|
||||
<ng-template td-autocomplete-option let-option="option">
|
||||
<div layout="row" layout-align="start center">
|
||||
{{option.name}}
|
||||
</div>
|
||||
</ng-template>
|
||||
<mat-progress-bar [style.height.px]="2" *ngIf="filteringOrganisationsAsync" mode="indeterminate"></mat-progress-bar>
|
||||
</td-chips>
|
||||
|
||||
<td-chips style="margin-bottom:25px;" color="accent" [items]="filteredResearchers" formControlName="researchers" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
|
||||
(inputChange)="filterResearchers($event)" requireMatch>
|
||||
<ng-template td-chip let-chip="chip">
|
||||
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.name.substring(0, 1).toUpperCase()}}</div>
|
||||
{{chip.name}}
|
||||
</ng-template>
|
||||
<ng-template td-autocomplete-option let-option="option">
|
||||
<div layout="row" layout-align="start center">
|
||||
{{option.name}}
|
||||
</div>
|
||||
</ng-template>
|
||||
<mat-progress-bar [style.height.px]="2" *ngIf="filteringResearchersAsync" mode="indeterminate"></mat-progress-bar>
|
||||
</td-chips>
|
||||
|
||||
<mat-list *ngIf="associatedUsers?.length" role="list">
|
||||
<h3 mat-subheader>Associated Users</h3>
|
||||
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
|
||||
<mat-icon mat-list-icon>person</mat-icon>
|
||||
<div>{{user.name}}</div>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</form>
|
||||
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
|
||||
</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);
|
||||
}
|
||||
|
||||
.data-management-plan-wizard-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,174 @@
|
|||
import { DatasetProfileModel } from '../../../models/datasets/DatasetProfileModel';
|
||||
import { DatasetProfileCriteria } from '../../../models/criteria/dataset/DatasetProfileCriteria';
|
||||
import { BaseErrorModel } from '../../../models/error/BaseErrorModel';
|
||||
import { SnackBarNotificationComponent } from '../../../shared/components/notificaiton/snack-bar-notification.component';
|
||||
import { JsonSerializer } from '../../../utilities/JsonSerializer';
|
||||
import { RequestItem } from '../../../models/criteria/RequestItem';
|
||||
import { ProjectCriteria } from '../../../models/criteria/project/ProjectCriteria';
|
||||
import { DmpUsersModel } from '../../../models/dmpUsers/DmpUsersModel';
|
||||
import { AutoCompleteConfiguration } from '../../../shared/components/autocomplete/AutoCompleteConfiguration';
|
||||
import { ExternalSourcesItemModel } from '../../../models/external-sources/ExternalSourcesItemModel';
|
||||
import { DataManagementPlanModel } from '../../../models/data-managemnt-plans/DataManagementPlanModel';
|
||||
import { ProjectService } from '../../../services/project/project.service';
|
||||
import { ExternalSourcesService } from '../../../services/external-sources/external-sources.service';
|
||||
import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service';
|
||||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, Input } 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 { FormGroup } from '@angular/forms';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-wizard-editor-component',
|
||||
templateUrl: 'dmp-wizard-editor.component.html',
|
||||
styleUrls: ['./dmp-wizard-editor.component.scss'],
|
||||
providers: [DataManagementPlanService, ExternalSourcesService, ProjectService],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DataManagementPlanWizardEditorComponent implements AfterViewInit {
|
||||
|
||||
|
||||
isNew = true;
|
||||
@Input() formGroup: FormGroup = null;
|
||||
|
||||
filteringOrganisationsAsync: boolean = false;
|
||||
filteringResearchersAsync: boolean = false;
|
||||
filteredProfilesAsync: boolean = false;
|
||||
filteredOrganisations: ExternalSourcesItemModel[];
|
||||
filteredResearchers: ExternalSourcesItemModel[];
|
||||
filteredProfiles: DatasetProfileModel[];
|
||||
|
||||
projectAutoCompleteConfiguration: AutoCompleteConfiguration;
|
||||
createNewVersion;
|
||||
associatedUsers: Array<DmpUsersModel>
|
||||
|
||||
constructor(
|
||||
private dataManagementPlanService: DataManagementPlanService,
|
||||
private projectService: ProjectService,
|
||||
private externalSourcesService: ExternalSourcesService,
|
||||
private route: ActivatedRoute,
|
||||
public snackBar: MatSnackBar,
|
||||
public router: Router,
|
||||
public language: TranslateService,
|
||||
private _service: DataManagementPlanService
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
|
||||
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
||||
projectRequestItem.criteria = new ProjectCriteria();
|
||||
this.projectAutoCompleteConfiguration = new AutoCompleteConfiguration(this.projectService.getWithExternal.bind(this.projectService), projectRequestItem);
|
||||
}
|
||||
|
||||
formSubmit(): void {
|
||||
//this.touchAllFormFields(this.formGroup);
|
||||
if (!this.isFormValid()) { return; }
|
||||
this.onSubmit();
|
||||
}
|
||||
|
||||
public isFormValid() {
|
||||
return this.formGroup.valid;
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
debugger;
|
||||
this.dataManagementPlanService.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(['/dmps']);
|
||||
}
|
||||
|
||||
onCallbackError(error: any) {
|
||||
this.setErrorModel(error.error);
|
||||
//this.validateAllFormFields(this.formGroup);
|
||||
}
|
||||
|
||||
public setErrorModel(errorModel: BaseErrorModel) {
|
||||
Object.keys(errorModel).forEach(item => {
|
||||
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
|
||||
})
|
||||
}
|
||||
|
||||
public cancel(): void {
|
||||
this.router.navigate(['/dmps']);
|
||||
}
|
||||
|
||||
filterOrganisations(value: string): void {
|
||||
|
||||
this.filteredOrganisations = undefined;
|
||||
if (value) {
|
||||
this.filteringOrganisationsAsync = true;
|
||||
|
||||
this.externalSourcesService.searchDMPOrganizations(value).subscribe(items => {
|
||||
this.filteredOrganisations = items;
|
||||
this.filteringOrganisationsAsync = false;
|
||||
|
||||
// this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||
// return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||
// });
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
filterResearchers(value: string): void {
|
||||
|
||||
this.filteredResearchers = undefined;
|
||||
if (value) {
|
||||
this.filteringResearchersAsync = true;
|
||||
|
||||
this.externalSourcesService.searchDMPResearchers(value).subscribe(items => {
|
||||
this.filteredResearchers = items;
|
||||
this.filteringResearchersAsync = false;
|
||||
|
||||
// this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||
// return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||
// });
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
filterProfiles(value: string): void {
|
||||
|
||||
this.filteredProfiles = undefined;
|
||||
if (value) {
|
||||
this.filteredProfilesAsync = true;
|
||||
|
||||
// this.externalSourcesService.searchDMPProfiles(value).subscribe(items => {
|
||||
// this.filteredProfiles = items;
|
||||
// this.filteredProfilesAsync = false;
|
||||
|
||||
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||
// // });
|
||||
|
||||
// });
|
||||
|
||||
const request = new RequestItem<DatasetProfileCriteria>();
|
||||
let criteria = new DatasetProfileCriteria();
|
||||
criteria.like = value;
|
||||
request.criteria = criteria;
|
||||
this._service.searchDMPProfiles(request).subscribe(items => {
|
||||
this.filteredProfiles = items;
|
||||
this.filteredProfilesAsync = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<div class="container-fluid">
|
||||
<h3>{{titlePrefix}} {{'DATASET-LISTING.TITLE' | translate}}</h3>
|
||||
<mat-card class="mat-card">
|
||||
<mat-selection-list #selectedItems (selectionChange)="selectionChanged($event,selectedItems)">
|
||||
<mat-list-option *ngFor="let dataset of datasets;" [value]="dataset.id" >
|
||||
{{dataset.label}}
|
||||
</mat-list-option>
|
||||
</mat-selection-list>
|
||||
</mat-card>
|
||||
</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,84 @@
|
|||
import { DataTableData } from '../../../models/data-table/DataTableData';
|
||||
import { JsonSerializer } from '../../../utilities/JsonSerializer';
|
||||
import { DataTableRequest } from '../../../models/data-table/DataTableRequest';
|
||||
import { DatasetListingModel } from '../../../models/datasets/DatasetListingModel';
|
||||
import { DatasetCriteria } from '../../../models/criteria/dataset/DatasetCriteria';
|
||||
import { DataManagementPlanModel } from '../../../models/data-managemnt-plans/DataManagementPlanModel';
|
||||
import { DatasetCriteriaComponent } from '../../../shared/components/criteria/datasets/datasets-criteria.component';
|
||||
import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service';
|
||||
import { DatasetService } from '../../../services/dataset/dataset.service';
|
||||
import { Component, ViewChild, OnInit, AfterViewInit, Input } from "@angular/core";
|
||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||
import { Router, Params, ActivatedRoute } from "@angular/router";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { FormGroup, FormBuilder, FormControl, FormArray } from "@angular/forms"
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { PageEvent } from '@angular/material';
|
||||
import { SelectionModel } from '@angular/cdk/collections';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-wizard-listing-component',
|
||||
templateUrl: 'dataset-wizard-listing.component.html',
|
||||
styleUrls: ['./dataset-wizard-listing.component.scss'],
|
||||
providers: [DatasetService, DataManagementPlanService]
|
||||
})
|
||||
export class DatasetWizardListingComponent implements OnInit {
|
||||
|
||||
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
|
||||
|
||||
|
||||
titlePrefix: String;
|
||||
datasets: DatasetListingModel[] = []
|
||||
|
||||
@Input() dmpId: String;
|
||||
@Input() formGroup: FormGroup
|
||||
selection = new SelectionModel<Element>(true, []);
|
||||
|
||||
statuses = [
|
||||
{ value: '0', viewValue: 'Active' },
|
||||
{ value: '1', viewValue: 'Inactive' }
|
||||
];
|
||||
|
||||
constructor(
|
||||
private datasetService: DatasetService,
|
||||
private router: Router,
|
||||
private languageService: TranslateService,
|
||||
public snackBar: MatSnackBar,
|
||||
public route: ActivatedRoute,
|
||||
public dataManagementPlanService: DataManagementPlanService
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
if (this.dmpId != null) this.setDmpTitle(this.dmpId);
|
||||
let request: DataTableRequest<DatasetCriteria> = new DataTableRequest<DatasetCriteria>(null, null, null);
|
||||
request.criteria = new DatasetCriteria();
|
||||
request.criteria.dmpIds = [this.dmpId];
|
||||
this.datasetService.getPaged(request).subscribe(items => {
|
||||
this.datasets = JsonSerializer.fromJSONArray(items.data, DatasetListingModel)
|
||||
})
|
||||
this.formGroup.addControl("datasets", new FormBuilder().array(new Array<FormControl>()))
|
||||
}
|
||||
|
||||
setDmpTitle(dmpId: String) {
|
||||
this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel)
|
||||
.subscribe(data => {
|
||||
this.titlePrefix = data.label;
|
||||
});
|
||||
}
|
||||
|
||||
selectionChanged(event,selectedItems) {
|
||||
this.formGroup.removeControl("datasets");
|
||||
this.formGroup.addControl("datasets", new FormBuilder().array(new Array<FormControl>()))
|
||||
selectedItems.selectedOptions.selected.forEach(element => {
|
||||
(<FormArray>this.formGroup.get("datasets")).push(new FormBuilder().group({ id: element.value }))
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -49,7 +49,7 @@ export class DataManagementPlanService {
|
|||
return this.http.post<DatasetProfileModel[]>(this.actionUrl + "datasetprofiles/get", dataSetProfileRequest, { headers: this.headers });
|
||||
}
|
||||
|
||||
createDataManagementPlanClone(dataManagementPlanModel: DataManagementPlanModel, id:String): Observable<DataManagementPlanModel> {
|
||||
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'clone/' + 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 });
|
||||
}
|
||||
}
|
||||
|
|
6680
hs_err_pid11912.log
6680
hs_err_pid11912.log
File diff suppressed because it is too large
Load Diff
6707
hs_err_pid11972.log
6707
hs_err_pid11972.log
File diff suppressed because it is too large
Load Diff
6608
hs_err_pid12228.log
6608
hs_err_pid12228.log
File diff suppressed because it is too large
Load Diff
6725
hs_err_pid12896.log
6725
hs_err_pid12896.log
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue