Skip to content

Commit

Permalink
Merge pull request #157 from asascience-open/rel-1.0-bug-fixes
Browse files Browse the repository at this point in the history
Addresses issues identified in Nov. 2014 test report #156
  • Loading branch information
cheryldmorse committed Dec 3, 2014
2 parents 8f1e896 + bf19476 commit 84364a4
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 34 deletions.
Binary file added jar/ncSOS-1.1.zip
Binary file not shown.
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.asascience</groupId>
<artifactId>ncsos</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>jar</packaging>

<name>ncsos</name>
Expand Down Expand Up @@ -156,6 +156,17 @@
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/com/asascience/ncsos/ds/Ioos10Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.asascience.ncsos.service.BaseRequestHandler;
import com.asascience.ncsos.util.IFReportMechanism;

import ucar.nc2.Attribute;
import ucar.nc2.VariableSimpleIF;
import ucar.nc2.dataset.NetcdfDataset;
Expand All @@ -13,9 +14,11 @@ public class Ioos10Handler extends BaseRequestHandler {
private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Ioos10Handler.class);

protected final IFReportMechanism reporter;
protected final static String DEFAULT_STRING = "UNKNOWN";
protected final static String MISSING_VALUE = "Missing Value";
protected final static String URN_BASE = "urn:ioos:";
protected final static String ATTRIBUTE_MISSING = "Attribute not present in source data";
protected final static String ATTRIBUTE_VALUE_MISSING = "Attribute value not defined in source data";
protected final static String INSTITUTION = "institution";

public Ioos10Handler(NetcdfDataset dataset) throws IOException {
super(dataset);
reporter = null;
Expand Down Expand Up @@ -60,10 +63,10 @@ protected String checkForRequiredValue(String globalName) {
try {
if (retval == null) {
reporter.ReportMissing(globalName);
return DEFAULT_STRING;
return ATTRIBUTE_MISSING;
} else if (retval.equalsIgnoreCase("")) {
reporter.ReportInvalid(globalName, "");
return DEFAULT_STRING;
return ATTRIBUTE_VALUE_MISSING;
}
} catch (Exception ex) { }

Expand All @@ -86,7 +89,7 @@ protected String checkForRequiredValue(VariableSimpleIF var, String attribueName
reporter.ReportMissing(attribueName + " from variable " + var.getShortName());
} catch (Exception ex) { }

return DEFAULT_STRING;
return ATTRIBUTE_MISSING;
}

protected VariableSimpleIF checkForRequiredVariable(String varName) {
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/com/asascience/ncsos/ds/IoosNetwork10Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ private void formatSmlIdentification() {

private void formatSmlClassification() {
// add platformType, operatorSector and publisher classifications (assuming they are global variables
network.addSmlClassifier("platformType", VocabDefinitions.GetIoosDefinition("platformType"), "platform", this.checkForRequiredValue("platform_type"));
network.addSmlClassifier("platformType", VocabDefinitions.GetIoosDefinition("platformType"),
"platform", this.checkForRequiredValue("platform_type"));
network.addSmlClassifier("operatorSector", VocabDefinitions.GetIoosDefinition("operatorSector"), "sector", this.checkForRequiredValue("operator_sector"));
network.addSmlClassifier("publisher", VocabDefinitions.GetIoosDefinition("publisher"), "organization", this.checkForRequiredValue("publisher"));
network.addSmlClassifier("parentNetwork", "http://mmisw.org/ont/ioos/definition/parentNetwork", "organization", (String)this.getGlobalAttribute("parent_network", ""));
network.addSmlClassifier("parentNetwork", "http://mmisw.org/ont/ioos/definition/parentNetwork",
"organization", (String)this.getGlobalAttribute(INSTITUTION, ATTRIBUTE_MISSING ));

// sponsor is optional
String value = (String)this.getGlobalAttribute("sponsor", null);
Expand Down Expand Up @@ -300,9 +302,12 @@ private void formatSingleComponent() {
for (Map.Entry<Integer,String> station : this.getStationNames().entrySet()) {
network.addSmlComponent(station.getValue());
// identifiers for station
network.addIdentifierToComponent(station.getValue(), "stationID", GetIoosDef("stationID"), this.getUrnName(station.getValue()));
network.addIdentifierToComponent(station.getValue(), "shortName", GetIoosDef("shortName"), this.checkForRequiredValue(identVar, "short_name"));
network.addIdentifierToComponent(station.getValue(), "longName", GetIoosDef("longName"), this.checkForRequiredValue(identVar, "long_name"));
network.addIdentifierToComponent(station.getValue(), "stationID", GetIoosDef("stationID"),
this.getUrnName(station.getValue()));
network.addIdentifierToComponent(station.getValue(), "shortName", GetIoosDef("shortName"),
this.checkForRequiredValue(identVar, "short_name"));
network.addIdentifierToComponent(station.getValue(), "longName", GetIoosDef("longName"),
this.checkForRequiredValue(identVar, "long_name"));
// wmoid, if it exists
Attribute identAtt = identVar.findAttribute("wmo_code");
if (identAtt != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class IoosPlatform10Handler extends Ioos10Handler implements BaseDSInterf
private iStationData stationData;
private String errorString;
private boolean locationLineFlag;

private final static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(IoosPlatform10Handler.class);
private final static String QUERY = "?service=SOS&request=DescribeSensor&version=1.0.0&outputFormat=text/xml;subtype=\"sensorML/1.0.1\"&procedure=";

Expand Down Expand Up @@ -62,8 +61,9 @@ private void describePlatform() {
platform.setName(this.procedure);
this.formatSmlIdentification();
this.formatSmlClassification();
this.formatSmlNetworkProcedures();
this.formatSmlValidTime();
this.formatSmlNetworkProcedures();

this.formatSmlContacts();
this.formatSmlHistory();
this.formatSmlDocumentation();
Expand Down Expand Up @@ -156,12 +156,13 @@ private void formatSmlClassification() {
platform.addSmlClassifier("platformType", VocabDefinitions.GetIoosDefinition("platformType"), "platform", this.checkForRequiredValue("platform_type"));
platform.addSmlClassifier("operatorSector", VocabDefinitions.GetIoosDefinition("operatorSector"), "sector", this.checkForRequiredValue("operator_sector"));
platform.addSmlClassifier("publisher", VocabDefinitions.GetIoosDefinition("publisher"), "organization", this.checkForRequiredValue("publisher"));
platform.addSmlClassifier("parentNetwork", "http://mmisw.org/ont/ioos/definition/parentNetwork", "organization", (String)this.getGlobalAttribute("institution", "UNKNOWN"));
platform.addSmlClassifier("parentNetwork", "http://mmisw.org/ont/ioos/definition/parentNetwork",
"organization", (String)this.getGlobalAttribute(INSTITUTION, ATTRIBUTE_MISSING ));


String value = (String)this.getGlobalAttribute("sponsor");
if (value == null) {
value = MISSING_VALUE;
value = ATTRIBUTE_MISSING;
}
platform.addSmlClassifier("sponsor", VocabDefinitions.GetIoosDefinition("sponsor"), "organization", value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ protected Element addNewNode(Element parent, String nodeName, Namespace nodeNS)
return child;
}

protected Element addNewNode(Element parent, String nodeName, Namespace nodeNS, int childIndex) {
Element child = new Element(nodeName, nodeNS);
if(childIndex >= 0)
parent.addContent(childIndex, child);
else
parent.addContent(child);
return child;
}

protected Element addNewNode(Element parent,
String nodeName,
Namespace nodeNS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public abstract class OutputFormatter {

private HashMap<String, Namespace> namespaces;
public static final String NCSOS_VERSION = "RC9";
public static final String NCSOS_VERSION = OutputFormatter.class.getPackage().getImplementationVersion();
public static final String OBSERVATION = "Observation";
public static final String OBSERVATION_COLLECTION = "ObservationCollection";
public static final String MEMBER = "member";
Expand Down Expand Up @@ -78,7 +78,6 @@ public abstract class OutputFormatter {
public static final String FEATURE_COLLECTION = "FeatureCollection";
public static final String USE = "use";
public static final String REQUIRED = "required";

public static final String HISTORY = "history";
public static final String IDENTIFIER = "identifier";
public static final String SML_VALUE = "value";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void addSmlClassifier(String name, String definition, String codeSpace, S
*/
public void setValidTime(String timeBegin, String timeEnd) {
/*
<sml:capabilities name="observationTimeRange">
<swe:DataRecord>
<swe:field name="observationTimeRange">
Expand All @@ -143,20 +143,20 @@ public void setValidTime(String timeBegin, String timeEnd) {
</swe:field>
</swe:DataRecord>
</sml:capabilities>
*/

Element memberNode = this.getRoot().getChild(MEMBER, this.SML_NS);
if(memberNode != null) {
Element systemNode = memberNode.getChild(SYSTEM, this.SML_NS);
if(systemNode != null){
Element parentNode = systemNode.getChild(SML_CAPABILITIES, SML_NS);
parentNode.setAttribute(NAME, OBSERVATION_TIME_RANGE);
Element parent = addNewNode(parentNode, DATA_RECORD, this.SWE_NS);
setValidTime(parent, timeBegin, timeEnd);
}
}
Element systemNode = memberNode.getChild(SYSTEM, this.SML_NS);
if(systemNode != null){
Element parentNode = systemNode.getChild(SML_CAPABILITIES, SML_NS);
parentNode.setAttribute(NAME, OBSERVATION_TIME_RANGE);
Element parent = addNewNode(parentNode, DATA_RECORD, this.SWE_NS);
setValidTime(parent, timeBegin, timeEnd);
}
}
}


public void setValidTime(Element parent, String timeBegin, String timeEnd) {
parent = addNewNode(parent, FIELD, SWE_NS, NAME, OBSERVATION_TIME_RANGE);
Expand All @@ -181,13 +181,27 @@ public void addSmlCapabilitiesNetwork(String parentName, String urn) {
* </swe:SimpleDataRecord>
* </sml:capabilities>
*/
Element parent = ((parentName != null) ? XMLDomUtils.getNestedChild(this.getRoot(), parentName, SML_NS) : this.getRoot());
parent = addNewNode(parent, CAPABILITIES, SML_NS, NAME, "networkProcedures");
parent = addNewNode(parent, SIMPLEDATARECORD, SWE_NS);

Element memberNode = this.getRoot().getChild(MEMBER, this.SML_NS);
if(memberNode != null) {
Element systemNode = memberNode.getChild(SYSTEM, this.SML_NS);
if(systemNode != null){
Element prevSmlCap = systemNode.getChild(SML_CAPABILITIES, SML_NS);
int currCapIndex = systemNode.getContent().indexOf(prevSmlCap);
if(currCapIndex >= 0)
currCapIndex++;
Element parentNode = addNewNode(systemNode, SML_CAPABILITIES, SML_NS, currCapIndex);


parentNode.setAttribute( NAME, "networkProcedures");

Element field = addNewNode(parent, FIELD, SWE_NS, NAME, "network-all");
Element textNode = addNewNode(field, TEXT, SWE_NS, DEFINITION, "http://mmisw.org/ont/ioos/definition/networkID");
addNewNode(textNode, VALUE, SWE_NS, urn);
parentNode = addNewNode(parentNode, SIMPLEDATARECORD, SWE_NS);

Element field = addNewNode(parentNode, FIELD, SWE_NS, NAME, "network-all");
Element textNode = addNewNode(field, TEXT, SWE_NS, DEFINITION, "http://mmisw.org/ont/ioos/definition/networkID");
addNewNode(textNode, VALUE, SWE_NS, urn);
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void setOperationsMetadataGetObs(String threddsURI, List<String> dataVarS
for (String s : stationNames) {
allowed.addContent(new Element("Value", owsns).setText(this.handler.getUrnName(s)));
}
allowed.addContent(new Element("Value", owsns).setText(this.handler.getUrnNetworkAll()));
p.addContent(allowed);
}
}
Expand Down Expand Up @@ -170,6 +171,7 @@ public void setOperationsMetadataDescSen(String threddsURI, String[] stationName
for (String s : stationNames) {
allowed.addContent(new Element("Value", owsns).setText(this.handler.getUrnName(s)));
}
allowed.addContent(new Element("Value", owsns).setText(this.handler.getUrnNetworkAll()));
p.addContent(allowed);
}
}
Expand Down

0 comments on commit 84364a4

Please sign in to comment.