Skip to content

Commit

Permalink
alternative title
Browse files Browse the repository at this point in the history
  • Loading branch information
lubitchv committed Apr 25, 2023
1 parent 2fcdebc commit 9d81846
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 19 deletions.
2 changes: 1 addition & 1 deletion conf/solr/8.11.1/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
<!-- SCHEMA-FIELDS::BEGIN -->
<field name="accessToSources" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="actionsToMinimizeLoss" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="alternativeTitle" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="alternativeTitle" type="text_en" multiValued="true" stored="true" indexed="true"/>
<field name="alternativeURL" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="astroFacility" type="text_en" multiValued="true" stored="true" indexed="true"/>
<field name="astroInstrument" type="text_en" multiValued="true" stored="true" indexed="true"/>
Expand Down
2 changes: 1 addition & 1 deletion scripts/api/data/metadatablocks/citation.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#datasetField name title description watermark fieldType displayOrder displayFormat advancedSearchField allowControlledVocabulary allowmultiples facetable displayoncreate required parent metadatablock_id termURI
title Title The main title of the Dataset text 0 TRUE FALSE FALSE FALSE TRUE TRUE citation http://purl.org/dc/terms/title
subtitle Subtitle A secondary title that amplifies or states certain limitations on the main title text 1 FALSE FALSE FALSE FALSE FALSE FALSE citation
alternativeTitle Alternative Title Either 1) a title commonly used to refer to the Dataset or 2) an abbreviation of the main title text 2 FALSE FALSE FALSE FALSE FALSE FALSE citation http://purl.org/dc/terms/alternative
alternativeTitle Alternative Title Either 1) a title commonly used to refer to the Dataset or 2) an abbreviation of the main title text 2 FALSE FALSE TRUE FALSE FALSE FALSE citation http://purl.org/dc/terms/alternative
alternativeURL Alternative URL Another URL where one can view or access the data in the Dataset, e.g. a project or personal webpage https:// url 3 <a href="#VALUE" target="_blank">#VALUE</a> FALSE FALSE FALSE FALSE FALSE FALSE citation https://schema.org/distribution
otherId Other Identifier Another unique identifier for the Dataset (e.g. producer's or another repository's identifier) none 4 : FALSE FALSE TRUE FALSE FALSE FALSE citation
otherIdAgency Agency The name of the agency that generated the other identifier text 5 #VALUE FALSE FALSE FALSE FALSE FALSE FALSE otherId citation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,7 @@ private void processProdStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) th
List<HashSet<FieldDTO>> producers = new ArrayList<>();
List<HashSet<FieldDTO>> grants = new ArrayList<>();
List<HashSet<FieldDTO>> software = new ArrayList<>();
List<String> prodPlac = new ArrayList<>();

for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) {
if (event == XMLStreamConstants.START_ELEMENT) {
Expand All @@ -1352,9 +1353,7 @@ private void processProdStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) th
} else if (xmlr.getLocalName().equals("prodDate")) {
citation.getFields().add(FieldDTO.createPrimitiveFieldDTO("productionDate", parseDate(xmlr, "prodDate")));
} else if (xmlr.getLocalName().equals("prodPlac")) {
List<String> prodPlac = new ArrayList<>();
prodPlac.add(parseText(xmlr, "prodPlac"));
citation.getFields().add(FieldDTO.createMultiplePrimitiveFieldDTO(DatasetFieldConstant.productionPlace, prodPlac));
} else if (xmlr.getLocalName().equals("software")) {
HashSet<FieldDTO> set = new HashSet<>();
addToSet(set,"softwareVersion", xmlr.getAttributeValue(null, "version"));
Expand Down Expand Up @@ -1387,6 +1386,9 @@ private void processProdStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) th
if (producers.size()>0) {
citation.getFields().add(FieldDTO.createMultipleCompoundFieldDTO("producer", producers));
}
if (prodPlac.size() > 0) {
citation.getFields().add(FieldDTO.createMultiplePrimitiveFieldDTO(DatasetFieldConstant.productionPlace, prodPlac));
}
return;
}
}
Expand All @@ -1396,6 +1398,7 @@ private void processProdStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) th
private void processTitlStmt(XMLStreamReader xmlr, DatasetDTO datasetDTO) throws XMLStreamException, ImportException {
MetadataBlockDTO citation = datasetDTO.getDatasetVersion().getMetadataBlocks().get("citation");
List<HashSet<FieldDTO>> otherIds = new ArrayList<>();
List<String> altTitles = new ArrayList<>();

for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) {
if (event == XMLStreamConstants.START_ELEMENT) {
Expand All @@ -1406,8 +1409,7 @@ private void processTitlStmt(XMLStreamReader xmlr, DatasetDTO datasetDTO) throws
FieldDTO field = FieldDTO.createPrimitiveFieldDTO("subtitle", parseText(xmlr));
citation.getFields().add(field);
} else if (xmlr.getLocalName().equals("altTitl")) {
FieldDTO field = FieldDTO.createPrimitiveFieldDTO("alternativeTitle", parseText(xmlr));
citation.getFields().add(field);
altTitles.add(parseText(xmlr));
} else if (xmlr.getLocalName().equals("IDNo")) {
if ( AGENCY_HANDLE.equals( xmlr.getAttributeValue(null, "agency") ) || AGENCY_DOI.equals( xmlr.getAttributeValue(null, "agency") ) ) {
importGenericService.reassignIdentifierAsGlobalId(parseText(xmlr), datasetDTO);
Expand Down Expand Up @@ -1435,6 +1437,9 @@ private void processTitlStmt(XMLStreamReader xmlr, DatasetDTO datasetDTO) throws
if (otherIds.size()>0) {
citation.addField(FieldDTO.createMultipleCompoundFieldDTO("otherId", otherIds));
}
if (altTitles.size()>0) {
citation.addField(FieldDTO.createMultiplePrimitiveFieldDTO("alternativeTitle", altTitles));
}
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ private static void createStdyDscr(XMLStreamWriter xmlw, DatasetDTO datasetDto)

writeFullElement(xmlw, "titl", dto2Primitive(version, DatasetFieldConstant.title), datasetDto.getMetadataLanguage());
writeFullElement(xmlw, "subTitl", dto2Primitive(version, DatasetFieldConstant.subTitle));
writeFullElement(xmlw, "altTitl", dto2Primitive(version, DatasetFieldConstant.alternativeTitle));
FieldDTO altField = dto2FieldDTO( version, DatasetFieldConstant.alternativeTitle, "citation" );
if (altField != null) {
writeMultipleElement(xmlw, "altTitl", altField, datasetDto.getMetadataLanguage());
}

xmlw.writeStartElement("IDNo");
writeAttribute(xmlw, "agency", persistentAgency);
Expand Down Expand Up @@ -891,8 +894,11 @@ private static void writeProducersElement(XMLStreamWriter xmlw, DatasetVersionDT
}
}
}
writeFullElement(xmlw, "prodDate", dto2Primitive(version, DatasetFieldConstant.productionDate));
writeFullElement(xmlw, "prodPlac", dto2Primitive(version, DatasetFieldConstant.productionPlace));
writeFullElement(xmlw, "prodDate", dto2Primitive(version, DatasetFieldConstant.productionDate));
FieldDTO prodPlac = dto2FieldDTO( version, DatasetFieldConstant.productionPlace, "citation" );
if (prodPlac != null) {
writeMultipleElement(xmlw, "prodPlac", prodPlac, null);
}
writeSoftwareElement(xmlw, version);

writeGrantElement(xmlw, version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import java.util.List;

import javax.json.JsonObject;
import javax.xml.stream.XMLOutputFactory;
Expand Down Expand Up @@ -368,8 +369,7 @@ public static void writeTitlesElement(XMLStreamWriter xmlw, DatasetVersionDTO da
String subtitle = dto2Primitive(datasetVersionDTO, DatasetFieldConstant.subTitle);
title_check = writeTitleElement(xmlw, "Subtitle", subtitle, title_check, language);

String alternativeTitle = dto2Primitive(datasetVersionDTO, DatasetFieldConstant.alternativeTitle);
title_check = writeTitleElement(xmlw, "AlternativeTitle", alternativeTitle, title_check, language);
title_check = writeMultipleTitleElement(xmlw, "AlternativeTitle", datasetVersionDTO, "citation", title_check, language);

writeEndTag(xmlw, title_check);
}
Expand Down Expand Up @@ -405,6 +405,30 @@ private static boolean writeTitleElement(XMLStreamWriter xmlw, String titleType,
return title_check;
}

private static boolean writeMultipleTitleElement(XMLStreamWriter xmlw, String titleType, DatasetVersionDTO datasetVersionDTO, String metadataBlockName, boolean title_check, String language) throws XMLStreamException {
MetadataBlockDTO block = datasetVersionDTO.getMetadataBlocks().get(metadataBlockName);
if (block != null) {
logger.info("Block is not empty");
List<FieldDTO> fieldsBlock = block.getFields();
if (fieldsBlock != null) {
for (FieldDTO fieldDTO : fieldsBlock) {
logger.info(titleType + " " + fieldDTO.getTypeName());
if (titleType.toLowerCase().equals(fieldDTO.getTypeName().toLowerCase())) {
logger.info("Found Alt title");
List<String> fields = fieldDTO.getMultiplePrimitive();
for (String value : fields) {
if (!writeTitleElement(xmlw, titleType, value, title_check, language))
title_check = false;
}
break;
}
}
}
}

return title_check;
}

/**
* 5, PublicationYear (M)
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
},
{
"typeName": "alternativeTitle",
"multiple": false,
"multiple": true,
"typeClass": "primitive",
"value": "Alternative Title"
"value": ["Alternative Title"]
},
{
"typeName": "alternativeURL",
Expand Down Expand Up @@ -450,9 +450,9 @@
},
{
"typeName": "productionPlace",
"multiple": false,
"multiple": true,
"typeClass": "primitive",
"value": "ProductionPlace"
"value": ["ProductionPlace"]
},
{
"typeName": "contributor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
},
{
"typeName": "alternativeTitle",
"multiple": false,
"multiple": true,
"typeClass": "primitive",
"value": "Alternative Title"
"value": ["Alternative Title"]
},
{
"typeName": "otherId",
Expand Down Expand Up @@ -409,9 +409,9 @@
},
{
"typeName": "productionPlace",
"multiple": false,
"multiple": true,
"typeClass": "primitive",
"value": "ProductionPlace"
"value": ["ProductionPlace"]
},
{
"typeName": "contributor",
Expand Down

0 comments on commit 9d81846

Please sign in to comment.