From 9f0617a75718041102c8ffd7ff5ae7b34337ba3a Mon Sep 17 00:00:00 2001 From: Baptiste Toulemonde <toulemonde@cines.fr> Date: Thu, 2 Sep 2021 09:21:47 +0200 Subject: [PATCH] fix vocabulary duplication bug --- src/app/mapping/class/dataset.ts | 4 +- src/app/mapping/mapping.component.html | 4 +- src/app/mapping/mapping.component.ts | 5 +- src/assets/dataset.json | 105 ++++++++++++++++--------- 4 files changed, 77 insertions(+), 41 deletions(-) diff --git a/src/app/mapping/class/dataset.ts b/src/app/mapping/class/dataset.ts index 080bc153a..526b7b769 100644 --- a/src/app/mapping/class/dataset.ts +++ b/src/app/mapping/class/dataset.ts @@ -2,11 +2,13 @@ export class Dataset { public name: string; public identifier: string; public usageNote: string; + public isDuplicated: boolean; - constructor(name: string, identifier: string, usageNote: string) { + constructor(name: string, identifier: string, usageNote: string, isDuplicated: boolean) { this.name = name; this.identifier = identifier; this.usageNote = usageNote; + this.isDuplicated = isDuplicated; } } diff --git a/src/app/mapping/mapping.component.html b/src/app/mapping/mapping.component.html index 0bae916d0..b631d2f17 100644 --- a/src/app/mapping/mapping.component.html +++ b/src/app/mapping/mapping.component.html @@ -63,12 +63,12 @@ </nb-form-field> </div> <div class="col-2" *ngIf="isMultiple(dataset.identifier)" style="margin-left: 10px;"> - <button nbButton ghost (click)="addField(index)"> + <button nbButton ghost (click)="addField(index)" *ngIf="!dataset.isDuplicated"> <nb-icon icon="plus-outline" status="primary"> </nb-icon> </button> <button nbButton ghost - *ngIf="dataset.identifier !== 'dct:hasVersion' && dataset.identifier !== 'dct:title'" + *ngIf="dataset.isDuplicated" (click)="deleteField(index)"> <nb-icon icon="trash-2-outline" status="danger"> </nb-icon> diff --git a/src/app/mapping/mapping.component.ts b/src/app/mapping/mapping.component.ts index a54053c5e..f718245ad 100644 --- a/src/app/mapping/mapping.component.ts +++ b/src/app/mapping/mapping.component.ts @@ -4,7 +4,6 @@ import { HttpResponse } from '@angular/common/http'; import { Component, Input, OnInit, ViewChild } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; -import { escapeRegExp } from 'lodash'; import { FileSaverService } from 'ngx-filesaver'; import { Observable, of, Subscription } from 'rxjs'; @@ -377,8 +376,8 @@ export class MappingComponent implements OnInit { } addField(index: number) { - this.dcatVocabulary.splice(index + 1, 0, this.dcatVocabulary[index]); - console.log('add'); + let addedDcat: Dataset = new Dataset(this.dcatVocabulary[index].name, this.dcatVocabulary[index].identifier, this.dcatVocabulary[index].usageNote, true); + this.dcatVocabulary.splice(index + 1, 0, addedDcat); } deleteField(index: number) { diff --git a/src/assets/dataset.json b/src/assets/dataset.json index ce2018555..b811a960b 100644 --- a/src/assets/dataset.json +++ b/src/assets/dataset.json @@ -2,176 +2,211 @@ { "name": "title", "identifier": "dct:title", - "usageNote": "Mandatory property. This property contains a name given to the Dataset. This property can be repeated for parallel language versions of the name." + "usageNote": "Mandatory property. This property contains a name given to the Dataset. This property can be repeated for parallel language versions of the name.", + "isDuplicated": false }, { "name": "has Version", "identifier": "dct:hasVersion", - "usageNote": "Optional property.This property refers to a related Dataset that is a version, edition, or adaptation of the described Dataset." + "usageNote": "Optional property.This property refers to a related Dataset that is a version, edition, or adaptation of the described Dataset.", + "isDuplicated": false }, { "name": "description", "identifier": "dct:description", - "usageNote": "Mandatory property. This property contains a free-text account of the Dataset. This property can be repeated for parallel language versions of the description." + "usageNote": "Mandatory property. This property contains a free-text account of the Dataset. This property can be repeated for parallel language versions of the description.", + "isDuplicated": false }, { "name": "contact point", "identifier": "dcat:contactPoint", - "usageNote": "Recommended property.This property contains contact information that can be used for sending comments about the Dataset." + "usageNote": "Recommended property.This property contains contact information that can be used for sending comments about the Dataset.", + "isDuplicated": false }, { "name": "dataset distribution", "identifier": "dcat:distribution", - "usageNote": "Recommended property. This property links the Dataset to an available Distribution." + "usageNote": "Recommended property. This property links the Dataset to an available Distribution.", + "isDuplicated": false }, { "name": "keyword/ tag", "identifier": "dcat:keyword", - "usageNote": "Recommended property. This property contains a keyword or tag describing the Dataset." + "usageNote": "Recommended property. This property contains a keyword or tag describing the Dataset.", + "isDuplicated": false }, { "name": "publisher", "identifier": "dct:publisher", - "usageNote": "Recommended property. This property refers to an entity (organisation) responsible for making the Dataset available." + "usageNote": "Recommended property. This property refers to an entity (organisation) responsible for making the Dataset available.", + "isDuplicated": false }, { "name": "spatial/geographical coverage", "identifier": "dct:spatial", - "usageNote": "Recommended property. This property refers to a geographic region that is covered by the Dataset. " + "usageNote": "Recommended property. This property refers to a geographic region that is covered by the Dataset. ", + "isDuplicated": false }, { "name": "theme/category", "identifier": "dcat:theme", - "usageNote": "Recommended property. This property refers to a category of the Dataset. A Dataset may be associated with multiple themes. Subproperty of dct:subject." + "usageNote": "Recommended property. This property refers to a category of the Dataset. A Dataset may be associated with multiple themes. Subproperty of dct:subject.", + "isDuplicated": false }, { "name": "temporal coverage", "identifier": "dct:temporal", - "usageNote": "Recommended property. This property refers to a temporal period that the Dataset covers." + "usageNote": "Recommended property. This property refers to a temporal period that the Dataset covers.", + "isDuplicated": false }, { "name": "conforms to", "identifier": "dct:conformsTo", - "usageNote": "Optional property. This property refers to an implementing rule or other specification." + "usageNote": "Optional property. This property refers to an implementing rule or other specification.", + "isDuplicated": false }, { "name": "frequency", "identifier": "dct:accrualPeriodicity", - "usageNote": "Optional property. This property refers to the frequency at which Dataset is updated." + "usageNote": "Optional property. This property refers to the frequency at which Dataset is updated.", + "isDuplicated": false }, { "name": "identifier", "identifier": "dct:identifier", - "usageNote": "Optional property. This property contains the main identifier for the Dataset, e.g. the URI or other unique identifier in the context of the Catalogue." + "usageNote": "Optional property. This property contains the main identifier for the Dataset, e.g. the URI or other unique identifier in the context of the Catalogue.", + "isDuplicated": false }, { "name": "landing page", "identifier": "dcat:landingPage", - "usageNote": "Optional property. This property refers to a web page that provides access to the Dataset, its Distributions and/or additional information." + "usageNote": "Optional property. This property refers to a web page that provides access to the Dataset, its Distributions and/or additional information.", + "isDuplicated": false }, { "name": "language", "identifier": "dct:language", - "usageNote": "Optional property. This property refers to a language of the Dataset. This property can be repeated if there are multiple languages in the Dataset." + "usageNote": "Optional property. This property refers to a language of the Dataset. This property can be repeated if there are multiple languages in the Dataset.", + "isDuplicated": false }, { "name": "other identifier", "identifier": "adms:identifier", - "usageNote": "Optional property. This property refers to a secondary identifier of the Dataset, such as MAST/ADS[1], DataCite[2], DOI[3], EZID[4] or W3ID[5]." + "usageNote": "Optional property. This property refers to a secondary identifier of the Dataset, such as MAST/ADS[1], DataCite[2], DOI[3], EZID[4] or W3ID[5].", + "isDuplicated": false }, { "name": "release date datele", "identifier": "dct:issued", - "usageNote": "Optional property. This property contains the date of formal issuance (e.g., publication) of the Dataset." + "usageNote": "Optional property. This property contains the date of formal issuance (e.g., publication) of the Dataset.", + "isDuplicated": false }, { "name": "update/modification date", "identifier": "dct:modified", - "usageNote": "Optional property. This property contains the most recent date on which the Dataset was changed or modified." + "usageNote": "Optional property. This property contains the most recent date on which the Dataset was changed or modified.", + "isDuplicated": false }, { "name": "provenance", "identifier": "dct:provenance", - "usageNote": "Optional property. This property contains a statement about the lineage of a Dataset." + "usageNote": "Optional property. This property contains a statement about the lineage of a Dataset.", + "isDuplicated": false }, { "name": "sample", "identifier": "adms:sample", - "usageNote": "Optional property. This property refers to a sample distribution of the dataset." + "usageNote": "Optional property. This property refers to a sample distribution of the dataset.", + "isDuplicated": false }, { "name": "source", "identifier": "dct:source", - "usageNote": "Optional property. This property refers to a related Dataset from which the described Dataset is derived." + "usageNote": "Optional property. This property refers to a related Dataset from which the described Dataset is derived.", + "isDuplicated": false }, { "name": "type", "identifier": "dct:type", - "usageNote": "Optional property. This property refers to the type of the Dataset. A controlled vocabulary for the values has not been established." + "usageNote": "Optional property. This property refers to the type of the Dataset. A controlled vocabulary for the values has not been established.", + "isDuplicated": false }, { "name": "related resource", "identifier": "dct:relation", - "usageNote": "Optional property. This property refers to a related resource." + "usageNote": "Optional property. This property refers to a related resource.", + "isDuplicated": false }, { "name": "version", "identifier": "owl:versionInfo", - "usageNote": "Optional property. This property contains a version number or other version designation of the Dataset." + "usageNote": "Optional property. This property contains a version number or other version designation of the Dataset.", + "isDuplicated": false }, { "name": "version notes", "identifier": "adms:versionNotes", - "usageNote": "Optional property. This property contains a description of the differences between this version and a previous version of the Dataset." + "usageNote": "Optional property. This property contains a description of the differences between this version and a previous version of the Dataset.", + "isDuplicated": false }, { "name": "is Version Of", "identifier": "dct:isVersionOf", - "usageNote": "Optional property. This property refers to a related Dataset of which the described Dataset is a version, edition, or adaptation." + "usageNote": "Optional property. This property refers to a related Dataset of which the described Dataset is a version, edition, or adaptation.", + "isDuplicated": false }, { "name": "documentation", "identifier": "foaf:page", - "usageNote": "Optional property. This property refers to a page or document about this Dataset." + "usageNote": "Optional property. This property refers to a page or document about this Dataset.", + "isDuplicated": false }, { "name": "access rights", "identifier": "dct:accessRights", - "usageNote": "Optional property. This property refers to information that indicates whether the Dataset is open data, has access restrictions or is not public. A controlled vocabulary with three members (:public, :restricted, :non-public) will be created and maintained by the Publications Office of the EU." + "usageNote": "Optional property. This property refers to information that indicates whether the Dataset is open data, has access restrictions or is not public. A controlled vocabulary with three members (:public, :restricted, :non-public) will be created and maintained by the Publications Office of the EU.", + "isDuplicated": false }, { "name": "creator", "identifier": "dct:creator", - "usageNote": "Optional property. This property refers to an entity primarily responsible for making the resource." + "usageNote": "Optional property. This property refers to an entity primarily responsible for making the resource.", + "isDuplicated": false }, { "name": "qualified attribution", "identifier": "prov:qualifiedAttribution", - "usageNote": "Optional property. This property refers to the link to an Agent having some form of responsibility for the resource. " + "usageNote": "Optional property. This property refers to the link to an Agent having some form of responsibility for the resource. ", + "isDuplicated": false }, { "name": "was generated by", "identifier": "prov:wasGeneratedBy", - "usageNote": "Optional property. This property refers to an activity that generated, or provides the business context for, the creation of the dataset." + "usageNote": "Optional property. This property refers to an activity that generated, or provides the business context for, the creation of the dataset.", + "isDuplicated": false }, { "name": "temporal resolution", "identifier": "dcat:temporalResolution", - "usageNote": "This property refers to the minimum time period resolvable in the dataset." + "usageNote": "This property refers to the minimum time period resolvable in the dataset.", + "isDuplicated": false }, { "name": "spatial resolution", "identifier": "dcat:spatialResolutionInMeters", - "usageNote": "Optional property. This property refers to the minimum spatial separation resolvable in a dataset, measured in meters. " + "usageNote": "Optional property. This property refers to the minimum spatial separation resolvable in a dataset, measured in meters. ", + "isDuplicated": false }, { "name": "qualified Relation", "identifier": "dcat:qualifiedRelation", - "usageNote": "Optional property. This property provides a link to a description of a relationship with another resource." + "usageNote": "Optional property. This property provides a link to a description of a relationship with another resource.", + "isDuplicated": false }, { "name": "is reference by", "identifier": "dct:isReferencedBy", - "usageNote": "Optional property. This property refers to a related resource, such as a publication, that references, cites, or otherwise points to the dataset." + "usageNote": "Optional property. This property refers to a related resource, such as a publication, that references, cites, or otherwise points to the dataset.", + "isDuplicated": false } ] \ No newline at end of file -- GitLab