Skip to content

Commit

Permalink
Overwrite consistently contact names in service metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroNeumann committed Apr 9, 2024
1 parent 6d8b247 commit 2ebad8d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ protected String getResponsiblePartyPath(Topic topic, String role) {
return getIdentificationPath(topic) +
"/gmd:pointOfContact" +
"/gmd:CI_ResponsibleParty" +

"[gmd:role" +
"/gmd:CI_RoleCode" +
"/@codeListValue" +
Expand Down Expand Up @@ -642,7 +641,13 @@ protected String getMetaDataPointOfContactPath(String role) {
;
}

protected String getMetaDataPointOfContactNamePath(String role) {
protected String getMetaDataPointOfContactIndividualNamePath(String role) {
return getMetaDataPointOfContactPath(role) +
"/gmd:individualName" +
"/gco:CharacterString";
}

protected String getMetaDataPointOfContactOrganisationNamePath(String role) {
return getMetaDataPointOfContactPath(role) +
"/gmd:organisationName" +
"/gco:CharacterString";
Expand All @@ -658,23 +663,70 @@ protected String getMetaDataPointOfContactEmailPath(String role) {
"/gco:CharacterString";
}

public String getMetaDataPointOfContactName(String role) throws NotFound{
return isoMetadata.getString(namespaces, getMetaDataPointOfContactNamePath(role));
public String getMetaDataPointOfContactIndividualName(String role) throws NotFound{
return isoMetadata.getString(namespaces, getMetaDataPointOfContactIndividualNamePath(role));
}

public String getMetaDataPointOfContactOrganisationName(String role) throws NotFound{
return isoMetadata.getString(namespaces, getMetaDataPointOfContactOrganisationNamePath(role));
}

public String getMetaDataPointOfContactEmail(String role) throws Exception{
return isoMetadata.getString(namespaces, getMetaDataPointOfContactEmailPath(role));
}

public void setMetaDataPointOfContactName(String role, String name) throws Exception{
isoMetadata.updateString(namespaces, getMetaDataPointOfContactNamePath(role), name);
public void setMetaDataPointOfContactIndividualName(String role, String name) throws Exception{
isoMetadata.updateString(namespaces, getMetaDataPointOfContactIndividualNamePath(role), name);
}

public void setMetaDataPointOfContactOrganisationName(String role, String name) throws Exception{
isoMetadata.updateString(namespaces, getMetaDataPointOfContactOrganisationNamePath(role), name);
}

public void setMetaDataPointOfContactEmail(String role, String email) throws Exception{
isoMetadata.updateString(namespaces, getMetaDataPointOfContactEmailPath(role), email);
}


/*
* Metadata Distributor
*/

protected String getDistributorPath(String role) {
return
"/gmd:MD_Metadata" +
"/gmd:distributionInfo" +
"/gmd:MD_Distribution" +
"/gmd:distributor" +
"/gmd:MD_Distributor" +
"/gmd:distributorContact" +
"/gmd:CI_ResponsibleParty" +
"[gmd:role" +
"/gmd:CI_RoleCode" +
"/@codeListValue" +
"='" + role + "']"
;
}

protected String getDistributorIndividualNamePath(String role) {
return getDistributorPath(role) +
"/gmd:individualName" +
"/gco:CharacterString";
}

protected String getDistributorOrganisationNamePath(String role) {
return getDistributorPath(role) +
"/gmd:organisationName" +
"/gco:CharacterString";
}

public void setDistributorIndividualName(String role, String name) throws Exception{
isoMetadata.updateString(namespaces, getDistributorIndividualNamePath(role), name);
}

public void setDistributorOrganisationName(String role, String name) throws Exception{
isoMetadata.updateString(namespaces, getDistributorOrganisationNamePath(role), name);
}

/*
* Metadata creation date
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private Map<String, Object> mapDcat(Tuple ds) {
Map<String, String> contactPoint = new HashMap<>();
contactPoint.put("@type", "vcard:Contact");
try {
contactPoint.put("fn", metadataDocument.getMetaDataPointOfContactName("pointOfContact"));
contactPoint.put("fn", metadataDocument.getMetaDataPointOfContactOrganisationName("pointOfContact"));
contactPoint.put("hasEmail", metadataDocument.getMetaDataPointOfContactEmail("pointOfContact"));
} catch (NotFound nf) {
contactPoint.put("fn", null);
Expand Down
10 changes: 8 additions & 2 deletions publisher-metadata/app/controllers/ServiceMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,18 @@ public Optional<Resource> resource(String name) {
"http://www.isotc211.org/2005/resources/codeList.xml#CI_DateTypeCode",
"publication");

String role = "pointOfContact";
String role = "pointOfContact";

metadataDocument.setServiceResponsiblePartyName(role, serviceTuple.get(constants.organization));
metadataDocument.setServiceResponsiblePartyEmail(role, serviceTuple.get(constants.email));
metadataDocument.setMetaDataPointOfContactName(role, serviceTuple.get(constants.organization));

metadataDocument.setMetaDataPointOfContactIndividualName(role, serviceTuple.get(constants.contact));
metadataDocument.setMetaDataPointOfContactOrganisationName(role, serviceTuple.get(constants.organization));
metadataDocument.setMetaDataPointOfContactEmail(role, serviceTuple.get(constants.email));

metadataDocument.setDistributorIndividualName(role, serviceTuple.get(constants.contact));
metadataDocument.setDistributorOrganisationName(role, serviceTuple.get(constants.organization));

metadataDocument.removeOperatesOn();

Integer lastDatasetIdForOperatesOn = null;
Expand Down

0 comments on commit 2ebad8d

Please sign in to comment.