From b881aebd7f60668a506c7ca2e6b484210938ba97 Mon Sep 17 00:00:00 2001 From: cazenave <cazenave@cines.fr> Date: Thu, 4 Feb 2021 18:07:45 +0100 Subject: [PATCH] sparql search dor title dataset retrun dataset id --- src/app/app-routing.module.ts | 3 +-- src/app/app.module.ts | 2 -- src/app/datasets/datasets.component.ts | 6 +++-- .../datasets/services/dataset-crud.service.ts | 18 ++++++++++++- src/app/publish/publish.component.html | 0 src/app/publish/publish.component.scss | 0 src/app/publish/publish.component.spec.ts | 25 ------------------- src/app/publish/publish.component.ts | 18 ------------- 8 files changed, 22 insertions(+), 50 deletions(-) delete mode 100644 src/app/publish/publish.component.html delete mode 100644 src/app/publish/publish.component.scss delete mode 100644 src/app/publish/publish.component.spec.ts delete mode 100644 src/app/publish/publish.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 0eefb4662..8ffa36222 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -4,7 +4,6 @@ import { UserComponent } from './user/user.component'; import { RepositoryComponent } from './repository/repository.component'; import { AccessapiComponent } from './accessapi/accessapi.component'; import { DatasetsComponent } from './datasets/datasets.component'; -import { PublishComponent } from './publish/publish.component'; import { SettingfdpComponent } from './settingfdp/settingfdp.component'; import { SettingsmartapiComponent } from './settingsmartapi/settingsmartapi.component'; import { RepositoryinfoComponent } from './repositoryinfo/repositoryinfo.component'; @@ -22,6 +21,7 @@ export interface ICustomRoute extends Route { name?: string; } + const routes: ICustomRoute[] = [ { path: '', redirectTo: '/auth/signin', pathMatch: 'full' }, { path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuardService], @@ -32,7 +32,6 @@ const routes: ICustomRoute[] = [ { path: 'repositoryinfo', component: RepositoryinfoComponent }, { path: 'accessapi', component: AccessapiComponent }, { path: 'datasets', component: DatasetsComponent }, - { path: 'publish', component: PublishComponent }, { path: 'stats', component: StatsComponent }, { path: 'settingfdp', component: SettingfdpComponent }, { path: 'settingsmartharvester', component: SettingsmartapiComponent }, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 57e990f6f..55e84899a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -13,7 +13,6 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { RepositoryComponent } from './repository/repository.component'; import { AccessapiComponent } from './accessapi/accessapi.component'; import { DatasetsComponent } from './datasets/datasets.component'; -import { PublishComponent } from './publish/publish.component'; import { SettingfdpComponent } from './settingfdp/settingfdp.component'; import { SettingsmartapiComponent } from './settingsmartapi/settingsmartapi.component'; import { UserComponent } from './user/user.component'; @@ -49,7 +48,6 @@ import { DashboardComponent } from './dashboard/dashboard.component'; RepositoryComponent, AccessapiComponent, DatasetsComponent, - PublishComponent, SettingfdpComponent, SettingsmartapiComponent, UserComponent, diff --git a/src/app/datasets/datasets.component.ts b/src/app/datasets/datasets.component.ts index a63f446a7..59cac69aa 100644 --- a/src/app/datasets/datasets.component.ts +++ b/src/app/datasets/datasets.component.ts @@ -40,7 +40,7 @@ export class DatasetsComponent implements OnInit { // https://data.inrae.fr/api/search?q=*&per_page=10&type=dataset&start=16000&show_entity_ids=true&show_my_data=true // var myRequest = new Request(this.appConfig.smartapiurl+'harvest/allurls',myInit); - var myRequest = new Request('https://dataverse.ird.fr/api/search?q=*&per_page=100&show_facets=true&show_my_data=true', myInit); + var myRequest = new Request('https://dataverse.ird.fr/api/search?q=*&per_page=20&show_facets=true&show_my_data=true', myInit); fetch(myRequest, myInit) .then(response => { @@ -50,7 +50,9 @@ export class DatasetsComponent implements OnInit { this.itemsdatasets = data['data']['items']; console.log(this.itemsdatasets); for (var i = 0; i < this.itemsdatasets.length; i++) { - this.createdataset(data['data']['items'][i]); + this.dataSetService.findDataSetByTitle(data['data']['items'][i]['name']) ; + //this.createdataset(data['data']['items'][i]); + } }); }); diff --git a/src/app/datasets/services/dataset-crud.service.ts b/src/app/datasets/services/dataset-crud.service.ts index 1f134dd0b..545ef6001 100644 --- a/src/app/datasets/services/dataset-crud.service.ts +++ b/src/app/datasets/services/dataset-crud.service.ts @@ -2,6 +2,8 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { AppConfiguration } from 'src/app/AppConfiguration'; import { AuthService } from 'src/app/authentication/services/auth.service'; +import { ParseXmlService } from '../../services/parse-xml.service'; + @Injectable({ providedIn: 'root' @@ -9,7 +11,8 @@ import { AuthService } from 'src/app/authentication/services/auth.service'; export class DatasetCrudService { fds2Token: string - constructor(private http: HttpClient,private appConfig: AppConfiguration, private authService: AuthService) { } + public results: string[] = []; + constructor(private http: HttpClient,private appConfig: AppConfiguration, private authService: AuthService, private parserService: ParseXmlService) { } createDataSet(data:string){ @@ -33,4 +36,17 @@ export class DatasetCrudService { return "The repository has not been published" } } + + findDataSetByTitle(title:string){ + + let query1='query=PREFIX dcterms: <http://purl.org/dc/terms/> SELECT * WHERE { ?uri dcterms:title "'+ title +'". }' + this.parserService.getXmlResult(query1).subscribe(data=>{if (data){this.results = []; data.results.bindings.forEach(element => { this.results.push(element);}); + if (this.results[0]) { + console.log(this.results[0]['uri'].value.substring(36,72)) + } + }}); + } + + + } diff --git a/src/app/publish/publish.component.html b/src/app/publish/publish.component.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/app/publish/publish.component.scss b/src/app/publish/publish.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/app/publish/publish.component.spec.ts b/src/app/publish/publish.component.spec.ts deleted file mode 100644 index 2c37e9751..000000000 --- a/src/app/publish/publish.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { PublishComponent } from './publish.component'; - -describe('PublishComponent', () => { - let component: PublishComponent; - let fixture: ComponentFixture<PublishComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ PublishComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(PublishComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/publish/publish.component.ts b/src/app/publish/publish.component.ts deleted file mode 100644 index 1e050fac5..000000000 --- a/src/app/publish/publish.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - - -@Component({ - selector: 'app-publish', - templateUrl: './publish.component.html', - styleUrls: ['./publish.component.scss'] -}) -export class PublishComponent implements OnInit { - - - constructor() { } - - ngOnInit() { - } - - -} -- GitLab