Skip to content

Commit

Permalink
Support for RIOXX v3 OAI profile
Browse files Browse the repository at this point in the history
  • Loading branch information
amgciadev committed Jan 13, 2024
1 parent 4bf7d17 commit 5c72d2f
Show file tree
Hide file tree
Showing 15 changed files with 2,810 additions and 18 deletions.
10 changes: 10 additions & 0 deletions dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,16 @@ private SolrInputDocument index(Item item)
doc.addField("item.communities", "com_" + com.getHandle().replace("/", "_"));
}

boolean hasBitstream = false;

for (Bundle b : item.getBundles("ORIGINAL")) {
if (b.getBitstreams().size() > 0) {
hasBitstream = true;
}
}

doc.addField("item.hasbitstream", hasBitstream);

List<MetadataValue> allData = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
for (MetadataValue dc : allData) {
MetadataField field = dc.getMetadataField();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.xoai.filter;

import java.sql.SQLException;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.dspace.content.Bundle;
import org.dspace.content.Item;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.xoai.data.DSpaceItem;
import org.dspace.xoai.filter.results.SolrFilterResult;


/**
* Created by Philip Vissenaekens (philip at atmire dot com)
* Date: 21/04/15
* Time: 15:18
*/
public class ItemsWithBitstreamFilter extends DSpaceFilter {

private static Logger log = LogManager.getLogger(ItemsWithBitstreamFilter.class);

private static final HandleService handleService
= HandleServiceFactory.getInstance().getHandleService();

@Override
public SolrFilterResult buildSolrQuery() {
return new SolrFilterResult("item.hasbitstream:true");
}

@Override
public boolean isShown(DSpaceItem item) {
try {
String handle = DSpaceItem.parseHandle(item.getIdentifier());
if (handle == null) {
return false;
}
Item dspaceItem = (Item) handleService.resolveToObject(context, handle);
for (Bundle b : dspaceItem.getBundles("ORIGINAL")) {
if (b.getBitstreams().size() > 0) {
return true;
}
}
} catch (SQLException e) {
log.error(e.getMessage(), e);
}
return false;
}
}
78 changes: 63 additions & 15 deletions dspace-oai/src/main/java/org/dspace/xoai/util/ItemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.lyncode.xoai.dataprovider.xml.xoai.Element;
Expand All @@ -21,6 +23,7 @@
import org.dspace.app.util.factory.UtilServiceFactory;
import org.dspace.app.util.service.MetadataExposureService;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.ResourcePolicy;
import org.dspace.authorize.factory.AuthorizeServiceFactory;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.content.Bitstream;
Expand Down Expand Up @@ -114,23 +117,21 @@ private static Element createBundlesElement(Context context, Item item) throws S
log.error("Null bitstream found, check item uuid: " + item.getID());
break;
}
boolean primary = false;
// Check if current bitstream is in original bundle + 1 of the 2 following
// Bitstream = primary bitstream in bundle -> true
// No primary bitstream found in bundle-> only the first one gets flagged as "primary"
if (b.getName() != null && b.getName().equals("ORIGINAL") && (b.getPrimaryBitstream() != null
&& b.getPrimaryBitstream().getID() == bit.getID()
|| b.getPrimaryBitstream() == null && bit.getID() == bits.get(0).getID())) {
primary = true;
}

Element bitstream = create("bitstream");
bitstreams.getElement().add(bitstream);
String url = "";
String bsName = bit.getName();
String sid = String.valueOf(bit.getSequenceID());

String baseUrl = configurationService.getProperty("oai.bitstream.baseUrl");
String handle = null;
// get handle of parent Item of this bitstream, if there
// is one:
List<Bundle> bn = bit.getBundles();
if (!bn.isEmpty()) {
List<Item> bi = bn.get(0).getItems();
if (!bi.isEmpty()) {
handle = bi.get(0).getHandle();
}
}
url = baseUrl + "/bitstreams/" + bit.getID().toString() + "/download";
String url = baseUrl + "/bitstreams/" + bit.getID().toString() + "/download";

String cks = bit.getChecksum();
String cka = bit.getChecksumAlgorithm();
Expand All @@ -147,18 +148,65 @@ private static Element createBundlesElement(Context context, Item item) throws S
if (description != null) {
bitstream.getField().add(createValue("description", description));
}
// Add bitstream embargo information (READ policy present, for Anonymous group with a start date)
addResourcePolicyInformation(context, bit, bitstream);

bitstream.getField().add(createValue("format", bit.getFormat(context).getMIMEType()));
bitstream.getField().add(createValue("size", "" + bit.getSizeBytes()));
bitstream.getField().add(createValue("url", url));
bitstream.getField().add(createValue("checksum", cks));
bitstream.getField().add(createValue("checksumAlgorithm", cka));
bitstream.getField().add(createValue("sid", bit.getSequenceID() + ""));
// Add primary bitstream field to allow locating easily the primary bitstream information
bitstream.getField().add(createValue("primary", primary + ""));
}
}

return bundles;
}

/**
* This method will add metadata information about associated resource policies for a give bitstream.
* It will parse of relevant policies and add metadata information
* @param context
* @param bitstream the bitstream object
* @param bitstreamEl the bitstream metadata object to add resource policy information to
* @throws SQLException
*/
private static void addResourcePolicyInformation(Context context, Bitstream bitstream, Element bitstreamEl)
throws SQLException {
// Pre-filter access policies by DSO (bitstream) and Action (READ)
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, bitstream, Constants.READ);

// Create resourcePolicies container
Element resourcePolicies = create("resourcePolicies");

for (ResourcePolicy policy : policies) {
String groupName = policy.getGroup() != null ? policy.getGroup().getName() : null;
String user = policy.getEPerson() != null ? policy.getEPerson().getName() : null;
String action = Constants.actionText[policy.getAction()];
Date startDate = policy.getStartDate();
Date endDate = policy.getEndDate();

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

Element resourcePolicyEl = create("resourcePolicy");
resourcePolicyEl.getField().add(createValue("group", groupName));
resourcePolicyEl.getField().add(createValue("user", user));
resourcePolicyEl.getField().add(createValue("action", action));
if (startDate != null) {
resourcePolicyEl.getField().add(createValue("start-date", formatter.format(startDate)));
}
if (endDate != null) {
resourcePolicyEl.getField().add(createValue("end-date", formatter.format(endDate)));
}
// Add resourcePolicy to list of resourcePolicies
resourcePolicies.getElement().add(resourcePolicyEl);
}
// Add list of resource policies to the corresponding Bitstream XML Element
bitstreamEl.getElement().add(resourcePolicies);
}

private static Element createLicenseElement(Context context, Item item)
throws SQLException, AuthorizeException, IOException {
Element license = create("license");
Expand All @@ -178,7 +226,7 @@ private static Element createLicenseElement(Context context, Item item)
license.getField().add(createValue("bin", Base64Utils.encode(out.toString())));
} else {
log.info("Missing READ rights for license bitstream. Did not include license bitstream for item: "
+ item.getID() + ".");
+ item.getID() + ".");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.xoai.tests.stylesheets;

import static org.dspace.xoai.tests.support.XmlMatcherBuilder.xml;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;

import org.dspace.xoai.tests.support.XmlMatcherBuilder;
import org.junit.Test;

public class RioxxXslTest extends AbstractXSLTest {
@Test
public void rioxxCanTransformInput() throws Exception {
String result = apply("rioxx.xsl").to(resource("xoai-rioxx-test.xml"));

assertThat(result, is(rioxx().withXPath("//dc:title", equalTo("The Intercorrelation Between " +
"Executive Function, Physics Problem Solving, Mathematical, and Matrix Reasoning Skills: " +
"Reflections from a Small-Scale Experiment"))));
}

private XmlMatcherBuilder rioxx() {
return xml()
.withNamespace("rioxx", "http://www.rioxx.net/schema/v3.0/rioxx/")
.withNamespace("rioxxterms", "http://docs.rioxx.net/schema/v3.0/rioxxterms/")
.withNamespace("dcterms", "http://purl.org/dc/terms/")
.withNamespace("dc", "http://purl.org/dc/elements/1.1/");
}
}
89 changes: 89 additions & 0 deletions dspace-oai/src/test/resources/rioxx-test-invalid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version='1.0' encoding='UTF-8'?><!--
The contents of this file are subject to the license and copyright
detailed in the LICENSE and NOTICE files at the root of the source
tree and available online at
http://www.dspace.org/license/
-->
<rioxx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.rioxx.net/schema/v3.0/rioxx/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:rioxxterms="http://docs.rioxx.net/schema/v3.0/rioxxterms/">
<dc:description>Data on Secchi disc depth (the depth at which a standard white disc lowered into the water just becomes invisible to a surface observer) show that water clarity in the North Sea declined during the 20th century, with likely consequences for marine primary production. However, the causes of this trend remain unknown. Here we analyse the hypothesis that changes in the North Sea's wave climate were largely responsible by causing an increase in the concentrations of suspended particulate matter (SPM) in the water column through the resuspension of seabed sediments. First, we analysed the broad-scale statistical relationships between SPM and bed shear stress due to waves and tides. We used hindcasts of wave and current data to construct a space–time dataset of bed shear stress between 1997 and 2017 across the northwest European Continental Shelf and compared the results with satellite-derived SPM concentrations. Bed shear stress was found to drive most of the inter-annual variation in SPM in the hydrographically mixed waters of the central and southern North Sea. We then used a long-term wave reanalysis to construct a time series of bed shear stress from 1900 to 2010. This shows that bed shear stress increased significantly across much of the shelf during this period, with increases of over 20 % in the southeastern North Sea. An increase in bed shear stress of this magnitude would have resulted in a large reduction in water clarity. Wave-driven processes are rarely included in projections of climate change impacts on marine ecosystems, but our analysis indicates that this should be reconsidered for shelf sea regions.</dc:description>

<dc:language>en</dc:language>

<rioxxterms:publisher>
<rioxxterms:name>European Geosciences Union</rioxxterms:name>
<rioxxterms:id>https://isni.org/isni/0000000110927289</rioxxterms:id>
</rioxxterms:publisher>

<dc:source>1812-0792</dc:source>

<dc:title>Increasing turbidity in the North Sea during the 20th century due to changing wave climate</dc:title>

<dcterms:dateAccepted>2019-10-02</dcterms:dateAccepted>

<rioxxterms:creator
first-named-author="true">
<rioxxterms:name>Wilson, Robert J.</rioxxterms:name>
<rioxxterms:id>https://orcid.org/0000-0002-0592-366X</rioxxterms:id>
</rioxxterms:creator>

<rioxxterms:creator>
<rioxxterms:name>Heath, Michael R.</rioxxterms:name>
<rioxxterms:id>https://orcid.org/0000-0001-6602-3107</rioxxterms:id>
<rioxxterms:id> https://viaf.org/viaf/15147423189944882613</rioxxterms:id>
</rioxxterms:creator>

<rioxxterms:publication_date>2019-12-09</rioxxterms:publication_date>

<rioxxterms:record_public_release_date>2019-10-15</rioxxterms:record_public_release_date>

<dc:type>https://purl.org/coar/resource_type/c_2df8fbb1</dc:type>

<rioxxterms:grant
funder_name="Australian Research Council"
funder_id="https://ror.org/05mmh0f86">
DP190101507
</rioxxterms:grant>

<rioxxterms:grant
funder_name="John Templeton Foundation"
funder_id="https://ror.org/035tnyy05">
61387
</rioxxterms:grant>

<dc:relation
rel="item"
type="application/pdf"
coar_type="https://purl.org/coar/resource_type/c_6501"
coar_version="https://purl.org/coar/version/c_ab4af688f83e57aa"
deposit_date="2019-12-11"
resource_exposed_date="2019-12-11"
access_rights_="https://purl.org/coar/access_right/c_abf2"
license_ref="https://creativecommons.org/licenses/by-nc-nd/4.0/">
https://strathprints.strath.ac.uk/70117/7/Wilson_Heath_OS2019_Increasing_turbidity_in_the_North_Sea_during_the_20th_century.pdf
</dc:relation>

<!-- Other expressions (or 'instances') - publisher version -->
<rioxxterms:ext_relation
rel="cite-as"
coar_type="https://purl.org/coar/resource_type/c_6501"
coar_version="https://purl.org/coar/version/c_970fb48d4fbd8a85">
https://doi.org/10.1007/s11229-020-02724-x
</rioxxterms:ext_relation>

<!-- related dataset -->
<rioxxterms:ext_relation
rel="cite-as"
coar_type="https://purl.org/coar/resource_type/c_ddb1">
https://doi.org/10.15129/5d28213e-8f9f-402a-b550-fc588518cb8b
</rioxxterms:ext_relation >

<!-- related software -->
<rioxxterms:ext_relation
rel="cite-as"
coar_type="https://purl.org/coar/resource_type/QH80-2R4E">
https://doi.org/10.5281/zenodo.3478185
</rioxxterms:ext_relation>
</rioxx>
Loading

0 comments on commit 5c72d2f

Please sign in to comment.