Skip to content

Commit

Permalink
Fix dspace-swordv2 module per new code style
Browse files Browse the repository at this point in the history
  • Loading branch information
tdonohue committed Feb 13, 2018
1 parent fdbfa24 commit 8110062
Show file tree
Hide file tree
Showing 49 changed files with 2,647 additions and 4,028 deletions.
3 changes: 2 additions & 1 deletion dspace-swordv2/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.dspace</groupId>
<artifactId>dspace-swordv2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,48 @@

package org.dspace.sword2;

import java.util.HashMap;
import java.util.List;
import java.util.Properties;

import org.dspace.content.Item;
import org.dspace.content.MetadataField;
import org.dspace.content.MetadataValue;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;

import java.util.HashMap;
import java.util.List;
import java.util.Properties;

public class AbstractSimpleDC
{
public class AbstractSimpleDC {
protected HashMap<String, String> dcMap = null;

protected HashMap<String, String> atomMap = null;

protected ItemService itemService = ContentServiceFactory.getInstance()
.getItemService();
.getItemService();

protected void loadMetadataMaps()
{
if (this.dcMap == null)
{
protected void loadMetadataMaps() {
if (this.dcMap == null) {
// we should load our DC map from configuration
this.dcMap = new HashMap<>();
Properties props = ConfigurationManager
.getProperties("swordv2-server");
for (Object key : props.keySet())
{
.getProperties("swordv2-server");
for (Object key : props.keySet()) {
String keyString = (String) key;
if (keyString.startsWith("simpledc."))
{
if (keyString.startsWith("simpledc.")) {
String k = keyString.substring("simpledc.".length());
String v = (String) props.get(key);
this.dcMap.put(k, v);
}
}
}

if (this.atomMap == null)
{
if (this.atomMap == null) {
this.atomMap = new HashMap<>();
Properties props = ConfigurationManager
.getProperties("swordv2-server");
for (Object key : props.keySet())
{
.getProperties("swordv2-server");
for (Object key : props.keySet()) {
String keyString = (String) key;
if (keyString.startsWith("atom."))
{
if (keyString.startsWith("atom.")) {
String k = keyString.substring("atom.".length());
String v = (String) props.get(key);
this.atomMap.put(k, v);
Expand All @@ -66,40 +58,33 @@ protected void loadMetadataMaps()
}
}

protected SimpleDCMetadata getMetadata(Item item)
{
protected SimpleDCMetadata getMetadata(Item item) {
this.loadMetadataMaps();

SimpleDCMetadata md = new SimpleDCMetadata();
List<MetadataValue> all = itemService
.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);

for (MetadataValue dcv : all)
{
for (MetadataValue dcv : all) {
MetadataField field = dcv.getMetadataField();
String valueMatch = field.getMetadataSchema().getName() + "." +
field.getElement();
if (field.getQualifier() != null)
{
field.getElement();
if (field.getQualifier() != null) {
valueMatch += "." + field.getQualifier();
}

// look for the metadata in the dublin core map
for (String key : this.dcMap.keySet())
{
for (String key : this.dcMap.keySet()) {
String value = this.dcMap.get(key);
if (valueMatch.equals(value))
{
if (valueMatch.equals(value)) {
md.addDublinCore(key, dcv.getValue());
}
}

// look for the metadata in the atom map
for (String key : this.atomMap.keySet())
{
for (String key : this.atomMap.keySet()) {
String value = this.atomMap.get(key);
if (valueMatch.equals(value))
{
if (valueMatch.equals(value)) {
md.addAtom(key, dcv.getValue());
}
}
Expand Down
Loading

0 comments on commit 8110062

Please sign in to comment.