Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring
This commit is contained in:
commit
68610bda1b
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><root><dmp><dmpName>DMP Demodfgdfg</dmpName><projectName>OpenAIREplus</projectName><organisations><organisation name="Nord University" reference="organizationrepo:cristin/204"/><organisation name="Hanne Moa" reference="personrepo:orcid-sandbox/0000-0003-2050-142X"/></organisations><researchers/><datasets/></dmp></root>
|
File diff suppressed because one or more lines are too long
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>dmp-backend</artifactId>
|
||||
<groupId>eu.eudat</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>query-engine</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.eudat</groupId>
|
||||
<artifactId>data</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,23 +0,0 @@
|
|||
import eu.eudat.data.entities.DataRepository;
|
||||
import eu.eudat.query.engine.builder.QueryBuilder;
|
||||
import eu.eudat.query.engine.builder.QueryBuilderImpl;
|
||||
import eu.eudat.query.engine.predicates.ComparisonPredicate;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args){
|
||||
new Main().Test();
|
||||
}
|
||||
public void Test(){
|
||||
QueryBuilder<DataRepository> queryBuilder = new QueryBuilderImpl<>(DataRepository.class);
|
||||
queryBuilder.<ComparisonPredicate>where((comparisonExpression) -> comparisonExpression.field("id").greaterThan(5) );
|
||||
queryBuilder.<ComparisonPredicate>where((comparisonExpression) -> comparisonExpression.field("label").equal("mitsos") );
|
||||
queryBuilder.toList();
|
||||
|
||||
QueryBuilder<DataRepository> queryBuilder2 = new QueryBuilderImpl<>(DataRepository.class);
|
||||
queryBuilder2.<ComparisonPredicate>where((comparisonExpression) -> comparisonExpression.field("id").lessOrEqualThan(11111) );
|
||||
queryBuilder2.toList();
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package eu.eudat.query.engine.builder;
|
||||
|
||||
import eu.eudat.query.engine.expressions.Expression;
|
||||
import eu.eudat.query.engine.predicates.Predicate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public interface QueryBuilder<T> {
|
||||
|
||||
<P extends Predicate> Expression where(P wherePredicate);
|
||||
|
||||
List<T> toList();
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package eu.eudat.query.engine.builder;
|
||||
|
||||
import eu.eudat.query.engine.expressions.ComparisonExpression;
|
||||
import eu.eudat.query.engine.expressions.Expression;
|
||||
import eu.eudat.query.engine.predicates.Predicate;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public class QueryBuilderImpl<T> implements QueryBuilder<T> {
|
||||
|
||||
private List<Expression> expressions = new LinkedList<>();
|
||||
private Class<T> tClass;
|
||||
|
||||
public QueryBuilderImpl(Class<T> tClass) {
|
||||
this.tClass = tClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <P extends Predicate> Expression where(P wherePredicate) {
|
||||
ComparisonExpression comparisonExpression = new ComparisonExpression();
|
||||
Expression expression = wherePredicate.apply(comparisonExpression);
|
||||
this.expressions.add(expression);
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> toList() {
|
||||
String query = "Select * from ";
|
||||
Optional<Annotation> optionalAnnotation = Arrays.stream(this.tClass.getAnnotations())
|
||||
.filter(x-> x.annotationType().equals(javax.persistence.Table.class))
|
||||
.findFirst();
|
||||
|
||||
javax.persistence.Table annotation = optionalAnnotation.isPresent() ? (javax.persistence.Table)optionalAnnotation.get() : null;
|
||||
query += annotation.name()+" ";
|
||||
for (Expression expression : expressions) {
|
||||
if(expressions.indexOf(expression) > 0) query+= " and ";
|
||||
else query += " where ";
|
||||
query += expression.evaluate();
|
||||
}
|
||||
System.out.println(query);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package eu.eudat.query.engine.expressions;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public abstract class AbstractFieldExpression<T extends AbstractFieldExpression<T>> {
|
||||
private String field;
|
||||
|
||||
protected String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public T field(String field) {
|
||||
this.field = field;
|
||||
return (T)this;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package eu.eudat.query.engine.expressions;
|
||||
|
||||
import eu.eudat.query.engine.types.expression.comparison.ComparisonExpressionType;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public class ComparisonExpression extends AbstractFieldExpression<ComparisonExpression> implements Expression {
|
||||
|
||||
private ComparisonExpressionType type;
|
||||
private Object value;
|
||||
|
||||
public <T> Expression greaterThan(T value){
|
||||
this.value = value;
|
||||
this.type = ComparisonExpressionType.GREATER_THAN;
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T> Expression greaterThanOrEqual(T value){
|
||||
this.value = value;
|
||||
this.type = ComparisonExpressionType.GREATER_OR_EQUAL_THAN;
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T> Expression equal(T value){
|
||||
this.value = value;
|
||||
this.type = ComparisonExpressionType.EQUAL;
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T> Expression lessThan(T value){
|
||||
this.value = value;
|
||||
this.type = ComparisonExpressionType.LESS_THAN;
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T> Expression lessOrEqualThan(T value){
|
||||
this.value = value;
|
||||
this.type = ComparisonExpressionType.LESS_OR_EQUAL_THAN;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String evaluate() {
|
||||
return this.getField() +" " + type.toString() + " " + value ;
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package eu.eudat.query.engine.expressions;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public interface Expression {
|
||||
String evaluate();
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package eu.eudat.query.engine.predicates;
|
||||
|
||||
import eu.eudat.query.engine.expressions.ComparisonExpression;
|
||||
import eu.eudat.query.engine.expressions.Expression;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public interface ComparisonPredicate extends Predicate<ComparisonExpression> {
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package eu.eudat.query.engine.predicates;
|
||||
|
||||
import eu.eudat.query.engine.expressions.ComparisonExpression;
|
||||
import eu.eudat.query.engine.expressions.Expression;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public interface Predicate<E extends Expression> {
|
||||
Expression apply( E expression);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package eu.eudat.query.engine.types.expression.comparison;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public enum ComparisonExpressionType {
|
||||
EQUAL, GREATER_THAN, GREATER_OR_EQUAL_THAN, LESS_THAN, LESS_OR_EQUAL_THAN
|
||||
}
|
|
@ -46,72 +46,66 @@ public class DMPs extends BaseController {
|
|||
|
||||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
private Environment environment;
|
||||
private DataManagementPlanManager dataManagementPlanManager;
|
||||
|
||||
@Autowired
|
||||
public DMPs(ApiContext apiContext, DynamicProjectConfiguration dynamicProjectConfiguration, Environment environment) {
|
||||
public DMPs(ApiContext apiContext, DynamicProjectConfiguration dynamicProjectConfiguration, Environment environment, DataManagementPlanManager dataManagementPlanManager) {
|
||||
super(apiContext);
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
this.environment = environment;
|
||||
|
||||
this.dataManagementPlanManager = dataManagementPlanManager;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
|
||||
new DataManagementPlanManager().unlock(this.getApiContext(), id);
|
||||
this.dataManagementPlanManager.unlock(this.getApiContext(), id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal) throws Exception {
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataManagementPlanManager().getPaged(this.getApiContext(), dataManagementPlanTableRequest, principal);
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = this.dataManagementPlanManager.getPaged(this.getApiContext(), dataManagementPlanTableRequest, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataManagementPlan>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = new DataManagementPlanManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, principal, this.dynamicProjectConfiguration);
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, principal, this.dynamicProjectConfiguration);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/post"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> createOrUpdate(@RequestBody eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
|
||||
DataManagementPlanManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
|
||||
this.dataManagementPlanManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/new/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @Valid @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
DataManagementPlanManager.newVersion(this.getApiContext(), id, dataManagementPlan, principal);
|
||||
this.dataManagementPlanManager.newVersion(this.getApiContext(), id, dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
DataManagementPlanManager.clone(this.getApiContext(), id, dataManagementPlan, principal);
|
||||
this.dataManagementPlanManager.clone(this.getApiContext(), id, dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/get"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<DataManagementPlan>>> getWithCriteria(@RequestBody DataManagementPlanCriteriaRequest dataManagementPlanCriteria, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||
List<DataManagementPlan> dataTable = new DataManagementPlanManager().getWithCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), dataManagementPlanCriteria, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataManagementPlan>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> delete(@PathVariable UUID id, Principal principal) {
|
||||
try{
|
||||
DataManagementPlanManager.delete(this.getApiContext(), id);
|
||||
this.dataManagementPlanManager.delete(this.getApiContext(), id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Datamanagement Plan"));
|
||||
}catch (DMPWithDatasetsDeleteException exception){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
||||
|
@ -122,14 +116,14 @@ public class DMPs extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||
List<Tuple<String, String>> dataTable = new DataManagementPlanManager().getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicProjectConfiguration, criteriaRequestItem.getCriteria());
|
||||
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicProjectConfiguration, criteriaRequestItem.getCriteria());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<byte[]> getXml(@PathVariable String id) throws IllegalAccessException, IOException, InstantiationException {
|
||||
FileEnvelope envelope = new DataManagementPlanManager().getXmlDocument(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
FileEnvelope envelope = this.dataManagementPlanManager.getXmlDocument(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
InputStream resource = new FileInputStream(envelope.getFile());
|
||||
System.out.println("Mime Type of " + envelope.getFilename() + " is " +
|
||||
new MimetypesFileTypeMap().getContentType(envelope.getFile()));
|
||||
|
@ -149,7 +143,7 @@ public class DMPs extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = {"/getWord/{id}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<byte[]> getWordDocument(@PathVariable String id) throws IOException, IllegalAccessException, InstantiationException {
|
||||
File file = new DataManagementPlanManager().getWordDocument(this.environment, this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
File file = this.dataManagementPlanManager.getWordDocument(this.environment, this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
InputStream resource = new FileInputStream(file);
|
||||
System.out.println("Mime Type of " + file.getName() + " is " +
|
||||
new MimetypesFileTypeMap().getContentType(file));
|
||||
|
@ -169,7 +163,7 @@ public class DMPs extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
|
||||
File file = new DataManagementPlanManager().getWordDocument(this.environment, this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
File file = this.dataManagementPlanManager.getWordDocument(this.environment, this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
File pdffile = new DatasetManager().convertToPDF(file, environment, file.getName());
|
||||
InputStream resource = new FileInputStream(pdffile);
|
||||
System.out.println("Mime Type of " + file.getName() + " is " +
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|||
import org.json.JSONObject;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -48,6 +49,7 @@ import java.util.*;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class DataManagementPlanManager {
|
||||
|
||||
public DataTableData<DataManagementPlanListingModel> getPaged(ApiContext apiContext, DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal) throws Exception {
|
||||
|
@ -208,7 +210,7 @@ public class DataManagementPlanManager {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static void createOrUpdate(ApiContext apiContext, DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
|
||||
public void createOrUpdate(ApiContext apiContext, DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
|
||||
|
@ -226,7 +228,7 @@ public class DataManagementPlanManager {
|
|||
assignUser(newDmp, user, apiContext);
|
||||
}
|
||||
|
||||
public static void assignUser(DMP dmp, UserInfo userInfo, ApiContext apiContext) {
|
||||
public void assignUser(DMP dmp, UserInfo userInfo, ApiContext apiContext) {
|
||||
UserDMP userDMP = new UserDMP();
|
||||
userDMP.setDmp(dmp);
|
||||
userDMP.setUser(userInfo);
|
||||
|
@ -234,7 +236,7 @@ public class DataManagementPlanManager {
|
|||
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
|
||||
}
|
||||
|
||||
public static void newVersion(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
public void newVersion(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
|
@ -249,7 +251,7 @@ public class DataManagementPlanManager {
|
|||
copyDatasets(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao());
|
||||
}
|
||||
|
||||
public static void clone(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
public void clone(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
|
||||
|
@ -263,7 +265,7 @@ public class DataManagementPlanManager {
|
|||
copyDatasets(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao());
|
||||
}
|
||||
|
||||
public static void delete(ApiContext apiContext, UUID uuid) throws DMPWithDatasetsDeleteException {
|
||||
public void delete(ApiContext apiContext, UUID uuid) throws DMPWithDatasetsDeleteException {
|
||||
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
|
||||
if (oldDmp.getDataset().size() > 0)
|
||||
throw new DMPWithDatasetsDeleteException("You cannot Remove Datamanagement Plan with Datasets");
|
||||
|
@ -271,7 +273,7 @@ public class DataManagementPlanManager {
|
|||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(oldDmp);
|
||||
}
|
||||
|
||||
private static void createResearchersIfTheyDontExist(DMP newDmp, ResearcherDao researcherRepository) {
|
||||
private void createResearchersIfTheyDontExist(DMP newDmp, ResearcherDao researcherRepository) {
|
||||
if (newDmp.getResearchers() != null && !newDmp.getResearchers().isEmpty()) {
|
||||
for (eu.eudat.data.entities.Researcher researcher : newDmp.getResearchers()) {
|
||||
ResearcherCriteria criteria = new ResearcherCriteria();
|
||||
|
@ -283,7 +285,7 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
}
|
||||
|
||||
private static void createOrganisationsIfTheyDontExist(DMP newDmp, OrganisationDao organisationRepository) {
|
||||
private void createOrganisationsIfTheyDontExist(DMP newDmp, OrganisationDao organisationRepository) {
|
||||
if (newDmp.getOrganisations() != null && !newDmp.getOrganisations().isEmpty()) {
|
||||
for (eu.eudat.data.entities.Organisation organisation : newDmp.getOrganisations()) {
|
||||
OrganisationCriteria criteria = new OrganisationCriteria();
|
||||
|
@ -295,7 +297,7 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
}
|
||||
|
||||
private static void createProjectIfItDoesntExist(DMP newDmp, ProjectDao projectDao, UserInfo userInfo) {
|
||||
private void createProjectIfItDoesntExist(DMP newDmp, ProjectDao projectDao, UserInfo userInfo) {
|
||||
if (newDmp.getProject() != null) {
|
||||
Project project = newDmp.getProject();
|
||||
ProjectCriteria criteria = new ProjectCriteria();
|
||||
|
@ -310,7 +312,7 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
|
||||
|
||||
private static void copyDatasets(DMP newDmp, DatasetDao datasetDao) {
|
||||
private void copyDatasets(DMP newDmp, DatasetDao datasetDao) {
|
||||
List<CompletableFuture<Dataset>> futures = new LinkedList<>();
|
||||
for (Dataset dataset : newDmp.getDataset()) {
|
||||
datasetDao.asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)).where((builder, root) -> builder.equal(root.get("id"), dataset.getId())).getSingleAsync()
|
||||
|
|
|
@ -24,18 +24,18 @@ export class DmpService {
|
|||
}
|
||||
|
||||
getPaged(dataTableRequest: DataTableRequest<DmpCriteria>): Observable<DataTableData<DmpListingModel>> {
|
||||
return this.http.post<DataTableData<DmpListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers });
|
||||
return this.http.post<DataTableData<DmpListingModel>>(this.actionUrl + 'paged', dataTableRequest, { headers: this.headers });
|
||||
}
|
||||
|
||||
getSingle(id: String): Observable<DmpModel> {
|
||||
return this.http.get<DmpModel>(this.actionUrl + 'getSingle/' + id, { headers: this.headers });
|
||||
return this.http.get<DmpModel>(this.actionUrl + id, { headers: this.headers }); //'getSingle/' +
|
||||
}
|
||||
|
||||
unlock(id: String): Observable<DmpModel> {
|
||||
return this.http.get<DmpModel>(this.actionUrl + id + '/unlock', { headers: this.headers });
|
||||
}
|
||||
createDmp(dataManagementPlanModel: DmpModel): Observable<DmpModel> {
|
||||
return this.http.post<DmpModel>(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers });
|
||||
return this.http.post<DmpModel>(this.actionUrl + 'post', dataManagementPlanModel, { headers: this.headers });
|
||||
}
|
||||
|
||||
inactivate(id: String): Observable<DmpModel> {
|
||||
|
@ -55,17 +55,13 @@ export class DmpService {
|
|||
}
|
||||
|
||||
delete(id: String): Observable<DmpModel> {
|
||||
return this.http.delete<DmpModel>(this.actionUrl + 'delete/' + id, { headers: this.headers });
|
||||
return this.http.delete<DmpModel>(this.actionUrl + id, { headers: this.headers }); // + 'delete/'
|
||||
}
|
||||
|
||||
getDynamicField(requestItem: RequestItem<DynamicFieldProjectCriteria>): any {
|
||||
return this.http.post<any>(this.actionUrl + 'dynamic', requestItem, { headers: this.headers });
|
||||
}
|
||||
|
||||
get(requestItem: RequestItem<DmpCriteria>): Observable<DmpListingModel[]> {
|
||||
return this.http.post<DmpListingModel[]>(this.actionUrl + 'get', requestItem, { headers: this.headers });
|
||||
}
|
||||
|
||||
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
||||
return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response' });
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCru
|
|||
import { DatasetDescriptionFormEditorModel } from '../../misc/dataset-description-form/dataset-description-form.model';
|
||||
import { DatasetWizardEditorModel } from './dataset-wizard-editor.model';
|
||||
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
|
||||
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
|
||||
import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-wizard-component',
|
||||
|
@ -206,15 +208,17 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe((params: Params) => {
|
||||
const itemId = params['id'];
|
||||
if (itemId != null) { setTimeout(()=> this.stepper.selectedIndex = 2); }
|
||||
if (itemId != null) { setTimeout(() => this.stepper.selectedIndex = 2); }
|
||||
});
|
||||
}
|
||||
|
||||
searchDmp(query: string): Observable<DmpListingModel[]> {
|
||||
const dmpRequestItem: RequestItem<DmpCriteria> = new RequestItem();
|
||||
dmpRequestItem.criteria = new DmpCriteria();
|
||||
dmpRequestItem.criteria.like = query;
|
||||
return this.dmpService.get(dmpRequestItem);
|
||||
const fields: Array<string> = new Array<string>();
|
||||
fields.push('asc');
|
||||
const dmpDataTableRequest: DataTableRequest<DmpCriteria> = new DataTableRequest(0, null, { fields: fields });
|
||||
dmpDataTableRequest.criteria = new DmpCriteria();
|
||||
dmpDataTableRequest.criteria.like = query;
|
||||
return this.dmpService.getPaged(dmpDataTableRequest).map(x => x.data);
|
||||
}
|
||||
|
||||
loadDatasetProfiles() {
|
||||
|
@ -235,7 +239,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
}
|
||||
|
||||
getDefinition() {
|
||||
if (this.formGroup.invalid) { setTimeout(()=> this.stepper.selectedIndex = 0); return; }
|
||||
if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; }
|
||||
if (this.isNew) {
|
||||
this.datasetWizardService.getDefinition(this.formGroup.get('profile').value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
|
@ -261,17 +265,17 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
this.datasetWizardService.createDataset(this.formGroup.value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => {
|
||||
this.datasetWizardService.getSingle(complete.id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
result => {
|
||||
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(result);
|
||||
}
|
||||
);
|
||||
this.onCallbackSuccess();
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
complete => {
|
||||
this.datasetWizardService.getSingle(complete.id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
result => {
|
||||
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(result);
|
||||
}
|
||||
);
|
||||
this.onCallbackSuccess();
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -387,25 +391,23 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
}
|
||||
|
||||
openConfirm(dmpLabel, id): void {
|
||||
// this._dialogService.openConfirm({
|
||||
// message: 'Are you sure you want to delete the "' + dmpLabel + '"',
|
||||
// disableClose: true || false,
|
||||
// viewContainerRef: this._viewContainerRef,
|
||||
// title: 'Confirm',
|
||||
// cancelButton: 'No',
|
||||
// acceptButton: 'Yes'
|
||||
// }).afterClosed()
|
||||
// .pipe(takeUntil(this._destroyed))
|
||||
// .subscribe((accept: boolean) => {
|
||||
// if (accept) {
|
||||
// this.datasetWizardService.delete(id)
|
||||
// .pipe(takeUntil(this._destroyed))
|
||||
// .subscribe(() => {
|
||||
// this.router.navigate(['/datasets']);
|
||||
// });
|
||||
// } else {
|
||||
// // DO SOMETHING ELSE
|
||||
// }
|
||||
// });
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
maxWidth: '300px',
|
||||
data: {
|
||||
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
||||
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.datasetWizardService.delete(id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => { this.onCallbackSuccess() },
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue