From 7ee9a0bf9d4c7165dbd320fafc6b6fb444216e60 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 20 Apr 2021 13:24:14 +0900 Subject: [PATCH] Add services for downloading dataset --- .../download/downloadApplicationService.ts | 16 ++++++++++++++++ .../download/downloadFormatApplicationService.ts | 13 +++++++++++++ .../services/application/download/formatData.ts | 14 ++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 frontend/services/application/download/downloadApplicationService.ts create mode 100644 frontend/services/application/download/downloadFormatApplicationService.ts create mode 100644 frontend/services/application/download/formatData.ts diff --git a/frontend/services/application/download/downloadApplicationService.ts b/frontend/services/application/download/downloadApplicationService.ts new file mode 100644 index 00000000..ad7c01b0 --- /dev/null +++ b/frontend/services/application/download/downloadApplicationService.ts @@ -0,0 +1,16 @@ +import { DownloadRepository } from '~/domain/models/download/downloadRepository' + +export class DownloadApplicationService { + constructor( + private readonly repository: DownloadRepository + ) {} + + public async request(projectId: string, format: string): Promise { + const item = await this.repository.prepare(projectId, format) + return item + } + + public download(projectId: string, taskId: string): void { + this.repository.download(projectId, taskId) + } +} diff --git a/frontend/services/application/download/downloadFormatApplicationService.ts b/frontend/services/application/download/downloadFormatApplicationService.ts new file mode 100644 index 00000000..ebbf4de6 --- /dev/null +++ b/frontend/services/application/download/downloadFormatApplicationService.ts @@ -0,0 +1,13 @@ +import { FormatDTO } from './formatData' +import { DownloadFormatRepository } from '~/domain/models/download/downloadFormatRepository' + +export class DownloadFormatApplicationService { + constructor( + private readonly repository: DownloadFormatRepository + ) {} + + public async list(projectId: string): Promise { + const items = await this.repository.list(projectId) + return items.map(item => new FormatDTO(item)) + } +} diff --git a/frontend/services/application/download/formatData.ts b/frontend/services/application/download/formatData.ts new file mode 100644 index 00000000..9294baaf --- /dev/null +++ b/frontend/services/application/download/formatData.ts @@ -0,0 +1,14 @@ +import { Format } from '~/domain/models/download/format' + + +export class FormatDTO { + name: string + example: string + properties: object + + constructor(item: Format) { + this.name = item.name + this.example = item.example + this.properties = item.properties + } +}