diff --git a/libs/api/metadata-converter/src/lib/iso19115-3/iso19115-3.converter.ts b/libs/api/metadata-converter/src/lib/iso19115-3/iso19115-3.converter.ts
index 968f1dcedf..371d253197 100644
--- a/libs/api/metadata-converter/src/lib/iso19115-3/iso19115-3.converter.ts
+++ b/libs/api/metadata-converter/src/lib/iso19115-3/iso19115-3.converter.ts
@@ -22,7 +22,6 @@ import {
writeLandingPage,
writeLineage,
writeOnlineResources,
- writeOwnerOrganization,
writeRecordCreated,
writeRecordPublished,
writeRecordUpdated,
@@ -60,7 +59,7 @@ export class Iso191153Converter extends Iso19139Converter {
this.writers['resourcePublished'] = writeResourcePublished
this.writers['contacts'] = writeContacts
this.writers['contactsForResource'] = writeContactsForResource
- this.writers['ownerOrganization'] = writeOwnerOrganization
+ this.writers['ownerOrganization'] = () => undefined // fixme: find a way to store this value properly
this.writers['landingPage'] = writeLandingPage
this.writers['lineage'] = writeLineage
this.writers['onlineResources'] = writeOnlineResources
diff --git a/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.spec.ts b/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.spec.ts
index 4056e3bb10..7bd1e6633e 100644
--- a/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.spec.ts
+++ b/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.spec.ts
@@ -1,5 +1,6 @@
import { GENERIC_DATASET_RECORD } from '../fixtures/generic.records'
import {
+ writeContacts,
writeContactsForResource,
writeOnlineResources,
writeRecordCreated,
@@ -449,6 +450,161 @@ describe('write parts', () => {
+`)
+ })
+ })
+
+ describe('writeContacts', () => {
+ it('works with incomplete contacts', () => {
+ const contacts = [
+ {
+ firstName: 'John',
+ role: 'point_of_contact',
+ email: 'aaa@bbb.ccc',
+ },
+ {
+ lastName: 'Doe',
+ role: 'contributor',
+ email: 'abc@def.ghi',
+ organization: {
+ name: 'ACME',
+ },
+ },
+ ]
+ const modified: DatasetRecord = {
+ ...datasetRecord,
+ contacts,
+ contactsForResource: contacts,
+ }
+ writeContacts(modified, rootEl)
+ writeContactsForResource(modified, rootEl)
+ expect(rootAsString()).toEqual(`
+
+
+
+ pointOfContact
+
+
+
+
+
+
+
+
+ aaa@bbb.ccc
+
+
+
+
+
+
+
+
+ John
+
+
+
+
+
+
+
+
+
+
+ contributor
+
+
+
+
+ ACME
+
+
+
+
+
+
+ abc@def.ghi
+
+
+
+
+
+
+
+
+ Doe
+
+
+
+
+
+
+
+
+
+
+
+
+ pointOfContact
+
+
+
+
+
+
+
+
+ aaa@bbb.ccc
+
+
+
+
+
+
+
+
+ John
+
+
+
+
+
+
+
+
+
+
+ contributor
+
+
+
+
+ ACME
+
+
+
+
+
+
+ abc@def.ghi
+
+
+
+
+
+
+
+
+ Doe
+
+
+
+
+
+
+
+
+
`)
})
})
diff --git a/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts b/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts
index 78a1d26d9e..feb3443acd 100644
--- a/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts
+++ b/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts
@@ -17,7 +17,6 @@ import {
findNestedElement,
findNestedElements,
readAttribute,
- removeAllChildren,
removeChildren,
removeChildrenByName,
setTextContent,
@@ -213,33 +212,6 @@ export function writeResourcePublished(
appendResourceDate(record.resourcePublished, 'publication')(rootEl)
}
-export function writeOwnerOrganization(
- record: CatalogRecord,
- rootEl: XmlElement
-) {
- // if no contact matches the owner org, create an empty one
- const ownerContact: Individual = record.contacts.find(
- (contact) => contact.organization.name === record.ownerOrganization.name
- )
- pipe(
- findChildOrCreate('mdb:contact'),
- removeAllChildren(),
- appendResponsibleParty(
- ownerContact
- ? {
- ...ownerContact,
- // owner responsible party is always point of contact
- role: 'point_of_contact',
- }
- : {
- organization: record.ownerOrganization,
- email: 'missing@missing.com',
- role: 'point_of_contact',
- }
- )
- )(rootEl)
-}
-
export function appendResponsibleParty(contact: Individual) {
const fullName = namePartsToFull(contact.firstName, contact.lastName)
diff --git a/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts b/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts
index ca6d3aeb92..7c038e5df4 100644
--- a/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts
+++ b/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts
@@ -9,6 +9,8 @@ import {
} from '../xml-utils'
import {
getISODuration,
+ writeContacts,
+ writeContactsForResource,
writeKeywords,
writeOnlineResources,
writeResourceCreated,
@@ -785,6 +787,129 @@ describe('write parts', () => {
})
})
+ describe('writeContacts', () => {
+ it('works with incomplete contacts', () => {
+ const contacts = [
+ {
+ firstName: 'John',
+ role: 'point_of_contact',
+ email: 'aaa@bbb.ccc',
+ },
+ {
+ lastName: 'Doe',
+ role: 'contributor',
+ email: 'abc@def.ghi',
+ organization: {
+ name: 'ACME',
+ },
+ },
+ ]
+ const modified: DatasetRecord = {
+ ...datasetRecord,
+ contacts,
+ contactsForResource: contacts,
+ }
+ writeContacts(modified, rootEl)
+ writeContactsForResource(modified, rootEl)
+ expect(rootAsString()).toEqual(`
+
+
+
+ John
+
+
+
+
+
+
+ aaa@bbb.ccc
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Doe
+
+
+ ACME
+
+
+
+
+
+
+ abc@def.ghi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ John
+
+
+
+
+
+
+ aaa@bbb.ccc
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Doe
+
+
+ ACME
+
+
+
+
+
+
+ abc@def.ghi
+
+
+
+
+
+
+
+
+
+
+
+
+`)
+ })
+ })
+
describe('getISODuration', () => {
it('keeps a partial weekly period', () => {
expect(
diff --git a/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts b/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts
index 96f9d14049..34a80e1b80 100644
--- a/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts
+++ b/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts
@@ -238,7 +238,7 @@ export function getISODuration(updateFrequency: UpdateFrequencyCustom): string {
return `P${duration.years}Y${duration.months}M${duration.days}D${hours}`
}
-export function appendResponsibleParty(contact: Individual) {
+function appendResponsibleParty(contact: Individual) {
const fullName = namePartsToFull(contact.firstName, contact.lastName)
const createAddress = pipe(
@@ -274,7 +274,7 @@ export function appendResponsibleParty(contact: Individual) {
)
: noop,
appendChildren(createAddress),
- 'website' in contact.organization
+ contact.organization?.website
? appendChildren(
pipe(
createElement('gmd:onlineResource'),
@@ -304,11 +304,16 @@ export function appendResponsibleParty(contact: Individual) {
)
)
: noop,
+
+ contact.organization?.name
+ ? appendChildren(
+ pipe(
+ createElement('gmd:organisationName'),
+ writeCharacterString(contact.organization.name)
+ )
+ )
+ : noop,
appendChildren(
- pipe(
- createElement('gmd:organisationName'),
- writeCharacterString(contact.organization.name)
- ),
createContact,
pipe(
createElement('gmd:role'),