-
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 #157 from IQSS/feature/125-integration-dataset-sum…
…mary-continued 125 - Integration dataset summary continued
- Loading branch information
Showing
23 changed files
with
656 additions
and
139 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
export interface MetadataBlockInfo { | ||
name: string | ||
fields: Record<string, MetadataFieldInfo> | ||
fields: MetadataBlockInfoFields | ||
} | ||
|
||
export type MetadataBlockInfoFields = Record<string, MetadataFieldInfo> | ||
|
||
export interface MetadataFieldInfo { | ||
displayFormat: string | ||
} | ||
|
||
export const METADATA_FIELD_DISPLAY_FORMAT_PLACEHOLDER = '#VALUE' | ||
export const METADATA_FIELD_DISPLAY_FORMAT_NAME_PLACEHOLDER = '#NAME' |
31 changes: 0 additions & 31 deletions
31
src/metadata-block-info/infrastructure/MetadataBlockInfoJSDataverseRepository.ts
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
src/metadata-block-info/infrastructure/mappers/JSMetadataBlockInfoMapper.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,51 @@ | ||
import { | ||
MetadataBlock as JSMetadataBlockInfo, | ||
MetadataFieldInfo as JSMetadataFieldInfo | ||
} from '@iqss/dataverse-client-javascript' | ||
import { MetadataBlockInfo, MetadataBlockInfoFields } from '../../domain/models/MetadataBlockInfo' | ||
|
||
export class JSMetadataBlockInfoMapper { | ||
static toMetadataBlockInfo(jsMetadataBlockInfo: JSMetadataBlockInfo): MetadataBlockInfo { | ||
return { | ||
name: jsMetadataBlockInfo.name, | ||
fields: this.toFields(jsMetadataBlockInfo.metadataFields) | ||
} | ||
} | ||
|
||
static toFields( | ||
jsMetadataBlockInfoFields: Record<string, JSMetadataFieldInfo> | ||
): MetadataBlockInfoFields { | ||
return Object.entries(jsMetadataBlockInfoFields).reduce( | ||
(fields: MetadataBlockInfoFields, [key, value]) => { | ||
fields[key] = { displayFormat: this.toDisplayFormat(value.displayFormat) } | ||
return fields | ||
}, | ||
{} | ||
) | ||
} | ||
|
||
static toDisplayFormat(jsDisplayFormat: string): string { | ||
const link = 'href="#VALUE"' | ||
if (jsDisplayFormat.includes(link)) { | ||
return '[#VALUE](#VALUE)' | ||
} | ||
|
||
const linkWithUrl = /<a\s+href='([^']*)\/#VALUE'[^>]*>#VALUE<\/a>/ | ||
const match = jsDisplayFormat.match(linkWithUrl) | ||
if (match) { | ||
return `[#VALUE](${match[1]}/#VALUE)` | ||
} | ||
|
||
const emailFormat = '#EMAIL' | ||
if (jsDisplayFormat === emailFormat) { | ||
return '[#VALUE](mailto:#VALUE)' | ||
} | ||
|
||
const imageFormat = '<img src="#VALUE" alt="#NAME" class="metadata-logo"/><br/>' | ||
if (jsDisplayFormat === imageFormat) { | ||
return '![#NAME](#VALUE)' | ||
} | ||
|
||
return jsDisplayFormat | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...metadata-block-info/infrastructure/repositories/MetadataBlockInfoJSDataverseRepository.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,17 @@ | ||
import { MetadataBlockInfoRepository } from '../../domain/repositories/MetadataBlockInfoRepository' | ||
import { MetadataBlockInfo } from '../../domain/models/MetadataBlockInfo' | ||
import { | ||
getMetadataBlockByName, | ||
MetadataBlock as JSMetadataBlockInfo | ||
} from '@iqss/dataverse-client-javascript' | ||
import { JSMetadataBlockInfoMapper } from '../mappers/JSMetadataBlockInfoMapper' | ||
|
||
export class MetadataBlockInfoJSDataverseRepository implements MetadataBlockInfoRepository { | ||
getByName(name: string): Promise<MetadataBlockInfo | undefined> { | ||
return getMetadataBlockByName | ||
.execute(name) | ||
.then((jsMetadataBlockInfo: JSMetadataBlockInfo) => | ||
JSMetadataBlockInfoMapper.toMetadataBlockInfo(jsMetadataBlockInfo) | ||
) | ||
} | ||
} |
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
Oops, something went wrong.