From 582217180307b613ae756670a066aa9820d34534 Mon Sep 17 00:00:00 2001
From: Baptiste Toulemonde <toulemonde@cines.fr>
Date: Tue, 20 Jul 2021 10:17:26 +0200
Subject: [PATCH] fix mapping

---
 .../datasets/services/dataset-crud.service.ts |  3 +++
 src/app/mapping/mapping.component.ts          |  5 +----
 src/app/publishapi/publishapi.component.html  |  2 +-
 src/app/publishapi/publishapi.component.ts    |  7 ++++++-
 src/assets/dataset.json                       | 20 +++++++++----------
 5 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/app/datasets/services/dataset-crud.service.ts b/src/app/datasets/services/dataset-crud.service.ts
index 5334b4c92..54921f9b7 100644
--- a/src/app/datasets/services/dataset-crud.service.ts
+++ b/src/app/datasets/services/dataset-crud.service.ts
@@ -80,6 +80,9 @@ export class DatasetCrudService {
   saveDatasets(obj: Object) {
     this.itemsDataset.push(obj);
   }
+  resetDataset() {
+    this.itemsDataset = [];
+  }
 
 
 }
diff --git a/src/app/mapping/mapping.component.ts b/src/app/mapping/mapping.component.ts
index e49b91e25..2eef97206 100644
--- a/src/app/mapping/mapping.component.ts
+++ b/src/app/mapping/mapping.component.ts
@@ -85,8 +85,6 @@ export class MappingComponent implements OnInit {
     let properties: string = '';
 
     this.mappedMetadatas.forEach((value: Map<string, string>, key: number) => {
-      this.ok = false;
-      this.err  = false;
       properties = "";
       value.forEach((value: string, key: string) => {
 
@@ -106,8 +104,7 @@ dct:isPartOf c:'+ this.catalogId + ';\n' + properties + '.';
 
       console.log('data: ' + data);
       this.dataSetService.createDataSet(data).subscribe(
-        () => this.ok = true,
-        error => this.err = true
+        
       );
     })
 
diff --git a/src/app/publishapi/publishapi.component.html b/src/app/publishapi/publishapi.component.html
index 29bd36ed7..d0a200dc8 100644
--- a/src/app/publishapi/publishapi.component.html
+++ b/src/app/publishapi/publishapi.component.html
@@ -301,7 +301,7 @@
           Map your metadata schema with DCAT schema
         </p> 
           <app-mapping *ngIf="initLabelThree" [catalogId]="openApi.info['x-catalog-id']"></app-mapping>
-        <button class="prev-button" nbButton nbStepperPrevious (click)="initLabelThree=false">prev</button>
+        <button class="prev-button" nbButton nbStepperPrevious (click)="initLabelThree=false;  resetDataset()">prev</button>
         <button class="next-button" nbButton disabled nbStepperNext>next</button>
       </nb-step>
       <!--<nb-step [label]="labelFour">
diff --git a/src/app/publishapi/publishapi.component.ts b/src/app/publishapi/publishapi.component.ts
index 3a3cf8853..32c4fa4cd 100644
--- a/src/app/publishapi/publishapi.component.ts
+++ b/src/app/publishapi/publishapi.component.ts
@@ -1,6 +1,7 @@
 import { ViewChild } from '@angular/core';
 import { Component, OnInit } from '@angular/core';
 import { cloneDeep } from 'lodash';
+import { DatasetCrudService } from '../datasets/services/dataset-crud.service';
 import { CatalogService, FdpApiResponseItem } from '../services/catalog.service';
 import HttpStatusCode from './class/http-enum';
 import { OpenApi, Parameter, Path, Request, Response } from './class/openapi';
@@ -22,7 +23,8 @@ export class PublishApiComponent implements OnInit {
   constructor(
     private openApiService: OpenApiService,
     private catalogService: CatalogService,
-    private openApiDTOMappingService: OpenApiDTOMappingService
+    private openApiDTOMappingService: OpenApiDTOMappingService,
+    private datasetService: DatasetCrudService
   ) { }
 
   openApi: OpenApi;
@@ -255,4 +257,7 @@ export class PublishApiComponent implements OnInit {
     request.responses.unshift(newResponse);
   }
 
+  resetDataset() {
+
+  }
 }
diff --git a/src/assets/dataset.json b/src/assets/dataset.json
index abaaa625f..6e2a19289 100644
--- a/src/assets/dataset.json
+++ b/src/assets/dataset.json
@@ -1,14 +1,19 @@
 [
-  {
-    "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."
-  },
   {
     "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."
   },
+  {
+    "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."
+  },
+  {
+    "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."
+  },
   {
     "name": "contact point",
     "identifier": "dcat:contactPoint",
@@ -124,11 +129,6 @@
     "identifier": "dct:isVersionOf",
     "usageNote": "Optional property. This property refers to a related Dataset of which the described Dataset is a version, edition, or adaptation."
   },
-  {
-    "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."
-  },
   {
     "name": "documentation",
     "identifier": "foaf:page",
-- 
GitLab