|
From: <chr...@us...> - 2018-11-21 04:55:14
|
Revision: 200
http://sourceforge.net/p/andspidclient/code/200
Author: chris-trapani
Date: 2018-11-21 04:42:41 +0000 (Wed, 21 Nov 2018)
Log Message:
-----------
peer review.
Modified Paths:
--------------
trunk/config/NOTICE.template
trunk/src/main/java/au/csiro/doiclient/business/GeoLocation.java
trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java
trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java
Removed Paths:
-------------
trunk/config/license-mappings.xml
Modified: trunk/config/NOTICE.template
===================================================================
--- trunk/config/NOTICE.template 2018-11-19 01:26:31 UTC (rev 199)
+++ trunk/config/NOTICE.template 2018-11-21 04:42:41 UTC (rev 200)
@@ -1,5 +1,5 @@
CASDA Commons
-Copyright (c) 2014, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230.
+Copyright (c) 2018, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230.
This project includes:
#GENERATED_NOTICES#
\ No newline at end of file
Deleted: trunk/config/license-mappings.xml
===================================================================
--- trunk/config/license-mappings.xml 2018-11-19 01:26:31 UTC (rev 199)
+++ trunk/config/license-mappings.xml 2018-11-21 04:42:41 UTC (rev 200)
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<license-lookup xmlns="https://source.jasig.org/schemas/maven-notice-plugin/license-lookup" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://source.jasig.org/schemas/maven-notice-plugin/license-lookup https://source.jasig.org/schemas/maven-notice-plugin/license-lookup/license-lookup-v1.0.xsd">
- <artifact>
- <groupId>ant</groupId>
- <artifactId>ant-nodeps</artifactId>
- <version>1.6.5</version>
- <license>Apache License, Version 2.0</license>
- </artifact>
- <artifact>
- <groupId>au.csiro</groupId>
- <artifactId>atnf-ivoa-tools</artifactId>
- <version>1.0.1</version>
- <license>Apache License, Version 2.0</license>
- </artifact>
- <artifact>
- <groupId>ehcache</groupId>
- <artifactId>ehcache</artifactId>
- <version>1.1</version>
- <license>Apache License, Version 2.0</license>
- </artifact>
- <artifact>
- <groupId>imagej</groupId>
- <artifactId>ij</artifactId>
- <version>1.47d</version>
- <license>Public Domain</license>
- </artifact>
- <artifact>
- <groupId>nom.tam</groupId>
- <artifactId>fits</artifactId>
- <version>0.9.100</version>
- <license>Public Domain</license>
- </artifact>
- <artifact>
- <groupId>ojdbc6</groupId>
- <artifactId>ojdbc6</artifactId>
- <version>11.2.0.3.0</version>
- <license>Oracle Technology Network Development and Distribution License</license>
- </artifact>
- <artifact>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>3.3.1</version>
- <license>Apache License, Version 2.0</license>
- </artifact>
- <artifact>
- <groupId>org.springframework.ldap</groupId>
- <artifactId>spring-ldap-odm</artifactId>
- <version>1.3.1.RELEASE</version>
- <license>Apache License, Version 2.0</license>
- </artifact>
- <artifact>
- <groupId>tomcat</groupId>
- <artifactId>naming-resources</artifactId>
- <version>5.0.28</version>
- <license>Apache License, Version 2.0</license>
- </artifact>
-</license-lookup>
Modified: trunk/src/main/java/au/csiro/doiclient/business/GeoLocation.java
===================================================================
--- trunk/src/main/java/au/csiro/doiclient/business/GeoLocation.java 2018-11-19 01:26:31 UTC (rev 199)
+++ trunk/src/main/java/au/csiro/doiclient/business/GeoLocation.java 2018-11-21 04:42:41 UTC (rev 200)
@@ -44,13 +44,16 @@
* East
* @param w
* West
+ * @param locationType
+ * The location type
*/
- public GeoLocation(String n, String s, String e, String w)
+ public GeoLocation(String n, String s, String e, String w, LocationType locationType)
{
this.north = n;
this.east = e;
this.south = s;
this.west = w;
+ this.locationType = locationType;
}
/**
@@ -60,11 +63,14 @@
* The latitude
* @param longitude
* The longitude
+ * @param locationType
+ * The location type
*/
- public GeoLocation(String latitude, String longitude)
+ public GeoLocation(String latitude, String longitude, LocationType locationType)
{
this.latitude = latitude;
this.longitude = longitude;
+ this.locationType = locationType;
}
public LocationType getLocationType()
Modified: trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java
===================================================================
--- trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java 2018-11-19 01:26:31 UTC (rev 199)
+++ trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java 2018-11-21 04:42:41 UTC (rev 200)
@@ -145,9 +145,7 @@
{
if (CollectionUtils.isNotEmpty(relatedIdentifiers))
{
- XPath xPath = XPath.newInstance(element);
- xPath.addNamespace(nameSpace, document.getRootElement().getNamespaceURI());
- Element baseElement = (Element) xPath.selectSingleNode(document);
+ Element baseElement = getElement(document, nameSpace, element);
Element relatedIdentifiersElement = baseElement.getParentElement();
relatedIdentifiersElement.getContent().clear();
relatedIdentifiersElement.addContent(baseElement);
@@ -211,9 +209,8 @@
{
if (CollectionUtils.isNotEmpty(subjects))
{
- XPath xPath = XPath.newInstance(element);
- xPath.addNamespace(nameSpace, document.getRootElement().getNamespaceURI());
- Element baseElement = (Element) xPath.selectSingleNode(document);
+ Element baseElement = getElement(document, nameSpace, element);
+
Element relatedIdentifiersElement = baseElement.getParentElement();
relatedIdentifiersElement.getContent().clear();
relatedIdentifiersElement.addContent(baseElement);
@@ -227,7 +224,7 @@
final Subject s = subjects.get(counter);
- updateSubjectElement(baseElement, s);
+ updateSubjectElement(newNode, s);
baseElement.getParentElement().addContent(1, newNode);
}
@@ -239,6 +236,26 @@
}
}
+ /**
+ * Gets an element by name.
+ *
+ * @param document
+ * The xml document
+ * @param nameSpace
+ * The namespace the element belongs to
+ * @param element
+ * The name of the element to retrieve.
+ * @return The element if found.
+ * @throws JDOMException
+ * On error.
+ */
+ private static Element getElement(Document document, String nameSpace, String element) throws JDOMException
+ {
+ XPath xPath = XPath.newInstance(element);
+ xPath.addNamespace(nameSpace, document.getRootElement().getNamespaceURI());
+ return (Element) xPath.selectSingleNode(document);
+ }
+
private static void updateSubjectElement(Element baseElement, final Subject firstNode)
{
baseElement.setText(stripNonValidXMLCharacters(firstNode.getSubject()));
@@ -283,6 +300,7 @@
XPath xPath = XPath.newInstance(element);
xPath.addNamespace(nameSpace, document.getRootElement().getNamespaceURI());
Element baseElement = (Element) xPath.selectSingleNode(document);
+
final GeoLocation firstNode = geoLocations.get(0);
Element geoLocationsElement = baseElement.getParentElement();
geoLocationsElement.getContent().clear();
@@ -390,6 +408,7 @@
XPath xPath = XPath.newInstance(element);
xPath.addNamespace(nameSpace, document.getRootElement().getNamespaceURI());
Element baseElement = (Element) xPath.selectSingleNode(document);
+
final Creator firstNode = creators.get(0);
final Element immutableclonedParentElement = (Element) baseElement.getParentElement().clone();
@@ -464,9 +483,8 @@
{
if (CollectionUtils.isNotEmpty(descriptions))
{
- XPath xPath = XPath.newInstance(element);
- xPath.addNamespace(nameSpace, document.getRootElement().getNamespaceURI());
- Element baseElement = (Element) xPath.selectSingleNode(document);
+ Element baseElement = getElement(document, nameSpace, element);
+
Element descriptionNode = baseElement.getParentElement();
descriptionNode.getContent().clear();
descriptionNode.addContent(baseElement);
@@ -586,10 +604,10 @@
public static void updateElementValues(Document document, String nameSpace, String element, List<String> values)
throws JDOMException
{
-
XPath xPath = XPath.newInstance(element);
xPath.addNamespace(nameSpace, document.getRootElement().getNamespaceURI());
Element baseElement = (Element) xPath.selectSingleNode(document);
+
baseElement.setText(stripNonValidXMLCharacters(values.get(0)));
detachExistingNodes(xPath, document);
Modified: trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java
===================================================================
--- trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java 2018-11-19 01:26:31 UTC (rev 199)
+++ trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java 2018-11-21 04:42:41 UTC (rev 200)
@@ -111,23 +111,20 @@
List<Description> descriptions = new ArrayList<>();
descriptions.add(desc);
doiDTO.setDescriptions(descriptions);
-
+
// add geo points
List<GeoLocation> geoLocations = new ArrayList<>();
- GeoLocation gl = new GeoLocation("-35.307380", "149.098210");
- gl.setLocationType(GeoLocation.LocationType.POINT);
+ GeoLocation gl = new GeoLocation("-35.307380", "149.098210", GeoLocation.LocationType.POINT);
geoLocations.add(gl);
-
- GeoLocation gl1 = new GeoLocation("-37.307380", "155.098210");
- gl1.setLocationType(GeoLocation.LocationType.POINT);
+
+ GeoLocation gl1 = new GeoLocation("-37.307380", "155.098210", GeoLocation.LocationType.POINT);
geoLocations.add(gl1);
// add geo area
- GeoLocation gl2 = new GeoLocation("-16.0", "-22.0", "145.0", "139.7");
- gl2.setLocationType(GeoLocation.LocationType.AREA);
+ GeoLocation gl2 = new GeoLocation("-16.0", "-22.0", "145.0", "139.7", GeoLocation.LocationType.AREA);
geoLocations.add(gl2);
doiDTO.setGeoLocations(geoLocations);
-
+
// subjects
List<Subject> subjects = new ArrayList<>();
Subject s = new Subject();
@@ -291,14 +288,14 @@
@SuppressWarnings("rawtypes")
List subjectNodes = subjectsXpath.selectNodes(document);
assertEquals(2, subjectNodes.size());
- assertEquals("subject1", ((Element)subjectNodes.get(0)).getText());
- assertEquals("subject", ((Element)subjectNodes.get(1)).getText());
- assertEquals("subjectScheme1", ((Element)subjectNodes.get(0)).getAttributeValue("subjectScheme"));
- assertEquals("subjectScheme", ((Element)subjectNodes.get(1)).getAttributeValue("subjectScheme"));
- assertEquals("schemeURI1", ((Element)subjectNodes.get(0)).getAttributeValue("schemeURI"));
- assertEquals("schemeURI", ((Element)subjectNodes.get(1)).getAttributeValue("schemeURI"));
- assertEquals("valueUri1", ((Element)subjectNodes.get(0)).getAttributeValue("valueURI"));
- assertEquals("valueUri", ((Element)subjectNodes.get(1)).getAttributeValue("valueURI"));
+ assertEquals("subject", ((Element)subjectNodes.get(0)).getText());
+ assertEquals("subject1", ((Element)subjectNodes.get(1)).getText());
+ assertEquals("subjectScheme", ((Element)subjectNodes.get(0)).getAttributeValue("subjectScheme"));
+ assertEquals("subjectScheme1", ((Element)subjectNodes.get(1)).getAttributeValue("subjectScheme"));
+ assertEquals("schemeURI", ((Element)subjectNodes.get(0)).getAttributeValue("schemeURI"));
+ assertEquals("schemeURI1", ((Element)subjectNodes.get(1)).getAttributeValue("schemeURI"));
+ assertEquals("valueUri", ((Element)subjectNodes.get(0)).getAttributeValue("valueURI"));
+ assertEquals("valueUri1", ((Element)subjectNodes.get(1)).getAttributeValue("valueURI"));
}
/**
@@ -562,14 +559,14 @@
@SuppressWarnings("rawtypes")
List subjectNodes = subjectsXpath.selectNodes(document);
assertEquals(2, subjectNodes.size());
- assertEquals("updatedSubject1", ((Element)subjectNodes.get(0)).getText());
- assertEquals("updatedSubject", ((Element)subjectNodes.get(1)).getText());
- assertEquals("subjectScheme1", ((Element)subjectNodes.get(0)).getAttributeValue("subjectScheme"));
- assertEquals("subjectScheme", ((Element)subjectNodes.get(1)).getAttributeValue("subjectScheme"));
- assertEquals("schemeURI1", ((Element)subjectNodes.get(0)).getAttributeValue("schemeURI"));
- assertEquals("schemeURI", ((Element)subjectNodes.get(1)).getAttributeValue("schemeURI"));
- assertEquals("valueUri1", ((Element)subjectNodes.get(0)).getAttributeValue("valueURI"));
- assertEquals("valueUri", ((Element)subjectNodes.get(1)).getAttributeValue("valueURI"));
+ assertEquals("updatedSubject", ((Element)subjectNodes.get(0)).getText());
+ assertEquals("updatedSubject1", ((Element)subjectNodes.get(1)).getText());
+ assertEquals("subjectScheme", ((Element)subjectNodes.get(0)).getAttributeValue("subjectScheme"));
+ assertEquals("subjectScheme1", ((Element)subjectNodes.get(1)).getAttributeValue("subjectScheme"));
+ assertEquals("schemeURI", ((Element)subjectNodes.get(0)).getAttributeValue("schemeURI"));
+ assertEquals("schemeURI1", ((Element)subjectNodes.get(1)).getAttributeValue("schemeURI"));
+ assertEquals("valueUri", ((Element)subjectNodes.get(0)).getAttributeValue("valueURI"));
+ assertEquals("valueUri1", ((Element)subjectNodes.get(1)).getAttributeValue("valueURI"));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|