Skip to content

Commit 84364a4

Browse files
committed
Merge pull request #157 from asascience-open/rel-1.0-bug-fixes
Addresses issues identified in Nov. 2014 test report #156
2 parents 8f1e896 + bf19476 commit 84364a4

File tree

9 files changed

+78
-34
lines changed

9 files changed

+78
-34
lines changed

jar/ncSOS-1.1.zip

183 KB
Binary file not shown.

pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.asascience</groupId>
66
<artifactId>ncsos</artifactId>
7-
<version>1.0</version>
7+
<version>1.1</version>
88
<packaging>jar</packaging>
99

1010
<name>ncsos</name>
@@ -156,6 +156,17 @@
156156
</resources>
157157

158158
<plugins>
159+
<plugin>
160+
<groupId>org.apache.maven.plugins</groupId>
161+
<artifactId>maven-jar-plugin</artifactId>
162+
<configuration>
163+
<archive>
164+
<manifest>
165+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
166+
</manifest>
167+
</archive>
168+
</configuration>
169+
</plugin>
159170
<plugin>
160171
<groupId>org.apache.maven.plugins</groupId>
161172
<artifactId>maven-compiler-plugin</artifactId>

src/main/java/com/asascience/ncsos/ds/Ioos10Handler.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.asascience.ncsos.service.BaseRequestHandler;
44
import com.asascience.ncsos.util.IFReportMechanism;
5+
56
import ucar.nc2.Attribute;
67
import ucar.nc2.VariableSimpleIF;
78
import ucar.nc2.dataset.NetcdfDataset;
@@ -13,9 +14,11 @@ public class Ioos10Handler extends BaseRequestHandler {
1314
private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Ioos10Handler.class);
1415

1516
protected final IFReportMechanism reporter;
16-
protected final static String DEFAULT_STRING = "UNKNOWN";
17-
protected final static String MISSING_VALUE = "Missing Value";
1817
protected final static String URN_BASE = "urn:ioos:";
18+
protected final static String ATTRIBUTE_MISSING = "Attribute not present in source data";
19+
protected final static String ATTRIBUTE_VALUE_MISSING = "Attribute value not defined in source data";
20+
protected final static String INSTITUTION = "institution";
21+
1922
public Ioos10Handler(NetcdfDataset dataset) throws IOException {
2023
super(dataset);
2124
reporter = null;
@@ -60,10 +63,10 @@ protected String checkForRequiredValue(String globalName) {
6063
try {
6164
if (retval == null) {
6265
reporter.ReportMissing(globalName);
63-
return DEFAULT_STRING;
66+
return ATTRIBUTE_MISSING;
6467
} else if (retval.equalsIgnoreCase("")) {
6568
reporter.ReportInvalid(globalName, "");
66-
return DEFAULT_STRING;
69+
return ATTRIBUTE_VALUE_MISSING;
6770
}
6871
} catch (Exception ex) { }
6972

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

89-
return DEFAULT_STRING;
92+
return ATTRIBUTE_MISSING;
9093
}
9194

9295
protected VariableSimpleIF checkForRequiredVariable(String varName) {

src/main/java/com/asascience/ncsos/ds/IoosNetwork10Handler.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ private void formatSmlIdentification() {
8383

8484
private void formatSmlClassification() {
8585
// add platformType, operatorSector and publisher classifications (assuming they are global variables
86-
network.addSmlClassifier("platformType", VocabDefinitions.GetIoosDefinition("platformType"), "platform", this.checkForRequiredValue("platform_type"));
86+
network.addSmlClassifier("platformType", VocabDefinitions.GetIoosDefinition("platformType"),
87+
"platform", this.checkForRequiredValue("platform_type"));
8788
network.addSmlClassifier("operatorSector", VocabDefinitions.GetIoosDefinition("operatorSector"), "sector", this.checkForRequiredValue("operator_sector"));
8889
network.addSmlClassifier("publisher", VocabDefinitions.GetIoosDefinition("publisher"), "organization", this.checkForRequiredValue("publisher"));
89-
network.addSmlClassifier("parentNetwork", "http://mmisw.org/ont/ioos/definition/parentNetwork", "organization", (String)this.getGlobalAttribute("parent_network", ""));
90+
network.addSmlClassifier("parentNetwork", "http://mmisw.org/ont/ioos/definition/parentNetwork",
91+
"organization", (String)this.getGlobalAttribute(INSTITUTION, ATTRIBUTE_MISSING ));
9092

9193
// sponsor is optional
9294
String value = (String)this.getGlobalAttribute("sponsor", null);
@@ -300,9 +302,12 @@ private void formatSingleComponent() {
300302
for (Map.Entry<Integer,String> station : this.getStationNames().entrySet()) {
301303
network.addSmlComponent(station.getValue());
302304
// identifiers for station
303-
network.addIdentifierToComponent(station.getValue(), "stationID", GetIoosDef("stationID"), this.getUrnName(station.getValue()));
304-
network.addIdentifierToComponent(station.getValue(), "shortName", GetIoosDef("shortName"), this.checkForRequiredValue(identVar, "short_name"));
305-
network.addIdentifierToComponent(station.getValue(), "longName", GetIoosDef("longName"), this.checkForRequiredValue(identVar, "long_name"));
305+
network.addIdentifierToComponent(station.getValue(), "stationID", GetIoosDef("stationID"),
306+
this.getUrnName(station.getValue()));
307+
network.addIdentifierToComponent(station.getValue(), "shortName", GetIoosDef("shortName"),
308+
this.checkForRequiredValue(identVar, "short_name"));
309+
network.addIdentifierToComponent(station.getValue(), "longName", GetIoosDef("longName"),
310+
this.checkForRequiredValue(identVar, "long_name"));
306311
// wmoid, if it exists
307312
Attribute identAtt = identVar.findAttribute("wmo_code");
308313
if (identAtt != null) {

src/main/java/com/asascience/ncsos/ds/IoosPlatform10Handler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public class IoosPlatform10Handler extends Ioos10Handler implements BaseDSInterf
2626
private iStationData stationData;
2727
private String errorString;
2828
private boolean locationLineFlag;
29-
3029
private final static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(IoosPlatform10Handler.class);
3130
private final static String QUERY = "?service=SOS&request=DescribeSensor&version=1.0.0&outputFormat=text/xml;subtype=\"sensorML/1.0.1\"&procedure=";
3231

@@ -62,8 +61,9 @@ private void describePlatform() {
6261
platform.setName(this.procedure);
6362
this.formatSmlIdentification();
6463
this.formatSmlClassification();
65-
this.formatSmlNetworkProcedures();
6664
this.formatSmlValidTime();
65+
this.formatSmlNetworkProcedures();
66+
6767
this.formatSmlContacts();
6868
this.formatSmlHistory();
6969
this.formatSmlDocumentation();
@@ -156,12 +156,13 @@ private void formatSmlClassification() {
156156
platform.addSmlClassifier("platformType", VocabDefinitions.GetIoosDefinition("platformType"), "platform", this.checkForRequiredValue("platform_type"));
157157
platform.addSmlClassifier("operatorSector", VocabDefinitions.GetIoosDefinition("operatorSector"), "sector", this.checkForRequiredValue("operator_sector"));
158158
platform.addSmlClassifier("publisher", VocabDefinitions.GetIoosDefinition("publisher"), "organization", this.checkForRequiredValue("publisher"));
159-
platform.addSmlClassifier("parentNetwork", "http://mmisw.org/ont/ioos/definition/parentNetwork", "organization", (String)this.getGlobalAttribute("institution", "UNKNOWN"));
159+
platform.addSmlClassifier("parentNetwork", "http://mmisw.org/ont/ioos/definition/parentNetwork",
160+
"organization", (String)this.getGlobalAttribute(INSTITUTION, ATTRIBUTE_MISSING ));
160161

161162

162163
String value = (String)this.getGlobalAttribute("sponsor");
163164
if (value == null) {
164-
value = MISSING_VALUE;
165+
value = ATTRIBUTE_MISSING;
165166
}
166167
platform.addSmlClassifier("sponsor", VocabDefinitions.GetIoosDefinition("sponsor"), "organization", value);
167168

src/main/java/com/asascience/ncsos/outputformatter/BaseOutputFormatter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ protected Element addNewNode(Element parent, String nodeName, Namespace nodeNS)
7878
return child;
7979
}
8080

81+
protected Element addNewNode(Element parent, String nodeName, Namespace nodeNS, int childIndex) {
82+
Element child = new Element(nodeName, nodeNS);
83+
if(childIndex >= 0)
84+
parent.addContent(childIndex, child);
85+
else
86+
parent.addContent(child);
87+
return child;
88+
}
89+
8190
protected Element addNewNode(Element parent,
8291
String nodeName,
8392
Namespace nodeNS,

src/main/java/com/asascience/ncsos/outputformatter/OutputFormatter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public abstract class OutputFormatter {
1919

2020
private HashMap<String, Namespace> namespaces;
21-
public static final String NCSOS_VERSION = "RC9";
21+
public static final String NCSOS_VERSION = OutputFormatter.class.getPackage().getImplementationVersion();
2222
public static final String OBSERVATION = "Observation";
2323
public static final String OBSERVATION_COLLECTION = "ObservationCollection";
2424
public static final String MEMBER = "member";
@@ -78,7 +78,6 @@ public abstract class OutputFormatter {
7878
public static final String FEATURE_COLLECTION = "FeatureCollection";
7979
public static final String USE = "use";
8080
public static final String REQUIRED = "required";
81-
8281
public static final String HISTORY = "history";
8382
public static final String IDENTIFIER = "identifier";
8483
public static final String SML_VALUE = "value";

src/main/java/com/asascience/ncsos/outputformatter/ds/IoosPlatform10Formatter.java

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void addSmlClassifier(String name, String definition, String codeSpace, S
133133
*/
134134
public void setValidTime(String timeBegin, String timeEnd) {
135135
/*
136-
136+
137137
<sml:capabilities name="observationTimeRange">
138138
<swe:DataRecord>
139139
<swe:field name="observationTimeRange">
@@ -143,20 +143,20 @@ public void setValidTime(String timeBegin, String timeEnd) {
143143
</swe:field>
144144
</swe:DataRecord>
145145
</sml:capabilities>
146-
146+
147147
*/
148+
148149
Element memberNode = this.getRoot().getChild(MEMBER, this.SML_NS);
149150
if(memberNode != null) {
150-
Element systemNode = memberNode.getChild(SYSTEM, this.SML_NS);
151-
if(systemNode != null){
152-
Element parentNode = systemNode.getChild(SML_CAPABILITIES, SML_NS);
153-
parentNode.setAttribute(NAME, OBSERVATION_TIME_RANGE);
154-
Element parent = addNewNode(parentNode, DATA_RECORD, this.SWE_NS);
155-
setValidTime(parent, timeBegin, timeEnd);
156-
}
157-
}
151+
Element systemNode = memberNode.getChild(SYSTEM, this.SML_NS);
152+
if(systemNode != null){
153+
Element parentNode = systemNode.getChild(SML_CAPABILITIES, SML_NS);
154+
parentNode.setAttribute(NAME, OBSERVATION_TIME_RANGE);
155+
Element parent = addNewNode(parentNode, DATA_RECORD, this.SWE_NS);
156+
setValidTime(parent, timeBegin, timeEnd);
157+
}
158+
}
158159
}
159-
160160

161161
public void setValidTime(Element parent, String timeBegin, String timeEnd) {
162162
parent = addNewNode(parent, FIELD, SWE_NS, NAME, OBSERVATION_TIME_RANGE);
@@ -181,13 +181,27 @@ public void addSmlCapabilitiesNetwork(String parentName, String urn) {
181181
* </swe:SimpleDataRecord>
182182
* </sml:capabilities>
183183
*/
184-
Element parent = ((parentName != null) ? XMLDomUtils.getNestedChild(this.getRoot(), parentName, SML_NS) : this.getRoot());
185-
parent = addNewNode(parent, CAPABILITIES, SML_NS, NAME, "networkProcedures");
186-
parent = addNewNode(parent, SIMPLEDATARECORD, SWE_NS);
184+
185+
Element memberNode = this.getRoot().getChild(MEMBER, this.SML_NS);
186+
if(memberNode != null) {
187+
Element systemNode = memberNode.getChild(SYSTEM, this.SML_NS);
188+
if(systemNode != null){
189+
Element prevSmlCap = systemNode.getChild(SML_CAPABILITIES, SML_NS);
190+
int currCapIndex = systemNode.getContent().indexOf(prevSmlCap);
191+
if(currCapIndex >= 0)
192+
currCapIndex++;
193+
Element parentNode = addNewNode(systemNode, SML_CAPABILITIES, SML_NS, currCapIndex);
194+
195+
196+
parentNode.setAttribute( NAME, "networkProcedures");
187197

188-
Element field = addNewNode(parent, FIELD, SWE_NS, NAME, "network-all");
189-
Element textNode = addNewNode(field, TEXT, SWE_NS, DEFINITION, "http://mmisw.org/ont/ioos/definition/networkID");
190-
addNewNode(textNode, VALUE, SWE_NS, urn);
198+
parentNode = addNewNode(parentNode, SIMPLEDATARECORD, SWE_NS);
199+
200+
Element field = addNewNode(parentNode, FIELD, SWE_NS, NAME, "network-all");
201+
Element textNode = addNewNode(field, TEXT, SWE_NS, DEFINITION, "http://mmisw.org/ont/ioos/definition/networkID");
202+
addNewNode(textNode, VALUE, SWE_NS, urn);
203+
}
204+
}
191205
}
192206

193207
/**

src/main/java/com/asascience/ncsos/outputformatter/gc/GetCapsFormatter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public void setOperationsMetadataGetObs(String threddsURI, List<String> dataVarS
128128
for (String s : stationNames) {
129129
allowed.addContent(new Element("Value", owsns).setText(this.handler.getUrnName(s)));
130130
}
131+
allowed.addContent(new Element("Value", owsns).setText(this.handler.getUrnNetworkAll()));
131132
p.addContent(allowed);
132133
}
133134
}
@@ -170,6 +171,7 @@ public void setOperationsMetadataDescSen(String threddsURI, String[] stationName
170171
for (String s : stationNames) {
171172
allowed.addContent(new Element("Value", owsns).setText(this.handler.getUrnName(s)));
172173
}
174+
allowed.addContent(new Element("Value", owsns).setText(this.handler.getUrnNetworkAll()));
173175
p.addContent(allowed);
174176
}
175177
}

0 commit comments

Comments
 (0)