no message

This commit is contained in:
Ioannis Kalyvas 2018-03-08 12:54:56 +02:00
parent e835c35c7c
commit 376ceb5cb8
32 changed files with 27289 additions and 108 deletions

View File

@ -229,6 +229,11 @@
<version>2.1</version> <version>2.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -2,10 +2,12 @@ package eu.eudat.builders;
import eu.eudat.builders.entity.*; import eu.eudat.builders.entity.*;
import eu.eudat.builders.model.criteria.DataRepositoryCriteriaBuilder; import eu.eudat.builders.model.criteria.DataRepositoryCriteriaBuilder;
import eu.eudat.builders.model.criteria.ExternalDatasetCriteriaBuilder;
import eu.eudat.builders.model.criteria.RegistryCriteriaBuilder; import eu.eudat.builders.model.criteria.RegistryCriteriaBuilder;
import eu.eudat.builders.model.models.DataTableDataBuilder; import eu.eudat.builders.model.models.DataTableDataBuilder;
import eu.eudat.builders.model.models.PrincipalBuilder; import eu.eudat.builders.model.models.PrincipalBuilder;
import eu.eudat.builders.model.models.ProjectBuilder; import eu.eudat.builders.model.models.ProjectBuilder;
import eu.eudat.builders.model.models.ResearcherBuilder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@ -25,6 +27,9 @@ public class BuilderFactoryImpl implements BuilderFactory {
if (tClass.equals(UserInfoBuilder.class)) return (T) new UserInfoBuilder(); if (tClass.equals(UserInfoBuilder.class)) return (T) new UserInfoBuilder();
if (tClass.equals(UserRoleBuilder.class)) return (T) new UserRoleBuilder(); if (tClass.equals(UserRoleBuilder.class)) return (T) new UserRoleBuilder();
if (tClass.equals(UserTokenBuilder.class)) return (T) new UserTokenBuilder(); if (tClass.equals(UserTokenBuilder.class)) return (T) new UserTokenBuilder();
if (tClass.equals(ResearcherBuilder.class)) return (T) new ResearcherBuilder();
if (tClass.equals(ExternalDatasetCriteriaBuilder.class)) return (T) new ExternalDatasetCriteriaBuilder();
return null; return null;
} }
} }

View File

@ -0,0 +1,60 @@
package eu.eudat.builders.model.models;
import eu.eudat.builders.Builder;
import eu.eudat.models.dmp.Researcher;
/**
* Created by ikalyvas on 3/6/2018.
*/
public class ResearcherBuilder extends Builder<Researcher> {
private String label;
private String name;
private String id;
private int status;
public String getLabel() {
return label;
}
public ResearcherBuilder label(String label) {
this.label = label;
return this;
}
public String getName() {
return name;
}
public ResearcherBuilder name(String name) {
this.name = name;
return this;
}
public String getId() {
return id;
}
public ResearcherBuilder id(String id) {
this.id = id;
return this;
}
public int getStatus() {
return status;
}
public ResearcherBuilder status(int status) {
this.status = status;
return this;
}
@Override
public Researcher build() {
Researcher researcher = new Researcher();
researcher.setId(id);
researcher.setLabel(label);
researcher.setName(name);
researcher.setStatus(status);
return researcher;
}
}

View File

@ -1,10 +1,7 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.services.ApiContext; import eu.eudat.services.ApiContext;
import eu.eudat.validators.DataManagementPlanTableRequestValidator; import eu.eudat.validators.*;
import eu.eudat.validators.DatasetProfileValidator;
import eu.eudat.validators.ProjectModelValidator;
import eu.eudat.validators.ProjectTableRequestValidator;
import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.InitBinder;
@ -31,6 +28,7 @@ public abstract class BaseController {
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("datasetProfileValidator", DatasetProfileValidator.class)); binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("datasetProfileValidator", DatasetProfileValidator.class));
if (binder.getTarget() != null && ProjectModelValidator.supportsType((binder.getTarget().getClass()))) if (binder.getTarget() != null && ProjectModelValidator.supportsType((binder.getTarget().getClass())))
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("projectModelValidator", ProjectModelValidator.class)); binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("projectModelValidator", ProjectModelValidator.class));
if (binder.getTarget() != null && DataManagementPlanNewVersionValidator.supportsType((binder.getTarget().getClass())))
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanNewVersionValidator", DataManagementPlanNewVersionValidator.class));
} }
} }

View File

@ -74,7 +74,7 @@ public class DMPs extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/new/{id}"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/dmps/new/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody public @ResponseBody
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @RequestBody eu.eudat.models.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) { ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id,@Valid @RequestBody eu.eudat.models.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) {
try { try {
DataManagementPlanManager.newVersion(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)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));

View File

@ -1,5 +1,6 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.managers.DatasetProfileManager;
import eu.eudat.managers.UserManager; import eu.eudat.managers.UserManager;
import eu.eudat.models.components.commons.datafield.AutoCompleteData; import eu.eudat.models.components.commons.datafield.AutoCompleteData;
import eu.eudat.models.helpers.common.AutoCompleteLookupItem; import eu.eudat.models.helpers.common.AutoCompleteLookupItem;
@ -14,9 +15,8 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -67,12 +67,12 @@ public class DatasetProfileController extends BaseController {
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody AutoCompleteLookupItem lookupItem) { public ResponseEntity<Object> getDataForAutocomplete(@RequestBody AutoCompleteLookupItem lookupItem) {
try { try {
eu.eudat.entities.Dataset dataset = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(lookupItem.getProfileID())); eu.eudat.entities.Dataset dataset = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(lookupItem.getProfileID()));
eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field modelfield = new eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field(); eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field modelfield = DatasetProfileManager.queryForField(dataset.getProfile().getDefinition(), lookupItem.getFieldID());
AutoCompleteData data = new AutoCompleteData().fromData(modelfield.getData()); AutoCompleteData data = (AutoCompleteData) modelfield.getData();
URL url = new URL(data.getUrl() + lookupItem.getSearchTerm()); RestTemplate restTemplate = new RestTemplate();
HttpURLConnection con = (HttpURLConnection) url.openConnection(); Map<String, Object> items = restTemplate.getForObject(data.getUrl() + "?query=" + lookupItem.getSearchTerm(), Map.class);
return ResponseEntity.status(HttpStatus.OK).body(null); return ResponseEntity.status(HttpStatus.OK).body(items);
} catch (Exception ex) { } catch (Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: " + ex.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: " + ex.getMessage());
} }

View File

@ -1,10 +1,14 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.managers.ProjectManager;
import eu.eudat.managers.ResearcherManager; import eu.eudat.managers.ResearcherManager;
import eu.eudat.models.criteria.ResearcherCriteria;
import eu.eudat.models.dmp.Researcher; import eu.eudat.models.dmp.Researcher;
import eu.eudat.models.external.ResearchersExternalSourcesModel; import eu.eudat.models.external.ResearchersExternalSourcesModel;
import eu.eudat.models.helpers.responses.ResponseItem; import eu.eudat.models.helpers.responses.ResponseItem;
import eu.eudat.models.project.ProjectCriteriaRequest;
import eu.eudat.models.researcher.ResearcherCriteriaRequest;
import eu.eudat.models.security.Principal; import eu.eudat.models.security.Principal;
import eu.eudat.proxy.config.exceptions.HugeResultSet; import eu.eudat.proxy.config.exceptions.HugeResultSet;
import eu.eudat.proxy.config.exceptions.NoURLFound; import eu.eudat.proxy.config.exceptions.NoURLFound;
@ -47,6 +51,18 @@ public class Researchers extends BaseController {
} }
} }
@RequestMapping(method = RequestMethod.POST, value = {"/researchers/getWithExternal"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<eu.eudat.models.dmp.Researcher>>> getWithExternal(@RequestBody ResearcherCriteriaRequest researcherCriteriaRequest, Principal principal) {
try {
List<eu.eudat.models.dmp.Researcher> dataTable = new ResearcherManager().getCriteriaWithExternal(this.getApiContext(),this.getApiContext().getOperationsContext().getRemoteFetcher(), researcherCriteriaRequest);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.dmp.Researcher>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
} catch (Exception ex) {
ex.printStackTrace();
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<eu.eudat.models.dmp.Researcher>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
}
}
@Transactional @Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/researchers/create"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/researchers/create"}, consumes = "application/json", produces = "application/json")
public @ResponseBody public @ResponseBody

View File

@ -80,7 +80,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
@Override @Override
public CompletableFuture<DMP> createOrUpdateAsync(DMP item) { public CompletableFuture<DMP> createOrUpdateAsync(DMP item) {
return CompletableFuture.supplyAsync(()->this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }
@Override @Override

View File

@ -24,6 +24,8 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
QueryableList<Researcher> query = this.getDatabaseService().getQueryable(Researcher.class); QueryableList<Researcher> query = this.getDatabaseService().getQueryable(Researcher.class);
if (criteria.getLike() != null) if (criteria.getLike() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike())); query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike()));
if (criteria.getName() != null)
query.where((builder, root) -> builder.equal(root.get("label"), criteria.getName()));
return query; return query;
} }

View File

@ -3,6 +3,7 @@ package eu.eudat.managers;
import eu.eudat.builders.model.models.DataTableDataBuilder; import eu.eudat.builders.model.models.DataTableDataBuilder;
import eu.eudat.dao.entities.DatasetProfileDao; import eu.eudat.dao.entities.DatasetProfileDao;
import eu.eudat.entities.DatasetProfile; import eu.eudat.entities.DatasetProfile;
import eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field;
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteItem; import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteItem;
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteRequest; import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteRequest;
import eu.eudat.models.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
@ -10,9 +11,12 @@ import eu.eudat.models.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.models.helpers.common.DataTableData; import eu.eudat.models.helpers.common.DataTableData;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.services.ApiContext; import eu.eudat.services.ApiContext;
import eu.eudat.utilities.builders.XmlBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.xml.xpath.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
public class DatasetProfileManager { public class DatasetProfileManager {
@ -35,4 +39,17 @@ public class DatasetProfileManager {
List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
return datasetProfiles; return datasetProfiles;
} }
public static eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field queryForField(String xml, String fieldId) throws XPathExpressionException {
eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field field = new Field();
Document document = XmlBuilder.fromXml(xml);
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
XPathExpression expr =
xpath.compile("//field[@id='" + fieldId + "']");
Element name = (Element) expr.evaluate(document, XPathConstants.NODE);
field.fromXml(name);
return field;
}
} }

View File

@ -1,8 +1,20 @@
package eu.eudat.managers; package eu.eudat.managers;
import eu.eudat.builders.model.models.ResearcherBuilder;
import eu.eudat.entities.Researcher; import eu.eudat.entities.Researcher;
import eu.eudat.models.external.ExternalSourcesItemModel;
import eu.eudat.models.external.ProjectsExternalSourcesModel;
import eu.eudat.models.external.ResearchersExternalSourcesModel;
import eu.eudat.models.researcher.ResearcherCriteriaRequest;
import eu.eudat.proxy.config.exceptions.HugeResultSet;
import eu.eudat.proxy.config.exceptions.NoURLFound;
import eu.eudat.proxy.fetching.RemoteFetcher;
import eu.eudat.queryable.QueryableList;
import eu.eudat.services.ApiContext; import eu.eudat.services.ApiContext;
import java.util.List;
import java.util.Map;
/** /**
* Created by ikalyvas on 2/5/2018. * Created by ikalyvas on 2/5/2018.
*/ */
@ -12,4 +24,21 @@ public class ResearcherManager {
Researcher researcherEntity = researcher.toDataModel(); Researcher researcherEntity = researcher.toDataModel();
return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity); return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity);
} }
public static List<eu.eudat.models.dmp.Researcher> getCriteriaWithExternal(ApiContext apiContext, RemoteFetcher remoteFetcher, ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSet, NoURLFound {
QueryableList<eu.eudat.entities.Researcher> items = apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(researcherCriteriaRequest.getCriteria());
List<eu.eudat.models.dmp.Researcher> researchers = items.select(item -> new eu.eudat.models.dmp.Researcher().fromDataModel(item));
List<Map<String, String>> remoteRepos = remoteFetcher.getResearchers(researcherCriteriaRequest.getCriteria().getLike());
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) {
eu.eudat.models.dmp.Researcher researcher = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ResearcherBuilder.class)
.label(externalListingItem.getAbbreviation()).id(externalListingItem.getId())
.name(externalListingItem.getName())
.build();
researchers.add(researcher);
}
researchers.stream().distinct();
return researchers;
}
} }

View File

@ -3,4 +3,13 @@ package eu.eudat.models.criteria;
import eu.eudat.entities.Researcher; import eu.eudat.entities.Researcher;
public class ResearcherCriteria extends Criteria<Researcher> { public class ResearcherCriteria extends Criteria<Researcher> {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} }

View File

@ -72,4 +72,19 @@ public class Researcher implements DataModel<eu.eudat.entities.Researcher, Resea
public String getHint() { public String getHint() {
return null; return null;
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Researcher that = (Researcher) o;
return id.equals(that.id);
}
@Override
public int hashCode() {
return id.hashCode();
}
} }

View File

@ -1,7 +1,6 @@
package eu.eudat.models.helpers.requests; package eu.eudat.models.helpers.requests;
public abstract class RequestItem<T> { public abstract class RequestItem<T> {
private boolean withHint;
private T criteria; private T criteria;
public T getCriteria() { public T getCriteria() {
@ -12,11 +11,4 @@ public abstract class RequestItem<T> {
this.criteria = criteria; this.criteria = criteria;
} }
public boolean getWithHint() {
return withHint;
}
public void setWithHint(boolean withHint) {
this.withHint = withHint;
}
} }

View File

@ -0,0 +1,10 @@
package eu.eudat.models.researcher;
import eu.eudat.models.criteria.ResearcherCriteria;
import eu.eudat.models.helpers.requests.RequestItem;
/**
* Created by ikalyvas on 3/6/2018.
*/
public class ResearcherCriteriaRequest extends RequestItem<ResearcherCriteria> {
}

View File

@ -0,0 +1,53 @@
package eu.eudat.validators;
import eu.eudat.entities.DMP;
import eu.eudat.models.criteria.DataManagementPlanCriteria;
import eu.eudat.models.dmp.DataManagementPlanNewVersionModel;
import eu.eudat.services.ApiContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
* Created by ikalyvas on 3/7/2018.
*/
@Component("dataManagementPlanNewVersionValidator")
public class DataManagementPlanNewVersionValidator implements Validator {
private ApiContext apiContext;
@Autowired
public DataManagementPlanNewVersionValidator(ApiContext apiContext) {
this.apiContext = apiContext;
}
@Override
public boolean supports(Class<?> aClass) {
return DataManagementPlanNewVersionModel.class.equals(aClass);
}
@Override
public void validate(Object obj, Errors errors) {
DataManagementPlanNewVersionModel dataManagementPlanNewVersionModel = (DataManagementPlanNewVersionModel) obj;
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
List<UUID> groupIds = Arrays.asList(dataManagementPlanNewVersionModel.getGroupId());
criteria.setGroupIds(groupIds);
DMP latestDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).getSingleOrDefault();
if (latestDmp.getVersion() >= dataManagementPlanNewVersionModel.getVersion()) {
errors.rejectValue("version", "datamanagementplannewversion.version.notacceptable");
}
else if (latestDmp.getVersion() + 1 != dataManagementPlanNewVersionModel.getVersion()) {
errors.rejectValue("version", "datamanagementplannewversion.version.notnext");
}
}
public static boolean supportsType(Class<?> aClass) {
return DataManagementPlanNewVersionModel.class.equals(aClass);
}
}

View File

@ -5,4 +5,6 @@ projectTableRequest.offset.negative=table offset cannot be negative
projectTableRequest.length.negative=table length cannot be negative projectTableRequest.length.negative=table length cannot be negative
datasetprofile.label.null=Dataset Profile Label cannot be null datasetprofile.label.null=Dataset Profile Label cannot be null
project.startDate.overlapping=Period Start cannot overlap Period project.startDate.overlapping=Period Start cannot overlap Period
dataset.public=Dataset Has Been Made Public dataset.public=Dataset Has Been Made Public
datamanagementplannewversion.version.notacceptable=There is already a newer version than the one you submitted
datamanagementplannewversion.version.notnext=The version you submitted is not the Subsequent value

View File

@ -113,7 +113,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
return this.formGroup.valid; return this.formGroup.valid;
} }
onSubmit(): void { onSubmit(): void {
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe( this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
@ -173,7 +173,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
if (value) { if (value) {
this.filteringResearchersAsync = true; this.filteringResearchersAsync = true;
this.externalSourcesService.searchDMPResearchers(value).subscribe(items => { this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }).subscribe(items => {
this.filteredResearchers = items; this.filteredResearchers = items;
this.filteringResearchersAsync = false; this.filteringResearchersAsync = false;
@ -221,7 +221,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
dmpName: rowName dmpName: rowName
} }
}); });
} }
availableProfiles() { availableProfiles() {
@ -232,25 +232,25 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
} }
}); });
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
this.formGroup.get("profiles").setValue(result); this.formGroup.get("profiles").setValue(result);
}); });
return false; return false;
} }
openConfirm(dmpLabel, id): void { openConfirm(dmpLabel, id): void {
this._dialogService.openConfirm({ this._dialogService.openConfirm({
message: 'Are you sure you want to delete the "' + dmpLabel +'"', message: 'Are you sure you want to delete the "' + dmpLabel + '"',
disableClose: true || false, // defaults to false disableClose: true || false, // defaults to false
viewContainerRef: this._viewContainerRef, //OPTIONAL viewContainerRef: this._viewContainerRef, //OPTIONAL
title: 'Confirm', //OPTIONAL, hides if not provided title: 'Confirm', //OPTIONAL, hides if not provided
cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL' cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL'
acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT' acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT'
// width: '500px', //OPTIONAL, defaults to 400px // width: '500px', //OPTIONAL, defaults to 400px
}).afterClosed().subscribe((accept: boolean) => { }).afterClosed().subscribe((accept: boolean) => {
if (accept) { if (accept) {
this.dataManagementPlanService.delete(id).subscribe(()=>{ this.dataManagementPlanService.delete(id).subscribe(() => {
this.router.navigate(['/dmps']) this.router.navigate(['/dmps'])
}); });
} else { } else {

View File

@ -45,12 +45,12 @@ export class DataManagementPlanWizardComponent implements OnInit {
submit() { submit() {
if (this.isClone) { if (this.isClone) {
this.dataManagementPlanService.clone(this.formGroup.value, this.itemId).subscribe( this.dataManagementPlanService.clone(this.formGroup.getRawValue(), this.itemId).subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} else { } else {
this.dataManagementPlanService.newVersion(this.formGroup.value, this.itemId).subscribe( this.dataManagementPlanService.newVersion(this.formGroup.getRawValue(), this.itemId).subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );

View File

@ -47,7 +47,7 @@ export class DataManagementPlanWizardEditorComponent implements AfterViewInit {
organisationsAutoCompleteConfiguration: AutoCompleteChipConfiguration; organisationsAutoCompleteConfiguration: AutoCompleteChipConfiguration;
createNewVersion; createNewVersion;
associatedUsers: Array<DmpUsersModel> associatedUsers: Array<DmpUsersModel>
labelDisabled: boolean =false; labelDisabled: boolean = false;
constructor( constructor(
private dataManagementPlanService: DataManagementPlanService, private dataManagementPlanService: DataManagementPlanService,
@ -71,12 +71,12 @@ export class DataManagementPlanWizardEditorComponent implements AfterViewInit {
let organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem(); let organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
organisationRequestItem.criteria = new BaseCriteria(); organisationRequestItem.criteria = new BaseCriteria();
this.organisationsAutoCompleteConfiguration = new AutoCompleteChipConfiguration(this.externalSourcesService.searchDMPOrganizations.bind(this.externalSourcesService), organisationRequestItem); this.organisationsAutoCompleteConfiguration = new AutoCompleteChipConfiguration(this.externalSourcesService.searchDMPOrganizations.bind(this.externalSourcesService), organisationRequestItem);
this.route.data.subscribe(value=>{ this.route.data.subscribe(value => {
if (value.clone==false && this.formGroup.get("label").value){ if (value.clone == false && this.formGroup.get("label").value) {
this.labelDisabled = true; this.labelDisabled = true;
} }
this.formGroup.controls["version"].disable(); this.formGroup.controls["version"].disable();
}) })
} }
@ -90,8 +90,8 @@ export class DataManagementPlanWizardEditorComponent implements AfterViewInit {
return this.formGroup.valid; return this.formGroup.valid;
} }
onSubmit(): void { onSubmit(): void {
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe( this.dataManagementPlanService.createDataManagementPlan(this.formGroup.getRawValue()).subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
@ -113,7 +113,7 @@ export class DataManagementPlanWizardEditorComponent implements AfterViewInit {
public setErrorModel(errorModel: BaseErrorModel) { public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => { Object.keys(errorModel).forEach(item => {
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item]; // (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
}) })
} }
@ -146,7 +146,7 @@ export class DataManagementPlanWizardEditorComponent implements AfterViewInit {
if (value) { if (value) {
this.filteringResearchersAsync = true; this.filteringResearchersAsync = true;
this.externalSourcesService.searchDMPResearchers(value).subscribe(items => { this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }).subscribe(items => {
this.filteredResearchers = items; this.filteredResearchers = items;
this.filteringResearchersAsync = false; this.filteringResearchersAsync = false;

View File

@ -1,3 +1,15 @@
<div [formGroup]="textFormGroup"> <div [formGroup]="form">
<!-- <input auto-complete class="form-control autocomplete" formControlName="text" [source]="values"> --> <mat-form-field>
<input matInput [matAutocomplete]="auto" formControlName="value" [required]="required">
<mat-progress-spinner matSuffix mode="indeterminate" *ngIf="loading" [diameter]="22"></mat-progress-spinner>
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="this.optionSelected($event)">
<mat-option *ngFor="let item of filteredItems " [value]="item">
<span *ngIf="titleKey">{{item[titleKey]}}</span>
<span *ngIf="subtitleKey">{{item[subtitleKey]}}</span>
</mat-option>
<!-- <mat-option *ngIf="filteredItems.length == 0" value="das">
<span>{{'GENERAL.AUTOCOMPLETE.NO-ITEMS' | translate}}</span>
</mat-option> -->
</mat-autocomplete>
</mat-form-field>
</div> </div>

View File

@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AutocompleteRemoteComponent } from './autocomplete-remote.component';
describe('AutocompleteRemoteComponent', () => {
let component: AutocompleteRemoteComponent;
let fixture: ComponentFixture<AutocompleteRemoteComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AutocompleteRemoteComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AutocompleteRemoteComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View File

@ -1,6 +1,8 @@
import { Field } from '../../../models/Field'; import { Field } from '../../../models/Field';
import { Component, OnInit, Input, Output, EventEmitter, forwardRef, ViewEncapsulation } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter, forwardRef, ViewEncapsulation } from '@angular/core';
import { ControlValueAccessor, FormControl, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms'; import { ControlValueAccessor, FormControl, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
import { DatasetProfileService } from '@app/services/dataset-profile.service';
import { ActivatedRoute } from '@angular/router';
declare var $: any; declare var $: any;
@ -9,7 +11,7 @@ declare var $: any;
selector: 'df-autocomplete', selector: 'df-autocomplete',
templateUrl: './autocomplete-remote.component.html', templateUrl: './autocomplete-remote.component.html',
styleUrls: ['./autocomplete-remote.component.css'], styleUrls: ['./autocomplete-remote.component.css'],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None,
}) })
@ -20,21 +22,21 @@ export class AutocompleteRemoteComponent implements OnInit/* , ControlValueAcces
@Input() field: Field; @Input() field: Field;
@Input() form: FormGroup; @Input() form: FormGroup;
private textFormGroup = new FormGroup({ text: new FormControl("") });
private loading: boolean; private loading: boolean;
private datasetId;
values: any[] = new Array(); values: any[] = new Array();
typeaheadMS: number = 1400; typeaheadMS: number = 1400;
constructor() { constructor(private datasetProfileService: DatasetProfileService, route: ActivatedRoute) {
this.datasetId = route.snapshot.params['id'];
} }
ngOnInit() { ngOnInit() {
let valueChanges = this.textFormGroup.controls['text'].valueChanges.share(); let valueChanges = this.form.controls['value'].valueChanges.share();
valueChanges.subscribe(searchTerm => { valueChanges.subscribe(searchTerm => {
this.loading = true; this.loading = true;
if (this.form.controls['text'].value) if (this.form.controls['value'].value)
this.resetFormGroupValue(); this.resetFormGroupValue();
}); });
@ -56,16 +58,17 @@ export class AutocompleteRemoteComponent implements OnInit/* , ControlValueAcces
updateByQuery(query: string) { updateByQuery(query: string) {
// this.serverService.getThroughProxy(this.field.data.url, query).subscribe( this.datasetProfileService.queryAutocomplete({ profileID: this.datasetId, fieldID: this.field.id, searchTerm: query })
// response => { .subscribe(
// this.values.length = 0; response => {
// /* response.data.forEach(element => { this.values.length = 0;
// this.values.push(element.attributes.name); response.payload.forEach(element => {
// }); */ this.values.push(element.attributes.name);
// }, });
// error => { },
// } error => {
// ); }
);
} }

View File

@ -29,6 +29,8 @@ import { HttpClient, HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NgModule } from "@angular/core"; import { NgModule } from "@angular/core";
import { DatasetProfileAdmin } from '@app/services/datasetProfileAdmin/datasetProfileAfmin.service';
import { DatasetProfileService } from '@app/services/dataset-profile.service';
@NgModule({ @NgModule({
@ -86,7 +88,9 @@ import { NgModule } from "@angular/core";
], ],
providers:[ providers:[
VisibilityRulesService, VisibilityRulesService,
PaginationService PaginationService,
DatasetProfileService,
DatasetProfileAdmin
] ]
}) })

View File

@ -0,0 +1,5 @@
export class AutocompleteLookupItem {
public profileID: String;
public fieldID: String;
public searchTerm: String;
}

View File

@ -0,0 +1,5 @@
import { BaseCriteria } from "@app/models/criteria/BaseCriteria";
export class ResearcherCriteria extends BaseCriteria {
public name: String
}

View File

@ -1,38 +1,48 @@
import { Component, Input, OnInit, AfterViewChecked, ViewChild } from '@angular/core'; import { Component, Input, OnInit, AfterViewChecked, ViewChild } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { DatasetProfileAdmin } from '@app/services/datasetProfileAdmin/datasetProfileAfmin.service'; import { DatasetProfileAdmin } from '@app/services/datasetProfileAdmin/datasetProfileAfmin.service';
import { HostConfiguration } from '@app/app.constants';
import { AutocompleteLookupItem } from '@app/models/autocomplete/AutocompleteLookupItem';
import { Observable } from 'rxjs/Observable';
@Injectable() @Injectable()
export class DatasetProfileService implements OnInit { export class DatasetProfileService implements OnInit {
constructor(public datasetProfileAdmin: DatasetProfileAdmin) { private actionUrl: string;
private headers: HttpHeaders;
constructor(private httpClient: HttpClient, private datasetProfileAdmin: DatasetProfileAdmin) {
this.actionUrl = HostConfiguration.Server + 'datasetwizard/';
this.headers = new HttpHeaders();
this.headers = this.headers.set('Content-Type', 'application/json');
this.headers = this.headers.set('Accept', 'application/json');
} }
fetchAllDatasetProfiles() {
ngOnInit(){ // return this.restBase.get("datasetprofiles/getAll");
} }
fetchAllDatasetProfiles(){ getDatasetProfileById(datasetProfileID) {
// return this.restBase.get("datasetprofiles/getAll");
}
getDatasetProfileById(datasetProfileID){
return this.datasetProfileAdmin.getDatasetProfileById(datasetProfileID); return this.datasetProfileAdmin.getDatasetProfileById(datasetProfileID);
} }
createDatasetProfile(datasetProfile){ createDatasetProfile(datasetProfile) {
// return this.restBase.post("datasetprofile/create", datasetProfile); // return this.restBase.post("datasetprofile/create", datasetProfile);
} }
updateDatasetProfile(datasetProfile){ updateDatasetProfile(datasetProfile) {
// return this.restBase.post("datasetprofile/update", datasetProfile); // return this.restBase.post("datasetprofile/update", datasetProfile);
} }
delete(datasetProfile){ delete(datasetProfile) {
// return this.restBase.post("datasetprofile/delete", datasetProfile); // return this.restBase.post("datasetprofile/delete", datasetProfile);
} }
queryAutocomplete(lookUpItem: AutocompleteLookupItem): Observable<any> {
return this.httpClient.post(HostConfiguration.Server + "search/autocomplete", lookUpItem)
}
} }

View File

@ -7,6 +7,7 @@ import { Observable } from 'rxjs/Observable';
import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel'; import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
import { BaseCriteria } from '@app/models/criteria/BaseCriteria'; import { BaseCriteria } from '@app/models/criteria/BaseCriteria';
import { RequestItem } from '@app/models/criteria/RequestItem'; import { RequestItem } from '@app/models/criteria/RequestItem';
import { ResearcherCriteria } from '@app/models/criteria/researchers/ResearcherCriteria';
@Injectable() @Injectable()
@ -40,8 +41,8 @@ export class ExternalSourcesService {
return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "datasets" + "?query=" + like, { headers: this.headers }); return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "datasets" + "?query=" + like, { headers: this.headers });
} }
public searchDMPResearchers(like: string): Observable<ExternalSourcesItemModel[]> { public searchDMPResearchers(requestItem: RequestItem<ResearcherCriteria>): Observable<ExternalSourcesItemModel[]> {
return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "researchers" + "?query=" + like, { headers: this.headers }); return this.http.post<ExternalSourcesItemModel[]>(HostConfiguration.Server + "/researchers/getWithExternal", requestItem, { headers: this.headers });
} }
public searchDMPOrganizations(like: string): Observable<ExternalSourcesItemModel[]> { public searchDMPOrganizations(like: string): Observable<ExternalSourcesItemModel[]> {

6645
hs_err_pid13164.log Normal file

File diff suppressed because it is too large Load Diff

6726
hs_err_pid13284.log Normal file

File diff suppressed because it is too large Load Diff

6782
hs_err_pid4976.log Normal file

File diff suppressed because it is too large Load Diff

6800
hs_err_pid8284.log Normal file

File diff suppressed because it is too large Load Diff