Skip to content

Commit

Permalink
Merge branch 'update_v6.3_code' into update_v6.3_archival_feature_plus
Browse files Browse the repository at this point in the history
  • Loading branch information
ffritze committed Sep 26, 2024
2 parents e839b84 + 94c3fba commit b18cef0
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public class DatasetFieldConstant implements java.io.Serializable {
public final static String topicClassValue="topicClassValue";
public final static String topicClassVocab="topicClassVocab";
public final static String topicClassVocabURI="topicClassVocabURI";
public final static String topicClassTermURI="topicClassTermURI";
public final static String descriptionText="dsDescriptionValue";
public final static String descriptionDate="dsDescriptionDate";
public final static String timePeriodCovered="timePeriodCovered"; // SEK added 6/13/2016
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@
import java.util.regex.Pattern;
import jakarta.mail.internet.AddressException;
import jakarta.mail.internet.InternetAddress;
import org.jsoup.Jsoup;

public class OpenAireExportUtil {

private static final Logger logger = Logger.getLogger(OpenAireExportUtil.class.getCanonicalName());

public static String XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance";
public static String SCHEMA_VERSION = "4.1";
public static String SCHEMA_VERSION = "4.5";
public static String RESOURCE_NAMESPACE = "http://datacite.org/schema/kernel-4";
public static String RESOURCE_SCHEMA_LOCATION = "http://schema.datacite.org/meta/kernel-4.1/metadata.xsd";
public static String RESOURCE_SCHEMA_LOCATION = "http://schema.datacite.org/meta/kernel-4.5/metadata.xsd";

public static String FunderType = "Funder";

Expand Down Expand Up @@ -480,6 +481,7 @@ public static void writeSubjectsElement(XMLStreamWriter xmlw, DatasetVersionDTO
String subject = null;
String subjectScheme = null;
String schemeURI = null;
String valueURI = null;

for (Iterator<FieldDTO> iterator = fieldDTOs.iterator(); iterator.hasNext();) {
FieldDTO next = iterator.next();
Expand All @@ -490,15 +492,19 @@ public static void writeSubjectsElement(XMLStreamWriter xmlw, DatasetVersionDTO
if (DatasetFieldConstant.topicClassVocab.equals(next.getTypeName())) {
subjectScheme = next.getSinglePrimitive();
}

if (DatasetFieldConstant.topicClassVocabURI.equals(next.getTypeName())) {
schemeURI = next.getSinglePrimitive();
}

if (DatasetFieldConstant.topicClassTermURI.equals(next.getTypeName())) {
valueURI = next.getSinglePrimitive();
}
}

if (StringUtils.isNotBlank(subject)) {
subject_check = writeOpenTag(xmlw, "subjects", subject_check);
writeSubjectElement(xmlw, subjectScheme, null, schemeURI, subject, language);
writeSubjectElement(xmlw, subjectScheme, valueURI, schemeURI, subject, language);
}
}
}
Expand Down Expand Up @@ -1139,6 +1145,8 @@ public static void writeDescriptionsElement(XMLStreamWriter xmlw, DatasetVersion
FieldDTO next = iterator.next();
if (DatasetFieldConstant.descriptionText.equals(next.getTypeName())) {
descriptionOfAbstract = next.getSinglePrimitive();
// From https://stackoverflow.com/questions/240546/remove-html-tags-from-a-string
descriptionOfAbstract = Jsoup.parse(descriptionOfAbstract).text();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import jakarta.ejb.Singleton;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import java.math.BigDecimal;
import java.util.function.Predicate;

/**
* Convert objects to Json.
Expand Down Expand Up @@ -639,9 +639,13 @@ public static JsonObjectBuilder json(MetadataBlock metadataBlock, boolean printO
jsonObjectBuilder.add("displayOnCreate", metadataBlock.isDisplayOnCreate());

JsonObjectBuilder fieldsBuilder = Json.createObjectBuilder();
Set<DatasetFieldType> datasetFieldTypes = new TreeSet<>(metadataBlock.getDatasetFieldTypes());

for (DatasetFieldType datasetFieldType : datasetFieldTypes) {

Predicate<DatasetFieldType> isNoChild = element -> element.isChild() == false;
List<DatasetFieldType> childLessList = metadataBlock.getDatasetFieldTypes().stream().filter(isNoChild).toList();
Set<DatasetFieldType> datasetFieldTypesNoChildSorted = new TreeSet<>(childLessList);

for (DatasetFieldType datasetFieldType : datasetFieldTypesNoChildSorted) {

Long datasetFieldTypeId = datasetFieldType.getId();
boolean requiredAsInputLevelInOwnerDataverse = ownerDataverse != null && ownerDataverse.isDatasetFieldTypeRequiredAsInputLevel(datasetFieldTypeId);
boolean includedAsInputLevelInOwnerDataverse = ownerDataverse != null && ownerDataverse.isDatasetFieldTypeIncludedAsInputLevel(datasetFieldTypeId);
Expand All @@ -658,7 +662,7 @@ public static JsonObjectBuilder json(MetadataBlock metadataBlock, boolean printO
fieldsBuilder.add(datasetFieldType.getName(), json(datasetFieldType, ownerDataverse));
}
}

jsonObjectBuilder.add("fields", fieldsBuilder);
return jsonObjectBuilder;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/propertyFiles/citation.properties
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ datasetfieldtype.topicClassValue.watermark=
datasetfieldtype.topicClassVocab.title=Controlled Vocabulary Name
datasetfieldtype.topicClassVocab.description=The controlled vocabulary used for the keyword term (e.g. LCSH, MeSH)
datasetfieldtype.topicClassVocab.watermark=
datasetfieldtype.topicClassVocabURI.title=Controlled Vocabulary URL
datasetfieldtype.topicClassVocabURI.description=The URL where one can access information about the term's controlled vocabulary
datasetfieldtype.topicClassVocabURI.title=Term URL
datasetfieldtype.topicClassVocabURI.description=The URL where one can access information about the term, if available. Otherwise the URL of the controlled vocabulary
datasetfieldtype.topicClassVocabURI.watermark=https://
datasetfieldtype.publication.title=Related Publication
datasetfieldtype.publication.description=The article or report that uses the data in the Dataset. The full list of related publications will be displayed on the metadata tab
Expand Down Expand Up @@ -149,7 +149,7 @@ datasetfieldtype.grantNumberAgency.title=Agency
datasetfieldtype.grantNumberAgency.description=The agency that provided financial support for the Dataset
datasetfieldtype.grantNumberAgency.watermark=Organization XYZ
datasetfieldtype.grantNumberValue.title=Identifier
datasetfieldtype.grantNumberValue.description=The grant identifier or contract identifier of the agency that provided financial support for the Dataset
datasetfieldtype.grantNumberValue.description=For DFG as agency: the grant identifier; Otherwise the grant identifier or contract identifier of the agency that provided financial support for the Dataset
datasetfieldtype.grantNumberValue.watermark=
datasetfieldtype.project.title=Project
datasetfieldtype.project.description=Information about the project as context of the data
Expand Down
21 changes: 21 additions & 0 deletions src/main/webapp/metadataFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,27 @@
$('#panelCollapse'+i).collapse('hide');
}
}
const project_url = "https://fis.uni-stuttgart.de/converis/portal/detail/Project/";
if(document.getElementById("metadata_project") !== null) {
var project_metadata = document.getElementById("metadata_project");
if(project_metadata.getElementsByTagName("td") !== null) {
var row = project_metadata.getElementsByTagName("td")[0];
if(row.getElementsByTagName("span") !== null) {
var number = row.getElementsByTagName("span").length;
if(number >= 1) {
const pattern = /[0-9]{6,}\b/gm;
var fisid = [];
if(pattern.test(row.innerText)) {
fisid = row.innerText.match(pattern);
for (let i = 0; i < number; i++) {
var project = row.getElementsByTagName("span")[i].innerText;
row.getElementsByTagName("span")[i].innerHTML = '<a href="' + project_url + fisid[i] + '" target="_blank">' +project+ '</a>';
}
}
}
}
}
}
});
//]]>
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void testGetXMLNameSpace() throws Exception {
public void testGetXMLSchemaLocation() throws Exception {
System.out.println("getXMLSchemaLocation");
OpenAireExporter instance = new OpenAireExporter();
String expResult = "http://schema.datacite.org/meta/kernel-4.1/metadata.xsd";
String expResult = "http://schema.datacite.org/meta/kernel-4.5/metadata.xsd";
String result = instance.getXMLSchemaLocation();
assertEquals(expResult, result);
}
Expand All @@ -197,7 +197,7 @@ public void testGetXMLSchemaLocation() throws Exception {
public void testGetXMLSchemaVersion() throws Exception {
System.out.println("getXMLSchemaVersion");
OpenAireExporter instance = new OpenAireExporter();
String expResult = "4.1";
String expResult = "4.5";
String result = instance.getXMLSchemaVersion();
assertEquals(expResult, result);
}
Expand Down

0 comments on commit b18cef0

Please sign in to comment.