-
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 branch 'develop' of https://github.com/IQSS/dataverse-frontend …
…into feature/249-boilerplate-file-page
- Loading branch information
Showing
17 changed files
with
252 additions
and
107 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
25 changes: 25 additions & 0 deletions
25
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,25 @@ | ||
import { DatasetPreview as JSDatasetPreview } from '@iqss/dataverse-client-javascript/dist/datasets/domain/models/DatasetPreview' | ||
import { DatasetPreview } from '../../domain/models/DatasetPreview' | ||
import { DatasetVersionInfo as JSDatasetVersionInfo } 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, | ||
JSDatasetVersionMapper.toVersion( | ||
jsDatasetPreview.versionId, | ||
jsDatasetPreview.versionInfo, | ||
jsDatasetPreview.title, | ||
jsDatasetPreview.citation | ||
), | ||
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 | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
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,56 @@ | ||
import { | ||
DatasetVersionInfo as JSDatasetVersionInfo, | ||
DatasetVersionState as JSDatasetVersionState | ||
} from '@iqss/dataverse-client-javascript/dist/datasets/domain/models/Dataset' | ||
import { | ||
DatasetPublishingStatus, | ||
DatasetVersion, | ||
DatasetVersionNumber | ||
} from '../../domain/models/Dataset' | ||
export class JSDatasetVersionMapper { | ||
static toVersion( | ||
jDatasetVersionId: number, | ||
jsDatasetVersionInfo: JSDatasetVersionInfo, | ||
jsDatasetTitle: string, | ||
jsDatasetCitation: string | ||
): DatasetVersion { | ||
return new DatasetVersion.Builder( | ||
jDatasetVersionId, | ||
jsDatasetTitle, | ||
this.toVersionNumber(jsDatasetVersionInfo), | ||
this.toStatus(jsDatasetVersionInfo.state), | ||
jsDatasetCitation, | ||
true, // TODO Connect with dataset version isLatest | ||
false, // TODO Connect with dataset version isInReview | ||
this.toStatus(jsDatasetVersionInfo.state), | ||
this.toSomeDatasetVersionHasBeenReleased(jsDatasetVersionInfo) | ||
) | ||
} | ||
|
||
static toVersionNumber(jsDatasetVersionInfo: JSDatasetVersionInfo): DatasetVersionNumber { | ||
return new DatasetVersionNumber( | ||
jsDatasetVersionInfo.majorNumber, | ||
jsDatasetVersionInfo.minorNumber | ||
) | ||
} | ||
|
||
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 | ||
} | ||
} | ||
|
||
static toSomeDatasetVersionHasBeenReleased(jsDatasetVersionInfo: JSDatasetVersionInfo): boolean { | ||
return ( | ||
jsDatasetVersionInfo.releaseTime !== undefined && | ||
!isNaN(jsDatasetVersionInfo.releaseTime.getTime()) | ||
) | ||
} | ||
} |
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
Oops, something went wrong.