Search in sources :

Example 26 with Metadata

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());
}
Also used : JobDetail(org.quartz.JobDetail) JobDataMap(org.quartz.JobDataMap) HashMap(java.util.HashMap) Stopwatch(org.n52.web.common.Stopwatch) IoParameters(org.n52.io.request.IoParameters) RenderingConfig(org.n52.io.PrerenderingJobConfig.RenderingConfig)

Example 27 with Metadata

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);
    }
}
Also used : RequestStyledParameterSet(org.n52.io.request.RequestStyledParameterSet) RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) FileOutputStream(java.io.FileOutputStream) ChartDimension(org.n52.io.quantity.img.ChartDimension) IoParameters(org.n52.io.request.IoParameters) IOException(java.io.IOException)

Example 28 with Metadata

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;
}
Also used : XmlException(org.apache.xmlbeans.XmlException) Node(org.w3c.dom.Node) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) Metadata(net.opengis.swes.x20.InsertSensorType.Metadata) SosInsertionMetadataPropertyType(net.opengis.sos.x20.SosInsertionMetadataPropertyType) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SosInsertionMetadataType(net.opengis.sos.x20.SosInsertionMetadataType)

Example 29 with Metadata

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);
    }
}
Also used : SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) CapabilityListType(net.opengis.sensorml.x20.CapabilityListType) SmlCapability(org.n52.shetland.ogc.sensorML.elements.SmlCapability) Capability(net.opengis.sensorml.x20.CapabilityListType.Capability) Capabilities(net.opengis.sensorml.x20.DescribedObjectType.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) DescribedObject(org.n52.shetland.ogc.sensorML.v20.DescribedObject) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SmlCapability(org.n52.shetland.ogc.sensorML.elements.SmlCapability)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)5 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)5 IoParameters (org.n52.io.request.IoParameters)4 DatasetOutput (org.n52.io.response.dataset.DatasetOutput)4 SeriesParameters (org.n52.io.response.dataset.SeriesParameters)4 DecodingException (org.n52.svalbard.decode.exception.DecodingException)4 Test (org.junit.Test)3 QuantityDatasetMetadata (org.n52.io.response.dataset.quantity.QuantityDatasetMetadata)3 InsertSensorRequest (org.n52.shetland.ogc.sos.request.InsertSensorRequest)3 Strings (com.google.common.base.Strings)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 XmlException (org.apache.xmlbeans.XmlException)2 DateTime (org.joda.time.DateTime)2 RequestStyledParameterSet (org.n52.io.request.RequestStyledParameterSet)2 ParameterOutput (org.n52.io.response.ParameterOutput)2 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)2 LocalizedString (org.n52.janmayen.i18n.LocalizedString)2