use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.
the class EmbeddedServerIT method connectEmbeddedMode.
@Test
public void connectEmbeddedMode() throws Exception {
settings.setNodeConnectionMode(ElasticsearchSettingsKeys.CONNECTION_MODE_EMBEDDED_SERVER);
adminHandler.init();
Map<String, Object> data = new HashMap<>();
data.put("test", "test-string");
IndexResponse idx = dataHandler.persist(data);
Thread.sleep(2000);
String ret = dataHandler.getClient().prepareGet(idx.getIndex(), idx.getType(), idx.getId()).get().getSourceAsString();
Assert.assertNotNull(ret);
adminHandler.destroy();
try {
FileUtils.deleteDirectory(new File("./elasticsearch"));
} catch (IOException e) {
logger.info(e.getMessage(), e);
}
}
use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.
the class UVFEncoder method encodeToUvf.
private File encodeToUvf(ObservationStream observationStream, File tempDir, MediaType contentType) throws IOException, EncodingException {
List<OmObservation> mergeObservations = mergeTotoList(observationStream);
String ending = getLineEnding(contentType);
String filename = getFilename(mergeObservations);
File uvfFile = new File(tempDir, filename);
try (Writer fw = new OutputStreamWriter(new FileOutputStream(uvfFile), "UTF-8")) {
for (OmObservation o : mergeObservations) {
if (o.isSetValue() && !checkForSingleObservationValue(o.getValue()) && !checkForMultiObservationValue(o.getValue())) {
String errorMessage = String.format("The resulting values are not of numeric type " + "which is only supported by this encoder '%s'.", this.getClass().getName());
LOGGER.error(errorMessage);
throw new EncodingException(errorMessage);
}
/*
* HEADER: Metadata
*/
writeFunktionInterpretation(fw, o, ending);
writeIndex(fw, ending);
writeMessGroesse(fw, o, ending);
writeMessEinheit(fw, o, ending);
writeMessStellennummer(fw, o, ending);
writeMessStellenname(fw, o, ending);
/*
* HEADER: Lines 1 - 4
*/
writeLine1(fw, ending);
TimePeriod temporalBBox = getTemporalBBoxFromObservations(mergeObservations);
writeLine2(fw, o, temporalBBox, ending);
writeLine3(fw, o, ending);
writeLine4(fw, temporalBBox, ending);
/*
* Observation Data
*/
writeObservationValue(fw, o, ending);
}
}
return uvfFile;
}
use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.
the class SensorMLDecoderV20 method parseDataInterfaceType.
protected SmlDataInterface parseDataInterfaceType(DataInterfaceType xbDataInterface) throws DecodingException {
SmlDataInterface dataInterface = new SmlDataInterface();
// TODO implement- no funding at the moment available
// When starting implementation: Do not forget to activate the already
// available unit tests
Object data = decodeXmlElement(xbDataInterface.getData());
if (data instanceof SweDataStream) {
dataInterface.setData((SweDataStream) data);
}
if (xbDataInterface.isSetInterfaceParameters()) {
Object parameter = decodeXmlElement(xbDataInterface.getInterfaceParameters());
if (parameter instanceof SweDataRecord) {
dataInterface.setInputParameters((SweDataRecord) parameter);
}
// TODO throw exception if not instance of SweDataRecord
}
return dataInterface;
}
use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseCapabilities.
/**
* Parses the capabilities, processing and removing special insertion metadata
*
* @param abstractProcess The AbstractProcess to which capabilities and insertion metadata are added
* @param capabilitiesArray XML capabilities
*
* @throws DecodingException if an error occurs
*/
private void parseCapabilities(final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws DecodingException {
for (final Capabilities xbcaps : capabilitiesArray) {
final SmlCapabilities caps = new SmlCapabilities();
if (xbcaps.isSetName()) {
caps.setName(xbcaps.getName());
}
if (xbcaps.isSetAbstractDataRecord()) {
final Object o = decodeXmlElement(xbcaps.getAbstractDataRecord());
if (o instanceof DataRecord) {
final DataRecord record = (DataRecord) o;
caps.setDataRecord(record).setName(xbcaps.getName());
} else {
throw new DecodingException(XmlHelper.getLocalName(xbcaps), "Error while parsing the capabilities of the SensorML (the " + "capabilities data record is not of type DataRecordPropertyType)!");
}
} else if (xbcaps.isSetHref()) {
caps.setHref(xbcaps.getHref());
if (xbcaps.isSetTitle()) {
caps.setTitle(xbcaps.getTitle());
}
}
if (caps.isSetName()) {
abstractProcess.addCapabilities(caps);
}
}
}
use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.
the class SpecimenEncoderv20 method createSpecimen.
private XmlObject createSpecimen(SfSpecimen specimen) throws EncodingException {
SFSpecimenDocument sfsd = SFSpecimenDocument.Factory.newInstance(getXmlOptions());
if (specimen.isSetXml()) {
try {
final XmlObject feature = XmlObject.Factory.parse(specimen.getXml(), getXmlOptions());
XmlHelper.updateGmlIDs(feature.getDomNode().getFirstChild(), specimen.getGmlId(), null);
if (XmlHelper.getNamespace(feature).equals(SfConstants.NS_SPEC) && feature instanceof SFSpecimenType) {
sfsd.setSFSpecimen((SFSpecimenType) feature);
addName(sfsd.getSFSpecimen(), specimen);
addDescription(sfsd.getSFSpecimen(), specimen);
return sfsd;
}
addName(((SFSpecimenDocument) feature).getSFSpecimen(), specimen);
addDescription(((SFSpecimenDocument) feature).getSFSpecimen(), specimen);
return feature;
} catch (final XmlException xmle) {
throw new EncodingException("Error while encoding GetFeatureOfInterest response, invalid specimen description!", xmle);
}
}
final SFSpecimenType sfst = sfsd.addNewSFSpecimen();
// TODO: CHECK for all fields set gml:id
addId(sfst, specimen);
addIdentifier(sfst, specimen);
// set type
addFeatureType(sfst, specimen);
addName(sfst, specimen);
addDescription(sfst, specimen);
// set sampledFeatures
addSampledFeatures(sfst, specimen);
addParameter(sfst, specimen);
// set specimen specific data
addMaterialClass(sfst, specimen);
addSamplingTime(sfst, specimen);
addSamplingMethod(sfst, specimen);
addSamplingLocation(sfst, specimen);
addProcessingDetails(sfst, specimen);
addSize(sfst, specimen);
addCurrentLocation(sfst, specimen);
addSpecimenType(sfst, specimen);
specimen.wasEncoded();
return sfsd;
}
Aggregations