-
Notifications
You must be signed in to change notification settings - Fork 10
Get Dataset Templates use case #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6df006e
feat: initial work, types methods
g-saracca ea487a0
Merge branch 'develop' into feat/317-get-dataset-templates
g-saracca 6bfc7d6
feat: methods and use cases
g-saracca aa34265
feat: tansform iconUrl to iconUri
g-saracca 6c9fb0e
refactor: move use case to datasets repository
g-saracca 9eb5ab8
feat: change property name to avoid confusion
g-saracca 70276ca
feat: change model returned
g-saracca 48785ee
chore: back to unstable image for tests
g-saracca 8720bdc
test: add integration cases
g-saracca 4405fc0
Merge branch 'develop' into feat/317-get-dataset-templates
g-saracca d06e2cb
fix: use mapper and correct test
g-saracca 0ec433f
refactor: update license handling across dataset models and transformers
g-saracca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
| import { DatasetMetadataBlock, TermsOfUse } from './Dataset' | ||
| import { License } from '../../../licenses/domain/models/License' | ||
|
|
||
| export interface DatasetTemplate { | ||
| id: number | ||
| name: string | ||
| collectionAlias: string | ||
| isDefault: boolean | ||
| usageCount: number | ||
| createTime: string | ||
| createDate: string | ||
| // 👇 From Edit Template Metadata | ||
| datasetMetadataBlocks: DatasetMetadataBlock[] | ||
| instructions: DatasetTemplateInstruction[] | ||
| // 👇 From Edit Template Terms | ||
| termsOfUse: TermsOfUse | ||
| license?: License // This license property is going to be present if not custom terms are added in the UI | ||
| } | ||
|
|
||
| export interface DatasetTemplateInstruction { | ||
| instructionField: string | ||
| instructionText: string | ||
| } |
This file contains hidden or 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 hidden or 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 { ROOT_COLLECTION_ID } from '../../../collections/domain/models/Collection' | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { DatasetTemplate } from '../models/DatasetTemplate' | ||
| import { IDatasetsRepository } from '../repositories/IDatasetsRepository' | ||
|
|
||
| export class GetDatasetTemplates implements UseCase<DatasetTemplate[]> { | ||
| private datasetsRepository: IDatasetsRepository | ||
|
|
||
| constructor(datasetsRepository: IDatasetsRepository) { | ||
| this.datasetsRepository = datasetsRepository | ||
| } | ||
|
|
||
| /** | ||
| * Returns a DatasetTemplate array containing the dataset templates of the requested collection, given the collection identifier or alias. | ||
| * | ||
| * @param {number | string} [collectionIdOrAlias = ':root'] - A generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId) | ||
| * If this parameter is not set, the default value is: ':root' | ||
| * @returns {Promise<DatasetTemplate[]>} | ||
| */ | ||
| async execute( | ||
| collectionIdOrAlias: number | string = ROOT_COLLECTION_ID | ||
| ): Promise<DatasetTemplate[]> { | ||
| return await this.datasetsRepository.getDatasetTemplates(collectionIdOrAlias) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
52 changes: 52 additions & 0 deletions
52
src/datasets/infra/repositories/transformers/DatasetTemplatePayload.ts
This file contains hidden or 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,52 @@ | ||
| import { LicensePayload } from '../../../../licenses/domain/repositories/transformers/LicensePayload' | ||
| import { MetadataFieldPayload } from './DatasetPayload' | ||
|
|
||
| export interface DatasetTemplatePayload { | ||
| id: number | ||
| name: string | ||
| dataverseAlias: string | ||
| isDefault: boolean | ||
| usageCount: number | ||
| createTime: string | ||
| createDate: string | ||
| // 👇 From Edit Template Metadata | ||
| datasetFields: DatasetFieldsPayload | ||
| instructions: Instruction[] | ||
| // 👇 From Edit Template Terms | ||
| termsOfUseAndAccess: { | ||
| id: number | ||
| fileAccessRequest: boolean | ||
| // This license property is going to be present if not custom terms are added in the UI | ||
| license?: LicensePayload | ||
| // Below fields are going to be present if are added in "Restricted Files + Terms of Access" | ||
| termsOfAccess?: string // This is terms of access for restricted files in the JSF UI | ||
| dataAccessPlace?: string | ||
| originalArchive?: string | ||
| availabilityStatus?: string | ||
| sizeOfCollection?: string | ||
| studyCompletion?: string | ||
| contactForAccess?: string | ||
| // Below fields are going to be present if custom terms are added in the UI, they will be mapped and grouped under customTerms | ||
| termsOfUse?: string | ||
| confidentialityDeclaration?: string | ||
| specialPermissions?: string | ||
| restrictions?: string | ||
| citationRequirements?: string | ||
| depositorRequirements?: string | ||
| conditions?: string | ||
| disclaimer?: string | ||
| } | ||
| } | ||
|
|
||
| type DatasetFieldsPayload = Record<string, DatasetFieldInfoPayload> | ||
|
|
||
| interface DatasetFieldInfoPayload { | ||
| displayName: string | ||
| name: string | ||
| fields: MetadataFieldPayload[] | ||
| } | ||
|
|
||
| interface Instruction { | ||
| instructionField: string | ||
| instructionText: string | ||
| } | ||
57 changes: 57 additions & 0 deletions
57
src/datasets/infra/repositories/transformers/datasetTemplateTransformers.ts
This file contains hidden or 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,57 @@ | ||
| import { transformPayloadLicenseToLicense } from '../../../../licenses/domain/repositories/transformers/licenseTransformers' | ||
| import { DatasetTemplate } from '../../../domain/models/DatasetTemplate' | ||
| import { DatasetTemplatePayload } from './DatasetTemplatePayload' | ||
| import { transformPayloadToDatasetMetadataBlocks } from './datasetTransformers' | ||
|
|
||
| export const transformDatasetTemplatePayloadToDatasetTemplate = ( | ||
| collectionDatasetTemplatePayload: DatasetTemplatePayload[] | ||
| ): DatasetTemplate[] => { | ||
| return collectionDatasetTemplatePayload.map((payload) => { | ||
| const datasetTemplate: DatasetTemplate = { | ||
| id: payload.id, | ||
| name: payload.name, | ||
| collectionAlias: payload.dataverseAlias, | ||
| isDefault: payload.isDefault, | ||
| usageCount: payload.usageCount, | ||
| createTime: payload.createTime, | ||
| createDate: payload.createDate, | ||
| datasetMetadataBlocks: transformPayloadToDatasetMetadataBlocks(payload.datasetFields, false), | ||
| instructions: payload.instructions.map((instruction) => ({ | ||
| instructionField: instruction.instructionField, | ||
| instructionText: instruction.instructionText | ||
| })), | ||
| termsOfUse: { | ||
| termsOfAccess: { | ||
| fileAccessRequest: payload.termsOfUseAndAccess.fileAccessRequest, | ||
| termsOfAccessForRestrictedFiles: payload.termsOfUseAndAccess.termsOfAccess, | ||
| dataAccessPlace: payload.termsOfUseAndAccess.dataAccessPlace, | ||
| originalArchive: payload.termsOfUseAndAccess.originalArchive, | ||
| availabilityStatus: payload.termsOfUseAndAccess.availabilityStatus, | ||
| contactForAccess: payload.termsOfUseAndAccess.contactForAccess, | ||
| sizeOfCollection: payload.termsOfUseAndAccess.sizeOfCollection, | ||
| studyCompletion: payload.termsOfUseAndAccess.studyCompletion | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (payload.termsOfUseAndAccess.license) { | ||
| datasetTemplate.license = transformPayloadLicenseToLicense( | ||
| payload.termsOfUseAndAccess.license | ||
| ) | ||
| } else { | ||
| datasetTemplate.termsOfUse.customTerms = { | ||
| termsOfUse: payload.termsOfUseAndAccess.termsOfUse as string, | ||
| confidentialityDeclaration: payload.termsOfUseAndAccess | ||
| .confidentialityDeclaration as string, | ||
| specialPermissions: payload.termsOfUseAndAccess.specialPermissions as string, | ||
| restrictions: payload.termsOfUseAndAccess.restrictions as string, | ||
| citationRequirements: payload.termsOfUseAndAccess.citationRequirements as string, | ||
| depositorRequirements: payload.termsOfUseAndAccess.depositorRequirements as string, | ||
| conditions: payload.termsOfUseAndAccess.conditions as string, | ||
| disclaimer: payload.termsOfUseAndAccess.disclaimer as string | ||
| } | ||
| } | ||
|
|
||
| return datasetTemplate | ||
| }) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we may need a separate interface for TermsOfUseAndAccess, based on dataverse TermsOfUseAndAccess? We could make changes on this part until we implement the use case of edit terms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as comment above, this is the payload, after the mapping I'm using the already there TermsOfUse model.