Browse Source

Add services for downloading dataset

pull/1310/head
Hironsan 3 years ago
parent
commit
7ee9a0bf9d
3 changed files with 43 additions and 0 deletions
  1. 16
      frontend/services/application/download/downloadApplicationService.ts
  2. 13
      frontend/services/application/download/downloadFormatApplicationService.ts
  3. 14
      frontend/services/application/download/formatData.ts

16
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<string> {
const item = await this.repository.prepare(projectId, format)
return item
}
public download(projectId: string, taskId: string): void {
this.repository.download(projectId, taskId)
}
}

13
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<FormatDTO[]> {
const items = await this.repository.list(projectId)
return items.map(item => new FormatDTO(item))
}
}

14
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
}
}
Loading…
Cancel
Save