-
Notifications
You must be signed in to change notification settings - Fork 16
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 #274 from IQSS/features/250-dataset-list-integration
Features/250 dataset list integration
- Loading branch information
Showing
14 changed files
with
238 additions
and
118 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
30 changes: 30 additions & 0 deletions
30
src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.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,30 @@ | ||
import { DatasetPreview as JSDatasetPreview } from '@iqss/dataverse-client-javascript/dist/datasets/domain/models/DatasetPreview' | ||
import { DatasetPreview } from '../../domain/models/DatasetPreview' | ||
import { | ||
DatasetVersionInfo as JSDatasetVersionInfo, | ||
DatasetVersionState as JSDatasetVersionState | ||
} from '@iqss/dataverse-client-javascript/dist/datasets/domain/models/Dataset' | ||
import { JSDatasetVersionMapper } from './JSDatasetVersionMapper' | ||
|
||
export class JSDatasetPreviewMapper { | ||
static toDatasetPreview(jsDatasetPreview: JSDatasetPreview): DatasetPreview { | ||
return new DatasetPreview( | ||
jsDatasetPreview.persistentId, | ||
jsDatasetPreview.title, | ||
JSDatasetVersionMapper.toDatasetVersion( | ||
jsDatasetPreview.versionId, | ||
jsDatasetPreview.versionInfo | ||
), | ||
jsDatasetPreview.versionInfo.releaseTime != undefined, | ||
jsDatasetPreview.citation, | ||
jsDatasetPreview.versionInfo.state === JSDatasetVersionState.DEACCESSIONED, | ||
JSDatasetPreviewMapper.toPreviewDate(jsDatasetPreview.versionInfo), | ||
jsDatasetPreview.description, | ||
undefined // TODO: get dataset thumbnail from Dataverse https://github.com/IQSS/dataverse-frontend/issues/203 | ||
) | ||
} | ||
|
||
static toPreviewDate(jsVersionInfo: JSDatasetVersionInfo): Date { | ||
return jsVersionInfo.releaseTime ? jsVersionInfo.releaseTime : jsVersionInfo.createTime | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/dataset/infrastructure/mappers/JSDatasetVersionMapper.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,36 @@ | ||
import { | ||
DatasetVersionInfo as JSDatasetVersionInfo, | ||
DatasetVersionState as JSDatasetVersionState | ||
} from '@iqss/dataverse-client-javascript/dist/datasets/domain/models/Dataset' | ||
import { DatasetPublishingStatus, DatasetVersion } from '../../domain/models/Dataset' | ||
export class JSDatasetVersionMapper { | ||
static toDatasetVersion( | ||
jDatasetVersionId: number, | ||
jsDatasetVersionInfo: JSDatasetVersionInfo, | ||
requestedVersion?: string | ||
): DatasetVersion { | ||
return new DatasetVersion( | ||
jDatasetVersionId, | ||
JSDatasetVersionMapper.toStatus(jsDatasetVersionInfo.state), | ||
true, // TODO Connect with dataset version isLatest | ||
false, // TODO Connect with dataset version isInReview | ||
JSDatasetVersionMapper.toStatus(jsDatasetVersionInfo.state), // TODO Connect with dataset version latestVersionState | ||
jsDatasetVersionInfo.majorNumber, | ||
jsDatasetVersionInfo.minorNumber, | ||
requestedVersion | ||
) | ||
} | ||
|
||
static toStatus(jsDatasetVersionState: JSDatasetVersionState): DatasetPublishingStatus { | ||
switch (jsDatasetVersionState) { | ||
case JSDatasetVersionState.DRAFT: | ||
return DatasetPublishingStatus.DRAFT | ||
case JSDatasetVersionState.DEACCESSIONED: | ||
return DatasetPublishingStatus.DEACCESSIONED | ||
case JSDatasetVersionState.RELEASED: | ||
return DatasetPublishingStatus.RELEASED | ||
default: | ||
return DatasetPublishingStatus.DRAFT | ||
} | ||
} | ||
} |
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
Oops, something went wrong.