use of org.n52.shetland.ogc.om.series.wml.Metadata in project series-rest-api by 52North.
the class PreRenderingJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
if (interrupted) {
return;
}
LOGGER.info("Start prerendering task");
final Stopwatch stopwatch = Stopwatch.startStopwatch();
final JobDetail details = context.getJobDetail();
JobDataMap jobDataMap = details.getJobDataMap();
taskConfigPrerendering = readJobConfig(jobDataMap.getString(JOB_DATA_CONFIG_FILE));
webappFolder = jobDataMap.getString(JOB_DATA_WEBAPP_FOLDER);
List<RenderingConfig> phenomenonStyles = taskConfigPrerendering.getPhenomenonStyles();
List<RenderingConfig> styles = taskConfigPrerendering.getSeriesStyles();
for (RenderingConfig config : phenomenonStyles) {
Map<String, String> parameters = new HashMap<>();
parameters.put("phenomenon", config.getId());
IoParameters query = QueryParameters.createFromQuery(parameters);
for (DatasetOutput<?, ?> metadata : datasetService.getCondensedParameters(query)) {
String timeseriesId = metadata.getId();
renderConfiguredIntervals(timeseriesId, config);
if (interrupted) {
return;
}
}
}
for (RenderingConfig config : styles) {
renderConfiguredIntervals(config.getId(), config);
if (interrupted) {
return;
}
}
LOGGER.debug("prerendering took '{}'", stopwatch.stopInSeconds());
}
use of org.n52.shetland.ogc.om.series.wml.Metadata in project series-rest-api by 52North.
the class PreRenderingJob method renderWithStyle.
private void renderWithStyle(String datasetId, RenderingConfig renderingConfig, String interval) throws IOException, DatasetFactoryException, URISyntaxException {
IntervalWithTimeZone timespan = createTimespanFromInterval(datasetId, interval);
IoParameters config = createConfig(timespan.toString(), renderingConfig);
DatasetOutput<?, ?> metadata = datasetService.getParameter(datasetId, config);
IoStyleContext context = IoStyleContext.createContextForSingleSeries(metadata, config);
RequestStyledParameterSet styleDefinition = context.getChartStyleDefinitions();
context.setDimensions(new ChartDimension(styleDefinition.getWidth(), styleDefinition.getHeight()));
RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(datasetId, config);
String chartQualifier = renderingConfig.getChartQualifier();
FileOutputStream fos = createFile(datasetId, interval, chartQualifier);
try (FileOutputStream out = fos) {
createIoFactory(parameters).createHandler(IMAGE_EXTENSION).writeBinary(out);
fos.flush();
} catch (IoHandlerException | IOException e) {
LOGGER.error("Image creation occures error.", e);
}
}
use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.
the class SwesDecoderv20 method parseMetadata.
private SosInsertionMetadata parseMetadata(final Metadata[] metadataArray) throws DecodingException {
final SosInsertionMetadata sosMetadata = new SosInsertionMetadata();
try {
for (final Metadata metadata : metadataArray) {
SosInsertionMetadataType xbSosInsertionMetadata = null;
if (metadata.getInsertionMetadata() != null && metadata.getInsertionMetadata().schemaType() == SosInsertionMetadataType.type) {
xbSosInsertionMetadata = (SosInsertionMetadataType) metadata.getInsertionMetadata();
} else {
if (metadata.getDomNode().hasChildNodes()) {
final Node node = getNodeFromNodeList(metadata.getDomNode().getChildNodes());
final SosInsertionMetadataPropertyType xbMetadata = SosInsertionMetadataPropertyType.Factory.parse(node);
xbSosInsertionMetadata = xbMetadata.getSosInsertionMetadata();
}
}
if (xbSosInsertionMetadata != null) {
// featureOfInterest types
if (xbSosInsertionMetadata.getFeatureOfInterestTypeArray() != null) {
sosMetadata.setFeatureOfInterestTypes(Arrays.asList(xbSosInsertionMetadata.getFeatureOfInterestTypeArray()));
}
// observation types
if (xbSosInsertionMetadata.getObservationTypeArray() != null) {
sosMetadata.setObservationTypes(Arrays.asList(xbSosInsertionMetadata.getObservationTypeArray()));
}
}
}
} catch (final XmlException xmle) {
throw new DecodingException("An error occurred while parsing the metadata in the http post request", xmle);
}
return sosMetadata;
}
use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.
the class SensorMLDecoderV20 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 cs : capabilitiesArray) {
final SmlCapabilities capabilities = new SmlCapabilities(cs.getName());
if (cs.isSetCapabilityList()) {
CapabilityListType cl = cs.getCapabilityList();
if (CollectionHelper.isNotNullOrEmpty(cl.getCapabilityArray())) {
for (Capability c : cl.getCapabilityArray()) {
final SmlCapability capability = new SmlCapability(c.getName());
if (c.isSetAbstractDataComponent()) {
final Object o = decodeXmlElement(c.getAbstractDataComponent());
if (o instanceof SweAbstractDataComponent) {
capability.setAbstractDataComponent((SweAbstractDataComponent) o);
capabilities.addCapability(capability);
} else {
throw new DecodingException(XmlHelper.getLocalName(cs), "Error while parsing the capabilities of " + "the SensorML (the capabilities data record " + "is not of type DataRecordPropertyType)!");
}
} else if (c.isSetHref()) {
capability.setHref(c.getHref());
if (c.isSetTitle()) {
capability.setTitle(c.getTitle());
}
}
}
}
}
abstractProcess.addCapabilities(capabilities);
}
}
Aggregations