-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from IQSS/197-compare-dataset-versions
197 compare dataset versions
- Loading branch information
Showing
13 changed files
with
464 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export interface DatasetVersionDiff { | ||
oldVersion: VersionSummary | ||
newVersion: VersionSummary | ||
metadataChanges?: MetadataBlockDiff[] | ||
filesAdded?: FileSummary[] | ||
filesRemoved?: FileSummary[] | ||
fileChanges?: FileDiff[] | ||
filesReplaced?: FileReplacement[] | ||
termsOfAccess?: FieldDiff[] | ||
} | ||
|
||
export interface FileSummary { | ||
fileName: string | ||
MD5: string | ||
type: string | ||
fileId: number | ||
filePath: string | ||
description: string | ||
isRestricted: boolean | ||
tags: string[] | ||
categories: string[] | ||
} | ||
|
||
export interface VersionSummary { | ||
versionNumber: string | ||
lastUpdatedDate: string | ||
} | ||
export interface MetadataBlockDiff { | ||
blockName: string | ||
changed: FieldDiff[] | ||
} | ||
|
||
export interface FileDiff { | ||
fileName: string | ||
md5: string | ||
fileId: number | ||
changed: FieldDiff[] | ||
} | ||
|
||
export interface FileReplacement { | ||
oldFile: FileSummary | ||
newFile: FileSummary | ||
} | ||
export interface FieldDiff { | ||
fieldName: string | ||
oldValue: string | ||
newValue: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
import { IDatasetsRepository } from '../repositories/IDatasetsRepository' | ||
import { DatasetVersionDiff } from '../models/DatasetVersionDiff' | ||
|
||
export class GetDatasetVersionDiff implements UseCase<DatasetVersionDiff> { | ||
private datasetsRepository: IDatasetsRepository | ||
|
||
constructor(datasetsRepository: IDatasetsRepository) { | ||
this.datasetsRepository = datasetsRepository | ||
} | ||
|
||
/** | ||
* Returns a DatasetVersionDiff instance, which contains the differences between the two given versions. | ||
* @param {number | string} [datasetId] - The dataset identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers). | ||
* @param {string } [oldVersionId] - The dataset version identifier, which can be a version-specific numeric string (for example, 1.0) or a DatasetNotNumberedVersion enum value. | ||
* @param {string } [newVersionId] - The dataset version identifier, which can be a version-specific numeric string (for example, 1.0) or a DatasetNotNumberedVersion enum value. | ||
*/ | ||
async execute( | ||
datasetId: number | string, | ||
oldVersionId: string, | ||
newVersionId: string | ||
): Promise<DatasetVersionDiff> { | ||
return await this.datasetsRepository.getDatasetVersionDiff( | ||
datasetId, | ||
oldVersionId, | ||
newVersionId | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/datasets/infra/repositories/transformers/DatasetVersionDiffPayload.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export interface DatasetVersionDiffPayload { | ||
oldVersion: VersionSummaryPayload | ||
newVersion: VersionSummaryPayload | ||
metadataChanges: MetadataBlockDiffPayload[] | ||
filesAdded: FileSummaryPayload[] | ||
filesRemoved: FileSummaryPayload[] | ||
fileChanges: FileDiffPayload[] | ||
filesReplaced: FileReplacementPayload[] | ||
TermsOfAccess: FieldDiffPayload[] | ||
} | ||
|
||
export interface FileSummaryPayload { | ||
fileName: string | ||
MD5: string | ||
type: string | ||
fileId: number | ||
filePath: string | ||
description: string | ||
isRestricted: boolean | ||
tags: string[] | ||
categories: string[] | ||
} | ||
|
||
export interface VersionSummaryPayload { | ||
versionNumber: string | ||
lastUpdatedDate: string | ||
} | ||
export interface MetadataBlockDiffPayload { | ||
blockName: string | ||
changed: FieldDiffPayload[] | ||
} | ||
|
||
export interface FileDiffPayload { | ||
fileName: string | ||
md5: string | ||
fileId: number | ||
changed: FieldDiffPayload[] | ||
} | ||
export interface FieldDiffPayload { | ||
fieldName: string | ||
oldValue: string | ||
newValue: string | ||
} | ||
|
||
export interface FileReplacementPayload { | ||
oldFile: FileSummaryPayload | ||
newFile: FileSummaryPayload | ||
} |
19 changes: 19 additions & 0 deletions
19
src/datasets/infra/repositories/transformers/datasetVersionDiffTransformers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { AxiosResponse } from 'axios' | ||
import { DatasetVersionDiff } from '../../../domain/models/DatasetVersionDiff' | ||
|
||
export const transformDatasetVersionDiffResponseToDatasetVersionDiff = ( | ||
response: AxiosResponse | ||
): DatasetVersionDiff => { | ||
const datasetVersionDiffPayload = response.data.data | ||
const retValue = { | ||
oldVersion: datasetVersionDiffPayload.oldVersion, | ||
newVersion: datasetVersionDiffPayload.newVersion, | ||
metadataChanges: datasetVersionDiffPayload.metadataChanges, | ||
filesAdded: datasetVersionDiffPayload.filesAdded, | ||
filesRemoved: datasetVersionDiffPayload.filesRemoved, | ||
fileChanges: datasetVersionDiffPayload.fileChanges, | ||
filesReplaced: datasetVersionDiffPayload.filesReplaced, | ||
termsOfAccess: datasetVersionDiffPayload.TermsOfAccess | ||
} | ||
return retValue | ||
} |
Oops, something went wrong.