feat(ENG-9817): collection-specific metadata with cedar#963
Open
Vlad0n20 wants to merge 1 commit intoCenterForOpenScience:feature/es2-consolidationfrom
Open
feat(ENG-9817): collection-specific metadata with cedar#963Vlad0n20 wants to merge 1 commit intoCenterForOpenScience:feature/es2-consolidationfrom
Vlad0n20 wants to merge 1 commit intoCenterForOpenScience:feature/es2-consolidationfrom
Conversation
nsemets
requested changes
Apr 22, 2026
Comment on lines
+156
to
+157
| id: creator.id, | ||
| fullName: creator.fullName, |
Collaborator
There was a problem hiding this comment.
Revert changes here, because user can be deleted and it will return erorr.
| [isProjectSubmissionsLoading]="isProjectSubmissionsLoading()" | ||
| [cedarRecords]="cedarRecords()" | ||
| [cedarTemplates]="cedarTemplates()?.data ?? null" | ||
| [isCedarMode]="environment.collectionSubmissionWithCedar" |
Collaborator
There was a problem hiding this comment.
It is wrong. Property environment is private and can't be accessible in html. Use variable for this or getter.
Comment on lines
+40
to
+48
| cedarTemplateById = computed(() => { | ||
| const templates = this.cedarTemplates(); | ||
| if (!templates?.length) return new Map<string, CedarMetadataDataTemplateJsonApi>(); | ||
| const map = new Map<string, CedarMetadataDataTemplateJsonApi>(); | ||
| for (const template of templates) { | ||
| map.set(template.id, template); | ||
| } | ||
| return map; | ||
| }); |
Collaborator
There was a problem hiding this comment.
Suggested change
| cedarTemplateById = computed(() => { | |
| const templates = this.cedarTemplates(); | |
| if (!templates?.length) return new Map<string, CedarMetadataDataTemplateJsonApi>(); | |
| const map = new Map<string, CedarMetadataDataTemplateJsonApi>(); | |
| for (const template of templates) { | |
| map.set(template.id, template); | |
| } | |
| return map; | |
| }); | |
| cedarTemplateById = computed(() => { | |
| const templates = this.cedarTemplates(); | |
| return new Map(templates?.map((t) => [t.id, t] as const) ?? []); | |
| }); |
Comment on lines
+27
to
+38
| cedarRecordByTemplateId = computed(() => { | ||
| const records = this.cedarRecords(); | ||
| if (!records?.length) return new Map<string, CedarMetadataRecordData>(); | ||
| const map = new Map<string, CedarMetadataRecordData>(); | ||
| for (const record of records) { | ||
| const templateId = record.relationships?.template?.data?.id; | ||
| if (templateId) { | ||
| map.set(templateId, record); | ||
| } | ||
| } | ||
| return map; | ||
| }); |
Collaborator
There was a problem hiding this comment.
Suggested change
| cedarRecordByTemplateId = computed(() => { | |
| const records = this.cedarRecords(); | |
| if (!records?.length) return new Map<string, CedarMetadataRecordData>(); | |
| const map = new Map<string, CedarMetadataRecordData>(); | |
| for (const record of records) { | |
| const templateId = record.relationships?.template?.data?.id; | |
| if (templateId) { | |
| map.set(templateId, record); | |
| } | |
| } | |
| return map; | |
| }); | |
| cedarRecordByTemplateId = computed(() => { | |
| const records = this.cedarRecords(); | |
| return new Map( | |
| records?.flatMap((record) => { | |
| const templateId = record.relationships?.template?.data?.id; | |
| return templateId ? [[templateId, record] as const] : []; | |
| }) ?? [] | |
| ); | |
| }); |
| it('should populate cedarFormData from existingCedarRecord', () => { | ||
| const existingRecord: CedarMetadataRecordData = { | ||
| attributes: { | ||
| metadata: { field: 'existing' } as CedarMetadataRecordData['attributes']['metadata'], |
Collaborator
There was a problem hiding this comment.
Fix this, as there is a type mismatch.
| const mockCedarRecord: CedarMetadataRecordData = { | ||
| id: 'record-1', | ||
| attributes: { | ||
| metadata: { field: 'value' } as CedarMetadataRecordData['attributes']['metadata'], |
Collaborator
There was a problem hiding this comment.
Fix this, as there is a type mismatch.
Comment on lines
+12
to
+62
| const mockSubmission: CollectionSubmission = { | ||
| id: '1', | ||
| type: 'collection-submission', | ||
| collectionTitle: 'Test Collection', | ||
| collectionId: 'collection-123', | ||
| reviewsState: CollectionSubmissionReviewState.Pending, | ||
| collectedType: 'preprint', | ||
| status: 'pending', | ||
| volume: '1', | ||
| issue: '1', | ||
| programArea: 'Science', | ||
| schoolType: 'University', | ||
| studyDesign: 'Experimental', | ||
| dataType: 'Quantitative', | ||
| disease: 'Cancer', | ||
| gradeLevels: 'Graduate', | ||
| requiredMetadataTemplateId: 'template-1', | ||
| }; | ||
|
|
||
| const mockCedarTemplate: CedarMetadataDataTemplateJsonApi = { | ||
| id: 'template-1', | ||
| type: 'cedar-metadata-templates', | ||
| attributes: { | ||
| schema_name: 'Test Template', | ||
| cedar_id: 'cedar-1', | ||
| template: { | ||
| '@id': 'https://repo.metadatacenter.org/templates/1', | ||
| '@type': 'https://schema.metadatacenter.org/core/Template', | ||
| type: 'object', | ||
| title: 'Test', | ||
| description: 'Test template', | ||
| $schema: 'http://json-schema.org/draft-04/schema#', | ||
| '@context': { | ||
| pav: 'http://purl.org/pav/', | ||
| xsd: 'http://www.w3.org/2001/XMLSchema#', | ||
| bibo: 'http://purl.org/ontology/bibo/', | ||
| oslc: 'http://open-services.net/ns/core#', | ||
| schema: 'http://schema.org/', | ||
| 'schema:name': { '@type': 'xsd:string' }, | ||
| 'pav:createdBy': { '@type': '@id' }, | ||
| 'pav:createdOn': { '@type': 'xsd:dateTime' }, | ||
| 'oslc:modifiedBy': { '@type': '@id' }, | ||
| 'pav:lastUpdatedOn': { '@type': 'xsd:dateTime' }, | ||
| 'schema:description': { '@type': 'xsd:string' }, | ||
| }, | ||
| required: [], | ||
| properties: {}, | ||
| _ui: { order: [], propertyLabels: {}, propertyDescriptions: {} }, | ||
| }, | ||
| }, | ||
| }; |
Collaborator
There was a problem hiding this comment.
It is better to move into testing/data/collections.
Comment on lines
+296
to
+309
| private saveCedarRecordIfNeeded(): Observable<unknown> { | ||
| const cedarData = this.pendingCedarData(); | ||
| const projectId = this.selectedProject()?.id; | ||
| const templateId = this.requiredMetadataTemplate()?.id; | ||
| if (!this.isCedarMode() || !cedarData || !projectId || !templateId) { | ||
| return of(null); | ||
| } | ||
|
|
||
| const existing = this.existingCedarRecord(); | ||
| if (existing?.id) { | ||
| return this.actions.updateCedarRecord(cedarData, existing.id, projectId, ResourceType.Project); | ||
| } | ||
| return this.actions.createCedarRecord(cedarData, projectId, ResourceType.Project); | ||
| } |
Collaborator
There was a problem hiding this comment.
Suggested change
| private saveCedarRecordIfNeeded(): Observable<unknown> { | |
| const cedarData = this.pendingCedarData(); | |
| const projectId = this.selectedProject()?.id; | |
| const templateId = this.requiredMetadataTemplate()?.id; | |
| if (!this.isCedarMode() || !cedarData || !projectId || !templateId) { | |
| return of(null); | |
| } | |
| const existing = this.existingCedarRecord(); | |
| if (existing?.id) { | |
| return this.actions.updateCedarRecord(cedarData, existing.id, projectId, ResourceType.Project); | |
| } | |
| return this.actions.createCedarRecord(cedarData, projectId, ResourceType.Project); | |
| } | |
| private saveCedarRecordIfNeeded(): Observable<unknown> { | |
| if (!this.isCedarMode()) return of(null); | |
| const cedarData = this.pendingCedarData(); | |
| const projectId = this.selectedProject()?.id; | |
| const templateId = this.requiredMetadataTemplate()?.id; | |
| if (!cedarData || !projectId || !templateId) return of(null); | |
| const existingId = this.existingCedarRecord()?.id; | |
| return existingId | |
| ? this.actions.updateCedarRecord(cedarData, existingId, projectId, ResourceType.Project) | |
| : this.actions.createCedarRecord(cedarData, projectId, ResourceType.Project); | |
| } |
Comment on lines
+18
to
+49
| const MOCK_CEDAR_TEMPLATE: CedarMetadataDataTemplateJsonApi = { | ||
| id: 'template-1', | ||
| type: 'cedar-metadata-templates', | ||
| attributes: { | ||
| schema_name: 'Test Template', | ||
| cedar_id: 'cedar-1', | ||
| template: { | ||
| '@id': 'https://repo.metadatacenter.org/templates/1', | ||
| '@type': 'https://schema.metadatacenter.org/core/Template', | ||
| type: 'object', | ||
| title: 'Test', | ||
| description: 'Test template', | ||
| $schema: 'http://json-schema.org/draft-04/schema#', | ||
| '@context': { | ||
| pav: 'http://purl.org/pav/', | ||
| xsd: 'http://www.w3.org/2001/XMLSchema#', | ||
| bibo: 'http://purl.org/ontology/bibo/', | ||
| oslc: 'http://open-services.net/ns/core#', | ||
| schema: 'http://schema.org/', | ||
| 'schema:name': { '@type': 'xsd:string' }, | ||
| 'pav:createdBy': { '@type': '@id' }, | ||
| 'pav:createdOn': { '@type': 'xsd:dateTime' }, | ||
| 'oslc:modifiedBy': { '@type': '@id' }, | ||
| 'pav:lastUpdatedOn': { '@type': 'xsd:dateTime' }, | ||
| 'schema:description': { '@type': 'xsd:string' }, | ||
| }, | ||
| required: [], | ||
| properties: {}, | ||
| _ui: { order: [], propertyLabels: {}, propertyDescriptions: {} }, | ||
| }, | ||
| }, | ||
| }; |
Collaborator
There was a problem hiding this comment.
Move it to testing/data/collections.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
Add support for collection-specific metadata using CEDAR (Center for
Expanded Data Annotation and Retrieval) templates when submitting or
editing a project in a collection. Collections that require structured
metadata can now enforce a CEDAR template form instead of the
standard filter-based metadata fields.
Summary of Changes
feature flag
requiredMetadataTemplateId field
field (full CEDAR template object)
requiredMetadataTemplateId from API responses into
CollectionSubmission and expose requiredMetadataTemplate on the
provider
required metadata template via the collections store
CEDAR form instead of the standard filter fields; saves/updates a
CEDAR record on submission via CreateCedarMetadataRecord /
UpdateCedarMetadataRecord actions
web component, tracks form data via
onCedarChange, and emits cedarDataSaved instead of metadataSaved
and isCedarMode inputs; builds lookup maps (cedarRecordByTemplateId,
cedarTemplateById) and passes matched data to each item
when in CEDAR mode and hides standard filter
attributes
Screenshot(s)
Side Effects
QA Notes