Issue #1822 created DataDeliveryRetrievalWmoHeaderApplier to generate WMO Header for data delivery retrievals.
Change-Id: If1037781d8fbf0e3a88556ef4401fb77621187d7 Former-commit-id:d5ee61dc2b
[formerly21c1b35c8b
[formerly 9ddb76125f51eb0ea73b7bb54a77e84fb32349e4]] Former-commit-id:21c1b35c8b
Former-commit-id:5ebe8ee093
This commit is contained in:
parent
3b787e12df
commit
b0779c9b4f
15 changed files with 386 additions and 25 deletions
|
@ -33,6 +33,7 @@ import javax.xml.bind.annotation.XmlEnum;
|
||||||
* Aug 22, 2012 0743 djohnson Initial creation
|
* Aug 22, 2012 0743 djohnson Initial creation
|
||||||
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
|
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
|
||||||
* Feb 21, 2013 754 dhladky Added point data type
|
* Feb 21, 2013 754 dhladky Added point data type
|
||||||
|
* Aug 07, 2013 1822 bgonzale Added PDA type.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -41,10 +42,7 @@ import javax.xml.bind.annotation.XmlEnum;
|
||||||
*/
|
*/
|
||||||
@XmlEnum
|
@XmlEnum
|
||||||
public enum DataType {
|
public enum DataType {
|
||||||
GRID(DataType.GRID_STRING_VALUE), POINT(DataType.POINT_STRING_VALUE);
|
GRID("GRID"), POINT("POINT"), PDA("PDA");
|
||||||
|
|
||||||
private static final String GRID_STRING_VALUE = "Grid";
|
|
||||||
private static final String POINT_STRING_VALUE = "Point";
|
|
||||||
|
|
||||||
private final String displayString;
|
private final String displayString;
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,11 @@
|
||||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.SerializeRetrievedDataToDirectory">
|
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.SerializeRetrievedDataToDirectory">
|
||||||
<constructor-arg value="${sbn.retrieval.transfer.directory}" />
|
<constructor-arg value="${sbn.retrieval.transfer.directory}" />
|
||||||
<constructor-arg>
|
<constructor-arg>
|
||||||
<bean class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.AlwaysSameWmoHeader">
|
<bean class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.DataDeliveryRetrievalWmoHeaderApplier">
|
||||||
<constructor-arg value="${sbn.retrieval.transfer.wmo.header}" />
|
<constructor-arg value="${sbn.retrieval.transfer.wmo.header}" />
|
||||||
|
<constructor-arg value="${sbn.retrieval.transfer.wmo.header.dataProviderMap}" />
|
||||||
|
<constructor-arg value="${sbn.retrieval.transfer.wmo.header.dataFormatMap}" />
|
||||||
|
<constructor-arg value="${sbn.retrieval.transfer.wmo.header.dataSourceMap}" />
|
||||||
</bean>
|
</bean>
|
||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
sbn.retrieval.transfer.directory=/awips2/crawl
|
sbn.retrieval.transfer.directory=/awips2/crawl
|
||||||
# TODO: What WMO Header should be used for SBN retrievals?
|
# maps for WMO header format values. mappings are <Name>:<WMO Header Value>
|
||||||
# The one below is just a random one to get things working...
|
sbn.retrieval.transfer.wmo.header.dataProviderMap=NOMADS:A,MADIS:B,PDA:C
|
||||||
sbn.retrieval.transfer.wmo.header=SMYG10 LYBM 280000
|
sbn.retrieval.transfer.wmo.header.dataFormatMap=GRID:A,MADIS:B,NETCDF:C
|
||||||
|
sbn.retrieval.transfer.wmo.header.dataSourceMap=MODEL:1,OBSERVATION:2,SATELLITE:3
|
||||||
|
# WMO Header MessageFormat should be used for SBN retrievals
|
||||||
|
sbn.retrieval.transfer.wmo.header=LZ{0}{1}9{2} KWBC {3,date,ddHH00}
|
||||||
# How often to check for retrievals to process
|
# How often to check for retrievals to process
|
||||||
# Valid units: [MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS]
|
# Valid units: [MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS]
|
||||||
retrieval.task.frequency=1 MINUTES
|
retrieval.task.frequency=1 MINUTES
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a WMO header that is always the same.
|
* Applies a WMO header that is always the same.
|
||||||
*
|
*
|
||||||
|
@ -29,6 +31,7 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Mar 04, 2013 1647 djohnson Initial creation
|
* Mar 04, 2013 1647 djohnson Initial creation
|
||||||
|
* Aug 09, 2013 1822 bgonzale Added parameters to IWmoHeaderApplier.applyWmoHeader().
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -47,7 +50,8 @@ public class AlwaysSameWmoHeader implements IWmoHeaderApplier {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String applyWmoHeader(String data) {
|
public String applyWmoHeader(String dataProvider, String dataFormat,
|
||||||
|
String sourceType, Date date, String data) {
|
||||||
return wmoHeader + "\n" + data;
|
return wmoHeader + "\n" + data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.Format;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||||
|
import com.raytheon.uf.edex.core.props.PropertiesException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the Data Delivery WMO header.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* From Brian Gockel:
|
||||||
|
*
|
||||||
|
* The general form will be:
|
||||||
|
* LZ$$# KWBC
|
||||||
|
* where "$$#" is two character ($$) variables and one numeric (#) variable,
|
||||||
|
* so we have three characters with which to work: $, $, and #.
|
||||||
|
* $ and $ can be assigned from A-Z, while # can be assigned from 1-6.
|
||||||
|
*
|
||||||
|
* The first $ is the data-provider indicator, with values (so far):
|
||||||
|
*
|
||||||
|
* A = NOMADS
|
||||||
|
* B = MADIS
|
||||||
|
* C = PDA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* The second $ is the data-format indicator (so far):
|
||||||
|
*
|
||||||
|
* A = binary grid (OPENDAP)
|
||||||
|
* B = <TBD point-data format, such as from MADIS>
|
||||||
|
* C = netCDF4
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* and the # is the general data type (so far):
|
||||||
|
*
|
||||||
|
* 1 = model
|
||||||
|
* 2 = observation
|
||||||
|
* 3 = satellite
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Aug 06, 2013 1822 bgonzale Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author bgonzale
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class DataDeliveryRetrievalWmoHeaderApplier implements IWmoHeaderApplier {
|
||||||
|
|
||||||
|
private final MessageFormat wmoHeaderMessage;
|
||||||
|
|
||||||
|
private final Map<String, String> dataProviderMap;
|
||||||
|
|
||||||
|
private final Map<String, String> dataFormatMap;
|
||||||
|
|
||||||
|
private final Map<String, String> dataSourceMap;
|
||||||
|
|
||||||
|
public DataDeliveryRetrievalWmoHeaderApplier(String wmoHeader,
|
||||||
|
String dataProviderMapping, String dataFormatMapping,
|
||||||
|
String dataSourceMapping) throws PropertiesException {
|
||||||
|
this.wmoHeaderMessage = new MessageFormat(wmoHeader);
|
||||||
|
// ensure any DateFormats in the given format are GMT
|
||||||
|
for (Format format : this.wmoHeaderMessage.getFormats()) {
|
||||||
|
if (format instanceof DateFormat) {
|
||||||
|
((DateFormat) format).setTimeZone(TimeUtil.GMT_TIME_ZONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.dataProviderMap = parseMapping(dataProviderMapping);
|
||||||
|
this.dataFormatMap = parseMapping(dataFormatMapping);
|
||||||
|
this.dataSourceMap = parseMapping(dataSourceMapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, String> parseMapping(String dataMapping)
|
||||||
|
throws PropertiesException {
|
||||||
|
Map<String, String> resultMap = new HashMap<String, String>();
|
||||||
|
String[] elementPairs = dataMapping.split(",");
|
||||||
|
|
||||||
|
for (String elementPair : elementPairs) {
|
||||||
|
String[] pair = elementPair.split(":");
|
||||||
|
|
||||||
|
if (pair.length == 2) {
|
||||||
|
String key = pair[0].toUpperCase();
|
||||||
|
String value = pair[1].toUpperCase();
|
||||||
|
|
||||||
|
resultMap.put(key, value);
|
||||||
|
} else {
|
||||||
|
throw new PropertiesException(
|
||||||
|
"Failed to Parse WMO Configuration Properties Mapping from: "
|
||||||
|
+ dataMapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String applyWmoHeader(String dataProvider, String dataFormat,
|
||||||
|
String sourceType, Date date, String data) {
|
||||||
|
final Object formatArgs = createMessageFormatArgs(dataProvider,
|
||||||
|
dataFormat, sourceType, date);
|
||||||
|
final String formattedWmoHeader = wmoHeaderMessage.format(formatArgs);
|
||||||
|
return formattedWmoHeader + "\n" + data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object createMessageFormatArgs(String dataProvider,
|
||||||
|
String dataFormat, String sourceType, Date date) {
|
||||||
|
final String provider = getElement(dataProvider, this.dataProviderMap);
|
||||||
|
final String format = getElement(dataFormat, this.dataFormatMap);
|
||||||
|
final String source = getElement(sourceType, this.dataSourceMap);
|
||||||
|
return new Object[] { provider, format, source, date };
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getElement(String dataProvider,
|
||||||
|
Map<String, String> mapping) {
|
||||||
|
String defaultKey = null;
|
||||||
|
|
||||||
|
for (String key : mapping.keySet()) {
|
||||||
|
if (defaultKey == null) {
|
||||||
|
defaultKey = key;
|
||||||
|
}
|
||||||
|
if (key.startsWith(dataProvider)) {
|
||||||
|
return mapping.get(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if no element found, default to first element, or if empty, default
|
||||||
|
// to null
|
||||||
|
return mapping.get(defaultKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,11 +19,13 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import com.raytheon.uf.common.serialization.SerializationException;
|
import com.raytheon.uf.common.serialization.SerializationException;
|
||||||
|
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter.TranslationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes {@link RetrievalResponseXml} that were generated from a
|
* Processes {@link RetrievalResponseXml} that were generated from a retrieval.
|
||||||
* retrieval.
|
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -32,6 +34,7 @@ import com.raytheon.uf.common.serialization.SerializationException;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Feb 01, 2013 1543 djohnson Initial creation
|
* Feb 01, 2013 1543 djohnson Initial creation
|
||||||
|
* Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -45,12 +48,22 @@ public interface IRetrievalPluginDataObjectsProcessor {
|
||||||
* Process plugin data objects that were created as a result of a data
|
* Process plugin data objects that were created as a result of a data
|
||||||
* delivery retrieval.
|
* delivery retrieval.
|
||||||
*
|
*
|
||||||
|
* @param dataProvider
|
||||||
|
* NOMADS, MADIS, or PDA
|
||||||
|
* @param dataFormat
|
||||||
|
* Binary Grid(OPENDAP), POINT(MADIS), NetCDF4
|
||||||
|
* @param sourceType
|
||||||
|
* Model, Observation, Satellite
|
||||||
|
* @param date
|
||||||
|
* the date
|
||||||
* @param retrievalPluginDataObjects
|
* @param retrievalPluginDataObjects
|
||||||
* the retrieval plugin data objects
|
* the retrieval plugin data objects
|
||||||
* @throws SerializationException
|
* @throws SerializationException
|
||||||
* on error with serialization
|
* on error with serialization
|
||||||
|
* @throws TranslationException
|
||||||
*/
|
*/
|
||||||
void processRetrievedPluginDataObjects(
|
void processRetrievedPluginDataObjects(String dataProvider,
|
||||||
|
String dataFormat, String sourceType, Date date,
|
||||||
RetrievalResponseXml retrievalPluginDataObjects)
|
RetrievalResponseXml retrievalPluginDataObjects)
|
||||||
throws Exception;
|
throws SerializationException, TranslationException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a WMO compliant header to text data.
|
* Apply a WMO compliant header to text data.
|
||||||
*
|
*
|
||||||
|
@ -29,6 +31,7 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Mar 04, 2013 1647 djohnson Initial creation
|
* Mar 04, 2013 1647 djohnson Initial creation
|
||||||
|
* Aug 07, 2013 1822 bgonzale Added arguments to applyWmoHeader.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -39,12 +42,21 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
public interface IWmoHeaderApplier {
|
public interface IWmoHeaderApplier {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a WMO compliant header.
|
* Apply the WMO compliant header.
|
||||||
*
|
*
|
||||||
|
* @param dataProvider
|
||||||
|
* NOMADS, MADIS, or PDA
|
||||||
|
* @param dataFormat
|
||||||
|
* Binary Grid(OPENDAP), POINT(MADIS), NetCDF4
|
||||||
|
* @param sourceType
|
||||||
|
* Model, Observation, Satellite
|
||||||
|
* @param date
|
||||||
|
* data date
|
||||||
* @param data
|
* @param data
|
||||||
* the data
|
* the data
|
||||||
* @return the data with a WMO compliant header
|
* @return the data with a WMO compliant header
|
||||||
*/
|
*/
|
||||||
String applyWmoHeader(final String data);
|
String applyWmoHeader(final String dataProvider, final String dataFormat,
|
||||||
|
final String sourceType, final Date date, final String data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
@ -42,6 +44,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||||
* Jan 30, 2013 1543 djohnson Constrain to the network retrievals are pulled for.
|
* Jan 30, 2013 1543 djohnson Constrain to the network retrievals are pulled for.
|
||||||
* Feb 15, 2013 1543 djohnson Using xml for retrievals now.
|
* Feb 15, 2013 1543 djohnson Using xml for retrievals now.
|
||||||
* Mar 05, 2013 1647 djohnson Change no retrievals found message to debug.
|
* Mar 05, 2013 1647 djohnson Change no retrievals found message to debug.
|
||||||
|
* Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -100,8 +103,10 @@ public class RetrievalTask implements Runnable {
|
||||||
request = retrievalDao.getById(retrievalPluginDataObject
|
request = retrievalDao.getById(retrievalPluginDataObject
|
||||||
.getRequestRecord());
|
.getRequestRecord());
|
||||||
success = retrievalPluginDataObject.isSuccess();
|
success = retrievalPluginDataObject.isSuccess();
|
||||||
retrievedDataProcessor
|
Date date = request.getInsertTime();
|
||||||
.processRetrievedPluginDataObjects(retrievalPluginDataObject);
|
retrievedDataProcessor.processRetrievedPluginDataObjects(
|
||||||
|
request.getProvider(), request.getPlugin(), null,
|
||||||
|
date, retrievalPluginDataObject);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusHandler.error(
|
statusHandler.error(
|
||||||
network + " retrieval processing error", e);
|
network + " retrieval processing error", e);
|
||||||
|
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
@ -44,6 +45,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.opendap.OpenDapRetrievalRespo
|
||||||
* Feb 15, 2013 1543 djohnson Serialize data out as XML.
|
* Feb 15, 2013 1543 djohnson Serialize data out as XML.
|
||||||
* Mar 05, 2013 1647 djohnson Apply WMO header.
|
* Mar 05, 2013 1647 djohnson Apply WMO header.
|
||||||
* Mar 07, 2013 1647 djohnson Write out as hidden file, then rename.
|
* Mar 07, 2013 1647 djohnson Write out as hidden file, then rename.
|
||||||
|
* Aug 09, 2013 1822 bgonzale Added parameters to IWmoHeaderApplier.applyWmoHeader().
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -78,7 +80,8 @@ public class SerializeRetrievedDataToDirectory implements
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void processRetrievedPluginDataObjects(
|
public void processRetrievedPluginDataObjects(String dataType,
|
||||||
|
String dataFormat, String sourceType, Date date,
|
||||||
RetrievalResponseXml retrievalPluginDataObjects)
|
RetrievalResponseXml retrievalPluginDataObjects)
|
||||||
throws SerializationException {
|
throws SerializationException {
|
||||||
retrievalPluginDataObjects.prepareForSerialization();
|
retrievalPluginDataObjects.prepareForSerialization();
|
||||||
|
@ -91,7 +94,8 @@ public class SerializeRetrievedDataToDirectory implements
|
||||||
|
|
||||||
final String xml = jaxbManager
|
final String xml = jaxbManager
|
||||||
.marshalToXml(retrievalPluginDataObjects);
|
.marshalToXml(retrievalPluginDataObjects);
|
||||||
final String textForFile = wmoHeaderWrapper.applyWmoHeader(xml);
|
final String textForFile = wmoHeaderWrapper.applyWmoHeader(
|
||||||
|
dataType, dataFormat, sourceType, date, xml);
|
||||||
|
|
||||||
// Write as hidden file, this is OS specific, but there is no
|
// Write as hidden file, this is OS specific, but there is no
|
||||||
// platform-neutral way to do this with Java
|
// platform-neutral way to do this with Java
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -58,6 +59,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.util.RetrievalPersistUtil;
|
||||||
* Jan 31, 2013 1543 djohnson Initial creation
|
* Jan 31, 2013 1543 djohnson Initial creation
|
||||||
* Feb 12, 2013 1543 djohnson Now handles the retrieval responses directly.
|
* Feb 12, 2013 1543 djohnson Now handles the retrieval responses directly.
|
||||||
* Feb 15, 2013 1543 djohnson Retrieve the retrieval attributes from the database.
|
* Feb 15, 2013 1543 djohnson Retrieve the retrieval attributes from the database.
|
||||||
|
* Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -90,7 +92,8 @@ public class StoreRetrievedData implements IRetrievalPluginDataObjectsProcessor
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void processRetrievedPluginDataObjects(
|
public void processRetrievedPluginDataObjects(String dataProvider,
|
||||||
|
String dataFormat, String sourceType, Date date,
|
||||||
RetrievalResponseXml retrievalPluginDataObjects)
|
RetrievalResponseXml retrievalPluginDataObjects)
|
||||||
throws SerializationException, TranslationException {
|
throws SerializationException, TranslationException {
|
||||||
Map<String, PluginDataObject[]> pluginDataObjects = Maps.newHashMap();
|
Map<String, PluginDataObject[]> pluginDataObjects = Maps.newHashMap();
|
||||||
|
|
|
@ -23,6 +23,8 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -40,6 +42,7 @@ import com.raytheon.uf.edex.wmo.message.WMOMessage;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Mar 04, 2013 1647 djohnson Initial creation
|
* Mar 04, 2013 1647 djohnson Initial creation
|
||||||
|
* Aug 09, 2013 1822 bgonzale Added parameters to IWmoHeaderApplier.applyWmoHeader().
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -51,7 +54,8 @@ public class AlwaysSameWmoHeaderTest {
|
||||||
private static final AlwaysSameWmoHeader WRAPPER = new AlwaysSameWmoHeader(
|
private static final AlwaysSameWmoHeader WRAPPER = new AlwaysSameWmoHeader(
|
||||||
"SMYG10 LYBM 280000");
|
"SMYG10 LYBM 280000");
|
||||||
|
|
||||||
private static final String wrapped = WRAPPER.applyWmoHeader("someData");
|
private static final String wrapped = WRAPPER.applyWmoHeader(null, null,
|
||||||
|
null, new Date(), "someData");
|
||||||
|
|
||||||
private static WMOMessage message;
|
private static WMOMessage message;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.raytheon.edex.esb.Headers;
|
||||||
|
import com.raytheon.uf.edex.core.props.PropertiesException;
|
||||||
|
import com.raytheon.uf.edex.wmo.message.WMOHeader;
|
||||||
|
import com.raytheon.uf.edex.wmo.message.WMOMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test {@link DataDeliveryRetrievalWmoHeaderApplier}.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Aug 08, 2013 1822 bgonzale Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author bgonzale
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class DataDeliveryRetrievalWmoHeaderApplierTest {
|
||||||
|
|
||||||
|
private DataDeliveryRetrievalWmoHeaderApplier applier;
|
||||||
|
|
||||||
|
private WMOMessage message;
|
||||||
|
|
||||||
|
private WMOHeader wmoHeader;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws PropertiesException, IOException {
|
||||||
|
applier = createApplier();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setHeader(String dataProvider, String dataFormat,
|
||||||
|
String sourceType, Date date) {
|
||||||
|
String dataWithHeader = applier.applyWmoHeader(dataProvider,
|
||||||
|
dataFormat, sourceType, date, "someData");
|
||||||
|
message = new WMOMessage(dataWithHeader, new Headers());
|
||||||
|
wmoHeader = message.getWmoHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DataDeliveryRetrievalWmoHeaderApplier createApplier()
|
||||||
|
throws PropertiesException {
|
||||||
|
String wmoHeader = "LZ{0}{1}9{2} KWBC {3,date,ddHH00}";
|
||||||
|
String dataProviderMapping = "NOMADS:A,MADIS:B,PDA:C";
|
||||||
|
String dataFormatMapping = "GRID:A,MADIS:B,NETCDF:C";
|
||||||
|
String dataSourceMapping = "MODEL:1,OBSERVATION:2,SATELLITE:3";
|
||||||
|
return new DataDeliveryRetrievalWmoHeaderApplier(wmoHeader,
|
||||||
|
dataProviderMapping, dataFormatMapping, dataSourceMapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createValidWmoHeader() {
|
||||||
|
Date date = new Date();
|
||||||
|
setHeader("NOMADS", "GRID", "MODEL", date);
|
||||||
|
assertThat(wmoHeader.isValid(), is(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createNomadsGridModel() {
|
||||||
|
Date date = new Date();
|
||||||
|
setHeader("NOMADS", "GRID", "MODEL", date);
|
||||||
|
assertThat(wmoHeader.getT1(), is(equalTo('L')));
|
||||||
|
assertThat(wmoHeader.getT2(), is(equalTo('Z')));
|
||||||
|
assertThat(wmoHeader.getA1(), is(equalTo('A')));
|
||||||
|
assertThat(wmoHeader.getA2(), is(equalTo('A')));
|
||||||
|
assertThat(wmoHeader.getIi(), is(equalTo(91)));
|
||||||
|
assertThat(wmoHeader.getCccc(), is(equalTo("KWBC")));
|
||||||
|
assertThat(message.getMessageBody(), is(equalTo("someData".getBytes())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createMadisGridModel() {
|
||||||
|
Date date = new Date();
|
||||||
|
setHeader("MADIS", "GRID", "MODEL", date);
|
||||||
|
assertThat(wmoHeader.getT1(), is(equalTo('L')));
|
||||||
|
assertThat(wmoHeader.getT2(), is(equalTo('Z')));
|
||||||
|
assertThat(wmoHeader.getA1(), is(equalTo('B')));
|
||||||
|
assertThat(wmoHeader.getA2(), is(equalTo('A')));
|
||||||
|
assertThat(wmoHeader.getIi(), is(equalTo(91)));
|
||||||
|
assertThat(wmoHeader.getCccc(), is(equalTo("KWBC")));
|
||||||
|
assertThat(message.getMessageBody(), is(equalTo("someData".getBytes())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createMadisPointModel() {
|
||||||
|
Date date = new Date();
|
||||||
|
setHeader("MADIS", "MADIS", "MODEL", date);
|
||||||
|
assertThat(wmoHeader.getT1(), is(equalTo('L')));
|
||||||
|
assertThat(wmoHeader.getT2(), is(equalTo('Z')));
|
||||||
|
assertThat(wmoHeader.getA1(), is(equalTo('B')));
|
||||||
|
assertThat(wmoHeader.getA2(), is(equalTo('B')));
|
||||||
|
assertThat(wmoHeader.getIi(), is(equalTo(91)));
|
||||||
|
assertThat(wmoHeader.getCccc(), is(equalTo("KWBC")));
|
||||||
|
assertThat(message.getMessageBody(), is(equalTo("someData".getBytes())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createMadisPointSatellite() {
|
||||||
|
Date date = new Date();
|
||||||
|
setHeader("MADIS", "MADIS", "SATELLITE", date);
|
||||||
|
assertThat(wmoHeader.getT1(), is(equalTo('L')));
|
||||||
|
assertThat(wmoHeader.getT2(), is(equalTo('Z')));
|
||||||
|
assertThat(wmoHeader.getA1(), is(equalTo('B')));
|
||||||
|
assertThat(wmoHeader.getA2(), is(equalTo('B')));
|
||||||
|
assertThat(wmoHeader.getIi(), is(equalTo(93)));
|
||||||
|
assertThat(wmoHeader.getCccc(), is(equalTo("KWBC")));
|
||||||
|
assertThat(message.getMessageBody(), is(equalTo("someData".getBytes())));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
* Feb 15, 2013 1543 djohnson Some renames.
|
* Feb 15, 2013 1543 djohnson Some renames.
|
||||||
* Mar 05, 2013 1647 djohnson Pass wmo header strategy to constructor.
|
* Mar 05, 2013 1647 djohnson Pass wmo header strategy to constructor.
|
||||||
* Mar 19, 2013 1794 djohnson Read from a queue rather than the file system.
|
* Mar 19, 2013 1794 djohnson Read from a queue rather than the file system.
|
||||||
|
* Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -113,7 +115,8 @@ public class DeserializeRetrievedDataFromIngestTest {
|
||||||
|
|
||||||
new SerializeRetrievedDataToDirectory(directory,
|
new SerializeRetrievedDataToDirectory(directory,
|
||||||
new AlwaysSameWmoHeader("SMYG10 LYBM 280000"))
|
new AlwaysSameWmoHeader("SMYG10 LYBM 280000"))
|
||||||
.processRetrievedPluginDataObjects(retrievalPluginDataObjects);
|
.processRetrievedPluginDataObjects("", "", "", new Date(),
|
||||||
|
retrievalPluginDataObjects);
|
||||||
|
|
||||||
final List<File> files = FileUtil.listFiles(directory,
|
final List<File> files = FileUtil.listFiles(directory,
|
||||||
FilenameFilters.ACCEPT_FILES, false);
|
FilenameFilters.ACCEPT_FILES, false);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import static org.mockito.Mockito.mock;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -64,6 +65,7 @@ import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||||
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceTypeFactory;
|
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceTypeFactory;
|
||||||
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
|
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
|
||||||
|
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter.TranslationException;
|
||||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
|
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
|
||||||
|
@ -85,6 +87,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse
|
||||||
* Mar 05, 2013 1647 djohnson Pass wmo header strategy to constructor.
|
* Mar 05, 2013 1647 djohnson Pass wmo header strategy to constructor.
|
||||||
* Mar 19, 2013 1794 djohnson RetrievalTasks integrate at a queue.
|
* Mar 19, 2013 1794 djohnson RetrievalTasks integrate at a queue.
|
||||||
* Apr 29, 2013 1910 djohnson Unregister from EventBus after each test.
|
* Apr 29, 2013 1910 djohnson Unregister from EventBus after each test.
|
||||||
|
* Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -107,9 +110,10 @@ public class RetrievalTaskTest {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void processRetrievedPluginDataObjects(
|
public void processRetrievedPluginDataObjects(String dataProvider,
|
||||||
|
String dataFormat, String sourceType, Date date,
|
||||||
RetrievalResponseXml retrievalPluginDataObjects)
|
RetrievalResponseXml retrievalPluginDataObjects)
|
||||||
throws Exception {
|
throws SerializationException, TranslationException {
|
||||||
final List<RetrievalResponseWrapper> retrievalAttributePluginDataObjects = retrievalPluginDataObjects
|
final List<RetrievalResponseWrapper> retrievalAttributePluginDataObjects = retrievalPluginDataObjects
|
||||||
.getRetrievalAttributePluginDataObjects();
|
.getRetrievalAttributePluginDataObjects();
|
||||||
final RetrievalRequestRecord requestRecord = dao
|
final RetrievalRequestRecord requestRecord = dao
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static com.raytheon.uf.common.util.Matchers.hasNumberOfFiles;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -43,6 +44,7 @@ import com.raytheon.uf.common.util.TestUtil;
|
||||||
* Feb 01, 2013 1543 djohnson Initial creation
|
* Feb 01, 2013 1543 djohnson Initial creation
|
||||||
* Feb 15, 2013 1543 djohnson Class renames.
|
* Feb 15, 2013 1543 djohnson Class renames.
|
||||||
* Mar 05, 2013 1647 djohnson Pass wmo header strategy to constructor.
|
* Mar 05, 2013 1647 djohnson Pass wmo header strategy to constructor.
|
||||||
|
* Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -69,7 +71,8 @@ public class SerializeRetrievedDataToDirectoryTest {
|
||||||
RetrievalResponseXml retrievalPluginDataObjects = RetrievalPluginDataObjectsFixture.INSTANCE
|
RetrievalResponseXml retrievalPluginDataObjects = RetrievalPluginDataObjectsFixture.INSTANCE
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
service.processRetrievedPluginDataObjects(retrievalPluginDataObjects);
|
service.processRetrievedPluginDataObjects("NOMADS", "GRID", "Model",
|
||||||
|
new Date(), retrievalPluginDataObjects);
|
||||||
|
|
||||||
assertThat(directory, hasNumberOfFiles(1));
|
assertThat(directory, hasNumberOfFiles(1));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue