DMP Editor. Prefixing queries on searching existing identifiers.

This commit is contained in:
Kristian Ntavidi 2021-04-30 14:34:28 +03:00
parent 8a7cfab3b8
commit a8f75aafb9
11 changed files with 39 additions and 31 deletions

View File

@ -17,6 +17,8 @@ export class AddOrganizationComponent extends BaseComponent implements OnInit {
public formGroup: FormGroup; public formGroup: FormGroup;
private readonly _REFERENCE_PREFIX:string = "Internal:";
private readonly _KEY: string = 'Internal';
private existingReferences: string[] = []; private existingReferences: string[] = [];
get referenceExists(){ get referenceExists(){
const reference = this.formGroup.get('reference').value; const reference = this.formGroup.get('reference').value;
@ -31,9 +33,9 @@ export class AddOrganizationComponent extends BaseComponent implements OnInit {
) { ) {
super(); super();
if(data){ if(data){
const researchers = (data as FormControl).value ; const organisations = (data as FormControl).value ;
if(researchers){ if(organisations){
this.existingReferences = (researchers as Array<any>).map(researcher => researcher.reference); this.existingReferences = (organisations as Array<any>).map(organisation => organisation.reference);
} }
}} }}
@ -62,11 +64,11 @@ export class AddOrganizationComponent extends BaseComponent implements OnInit {
return (control: AbstractControl) :Observable<ValidationErrors | null> =>{ return (control: AbstractControl) :Observable<ValidationErrors | null> =>{
return control.valueChanges.pipe( return control.valueChanges.pipe(
debounceTime(600), debounceTime(600),
mergeMap(value=>this.externalSourcesService.searchDMPOrganizations('',value)), mergeMap(value=>this.externalSourcesService.searchDMPOrganizations('',this._REFERENCE_PREFIX +value)),
takeUntil(this._destroyed), takeUntil(this._destroyed),
map((response)=>{ map((response)=>{
if(response && response.length){ if(response && response.length){
const internalOrganizations = (response as Array<any>).filter(organization=> organization.key === "Internal"); const internalOrganizations = (response as Array<any>).filter(organization=> organization.key === this._KEY);
if(internalOrganizations && internalOrganizations.length){ if(internalOrganizations && internalOrganizations.length){
return {organizationIdentifierExists:true}; return {organizationIdentifierExists:true};

View File

@ -16,7 +16,8 @@ export class AddResearcherComponent extends BaseComponent implements OnInit {
public formGroup: FormGroup; public formGroup: FormGroup;
// private readonly _REFERENCE_PREFIX:string = "dmp:"; private readonly _REFERENCE_PREFIX:string = "dmp:";
private readonly _KEY:string = 'Internal';
private existingReferences: string[] = []; private existingReferences: string[] = [];
get referenceExists(){ get referenceExists(){
const reference = this.formGroup.get('reference').value; const reference = this.formGroup.get('reference').value;
@ -70,12 +71,12 @@ export class AddResearcherComponent extends BaseComponent implements OnInit {
return control.valueChanges.pipe( return control.valueChanges.pipe(
debounceTime(600), debounceTime(600),
takeUntil(this._destroyed), takeUntil(this._destroyed),
mergeMap(value=>this.externalSourcesService.searchDMPResearchers({criteria:{name: '',like: null,reference:value }})), mergeMap(value=>this.externalSourcesService.searchDMPResearchers({criteria:{name: '',like: null,reference: (this._REFERENCE_PREFIX + value) }})),
map((response)=>{ map((response)=>{
if(response && response.length){ if(response && response.length){
let internalEntries = (response as any[]).filter(record=>record.key === 'Internal'); let internalEntries = (response as any[]).filter(record=>record.key === this._KEY);
if(internalEntries && internalEntries.length){ if(internalEntries && internalEntries.length){
internalEntries = internalEntries.filter(record=> (record.reference === (control.value))); internalEntries = internalEntries.filter(record=> (record.reference === (this._REFERENCE_PREFIX + control.value)));
} }
return internalEntries && internalEntries.length? {researcherIdentifierExists:true} : null; return internalEntries && internalEntries.length? {researcherIdentifierExists:true} : null;
} }

View File

@ -48,6 +48,11 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
isFunderPending:boolean = false; isFunderPending:boolean = false;
isGrantPending:boolean = false; isGrantPending:boolean = false;
isProjectPending:boolean = false; isProjectPending:boolean = false;
private readonly _FUNDER_PREFIX = "dmp:";
private readonly _GRANT_PREFIX = "dmp:";
private readonly _PROJECT_PREFIX = "dmp:";
private readonly _KEY = "Internal";
constructor( constructor(
private grantService: GrantService, private grantService: GrantService,
private projectService: ProjectService, private projectService: ProjectService,
@ -101,12 +106,12 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
switchMap(value=> { switchMap(value=> {
const requestItem = new RequestItem<FunderCriteria>(); const requestItem = new RequestItem<FunderCriteria>();
requestItem.criteria = new FunderCriteria(); requestItem.criteria = new FunderCriteria();
requestItem.criteria.exactReference = value; requestItem.criteria.exactReference = this._FUNDER_PREFIX +value;
return this.funderService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); return this.funderService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed));
}), }),
map(response=>{ map(response=>{
if(response && response.length){ if(response && response.length){
const internalFunders = (response as Array<any>).filter(funder=> funder.key === 'Internal'); const internalFunders = (response as Array<any>).filter(funder=> funder.key === this._KEY);
if(internalFunders && internalFunders.length){ if(internalFunders && internalFunders.length){
return {funderIdentifierExists:true}; return {funderIdentifierExists:true};
@ -136,12 +141,12 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
switchMap(value=> { switchMap(value=> {
const requestItem = new RequestItem<GrantCriteria>(); const requestItem = new RequestItem<GrantCriteria>();
requestItem.criteria = new GrantCriteria(); requestItem.criteria = new GrantCriteria();
requestItem.criteria.exactReference = value; requestItem.criteria.exactReference = this._GRANT_PREFIX + value;
return this.grantService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); return this.grantService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed));
}), }),
map(response=>{ map(response=>{
if(response && response.length){ if(response && response.length){
const internalGrants = (response as Array<any>).filter(grant=> grant.key === 'Internal'); const internalGrants = (response as Array<any>).filter(grant=> grant.key === this._KEY);
if(internalGrants && internalGrants.length){ if(internalGrants && internalGrants.length){
return {grantIdentifierExists:true}; return {grantIdentifierExists:true};
@ -171,12 +176,12 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
switchMap(value=> { switchMap(value=> {
const requestItem = new RequestItem<ProjectCriteria>(); const requestItem = new RequestItem<ProjectCriteria>();
requestItem.criteria = new ProjectCriteria(); requestItem.criteria = new ProjectCriteria();
requestItem.criteria.exactReference = value; requestItem.criteria.exactReference = this._PROJECT_PREFIX + value;
return this.projectService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); return this.projectService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed));
}), }),
map(response=>{ map(response=>{
if(response && response.length){ if(response && response.length){
const internalProjects = (response as Array<any>).filter(project=> project.key === 'Internal'); const internalProjects = (response as Array<any>).filter(project=> project.key === this._KEY);
if(internalProjects && internalProjects.length){ if(internalProjects && internalProjects.length){
return {projectIdentifierExists:true}; return {projectIdentifierExists:true};
} }

View File

@ -1006,8 +1006,8 @@
"HINT": "A brief description of what the DMP is about, its scope and objectives.", "HINT": "A brief description of what the DMP is about, its scope and objectives.",
"TYPING": "Type more letters of the name so its more possible to find the correct one.", "TYPING": "Type more letters of the name so its more possible to find the correct one.",
"UNIQUE-IDENTIFIER": "Unique Identifier", "UNIQUE-IDENTIFIER": "Unique Identifier",
"RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.",
"ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.",
"IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.",
"IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list."
}, },

View File

@ -1006,8 +1006,8 @@
"HINT": "A brief description of what the DMP is about, its scope and objectives.", "HINT": "A brief description of what the DMP is about, its scope and objectives.",
"TYPING": "Type more letters of the name so its more possible to find the correct one.", "TYPING": "Type more letters of the name so its more possible to find the correct one.",
"UNIQUE-IDENTIFIER": "Unique Identifier", "UNIQUE-IDENTIFIER": "Unique Identifier",
"RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.",
"ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.",
"IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.",
"IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list."
}, },

View File

@ -1006,8 +1006,8 @@
"HINT": "Una breve descripción sobre que trata el PGD, su ámbito y objetivos", "HINT": "Una breve descripción sobre que trata el PGD, su ámbito y objetivos",
"TYPING": "Escriba más letras del nombre para que sea más probable encontrar el correcto", "TYPING": "Escriba más letras del nombre para que sea más probable encontrar el correcto",
"UNIQUE-IDENTIFIER": "Unique Identifier", "UNIQUE-IDENTIFIER": "Unique Identifier",
"RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.",
"ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.",
"IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.",
"IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list."
}, },

View File

@ -1006,8 +1006,8 @@
"HINT": "Μία σύντομη περιγραφή του τι αφορά το Σχέδιο Διαχείρισης Δεδομένων, του πεδίου εφαρμογής και των στόχων του.", "HINT": "Μία σύντομη περιγραφή του τι αφορά το Σχέδιο Διαχείρισης Δεδομένων, του πεδίου εφαρμογής και των στόχων του.",
"TYPING": "Προσθέστε περισσότερα γράμματα στο όνομα ώστε να είναι πιο πιθανό να βρείτε το σωστό.", "TYPING": "Προσθέστε περισσότερα γράμματα στο όνομα ώστε να είναι πιο πιθανό να βρείτε το σωστό.",
"UNIQUE-IDENTIFIER": "Unique Identifier", "UNIQUE-IDENTIFIER": "Unique Identifier",
"RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.",
"ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.",
"IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.",
"IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list."
}, },

View File

@ -1006,8 +1006,8 @@
"HINT": "Uma breve descrição sobre o tema do PGD, o seu âmbito e objetivos.", "HINT": "Uma breve descrição sobre o tema do PGD, o seu âmbito e objetivos.",
"TYPING": "Digite mais letras do nome para que seja possível encontrá-lo mais facilmente.", "TYPING": "Digite mais letras do nome para que seja possível encontrá-lo mais facilmente.",
"UNIQUE-IDENTIFIER": "Unique Identifier", "UNIQUE-IDENTIFIER": "Unique Identifier",
"RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.",
"ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.",
"IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.",
"IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list."
}, },

View File

@ -1006,8 +1006,8 @@
"HINT": "Stručný opis toho, čoho sa DMP týka, jeho rozsah a ciele.", "HINT": "Stručný opis toho, čoho sa DMP týka, jeho rozsah a ciele.",
"TYPING": "Napíšte viac písmen názvu, aby bolo možné nájsť správny DMP.", "TYPING": "Napíšte viac písmen názvu, aby bolo možné nájsť správny DMP.",
"UNIQUE-IDENTIFIER": "Unique Identifier", "UNIQUE-IDENTIFIER": "Unique Identifier",
"RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.",
"ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.",
"IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.",
"IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list."
}, },

View File

@ -1006,8 +1006,8 @@
"HINT": "Kratki opis Plana sa namenom i ciljevima.", "HINT": "Kratki opis Plana sa namenom i ciljevima.",
"TYPING": "Unesite još neko slovo da bismo lakše pronašli tačno ime.", "TYPING": "Unesite još neko slovo da bismo lakše pronašli tačno ime.",
"UNIQUE-IDENTIFIER": "Unique Identifier", "UNIQUE-IDENTIFIER": "Unique Identifier",
"RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.",
"ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.",
"IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.",
"IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list."
}, },

View File

@ -1006,8 +1006,8 @@
"HINT": "VYP'nin ne hakkında olduğunun, kapsamının ve hedeflerinin kısa bir açıklaması.", "HINT": "VYP'nin ne hakkında olduğunun, kapsamının ve hedeflerinin kısa bir açıklaması.",
"TYPING": "Doğru olanı bulabilmek için daha fazla harf yazın.", "TYPING": "Doğru olanı bulabilmek için daha fazla harf yazın.",
"UNIQUE-IDENTIFIER": "Unique Identifier", "UNIQUE-IDENTIFIER": "Unique Identifier",
"RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.",
"ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.",
"IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.",
"IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list."
}, },