no message
This commit is contained in:
parent
2af51a18d2
commit
57f7b672aa
|
@ -37,7 +37,7 @@ public class Admin {
|
|||
|
||||
viewStyleDefinition = datasetProfileViewstyleDao.create(viewStyleDefinition);
|
||||
modelDefinition.setViewstyle(viewStyleDefinition);
|
||||
datasetProfileDao.create(modelDefinition);
|
||||
datasetProfileDao.createOrUpdate(modelDefinition);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body("");
|
||||
}catch(Exception ex){
|
||||
|
@ -54,7 +54,7 @@ public class Admin {
|
|||
eu.eudat.entities.DatasetProfileViewstyle viewStyleDefinition = AdminManager.generateViewStyleDefinition(profile);
|
||||
|
||||
|
||||
eu.eudat.entities.DatasetProfile datasetprofile = datasetProfileDao.read(UUID.fromString(id));
|
||||
eu.eudat.entities.DatasetProfile datasetprofile = datasetProfileDao.find(UUID.fromString(id));
|
||||
|
||||
eu.eudat.entities.DatasetProfileViewstyle oldviewStyle = datasetProfileViewstyleDao.read((datasetprofile.getViewstyle().getId()));
|
||||
oldviewStyle.setDefinition(viewStyleDefinition.getDefinition());
|
||||
|
@ -65,7 +65,7 @@ public class Admin {
|
|||
|
||||
datasetprofile.setViewstyle(oldviewStyle);
|
||||
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
||||
datasetProfileDao.update(datasetprofile);
|
||||
datasetProfileDao.createOrUpdate(datasetprofile);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(null);
|
||||
}catch(Exception ex){
|
||||
|
@ -77,7 +77,7 @@ public class Admin {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/admin/get/{id}" }, produces="application/json")
|
||||
public ResponseEntity<Object> get(@PathVariable String id){
|
||||
try{
|
||||
eu.eudat.entities.DatasetProfile profile = datasetProfileDao.read(UUID.fromString(id));
|
||||
eu.eudat.entities.DatasetProfile profile = datasetProfileDao.find(UUID.fromString(id));
|
||||
eu.eudat.models.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
|
||||
}catch(Exception ex){
|
||||
|
|
|
@ -9,6 +9,10 @@ import javax.transaction.Transactional;
|
|||
import eu.eudat.entities.DatasetProfile;
|
||||
import eu.eudat.entities.DatasetProfileRuleset;
|
||||
import eu.eudat.entities.DatasetProfileViewstyle;
|
||||
import eu.eudat.managers.DatasetProfileManager;
|
||||
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteItem;
|
||||
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteRequest;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -36,6 +40,7 @@ import eu.eudat.dao.entities.ServiceDao;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps" })
|
||||
public class DatasetProfiles {
|
||||
|
||||
@Autowired private DataRepositoryDao dataRepositoryDao;
|
||||
|
@ -50,10 +55,22 @@ public class DatasetProfiles {
|
|||
@Autowired private RegistryDao registryDao;
|
||||
@Autowired private ResearcherDao researcherDao;
|
||||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/datasetprofiles/get" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<DatasetProfileAutocompleteItem>> get(@RequestBody DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) {
|
||||
try {
|
||||
List<DatasetProfileAutocompleteItem> datasetProfileAutocompleteItems = DatasetProfileManager.getWithCriteria(datasetProfileDao,datasetProfileAutocompleteRequest);
|
||||
return new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.OK).payload(datasetProfileAutocompleteItems);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//FETCH BY DATASET PROFILE
|
||||
|
||||
/*
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofiles" }, produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listDMPs(){
|
||||
try {
|
||||
|
@ -181,6 +198,6 @@ public class DatasetProfiles {
|
|||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,9 @@ import eu.eudat.managers.DatasetManager;
|
|||
import eu.eudat.managers.DatasetWizardManager;
|
||||
import eu.eudat.models.dataset.DatasetTableRequest;
|
||||
import eu.eudat.models.datasetwizard.DataManagentPlanListingModel;
|
||||
import eu.eudat.models.datasetwizard.DatasetProfileWizardAutocompleteRequest;
|
||||
import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest;
|
||||
import eu.eudat.models.dmp.AssociatedProfile;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
|
@ -41,4 +43,16 @@ public class DatasetWizardController {
|
|||
return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/getAvailableProfiles" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<AssociatedProfile>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, Principal principal) {
|
||||
try {
|
||||
List<AssociatedProfile> dataManagementPlans = DatasetWizardManager.getAvailableProfiles(dMPDao,datasetProfileWizardAutocompleteRequest);
|
||||
return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.OK).payload(dataManagementPlans);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,23 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import eu.eudat.dao.Dao;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.DatasetProfile;
|
||||
import eu.eudat.entities.responses.IDLabelPair;
|
||||
import eu.eudat.models.criteria.DatasetCriteria;
|
||||
import eu.eudat.models.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
public interface DatasetProfileDao extends Dao<DatasetProfile, UUID> {
|
||||
public interface DatasetProfileDao {
|
||||
|
||||
public List<UUID> listAllIDs();
|
||||
QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria);
|
||||
|
||||
List<IDLabelPair> listAllIDsLabels();
|
||||
DatasetProfile createOrUpdate(DatasetProfile item);
|
||||
|
||||
DatasetProfile find(UUID id);
|
||||
|
||||
Long count();
|
||||
|
||||
|
||||
}
|
|
@ -8,37 +8,41 @@ import javax.persistence.Query;
|
|||
import javax.persistence.TypedQuery;
|
||||
|
||||
import eu.eudat.dao.JpaDao;
|
||||
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.DatasetProfile;
|
||||
import eu.eudat.entities.responses.IDLabelPair;
|
||||
import eu.eudat.models.criteria.DatasetCriteria;
|
||||
import eu.eudat.models.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("datasetProfileDao")
|
||||
public class DatasetProfileDaoImpl extends JpaDao<DatasetProfile, UUID> implements DatasetProfileDao {
|
||||
public class DatasetProfileDaoImpl implements DatasetProfileDao {
|
||||
|
||||
|
||||
public DatasetProfile loadDetails(DatasetProfile t) {
|
||||
// TODO Auto-generated method stub
|
||||
@Autowired
|
||||
DatabaseService<DatasetProfile> databaseService;
|
||||
|
||||
@Override
|
||||
public QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria) {
|
||||
QueryableList<DatasetProfile> query = databaseService.getQueryable(DatasetProfile.class);
|
||||
if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%"));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetProfile createOrUpdate(DatasetProfile item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UUID> listAllIDs() {
|
||||
String queryString = "SELECT dp.id FROM DatasetProfile dp";
|
||||
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
|
||||
return typedQuery.getResultList();
|
||||
public DatasetProfile find(UUID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IDLabelPair> listAllIDsLabels() {
|
||||
String queryString = "SELECT dp.id, dp.label FROM DatasetProfile dp";
|
||||
Query query = (Query) entityManager.createQuery(queryString);
|
||||
List<Object[]> rows = query.getResultList();
|
||||
return rows.stream().map(row -> {
|
||||
return new IDLabelPair(row[0].toString(), row[1].toString());
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long count() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.dao.entities.DMPDao;
|
||||
import eu.eudat.dao.entities.DatasetDao;
|
||||
import eu.eudat.dao.entities.DatasetProfileDao;
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.DatasetProfile;
|
||||
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteItem;
|
||||
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteRequest;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/20/2017.
|
||||
*/
|
||||
public class DatasetProfileManager {
|
||||
|
||||
public static List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileDao datasetProfileRepository, DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException{
|
||||
QueryableList<DatasetProfile> items = datasetProfileRepository.getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
|
||||
List<DatasetProfileAutocompleteItem> datasetProfiles = new DomainModelConverter<DatasetProfile, DatasetProfileAutocompleteItem>().fromDataModel( items.toList(), DatasetProfileAutocompleteItem.class);
|
||||
return datasetProfiles;
|
||||
}
|
||||
}
|
|
@ -6,14 +6,20 @@ import eu.eudat.entities.DMP;
|
|||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.datasetwizard.DataManagentPlanListingModel;
|
||||
import eu.eudat.models.datasetwizard.DatasetProfileWizardAutocompleteRequest;
|
||||
import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest;
|
||||
import eu.eudat.models.dmp.AssociatedProfile;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/20/2017.
|
||||
|
@ -27,4 +33,13 @@ public class DatasetWizardManager {
|
|||
List<DataManagentPlanListingModel> dataManagementPlans = new DomainModelConverter<DMP, DataManagentPlanListingModel>().fromDataModel( items.toList(), DataManagentPlanListingModel.class);
|
||||
return dataManagementPlans;
|
||||
}
|
||||
|
||||
public static List<AssociatedProfile> getAvailableProfiles(DMPDao dmpRepository, DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest) throws InstantiationException, IllegalAccessException {
|
||||
DataManagementPlan dataManagementPlan = new DomainModelConverter<eu.eudat.entities.DMP,DataManagementPlan>().fromDataModel(new LinkedList<DMP>(Arrays.asList(dmpRepository.find(datasetProfileWizardAutocompleteRequest.getCriteria().getId()))),DataManagementPlan.class).get(0);
|
||||
if(dataManagementPlan.getAssociatedProfile()==null||dataManagementPlan.getAssociatedProfile().getAssociatedProfiles()==null||dataManagementPlan.getAssociatedProfile().getAssociatedProfiles().isEmpty()){
|
||||
return new LinkedList<>();
|
||||
}
|
||||
List<AssociatedProfile> profiles = dataManagementPlan.getAssociatedProfile().getAssociatedProfiles();
|
||||
return profiles.stream().filter(item->item.getLabel().contains(datasetProfileWizardAutocompleteRequest.getCriteria().getLike())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package eu.eudat.models.criteria;
|
||||
|
||||
import eu.eudat.entities.DatasetProfile;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/20/2017.
|
||||
*/
|
||||
public class DatasetProfileCriteria extends Criteria<DatasetProfile>{
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package eu.eudat.models.criteria;
|
||||
|
||||
import eu.eudat.entities.DatasetProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/20/2017.
|
||||
*/
|
||||
public class DatasetProfileWizardCriteria extends Criteria<DatasetProfile> {
|
||||
private UUID id;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package eu.eudat.models.datasetprofile;
|
||||
|
||||
import eu.eudat.entities.DatasetProfile;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/20/2017.
|
||||
*/
|
||||
public class DatasetProfileAutocompleteItem implements DataModel<DatasetProfile> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String label;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DatasetProfile entity) throws InstantiationException, IllegalAccessException {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetProfile toDataModel() {
|
||||
DatasetProfile profile = new DatasetProfile();
|
||||
profile.setId(this.id);
|
||||
return profile;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package eu.eudat.models.datasetprofile;
|
||||
|
||||
import eu.eudat.models.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.models.criteria.DatasetProfileWizardCriteria;
|
||||
import eu.eudat.models.criteria.DatasetWizardUserDmpCriteria;
|
||||
import eu.eudat.models.helpers.requests.RequestItem;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/20/2017.
|
||||
*/
|
||||
public class DatasetProfileAutocompleteRequest extends RequestItem<DatasetProfileCriteria> {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package eu.eudat.models.datasetwizard;
|
||||
|
||||
import eu.eudat.models.criteria.DatasetProfileWizardCriteria;
|
||||
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteRequest;
|
||||
import eu.eudat.models.helpers.requests.RequestItem;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/20/2017.
|
||||
*/
|
||||
public class DatasetProfileWizardAutocompleteRequest extends RequestItem<DatasetProfileWizardCriteria> {
|
||||
}
|
|
@ -1,25 +1,30 @@
|
|||
<div class="data-management-plan-editor">
|
||||
<mat-horizontal-stepper [linear]="isLinear">
|
||||
<mat-step [stepControl]="firstStepFormGroup">
|
||||
<form [formGroup]="firstStepFormGroup">
|
||||
<ng-template matStepLabel>Fill out your name</ng-template>
|
||||
<mat-step [stepControl]="formGroup">
|
||||
<form *ngIf="formGroup" [formGroup]="formGroup">
|
||||
<ng-template matStepLabel>Dataset Profile Associations</ng-template>
|
||||
<auto-complete class="full-width" placeholder="{{'FORM-PAYMENT-ORDER.EDITOR.FIELDS.PROJECT' | translate}}"
|
||||
[configuration]="dmpAutoCompleteConfiguration"
|
||||
titleKey="label"
|
||||
[control]="firstStepFormGroup.get('dataManagementPlan')"
|
||||
[control]="formGroup.get('dmp')"
|
||||
[required]="true">
|
||||
</auto-complete>
|
||||
<auto-complete class="full-width" placeholder="{{'FORM-PAYMENT-ORDER.EDITOR.FIELDS.PROJECT' | translate}}"
|
||||
[configuration]="datasetProfileAutoCompleteConfiguration"
|
||||
titleKey="label"
|
||||
[control]="formGroup.get('profile')"
|
||||
[required]="true"
|
||||
[disabled]="!formGroup.get('dmp').value">
|
||||
</auto-complete>
|
||||
<div>
|
||||
<button mat-button matStepperNext>Next</button>
|
||||
</div>
|
||||
</form>
|
||||
</mat-step>
|
||||
<mat-step [stepControl]="secondFormGroup">
|
||||
<form [formGroup]="secondFormGroup">
|
||||
<ng-template matStepLabel>Fill out your address</ng-template>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Address" formControlName="secondCtrl" required>
|
||||
</mat-form-field>
|
||||
<mat-step [stepControl]="formGroup">
|
||||
<form *ngIf="formGroup" [formGroup]="formGroup">
|
||||
<ng-template matStepLabel>Dataset Profile Basic Info</ng-template>
|
||||
<app-dataset-editor-component [formGroup]="formGroup"></app-dataset-editor-component>
|
||||
<div>
|
||||
<button mat-button matStepperPrevious>Back</button>
|
||||
<button mat-button matStepperNext>Next</button>
|
||||
|
@ -27,11 +32,13 @@
|
|||
</form>
|
||||
</mat-step>
|
||||
<mat-step>
|
||||
<ng-template matStepLabel>Done</ng-template>
|
||||
<ng-template matStepLabel>Dataset Profile Form</ng-template>
|
||||
You are now done.
|
||||
<div>
|
||||
<button mat-button matStepperPrevious>Back</button>
|
||||
</div>
|
||||
</mat-step>
|
||||
</mat-horizontal-stepper>
|
||||
<div *ngIf="formGroup"> {{ formGroup.value | json }}</div>
|
||||
|
||||
</div>
|
|
@ -1,3 +1,8 @@
|
|||
import { ActivatedRoute, Router, Params} from '@angular/router';
|
||||
import { DatasetService } from '../services/dataset/dataset.service';
|
||||
import { DatasetWizardModel } from '../models/datasets/DatasetWizardModel';
|
||||
import { DatasetModel } from '../models/datasets/DatasetModel';
|
||||
import { DatasetProfileCriteria } from '../models/criteria/dataset-profile/DatasetProfileCriteria';
|
||||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
||||
import { DataManagementPlanService } from "../services/data-management-plan/data-management-plan.service";
|
||||
import { FormGroup, Validators, FormBuilder } from "@angular/forms";
|
||||
|
@ -19,10 +24,17 @@ import { RequestItem } from "../models/criteria/RequestItem";
|
|||
export class DatasetWizardComponent implements AfterViewInit {
|
||||
|
||||
dmpAutoCompleteConfiguration: AutoCompleteConfiguration;
|
||||
|
||||
datasetProfileAutoCompleteConfiguration: AutoCompleteConfiguration;
|
||||
datasetModel:DatasetWizardModel;
|
||||
isNew = true;
|
||||
formGroup:FormGroup;
|
||||
constructor(
|
||||
private datasetWizardService: DatasetWizardService,
|
||||
private formBuilder: FormBuilder
|
||||
private formBuilder: FormBuilder,
|
||||
private datasetService: DatasetService,
|
||||
private route: ActivatedRoute,
|
||||
|
||||
public router: Router,
|
||||
) {
|
||||
|
||||
}
|
||||
|
@ -36,12 +48,36 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
dmpRequestItem.criteria = new DataManagementPlanCriteria();
|
||||
this.dmpAutoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetWizardService.userDmps.bind(this.datasetWizardService), dmpRequestItem);
|
||||
|
||||
this.firstStepFormGroup = this.formBuilder.group({
|
||||
dataManagementPlan: ['dataManagementPlan', Validators.required]
|
||||
});
|
||||
this.secondFormGroup = this.formBuilder.group({
|
||||
secondCtrl: ['', Validators.required]
|
||||
let datasetProfileRequestItem: RequestItem<DatasetProfileCriteria> = new RequestItem();
|
||||
datasetProfileRequestItem.criteria = new DatasetProfileCriteria();
|
||||
this.route.params.subscribe((params: Params) => {
|
||||
const itemId = params['id'];
|
||||
if (itemId != null) {
|
||||
this.isNew = false;
|
||||
this.datasetService.getSingle(itemId).map(data => data as DatasetModel)
|
||||
.subscribe(data => {
|
||||
this.datasetModel = new JsonSerializer<DatasetWizardModel>().fromJSONObject(data, DatasetWizardModel);
|
||||
this.formGroup = this.datasetModel.buildForm();
|
||||
this.datasetProfileAutoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetWizardService.getAvailableProfiles.bind(this.datasetWizardService), datasetProfileRequestItem);
|
||||
this.formGroup.get("dmp").valueChanges.subscribe(change=>{
|
||||
this.datasetProfileAutoCompleteConfiguration.requestItem.criteria.id=change.id
|
||||
}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
this.datasetModel = new DatasetWizardModel();
|
||||
setTimeout(() => {
|
||||
this.formGroup = this.datasetModel.buildForm();
|
||||
this.datasetProfileAutoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetWizardService.getAvailableProfiles.bind(this.datasetWizardService), datasetProfileRequestItem);
|
||||
this.formGroup.get("dmp").valueChanges.subscribe(change=>{
|
||||
this.datasetProfileAutoCompleteConfiguration.requestItem.criteria.id=change.id
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
||||
import { AfterViewInit, Component, Input, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
@ -26,13 +26,16 @@ export class DatasetEditorComponent implements AfterViewInit {
|
|||
|
||||
isNew = true;
|
||||
dataset: DatasetModel;
|
||||
formGroup: FormGroup = null;
|
||||
@Input() formGroup: FormGroup = null;
|
||||
|
||||
filtereddataRepositoriesAsync: boolean = false;
|
||||
filteredRegistriesAsync: boolean = false;
|
||||
filteredServicesAsync: boolean = false;
|
||||
|
||||
filtereddataRepositories: ExternalSourcesItemModel[];
|
||||
filteredRegistries: ExternalSourcesItemModel[];
|
||||
|
||||
filteredServices: ExternalSourcesItemModel[];
|
||||
|
||||
constructor(
|
||||
private datasetService: DatasetService,
|
||||
private externalSourcesService: ExternalSourcesService,
|
||||
|
@ -45,7 +48,7 @@ export class DatasetEditorComponent implements AfterViewInit {
|
|||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.route.params.subscribe((params: Params) => {
|
||||
/* this.route.params.subscribe((params: Params) => {
|
||||
const itemId = params['id'];
|
||||
|
||||
if (itemId != null) {
|
||||
|
@ -61,7 +64,7 @@ export class DatasetEditorComponent implements AfterViewInit {
|
|||
this.formGroup = this.dataset.buildForm();
|
||||
});
|
||||
}
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
formSubmit(): void {
|
||||
|
@ -140,4 +143,22 @@ export class DatasetEditorComponent implements AfterViewInit {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
filterServices(value: string): void {
|
||||
|
||||
this.filteredServices = undefined;
|
||||
if (value) {
|
||||
this.filteredServicesAsync = true;
|
||||
|
||||
this.externalSourcesService.searchDMPResearchers(value).subscribe(items => {
|
||||
this.filteredServices = items;
|
||||
this.filteredServicesAsync = false;
|
||||
|
||||
// this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||
// return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||
// });
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
import { BaseCriteria } from '../BaseCriteria';
|
||||
export class DatasetProfileCriteria extends BaseCriteria{
|
||||
public id:string;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
import { BaseErrorModel } from '../error/BaseErrorModel';
|
||||
import { BackendErrorValidator } from '../../utilities/validators/BackendErrorValidator';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { ValidationContext } from '../../utilities/validators/ValidationContext';
|
||||
import { Serializable } from "../Serializable";
|
||||
|
||||
export class DatasetProfileModel implements Serializable<DatasetProfileModel> {
|
||||
public id: String;
|
||||
public errorModel: BaseErrorModel = new BaseErrorModel();
|
||||
|
||||
fromJSONObject(item: any): DatasetProfileModel {
|
||||
this.id = item.id;
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
|
||||
if (context == null) { context = this.createValidationContext(); }
|
||||
|
||||
const formGroup = new FormBuilder().group({
|
||||
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators]
|
||||
});
|
||||
|
||||
return formGroup;
|
||||
}
|
||||
|
||||
createValidationContext(): ValidationContext {
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
baseContext.validation.push({ key: 'id', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'id')] });
|
||||
return baseContext;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
import { DatasetProfileModel } from '../datasetprofile/DatasetProfileModel';
|
||||
import { DataManagementPlanModel } from '../data-managemnt-plans/DataManagementPlanModel';
|
||||
import { Serializable } from "../Serializable";
|
||||
import { ValidationContext } from "../../utilities/validators/ValidationContext";
|
||||
import { FormGroup, FormBuilder, FormControl, Validators } from "@angular/forms";
|
||||
import { BackendErrorValidator } from "../../utilities/validators/BackendErrorValidator";
|
||||
import { BaseErrorModel } from "../error/BaseErrorModel";
|
||||
import { ExternalSourcesItemModel } from "../external-sources/ExternalSourcesItemModel";
|
||||
import { ServiceModel } from "../services/ServiceModel";
|
||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||
import { RegisterModel } from "../registers/RegisterModel";
|
||||
import { DataRepositoryModel } from "../dataRepositories/DataRepositoryModel";
|
||||
|
||||
export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
|
||||
public id: String;
|
||||
public label: String;
|
||||
public profile: DatasetProfileModel = new DatasetProfileModel;
|
||||
public uri: String;
|
||||
public status: String;
|
||||
public description: String;
|
||||
public services: ServiceModel[] = [];
|
||||
public registries: RegisterModel[] = [];
|
||||
public dataRepositories: DataRepositoryModel[] = [];
|
||||
public dmp:DataManagementPlanModel = new DataManagementPlanModel();
|
||||
|
||||
public errorModel: BaseErrorModel = new BaseErrorModel();
|
||||
|
||||
fromJSONObject(item: any): DatasetWizardModel {
|
||||
this.id = item.id;
|
||||
this.label = item.label;
|
||||
this.profile = item.profile;
|
||||
this.uri = item.uri;
|
||||
this.status = item.status;
|
||||
this.description = item.description;
|
||||
this.services = new JsonSerializer<ServiceModel>().fromJSONArray(item.services, ServiceModel);
|
||||
this.registries = new JsonSerializer<RegisterModel>().fromJSONArray(item.registries, RegisterModel);
|
||||
this.dataRepositories = new JsonSerializer<DataRepositoryModel>().fromJSONArray(item.dataRepositories, DataRepositoryModel);
|
||||
this.dmp = new JsonSerializer<DataManagementPlanModel>().fromJSONObject(item.dmp, DataManagementPlanModel);
|
||||
this.profile = new JsonSerializer<DatasetWizardModel>().fromJSONObject(item.profile, DatasetWizardModel);
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
|
||||
if (context == null) { context = this.createValidationContext(); }
|
||||
|
||||
const formGroup = new FormBuilder().group({
|
||||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
uri: [{ value: this.uri, disabled: disabled }, context.getValidation('uri').validators],
|
||||
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
|
||||
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
|
||||
services: [{ value: this.services, disabled: disabled }, context.getValidation('services').validators],
|
||||
registries: [{ value: this.registries, disabled: disabled }, context.getValidation('registries').validators],
|
||||
dataRepositories: [{ value: this.dataRepositories, disabled: disabled }, context.getValidation('dataRepositories').validators],
|
||||
dmp: [{ value: this.dmp, disabled: disabled }, context.getValidation('dmp').validators],
|
||||
profile: [{ value: this.profile, disabled: disabled }, context.getValidation('profile').validators],
|
||||
|
||||
});
|
||||
return formGroup;
|
||||
}
|
||||
|
||||
createValidationContext(): ValidationContext {
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'label')] });
|
||||
baseContext.validation.push({ key: 'profile', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'profile')] });
|
||||
baseContext.validation.push({ key: 'uri', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'uri')] });
|
||||
baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'status')] });
|
||||
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'description')] });
|
||||
baseContext.validation.push({ key: 'services', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'services')] });
|
||||
baseContext.validation.push({ key: 'registries', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'registries')] });
|
||||
baseContext.validation.push({ key: 'dataRepositories', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'dataRepositories')] });
|
||||
baseContext.validation.push({ key: 'dmp', validators: [BackendErrorValidator(this.errorModel, 'dmp')] }); //TODO
|
||||
return baseContext;
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
import { DatasetProfileCriteria } from '../../models/criteria/dataset-profile/DatasetProfileCriteria';
|
||||
import 'rxjs/add/operator/map';
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
@ -27,4 +28,8 @@ export class DatasetWizardService {
|
|||
public userDmps(criteria: RequestItem<DataManagementPlanCriteria>): Observable<DataManagementPlanModel[]> {
|
||||
return this.http.post<DataManagementPlanModel[]>(this.actionUrl + 'userDmps', criteria, { headers: this.headers });
|
||||
}
|
||||
|
||||
public getAvailableProfiles(criteria: RequestItem<DatasetProfileCriteria>): Observable<DataManagementPlanModel[]> {
|
||||
return this.http.post<DataManagementPlanModel[]>(this.actionUrl + 'getAvailableProfiles/', criteria, { headers: this.headers });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<mat-error *ngIf="validationErrorString">{{errorString}}</mat-error>
|
||||
<mat-progress-spinner matSuffix mode="indeterminate" *ngIf="loading" [diameter]="22"></mat-progress-spinner>
|
||||
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayWith.bind(this)" (optionSelected)="this.optionSelected($event)">
|
||||
<mat-option *ngFor="let item of filteredItems | async" [value]="item">
|
||||
<mat-option *ngFor="let item of filteredItems " [value]="item">
|
||||
<span *ngIf="titleKey">{{item[titleKey]}}</span>
|
||||
<span *ngIf="subtitleKey">{{item[subtitleKey]}}</span>
|
||||
</mat-option>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { any } from 'codelyzer/util/function';
|
||||
import { FormControl, FormGroupDirective, NgForm, FormGroup, FormBuilder } from '@angular/forms';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { setTimeout } from 'timers';
|
||||
|
@ -38,6 +39,9 @@ export class AutocompleteComponent implements OnInit {
|
|||
@Input()
|
||||
required: boolean;
|
||||
|
||||
@Input()
|
||||
disabled: boolean = false;
|
||||
|
||||
// @Input() selectedDropdownItem: AutoCompleteItem;
|
||||
// @Output() selectedDropdownItemChange = new EventEmitter<AutoCompleteItem>();
|
||||
|
||||
|
@ -75,8 +79,8 @@ export class AutocompleteComponent implements OnInit {
|
|||
.switchMap(val => {
|
||||
//if (this.hasSelectedItem) return [];
|
||||
this.configuration.requestItem.criteria.like = this.control.value;
|
||||
return this.configuration.callback(this.configuration.requestItem)
|
||||
})
|
||||
return this.configuration.callback(this.configuration.requestItem).map(result=>this.filteredItems = (<any[]>result))
|
||||
}).subscribe()
|
||||
|
||||
// this.filteredItems = this.inputField.nativeElement.valueChanges.startWith(null)
|
||||
// .debounceTime(this.delay)
|
||||
|
|
Loading…
Reference in New Issue