pfafs, Date backDate,
Date currDate, long expirationTime, boolean rate) {
- double val = getBasinData("ALL").getAccumMaxValue(pfafs, currDate, backDate,
- expirationTime, rate);
-
+ double val = getBasinData("ALL").getAccumMaxValue(pfafs, currDate,
+ backDate, expirationTime, rate);
+
return val;
}
@@ -473,12 +464,12 @@ public class FFMPDataContainer {
}
}
- public void setFilePath(String filePath) {
- this.filePath = filePath;
- }
+ public void setFilePath(String filePath) {
+ this.filePath = filePath;
+ }
- public String getFilePath() {
- return filePath;
- }
+ public String getFilePath() {
+ return filePath;
+ }
}
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/META-INF/MANIFEST.MF
index 9f09b06c07..64f1c7ccb0 100644
--- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/META-INF/MANIFEST.MF
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/META-INF/MANIFEST.MF
@@ -35,6 +35,7 @@ Export-Package: com.raytheon.uf.common.dataplugin.gfe,
com.raytheon.uf.common.dataplugin.gfe.server.request,
com.raytheon.uf.common.dataplugin.gfe.slice,
com.raytheon.uf.common.dataplugin.gfe.textproduct,
+ com.raytheon.uf.common.dataplugin.gfe.time,
com.raytheon.uf.common.dataplugin.gfe.util,
com.raytheon.uf.common.dataplugin.gfe.weather,
com.raytheon.uf.common.dataplugin.gfe.weatherelement
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/GetActiveSitesRequest.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/GetActiveSitesRequest.java
deleted file mode 100644
index e03fb4c321..0000000000
--- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/GetActiveSitesRequest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.common.dataplugin.gfe.request;
-
-import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
-
-/**
- * TODO Add Description
- *
- *
- *
- * SOFTWARE HISTORY
- *
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * Jan 19, 2011 dgilling Initial creation
- *
- *
- *
- * @author dgilling
- * @version 1.0
- */
-
-@DynamicSerialize
-public class GetActiveSitesRequest extends AbstractGfeRequest {
-
-}
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/GetSelectTimeRangeRequest.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/GetSelectTimeRangeRequest.java
new file mode 100644
index 0000000000..b87aa14c02
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/GetSelectTimeRangeRequest.java
@@ -0,0 +1,90 @@
+/**
+ * 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.common.dataplugin.gfe.request;
+
+import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
+import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
+
+/**
+ * Request that allows a defined selection time range to be retrieved by name.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 1, 2012 dgilling Initial creation
+ *
+ *
+ *
+ * @author dgilling
+ * @version 1.0
+ */
+@DynamicSerialize
+public class GetSelectTimeRangeRequest extends AbstractGfeRequest {
+
+ @DynamicSerializeElement
+ private String name;
+
+ public GetSelectTimeRangeRequest() {
+ super();
+ this.name = null;
+ }
+
+ public GetSelectTimeRangeRequest(String name) {
+ super();
+ this.name = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("GetSelectTimeRangeRequest [name=");
+ builder.append(name);
+ builder.append(", workstationID=");
+ if (workstationID == null) {
+ builder.append("null");
+ } else {
+ builder.append(workstationID.toPrettyString());
+ }
+ builder.append(", siteID=");
+ if (siteID == null) {
+ builder.append("null");
+ } else {
+ builder.append(siteID);
+ }
+ builder.append("]");
+ return builder.toString();
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/time/SelectTimeRange.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/time/SelectTimeRange.java
similarity index 95%
rename from cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/time/SelectTimeRange.java
rename to edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/time/SelectTimeRange.java
index b6017859a8..32d11e5605 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/time/SelectTimeRange.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/time/SelectTimeRange.java
@@ -18,7 +18,7 @@
* further licensing information.
**/
-package com.raytheon.viz.gfe.core.time;
+package com.raytheon.uf.common.dataplugin.gfe.time;
import java.util.Calendar;
import java.util.Date;
@@ -36,7 +36,8 @@ import com.raytheon.uf.common.time.TimeRange;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Jun 24, 2008 mnash Initial creation
+ * Jun 24, 2008 mnash Initial creation
+ * Aug 01, 2012 #965 dgilling Moved to dataplugin.gfe project.
*
*
*
@@ -117,6 +118,7 @@ public class SelectTimeRange implements Comparable {
/**
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
+ @Override
public int compareTo(SelectTimeRange other) {
if (start != other.start) {
return start - other.start;
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/subgrid/SubGridDef.java b/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/subgrid/SubGridDef.java
index 60e07f2744..989fd6bf9e 100644
--- a/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/subgrid/SubGridDef.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/subgrid/SubGridDef.java
@@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlList;
import javax.xml.bind.annotation.XmlRootElement;
+import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
@@ -38,7 +39,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 25, 2010 rjpeter Initial creation
- *
+ * Jul 25, 2012 977 rjpeter Add optional centerLatitude/centerLongitude
*
*
* @author rjpeter
@@ -51,37 +52,39 @@ public class SubGridDef implements ISerializableObject {
@XmlElement(required = true)
@XmlList
private List modelNames;
-
+
@XmlElement(required = true)
private String referenceModel;
+ @XmlElement(required = true)
+ private double nx;
+
+ @XmlElement(required = true)
+ private double ny;
+
+ // annotation on setter to enforce data constraints
+ private Double centerLatitude;
+
+ // annotation on setter to enforce data constraints
+ private Double centerLongitude;
+
/** the lower left latitude */
- @XmlElement
private double lowerLeftLat;
/** the lower left longitude */
- @XmlElement
private double lowerLeftLon;
/** the upper right latitude */
- @XmlElement
private double upperRightLat;
/** the upper right longitude */
- @XmlElement
private double upperRightLon;
-
- @XmlElement(required = true)
- private double nx;
-
- @XmlElement(required = true)
- private double ny;
public List getModelNames() {
return modelNames;
}
- public void setModelNames(List modelNames) {
+ public void setModelNames(final List modelNames) {
this.modelNames = modelNames;
}
@@ -89,7 +92,7 @@ public class SubGridDef implements ISerializableObject {
return lowerLeftLat;
}
- public void setLowerLeftLat(double lowerLeftLat) {
+ public void setLowerLeftLat(final double lowerLeftLat) {
this.lowerLeftLat = lowerLeftLat;
}
@@ -97,7 +100,7 @@ public class SubGridDef implements ISerializableObject {
return lowerLeftLon;
}
- public void setLowerLeftLon(double lowerLeftLon) {
+ public void setLowerLeftLon(final double lowerLeftLon) {
this.lowerLeftLon = lowerLeftLon;
}
@@ -105,7 +108,7 @@ public class SubGridDef implements ISerializableObject {
return upperRightLat;
}
- public void setUpperRightLat(double upperRightLat) {
+ public void setUpperRightLat(final double upperRightLat) {
this.upperRightLat = upperRightLat;
}
@@ -113,7 +116,7 @@ public class SubGridDef implements ISerializableObject {
return upperRightLon;
}
- public void setUpperRightLon(double upperRightLon) {
+ public void setUpperRightLon(final double upperRightLon) {
this.upperRightLon = upperRightLon;
}
@@ -121,7 +124,7 @@ public class SubGridDef implements ISerializableObject {
return nx;
}
- public void setNx(double nx) {
+ public void setNx(final double nx) {
this.nx = nx;
}
@@ -129,7 +132,7 @@ public class SubGridDef implements ISerializableObject {
return ny;
}
- public void setNy(double ny) {
+ public void setNy(final double ny) {
this.ny = ny;
}
@@ -137,9 +140,33 @@ public class SubGridDef implements ISerializableObject {
return referenceModel;
}
- public void setReferenceModel(String referenceModel) {
+ public void setReferenceModel(final String referenceModel) {
this.referenceModel = referenceModel;
}
-
-
-}
\ No newline at end of file
+
+ public Double getCenterLatitude() {
+ return centerLatitude;
+ }
+
+ @XmlElement
+ public void setCenterLatitude(final Double centerLatitude) {
+ this.centerLatitude = centerLatitude;
+ if (this.centerLatitude != null) {
+ this.centerLatitude = new Double(MapUtil.correctLat(centerLatitude
+ .doubleValue()));
+ }
+ }
+
+ public Double getCenterLongitude() {
+ return centerLongitude;
+ }
+
+ @XmlElement
+ public void setCenterLongitude(final Double centerLongitude) {
+ this.centerLongitude = centerLongitude;
+ if (this.centerLongitude != null) {
+ this.centerLongitude = new Double(
+ MapUtil.correctLon(centerLongitude.doubleValue()));
+ }
+ }
+}
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.pirep/src/com/raytheon/uf/common/dataplugin/pirep/PirepRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.pirep/src/com/raytheon/uf/common/dataplugin/pirep/PirepRecord.java
index 250453f3f0..6a0d595114 100644
--- a/edexOsgi/com.raytheon.uf.common.dataplugin.pirep/src/com/raytheon/uf/common/dataplugin/pirep/PirepRecord.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.pirep/src/com/raytheon/uf/common/dataplugin/pirep/PirepRecord.java
@@ -70,6 +70,12 @@ import com.vividsolutions.jts.geom.Geometry;
* 20090408 952 jsanchez Updated getValue and getStrings methods.
* Added getMessageData method.
* 20090521 2338 jsanchez Changed the unit of the alititude.
+ * ======================================
+ * AWIPS2 DR Work
+ * 08/09/2012 1011 jkorman Added separate max icing level as well
+ * as separated code to generate distinct max icing/turbulence levels. Removed
+ * code that used "display" boolean to determine data access.
+ *
*
*
* @author jkorman
@@ -138,7 +144,10 @@ public class PirepRecord extends PluginDataObject implements ISpatialEnabled,
}
@Transient
- private PirepLayerData maxPirepLayerData = null;
+ private PirepLayerData maxTurbcLayerData = null;
+
+ @Transient
+ private PirepLayerData maxIcingLayerData = null;
@Transient
private boolean display = true;
@@ -591,32 +600,31 @@ public class PirepRecord extends PluginDataObject implements ISpatialEnabled,
*/
@Override
public Amount getValue(String paramName) {
+ findMaxIcingLayer();
+ findMaxTurbcLayer();
Amount a = null;
String pName = PARM_MAP.get(paramName);
- if (display) {
- if (SFC_TEMP.equals(pName) && (temp != null)) {
- a = new Amount(temp, TEMPERATURE_UNIT);
- } else if (SFC_WNDSPD.equals(pName) && (windSpeed != null)) {
- a = new Amount(windSpeed, WIND_SPEED_UNIT);
- } else if (SFC_WNDDIR.equals(pName) && (windDirection != null)) {
- a = new Amount(windDirection, WIND_DIR_UNIT);
- } else if (STA_LAT.equals(pName)) {
- a = new Amount(this.getLatitude(), LOCATION_UNIT);
- } else if (STA_LON.equals(pName)) {
- a = new Amount(this.getLongitude(), LOCATION_UNIT);
- } else if (UA_FLTLVL.equals(pName) && getFlightLevel() != null) {
- a = new Amount(this.getFlightLevel().intValue(), ALTITUDE_UNIT);
- } else if (UA_TOPHGT.equals(pName) && maxPirepLayerData != null
- && maxPirepLayerData.getTopLayerHeight() != null) {
- a = new Amount(
- maxPirepLayerData.getTopLayerHeight().intValue(),
- ALTITUDE_UNIT);
- } else if (UA_BOTHGT.equals(pName) && maxPirepLayerData != null
- && maxPirepLayerData.getBaseLayerHeight() != null) {
- a = new Amount(maxPirepLayerData.getBaseLayerHeight()
- .intValue(), ALTITUDE_UNIT);
- }
+ if (SFC_TEMP.equals(pName) && (temp != null)) {
+ a = new Amount(temp, TEMPERATURE_UNIT);
+ } else if (SFC_WNDSPD.equals(pName) && (windSpeed != null)) {
+ a = new Amount(windSpeed, WIND_SPEED_UNIT);
+ } else if (SFC_WNDDIR.equals(pName) && (windDirection != null)) {
+ a = new Amount(windDirection, WIND_DIR_UNIT);
+ } else if (STA_LAT.equals(pName)) {
+ a = new Amount(this.getLatitude(), LOCATION_UNIT);
+ } else if (STA_LON.equals(pName)) {
+ a = new Amount(this.getLongitude(), LOCATION_UNIT);
+ } else if (UA_FLTLVL.equals(pName) && getFlightLevel() != null) {
+ a = new Amount(this.getFlightLevel().intValue(), ALTITUDE_UNIT);
+ } else if (UA_TOPHGT.equals(pName) && maxTurbcLayerData != null
+ && maxTurbcLayerData.getTopLayerHeight() != null) {
+ a = new Amount(maxTurbcLayerData.getTopLayerHeight().intValue(),
+ ALTITUDE_UNIT);
+ } else if (UA_BOTHGT.equals(pName) && maxTurbcLayerData != null
+ && maxTurbcLayerData.getBaseLayerHeight() != null) {
+ a = new Amount(maxTurbcLayerData.getBaseLayerHeight().intValue(),
+ ALTITUDE_UNIT);
}
return a;
}
@@ -636,81 +644,85 @@ public class PirepRecord extends PluginDataObject implements ISpatialEnabled,
@Override
public String[] getStrings(String paramName) {
- if ("ICI".matches(paramName)) {
- int rank = -1;
- String iceIntensity = null;
- for (PirepLayerData layer : this.ancPirepData) {
- String intensity = "";
- if (layer.getLayerType().equals(PirepLayerData.LAYER_TYP_ICING)) {
- if (layer.getFirstValue() != null) {
- intensity = layer.getFirstValue();
- }
- if (layer.getSecondValue() != null) {
- intensity += layer.getSecondValue();
- }
+ findMaxIcingLayer();
+ findMaxTurbcLayer();
- if (ICING_MAP.get(intensity).intValue() > rank) {
- rank = ICING_MAP.get(intensity).intValue();
- iceIntensity = intensity;
- maxPirepLayerData = layer;
- }
+ String[] retData = null;
+ if ("ICI".matches(paramName)) {
+ if (maxIcingLayerData != null) {
+ String intensity = getIntensity(maxIcingLayerData);
+ if (intensity != null) {
+ retData = new String[] { intensity };
}
}
- if (iceIntensity != null) {
- String[] maxIntensity = { iceIntensity };
- return maxIntensity;
- } else {
- display = false;
- }
- } else if ("ICT".matches(paramName) && maxPirepLayerData != null) {
- if (maxPirepLayerData == null) {
- findMaxTurbcLayer();
- }
- if (maxPirepLayerData != null) {
- String type = maxPirepLayerData.getDataType();
+ } else if ("ICT".matches(paramName) && maxIcingLayerData != null) {
+ if (maxIcingLayerData != null) {
+ String type = maxIcingLayerData.getDataType();
if (type != null) {
- return new String[] { type, };
+ retData = new String[] { type, };
}
}
} else if ("TBI".matches(paramName)) {
- if (maxPirepLayerData == null) {
- findMaxTurbcLayer();
- }
- if (maxPirepLayerData != null) {
- String intensity = getIntensity(maxPirepLayerData);
+ if (maxTurbcLayerData != null) {
+ String intensity = getIntensity(maxTurbcLayerData);
if (intensity != null) {
- return new String[] { intensity, };
+ retData = new String[] { intensity };
}
}
} else if ("TBF".matches(paramName)) {
- if (maxPirepLayerData == null) {
- findMaxTurbcLayer();
- }
- if (maxPirepLayerData != null) {
- String freq = maxPirepLayerData.getFrequency();
+ findMaxTurbcLayer();
+ if (maxTurbcLayerData != null) {
+ String freq = maxTurbcLayerData.getFrequency();
if (freq != null) {
- return new String[] { freq, };
+ retData = new String[] { freq, };
}
}
}
- return null;
+ return retData;
+ }
+
+ private void findMaxIcingLayer() {
+ if (maxIcingLayerData == null) {
+ int rank = -1;
+ for (PirepLayerData layer : this.ancPirepData) {
+ if (layer.getLayerType().equals(PirepLayerData.LAYER_TYP_ICING)) {
+ String intensity = getIntensity(layer);
+ Integer n = ICING_MAP.get(intensity);
+ if ((n != null) && (n > rank)) {
+ rank = n;
+ maxIcingLayerData = layer;
+ }
+ }
+ }
+ if (maxIcingLayerData != null) {
+ display = (getIntensity(maxIcingLayerData) != null);
+ } else {
+ display = false;
+ }
+ }
}
/**
* Find a turbulence layer with the greatest ordinal intensity.
*/
private void findMaxTurbcLayer() {
- int rank = -1;
- for (PirepLayerData layer : this.ancPirepData) {
- if (PirepLayerData.LAYER_TYP_TURBC.equals(layer.getLayerType())) {
- String intensity = getIntensity(layer);
- if (TURB_MAP.containsKey(intensity)) {
- if (TURB_MAP.get(intensity).intValue() > rank) {
- rank = TURB_MAP.get(intensity).intValue();
- maxPirepLayerData = layer;
+ if (maxTurbcLayerData == null) {
+ int rank = -1;
+ for (PirepLayerData layer : this.ancPirepData) {
+ if (PirepLayerData.LAYER_TYP_TURBC.equals(layer.getLayerType())) {
+ String intensity = getIntensity(layer);
+ Integer n = TURB_MAP.get(intensity);
+ if ((n != null) && (n > rank)) {
+ rank = n;
+ maxTurbcLayerData = layer;
}
}
}
+ if (maxTurbcLayerData != null) {
+ display = (getIntensity(maxTurbcLayerData) != null);
+ } else {
+ display = false;
+ }
}
}
@@ -788,36 +800,4 @@ public class PirepRecord extends PluginDataObject implements ISpatialEnabled,
return false;
return true;
}
-
- public static final void main(String[] args) {
-
- PirepRecord rec = new PirepRecord();
-
- PirepLayerData layer = new PirepLayerData(rec);
- layer.setLayerType(PirepLayerData.LAYER_TYP_TURBC);
- layer.setFrequency("OCN");
- layer.setFirstValue("LGT");
- layer.setSecondValue("MOD");
- layer.setBaseLayerHeight(15000);
- layer.setTopLayerHeight(20000);
- rec.addLayer(layer);
-
- layer = new PirepLayerData(rec);
- layer.setLayerType(PirepLayerData.LAYER_TYP_TURBC);
- layer.setFrequency("CON");
- layer.setFirstValue("MOD");
- layer.setSecondValue("SEV");
- layer.setBaseLayerHeight(20000);
- layer.setTopLayerHeight(22000);
- rec.addLayer(layer);
-
- String[] data = rec.getStrings("TBF");
- if ((data != null) && (data.length > 0)) {
- System.out.println(data[0]);
- }
- data = rec.getStrings("TBI");
- if ((data != null) && (data.length > 0)) {
- System.out.println(data[0]);
- }
- }
}
\ No newline at end of file
diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/util/PythonFileGenerator.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/util/PythonFileGenerator.java
index 01808f374a..5b62498371 100644
--- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/util/PythonFileGenerator.java
+++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/util/PythonFileGenerator.java
@@ -45,6 +45,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 14, 2010 njensen Initial creation
+ * Jul 31, 2012 #965 dgilling Fix path to file header.
*
*
*
@@ -319,7 +320,8 @@ public class PythonFileGenerator {
}
public static String getHeaderInfo() throws IOException {
- File file = new File("../build.cave/tools/headup/AWIPS/awipsHeader.txt");
+ File file = new File(
+ "../../cave/build/tools/headup/AWIPS/awipsHeader.txt");
if (!file.exists()) {
System.out
.println("Unable to determine header information, skipping header");
diff --git a/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/requests/GetActiveSitesRequest.java b/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/requests/GetActiveSitesRequest.java
index ba45fcb234..ab56dbd594 100644
--- a/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/requests/GetActiveSitesRequest.java
+++ b/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/requests/GetActiveSitesRequest.java
@@ -20,7 +20,6 @@
package com.raytheon.uf.common.site.requests;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
-import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
/**
@@ -32,7 +31,8 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Aug 5, 2011 randerso Initial creation
+ * Aug 05, 2011 randerso Initial creation
+ * Jul 31, 2012 #965 dgilling Remove unnecessary code.
*
*
*
@@ -42,25 +42,5 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
@DynamicSerialize
public class GetActiveSitesRequest implements IServerRequest {
- @DynamicSerializeElement
- private String[] activeSites;
-
- public GetActiveSitesRequest() {
- }
-
- /**
- * @return the activeSites
- */
- public String[] getActiveSites() {
- return activeSites;
- }
-
- /**
- * @param activeSites
- * the activeSites to set
- */
- public void setActiveSites(String[] activeSites) {
- this.activeSites = activeSites;
- }
-
+ // No fields needed
}
diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/res/spring/ffmp-ingest.xml b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/res/spring/ffmp-ingest.xml
index 278c919249..7e563040f4 100644
--- a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/res/spring/ffmp-ingest.xml
+++ b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/res/spring/ffmp-ingest.xml
@@ -8,13 +8,20 @@
-
-
+
+
+
+
+
+
+
+
@@ -35,9 +42,4 @@
-
-
-
-
\ No newline at end of file
diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPGenerator.java b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPGenerator.java
index 53fabfb6bd..19f24a5ee3 100644
--- a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPGenerator.java
+++ b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPGenerator.java
@@ -103,6 +103,7 @@ import com.raytheon.uf.edex.plugin.ffmp.common.FFTIProcessor;
* ------------ ---------- ----------- --------------------------
* 06/21/2009 2521 dhladky Initial Creation.
* 02/03/2011 6500 cjeanbap Fixed NullPointerException.
+ * 07/31/2011 578 dhladky FFTI modifications
*
*
* @author dhladky
@@ -110,1491 +111,1805 @@ import com.raytheon.uf.edex.plugin.ffmp.common.FFTIProcessor;
*/
public class FFMPGenerator extends CompositeProductGenerator implements
- MonitorConfigListener {
- private static final transient IUFStatusHandler statusHandler = UFStatus
- .getHandler(FFMPGenerator.class);
+ MonitorConfigListener {
+ private static final transient IUFStatusHandler statusHandler = UFStatus
+ .getHandler(FFMPGenerator.class);
- /**
- * Public constructor for FFMPGenerator
- *
- * @param name
- * @param compositeProductType
- */
- public FFMPGenerator(Executor executor) {
+ /**
+ * Public constructor for FFMPGenerator
+ *
+ * @param name
+ * @param compositeProductType
+ */
+ public FFMPGenerator(Executor executor, Executor processexecutor) {
- super(genName, productType, executor);
- }
+ super(genName, productType, executor);
+ this.processexecutor = processexecutor;
+ }
- /** writer thread executor **/
- public Executor writerExecutor = null;
+ private static final String genName = "FFMP";
- private static final String genName = "FFMP";
+ private static final String templateTaskName = "FFMP Template";
- private static final String templateTaskName = "FFMP Template";
+ private static final String productType = "ffmp";
- private static final String productType = "ffmp";
+ /** ArrayList of domains to filter for */
+ private ArrayList domains = null;
- /** ArrayList of domains to filter for */
- private ArrayList domains = null;
+ /** template loader bool **/
+ public boolean loaded = false;
- /** template loader bool **/
- public boolean loaded = false;
+ /** check ffg first time you run **/
+ public boolean ffgCheck = false;
- /** check ffg first time you run **/
- public boolean ffgCheck = false;
-
- /** ffti finished processing **/
- public boolean fftiDone = true;
-
- /** products **/
- private ConcurrentHashMap products = null;
-
- /** Processes map **/
- private ConcurrentHashMap processes = null;
-
- /** array list of sources to evaluate **/
- public ArrayList fftiSources = new ArrayList();
-
- /** run configuration manager **/
- public FFMPRunConfigurationManager frcm = null;
-
- /** source configuration manager **/
- public FFMPSourceConfigurationManager fscm = null;
-
- /** temp cache **/
- public ConcurrentHashMap ffmpData = new ConcurrentHashMap();
-
- /** FFTI accum/ratio/diff cache **/
- public ConcurrentHashMap fftiData = new ConcurrentHashMap();
-
- /** checks for initial load **/
- public ArrayList loadedData = new ArrayList();
-
- /** template config manager **/
- public FFMPTemplateConfigurationManager tempConfig = null;
-
- /** FFMPConfig object **/
- public FFMPConfig config = null;
-
- /** template **/
- public FFMPTemplates template = null;
-
- private IPathManager pathManager;
-
- public static String sharePath = AppsDefaults.getInstance().getToken(
- "apps_dir")
- + File.separator + "ffmp" + File.separator;
-
- /** source bins used for finding basin to data correlations **/
- private HashMap sourceBins = new HashMap();
-
- @Override
- protected void configureFilters() {
-
- this.pathManager = PathManagerFactory.getPathManager();
-
- statusHandler.handle(Priority.DEBUG, getGeneratorName()
- + " process Filter Config...");
- domains = new ArrayList();
- boolean configValid = getRunConfig().isPopulated();
-
- if (configValid) {
- for (FFMPRunXML run : getRunConfig().getFFMPRunners()) {
- domains = run.getDomains();
- }
- } else {
-
- /**
- * Don't have one, so create an EDEX generated default
- */
- LocalizationContext commonStaticSite = pathManager.getContext(
- LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
-
- List sites = RadarsInUseUtil.getSite(null,
- RadarsInUseUtil.LOCAL_CONSTANT);
-
- FFMPRunXML runner = new FFMPRunXML();
- ArrayList products = new ArrayList();
- // these two are always there in default setups
- ProductRunXML hpeProduct = new ProductRunXML();
- hpeProduct.setProductName("DHRMOSAIC");
- hpeProduct.setProductKey("hpe");
- products.add(hpeProduct);
-
- ProductRunXML biasHpeProduct = new ProductRunXML();
- biasHpeProduct.setProductName("BDHRMOSAIC");
- biasHpeProduct.setProductKey("bhpe");
- products.add(biasHpeProduct);
-
- ArrayList rfc = new ArrayList();
-
- if (sites.isEmpty()) {
- RadarStationDao dao = new RadarStationDao();
- List stations = null;
- try {
- stations = dao.queryByWfo(PropertiesFactory.getInstance()
- .getEnvProperties().getEnvValue("SITENAME"));
- } catch (DataAccessLayerException e) {
- statusHandler
- .handle(Priority.ERROR,
- "Unable to access data object for radar station table");
- }
-
- for (RadarStation station : stations) {
- // this is just for a default
- ProductRunXML dhrProduct = new ProductRunXML();
- dhrProduct.setProductName("DHR");
- dhrProduct.setProductKey(station.getRdaId().toLowerCase());
- products.add(dhrProduct);
-
- String newRfc = FFMPUtils
- .getRFC(dhrProduct.getProductKey());
- if (!rfc.contains(newRfc)) {
- rfc.add(newRfc);
- }
-
- sites.add(station.getRdaId().toLowerCase());
- }
-
- } else {
- for (String site : sites) {
- // this is just for a default
- ProductRunXML dhrProduct = new ProductRunXML();
- dhrProduct.setProductName("DHR");
- dhrProduct.setProductKey(site);
- products.add(dhrProduct);
-
- String newRfc = FFMPUtils
- .getRFC(dhrProduct.getProductKey());
- if (!rfc.contains(newRfc)) {
- rfc.add(newRfc);
- }
- }
- }
-
- runner.setProducts(products);
-
- // Apply site list to all QPE types
- for (String source : getSourceConfig().getQPESources()) {
- SourceXML qpeSource = getSourceConfig().getSource(source);
- // Radar Derived sources use the primary source site keys for
- // mosiac datakey
- // Auto Config for any Radar derived sources
- if (qpeSource.getDataType().equals(
- DATA_TYPE.RADAR.getDataType())) {
- SourceIngestConfigXML sicm = new SourceIngestConfigXML();
- sicm.setSourceName(qpeSource.getSourceName());
- sicm.setUriSubLocation(3);
-
- for (String siteid : sites) {
- sicm.addDataKey(siteid);
- }
-
- runner.addSourceIngest(sicm);
- }
- }
-
- // We have a list of available RFC's, now find mosaic
- // Apply this to all RFCFFG sources
- for (String source : getSourceConfig().getGuidances()) {
- SourceXML guidSource = getSourceConfig().getSource(source);
-
- // Auto config for RFC sources
- if (guidSource.isRfc()) {
- // add a source mosaic config to the Run Config
- SourceIngestConfigXML sicm = new SourceIngestConfigXML();
- sicm.setSourceName(guidSource.getSourceName());
- sicm.setUriSubLocation(3);
-
- for (String dataKey : rfc) {
- sicm.addDataKey(dataKey);
- }
-
- runner.addSourceIngest(sicm);
- }
- }
-
- // Apply site list to all SCANQPF default
- for (String source : getSourceConfig().getQPFSources()) {
- SourceXML qpfSource = getSourceConfig().getSource(source);
- // Radar Derived sources use the primary source site keys for
- // mosiac datakey
- // Auto Config for any Radar derived sources (QPFSCAN) for
- // example
- if (qpfSource.getSourceName().equals("QPFSCAN")) {
- SourceIngestConfigXML sicm = new SourceIngestConfigXML();
- sicm.setSourceName(qpfSource.getSourceName());
- sicm.setUriSubLocation(3);
-
- for (String siteid : sites) {
- sicm.addDataKey(siteid);
- }
-
- runner.addSourceIngest(sicm);
- }
- }
-
- DomainXML domain = new DomainXML();
- domain.setPrimary(true);
- domain.setCwa(commonStaticSite.getContextName());
- runner.addDomain(domain);
-
- getRunConfig().addFFMPRunner(runner);
- getRunConfig().saveConfigXml();
- getRunConfig().setPopulated(true);
-
- domains.add(domain);
- }
-
- // kick off template generation
- this.getExecutor().execute(new TemplateLoader(domains));
- }
-
- @Override
- protected void createFilters() {
- // do more here if you wish
-
- ArrayList runners = getRunConfig().getFFMPRunners();
- ArrayList tmp = new ArrayList(
- runners.size());
-
- for (FFMPRunXML runner : runners) {
- DomainXML domain = runner.getPrimaryDomain();
- try {
- tmp.add(new FFMPURIFilter(getSiteString(runner) + ":"
- + getRFCString(runner) + ":" + domain.getCwa()));
-
- statusHandler.handle(Priority.INFO, "Created FFMP Filter.."
- + " primary Domain: " + domain.getCwa());
- } catch (Exception e) {
- statusHandler.handle(Priority.PROBLEM,
- "Couldn't create FFMP Filter.." + " primary Domain: "
- + domain.getCwa()
- + " this RUNNER is not a viable FFMP config.");
- e.printStackTrace();
- }
- }
-
- filters = tmp.toArray(new URIFilter[tmp.size()]);
-
- }
-
- /**
- * Slight difference in the way ffmp operates as opposed to the URIFilter in
- * general.
- */
- @Override
- public void matchURIs(DataURINotificationMessage messages) {
-
- if (messages instanceof DataURINotificationMessage) {
- URIFilter[] filters = getFilters();
- if (filters != null) {
- for (int i = 0; i < filters.length; i++) {
- if (filters[i] != null) {
- FFMPURIFilter filter = (FFMPURIFilter) filters[i];
-
- if (loaded) {
-
- synchronized (filter) {
-
- if (filter.isMatched(messages)) {
-
- if (!ffgCheck) {
-
- filter = getFFG(filter);
- filter.setValidTime(filter
- .getCurrentTime());
- ffgCheck = true;
- }
-
- dispatch(filter);
- }
- }
- } else {
- statusHandler
- .debug(getGeneratorName()
- + ": templates not loaded yet. Skipping product");
- }
- }
- }
- }
- }
- }
-
- @Override
- public void generateProduct(URIGenerateMessage genMessage) {
- if (loaded) {
- try {
- long time = System.currentTimeMillis();
- this.config = new FFMPConfig(
- (FFMPURIGenerateMessage) genMessage, this);
- products = new ConcurrentHashMap();
- processes = new ConcurrentHashMap();
- // read config updates, make sure we don't miss something
- getRunConfig().readConfigXml();
- getSourceConfig().readConfigXml();
-
- if (config.getSources() != null) {
- for (String source : config.getSources().keySet()) {
- processes.put(source,
- getSourceConfig().getSource(source));
- }
- }
-
- // start threads
-
- for (String source : processes.keySet()) {
- this.getExecutor().execute(
- new ProcessProduct(processes.get(source), this));
- }
-
- // count down latch
- while (processes.size() > 0) {
- // wait for all threads to finish before returning
- try {
- Thread.sleep(100);
- statusHandler.handle(Priority.DEBUG,
- "Checking status ..." + processes.size());
- for (String source : processes.keySet()) {
- statusHandler.handle(Priority.DEBUG,
- "Still processing ..." + source);
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- if (products.size() > 0) {
-
- // Do the FFTI evaluation, if we have FFTI sources
- if (fftiSources.size() > 0) {
- this.getExecutor().execute(new FFTI(this));
- }
-
- ArrayList records = new ArrayList(
- products.size());
- for (String source : products.keySet()) {
- for (FFMPRecord rec : products.get(source)) {
- records.add(rec);
- }
- }
-
- FFMPRecord[] recs = new FFMPRecord[records.size()];
- for (int i = 0; i < records.size(); i++) {
- recs[i] = records.get(i);
- }
-
- this.setPluginDataObjects(recs);
- this.setPluginDao(new FFMPDao(getCompositeProductType(),
- template, fscm, config.getCWA()));
-
- while (fftiSources.size() > 0) {
- try {
- Thread.sleep(100);
- statusHandler.handle(Priority.DEBUG,
- "Checking status ..." + fftiDone);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- statusHandler.handle(
- Priority.INFO,
- config.getCWA() + " finished, duration: "
- + (System.currentTimeMillis() - time)
- + " ms, wrote " + records.size() + " ");
-
- } else {
- statusHandler.handle(Priority.INFO, config.getCWA()
- + " no new products to produce.");
- }
- // dump data we don't need anymore
- ffmpData.clear();
-
- } catch (Throwable e) {
- statusHandler.handle(Priority.ERROR,
- "Unable to process FFMP Records.");
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Get the list of domains
- *
- * @return
- */
- public ArrayList getDomains() {
- return domains;
- }
-
- /**
- * Add a filtering CWA
- *
- * @param domain
- */
- public void addDomain(DomainXML domain) {
- domains.add(domain);
- }
-
- @Override
- public boolean isRunning() {
- return getConfigManager().getFFMPState();
- }
-
- /**
- * Set list of CWA's
- *
- * @param cwas
- */
- public void setDomains(ArrayList domains) {
- this.domains = domains;
- }
-
- /**
- * Inner class to thread the ffmp processing
- *
- * @author dhladky
- *
- */
- private class ProcessProduct implements Runnable {
-
- SourceXML ffmpProduct;
-
- FFMPGenerator generator;
-
- @Override
- public void run() {
- try {
- logger.debug("ProcessProduct: Starting thread "
- + ffmpProduct.getSourceName());
- process();
- logger.debug("ProcessProduct: Finishing thread "
- + ffmpProduct.getSourceName());
- } catch (Exception e) {
- processes.remove(ffmpProduct.getSourceName());
- logger.error("ProcessProduct: removed "
- + ffmpProduct.getSourceName());
- e.printStackTrace();
- }
- }
-
- public ProcessProduct(SourceXML ffmpProduct, FFMPGenerator generator) {
- this.ffmpProduct = ffmpProduct;
- this.generator = generator;
- }
-
- /**
- * The actual work gets done here
- */
- public void process() throws Exception {
-
- HashMap dataHash = config.getSourceData(ffmpProduct
- .getSourceName());
- ArrayList ffmpRecords = new ArrayList(
- dataHash.size());
-
- FFMPRunXML runner = getRunConfig().getRunner(config.getCWA());
-
- // process all of the dataKeys for this source
- for (String dataKey : dataHash.keySet()) {
-
- ArrayList sites = new ArrayList();
-
- // is it a mosaic?
- if (ffmpProduct.isMosaic()) {
-
- // Take care of defaults, all in this case
- for (ProductRunXML product : runner.getProducts()) {
- // no duplicate keys!
- if (!sites.contains(product.getProductKey())) {
- sites.add(product.getProductKey());
- }
- }
-
- // do filtering
- for (ProductRunXML product : runner.getProducts()) {
- // includes
- if (product.hasIncludes()) {
- for (String includeSourceName : product
- .getIncludes()) {
- if (ffmpProduct.getSourceName().equals(
- includeSourceName)) {
- // no duplicate keys!
- if (!sites
- .contains(product.getProductKey())) {
- sites.add(product.getProductKey());
- }
- }
- }
- }
- // excludes
- if (product.hasExcludes()) {
- for (String excludeSourceName : product
- .getExcludes()) {
- if (ffmpProduct.getSourceName().equals(
- excludeSourceName)) {
- sites.remove(product.getProductKey());
- }
- }
- }
- }
- } else {
- // No mosaic, just individual site run
- String siteKey = dataKey;
-
- // special case for XMRG's
- if (ffmpProduct.getDataType().equals(
- FFMPSourceConfigurationManager.DATA_TYPE.XMRG
- .getDataType())) {
-
- siteKey = null;
- String primarySource = null;
-
- for (ProductXML product : getSourceConfig()
- .getProducts()) {
- if (product.containsSource(ffmpProduct
- .getSourceName())) {
- primarySource = product.getPrimarySource();
- break;
- }
- }
-
- for (ProductRunXML productRun : runner.getProducts()) {
- if (productRun.getProductName().equals(
- primarySource)) {
- siteKey = productRun.getProductKey();
- break;
- }
- }
- }
-
- sites.add(siteKey);
- }
-
- for (String productKey : sites) {
-
- FFMPRecord ffmpRec = new FFMPRecord();
- ffmpRec.setSourceName(ffmpProduct.getSourceName());
- ffmpRec.setDataKey(dataKey);
- ffmpRec.setSiteKey(productKey);
- ffmpRec.setPluginName(getCompositeProductType());
- ffmpRec.setWfo(config.getCWA());
- FFMPProcessor ffmp = new FFMPProcessor(config, generator,
- ffmpRec, template);
- ffmpRec = ffmp.processFFMP(ffmpProduct);
- ffmpRec.constructDataURI();
-
- if (ffmpRec != null) {
-
- // Don't write loader buddy's on long duration
- // sources. Not necessary 6*60 = 360
- if (getSourceConfig()
- .getSource(ffmpRec.getSourceName())
- .getExpirationMinutes(productKey) < 360) {
-
- processDataContainer(ffmpRec);
- }
-
- if (ffmp.isFFTI()) {
- fftiDone = false;
- if (!fftiSources.contains(ffmp.getFFTISource())) {
- FFTIProcessor ffti = new FFTIProcessor(
- generator, ffmpRec,
- ffmp.getFFTISource());
- fftiSources.add(ffmp.getFFTISource());
- ffti.processFFTI();
- }
- }
-
- ffmpRecords.add(ffmpRec);
- }
- }
- }
-
- FFMPRecord[] recs = new FFMPRecord[ffmpRecords.size()];
- for (int i = 0; i < ffmpRecords.size(); i++) {
- recs[i] = ffmpRecords.get(i);
- }
- products.put(ffmpProduct.getSourceName(), recs);
- processes.remove(ffmpProduct.getSourceName());
- }
- }
-
- /**
- * Inner class to background template creation
- *
- * @author dhladky
- *
- */
- private class TemplateLoader implements Runnable {
-
- ArrayList templateDomains;
-
- DomainXML primaryDomain;
-
- @Override
- public void run() {
- statusHandler.handle(Priority.DEBUG, getGeneratorName()
- + " Start loader ");
-
- for (DomainXML domain : templateDomains) {
- if (domain.isPrimary()) {
- primaryDomain = domain;
- }
- }
-
- // generate templates and unify geometries
- loaded = load();
- statusHandler.handle(Priority.DEBUG, getGeneratorName()
- + " Finishing loader ");
- }
-
- public TemplateLoader(ArrayList templateDomains) {
- this.templateDomains = templateDomains;
- }
-
- /**
- *
- * @param domain
- * @return
- */
- public void createUnifiedGeometries(DomainXML domain) {
- ArrayList hucsToGen = new ArrayList();
- hucsToGen.add("ALL");
- hucsToGen.add("COUNTY");
-
- for (int i = template.getTotalHucLevels() - 1; i >= 0; i--) {
- hucsToGen.add("HUC" + i);
- }
-
- for (String huc : hucsToGen) {
- template.verifyUnifiedGeometries(huc, domain.getCwa());
- }
- }
-
- public boolean load() {
- // load / create primary domain
- ClusterTask task = null;
- String lockDetails = getGeneratorName() + ":"
- + primaryDomain.getCwa() + ":" + primaryDomain.getCwa();
- try {
- do {
- task = ClusterLockUtils.lock(templateTaskName, lockDetails,
- 600 * 1000, true);
- } while (task.getLockState() != LockState.SUCCESSFUL);
-
- template = FFMPTemplates.getInstance(primaryDomain, MODE.EDEX);
- // setup the config
- getTemplateConfig();
- createUnifiedGeometries(primaryDomain);
- } finally {
- if ((task != null)
- && (task.getLockState() == LockState.SUCCESSFUL)) {
- ClusterLockUtils.unlock(task, false);
- }
- }
-
- // load the secondary domains
- List domainsToGen = new ArrayList(
- templateDomains);
- while (domainsToGen.size() > 0) {
- Iterator iter = domainsToGen.iterator();
- boolean processedDomain = false;
- while (iter.hasNext()) {
- DomainXML domain = iter.next();
- lockDetails = getGeneratorName() + ":"
- + primaryDomain.getCwa() + ":" + domain.getCwa();
- try {
- task = ClusterLockUtils.lock(templateTaskName,
- lockDetails, 300 * 1000, false);
-
- if (task.getLockState() == LockState.SUCCESSFUL) {
- template.addDomain(domain);
- createUnifiedGeometries(domain);
- iter.remove();
- processedDomain = true;
- }
- } finally {
- if ((task != null)
- && (task.getLockState() == LockState.SUCCESSFUL)) {
- ClusterLockUtils.unlock(task, false);
- }
- }
- }
-
- if (!processedDomain) {
- // Didn't process a domain, locked by another cluster
- // member, sleep and try again
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
-
- }
- }
- }
-
- return template.done;
- }
- }
-
- /**
- * Gets the string buffer for the RFC's
- *
- * @param run
- * @return
- */
- private String getRFCString(FFMPRunXML run) {
- StringBuffer buf = new StringBuffer();
-
- for (SourceIngestConfigXML ingest : run.getSourceIngests()) {
- SourceXML source = FFMPSourceConfigurationManager.getInstance()
- .getSource(ingest.getSourceName());
- if (source.isRfc()) {
- int i = 0;
- for (String dataKey : ingest.getDataKey()) {
- if (i < ingest.getDataKey().size() - 1) {
- buf.append(dataKey + ",");
- } else {
- buf.append(dataKey);
- }
- i++;
- }
- break;
- }
- }
- return buf.toString();
- }
-
- /**
- * Gets the string buffer for the sites, specific to RADAR type data
- *
- * @param run
- * @return
- */
- private String getSiteString(FFMPRunXML run) {
- String sites = null;
- StringBuffer buf = new StringBuffer();
- for (ProductRunXML product : run.getProducts()) {
- SourceXML source = getSourceConfig().getSource(
- product.getProductName());
- if (source.getDataType().equals(DATA_TYPE.RADAR.getDataType())) {
- buf.append(product.getProductKey() + ",");
- }
- }
- sites = buf.toString();
- if (sites.endsWith(",")) {
- sites = sites.substring(0, sites.length() - 1);
- }
- return sites;
- }
-
- /**
- * Write your new SourceBins
- *
- * @param sourceList
- */
- public void writeSourceBins(SourceBinList sourceList) {
-
- try {
- LocalizationContext lc = pathManager.getContext(
- LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
-
- LocalizationFile lflist = pathManager.getLocalizationFile(lc,
- getAbsoluteFileName(sourceList.getSourceId()));
-
- FileUtil.bytes2File(
- SerializationUtil.transformToThrift(sourceList),
- lflist.getFile(), true);
-
- lflist.save();
-
- statusHandler.handle(Priority.INFO, "Wrote FFMP source Bin File: "
- + sourceList.getSourceId());
-
- } catch (SerializationException se) {
- se.printStackTrace();
- } catch (FileNotFoundException fnfe) {
- fnfe.printStackTrace();
- } catch (IOException ioe) {
- ioe.printStackTrace();
- } catch (LocalizationOpFailedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Read out your SourceBins
- *
- * @param sourceId
- * @return
- */
- public SourceBinList readSourceBins(String sourceId) {
-
- SourceBinList sbl = null;
- LocalizationContext lc = pathManager.getContext(
- LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
- LocalizationFile f = pathManager.getLocalizationFile(lc,
- getAbsoluteFileName(sourceId));
-
- try {
- sbl = (SourceBinList) SerializationUtil
- .transformFromThrift(FileUtil.file2bytes(f.getFile(), true));
- } catch (FileNotFoundException fnfe) {
- statusHandler.handle(Priority.ERROR,
- "Unable to locate file " + f.getName());
- } catch (SerializationException se) {
- statusHandler.handle(Priority.ERROR,
- "Unable to read file " + f.getName());
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
-
- return sbl;
- }
-
- /**
- * Gets the completed filename
- *
- * @return
- */
- public String getAbsoluteFileName(String sourceId) {
- return "ffmp" + File.separator + "sources" + File.separator + sourceId
- + ".bin";
- }
-
- /**
- * See if you have one
- *
- * @param sourceId
- * @return
- */
- public boolean isExistingSourceBin(String sourceId) {
- LocalizationContext lc = pathManager.getContext(
- LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
- LocalizationFile f = pathManager.getLocalizationFile(lc,
- getAbsoluteFileName(sourceId));
- return f.exists();
- }
-
- /**
- * Gets the list of bins for that source
- *
- * @param sourceId
- * @return
- */
- public SourceBinList getSourceBinList(String sourceId) {
- SourceBinList sbl = null;
- if (!sourceBins.containsKey(sourceId)) {
- sbl = readSourceBins(sourceId);
- sourceBins.put(sourceId, sbl);
- } else {
- sbl = sourceBins.get(sourceId);
- }
-
- return sbl;
- }
-
- /**
- * Sets the source bins, first time
- *
- * @param sbl
- */
- public void setSourceBinList(SourceBinList sbl) {
- sourceBins.put(sbl.getSourceId(), sbl);
- writeSourceBins(sbl);
- }
-
- /**
- * Do pull strategy on FFG data
- *
- * @param filter
- * @return
- */
- private FFMPURIFilter getFFG(FFMPURIFilter filter) {
-
- ArrayList uris = new ArrayList();
-
- for (String rfc : filter.getRFC()) {
- // get a hash of the sources and their grib ids
- HashMap sources = FFMPUtils.getFFGModelInfo(rfc);
- if (sources != null) {
- if (sources.size() > 0) {
- for (String source : sources.keySet()) {
-
- SourceXML sourceXml = getSourceConfig().getSource(
- source);
-
- if (sourceXml != null) {
-
- String plugin = getSourceConfig().getSource(source)
- .getPlugin();
- uris.add(FFMPUtils.getFFGDataURI(
- sources.get(source), plugin));
- }
- }
- }
- }
- }
- // treat it like a regular uri in the filter.
- if (uris.size() > 0) {
- for (String dataUri : uris) {
- // add your pattern checks to the key
- for (Pattern pattern : filter.getMatchURIs().keySet()) {
- statusHandler.handle(Priority.DEBUG,
- "Pattern: " + pattern.toString() + " Key: "
- + dataUri);
- try {
- if (pattern.matcher(dataUri).find()) {
- // matches one of them, which one?
- String matchKey = filter.getPatternName(pattern);
- // put the sourceName:dataPath key into the sources
- // array list
- filter.getSources().put(matchKey, dataUri);
- }
- } catch (Exception e) {
- statusHandler.handle(
- Priority.ERROR,
- "Unable to locate new FFG file. "
- + pattern.toString());
- }
- }
- }
- }
-
- return filter;
- }
-
- /**
- * get the FFMP data container for this source
- *
- * @param sourceName
- *
- * @return
- */
-
- public FFMPDataContainer getFFMPDataContainer(String siteSourceKey, ArrayList hucs, Date backDate) {
-
- FFMPDataContainer container = ffmpData.get(siteSourceKey);
-
- if (container == null) {
-
- String siteKey = null;
-
- String[] parts = siteSourceKey.split("-");
-
- if (parts.length > 1) {
- siteKey = parts[0];
- }
-
- container = loadFFMPDataContainer(siteSourceKey,
-
- hucs, siteKey,
-
- config.getCWA(), backDate);
-
- if (container != null) {
- ffmpData.put(siteSourceKey, container);
- }
- }
-
- return container;
- }
-
- /*
- * Gets the FFTI sources to be run
- */
- public ArrayList getFFTISources() {
- return fftiSources;
- }
-
- /**
- * source config manager
- *
- * @return
- */
- public FFMPSourceConfigurationManager getSourceConfig() {
- if (fscm == null) {
- fscm = FFMPSourceConfigurationManager.getInstance();
- fscm.addListener(this);
- }
- return fscm;
- }
-
- /**
- * run config manager
- *
- * @return
- */
- public FFMPRunConfigurationManager getRunConfig() {
- if (frcm == null) {
- frcm = FFMPRunConfigurationManager.getInstance();
- frcm.addListener(this);
- }
- return frcm;
- }
-
- /**
- * Template config manager
- *
- * @return
- */
- public FFMPTemplateConfigurationManager getTemplateConfig() {
- if (tempConfig == null) {
- tempConfig = FFMPTemplateConfigurationManager.getInstance();
- tempConfig.addListener(this);
- }
- return tempConfig;
- }
-
- /**
- * dispatch a filter for processing
- *
- * @param filter
- */
- private void dispatch(FFMPURIFilter filter) {
-
- try {
- EDEXUtil.getMessageProducer().sendAsync(
- routeId,
- SerializationUtil.transformToThrift(filter
- .createGenerateMessage()));
- } catch (Exception e) {
- statusHandler.handle(Priority.ERROR, getGeneratorName()
- + ": filter: " + filter.getName()
- + ": failed to route filter to generator", e);
- e.printStackTrace();
- }
-
- filter.setValidTime(new Date(System.currentTimeMillis()));
- filter.reset();
- }
-
- /**
- * FFMP buddy loader
- *
- * @param ffmpRec
- * @param siteKey
- */
- private void processDataContainer(FFMPRecord ffmpRec) {
-
- // write out the fast loader buddy file
- SourceXML source = getSourceConfig().getSource(ffmpRec.getSourceName());
- String sourceName = null;
- String dataKey = null;
-
- if (source.getSourceType().equals(SOURCE_TYPE.GUIDANCE.getSourceType())) {
- sourceName = source.getDisplayName();
- dataKey = SOURCE_TYPE.GUIDANCE.getSourceType();
- } else {
- sourceName = ffmpRec.getSourceName();
- dataKey = ffmpRec.getDataKey();
- }
-
- String sourceSiteDataKey = sourceName + "-" + ffmpRec.getSiteKey()
- + "-" + dataKey;
-
- // Make a 6 hour "Buddy" loader file
- Date backDate = new Date(ffmpRec.getDataTime().getRefTime().getTime()
- - (3600 * 1000 * 6));
-
- ArrayList hucs = template.getTemplateMgr().getHucLevels();
-
- if (source.getSourceType().equals(SOURCE_TYPE.GAGE.getSourceType())) {
- hucs.clear();
- hucs.add("ALL");
- } else {
- hucs.remove("VIRTUAL");
- }
-
- // pull from disk if there
- FFMPDataContainer fdc = loadFFMPDataContainer(sourceSiteDataKey,
- hucs, ffmpRec.getSiteKey(),
- ffmpRec.getWfo(), backDate);
-
- // brand new or initial load up
- if (fdc == null || !loadedData.contains(sourceSiteDataKey)) {
-
- long time = System.currentTimeMillis();
- fdc = new FFMPDataContainer(sourceSiteDataKey, hucs);
- fdc = FFTIProcessor.populateDataContainer(fdc, template, hucs, backDate, ffmpRec.getDataTime()
- .getRefTime(), ffmpRec.getWfo(), source, ffmpRec.getSiteKey());
- loadedData.add(sourceSiteDataKey);
- long time2 = System.currentTimeMillis();
- statusHandler.handle(Priority.INFO,
- "Populated new source: in " + (time2 - time)
- + " ms: source: " + sourceSiteDataKey);
-
- } else {
- // guidance sources are treated as a mosaic and are handled differently
- // This is the main line sequence a source will take when updated.
- if (!source.getSourceType().equals(
- SOURCE_TYPE.GUIDANCE.getSourceType())) {
-
- long time = System.currentTimeMillis();
- Date newDate = fdc.getNewest();
- Date oldDate = fdc.getOldest();
-
- if (newDate != null && oldDate != null) {
- if ((ffmpRec.getDataTime().getRefTime().getTime() - newDate
- .getTime()) >= (source.getExpirationMinutes(ffmpRec
- .getSiteKey()) * 60 * 1000)) {
- // force a re-query back to the newest time in
- // existing source container, this will fill in gaps if
- // they exist.
- fdc = FFTIProcessor.populateDataContainer(fdc,
- template, null, newDate, ffmpRec.getDataTime()
- .getRefTime(), ffmpRec.getWfo(),
- source, ffmpRec.getSiteKey());
-
- } else if (oldDate.after(new Date(
- backDate.getTime()
- - (source.getExpirationMinutes(ffmpRec
- .getSiteKey()) * 60 * 1000)))) {
- // force a re-query back to barrierTime for
- // existing source container, this happens if the
- // ingest was turned off for some period of time.
- fdc = FFTIProcessor.populateDataContainer(fdc,
- template, null, backDate, oldDate,
- ffmpRec.getWfo(), source, ffmpRec.getSiteKey());
- }
- }
- long time2 = System.currentTimeMillis();
- statusHandler.handle(Priority.INFO,
- "Checked Source files: in " + (time2 - time)
- + " ms: source: " + sourceSiteDataKey);
-
- // purge it up
- fdc.purge(backDate);
- }
- }
-
- // add current record data
- for (String huc : ffmpRec.getBasinsMap().keySet()) {
- fdc.addFFMPEntry(ffmpRec.getDataTime().getRefTime(), source,
- ffmpRec.getBasinData(huc), huc, ffmpRec.getSiteKey());
- }
-
- // set the name
- fdc.setFilePath("" + sharePath + ffmpRec.getWfo() + "/"+ sourceSiteDataKey);
- // cache it temporarily for FFTI use
- ffmpData.put(sourceSiteDataKey, fdc);
- // write it out
- writeLoaderBuddyFiles(fdc);
- }
-
- /**
- * load existing container
- *
- * @param sourceSiteDataKey
- * @param hucs
- * @param siteKey
- * @param wfo
- * @return
- */
- public FFMPDataContainer loadFFMPDataContainer(String sourceSiteDataKey,
- ArrayList hucs, String siteKey, String wfo, Date backDate) {
-
- long time = System.currentTimeMillis();
- FFMPDataContainer fdc = null;
-
- for (String huc : hucs) {
-
- FFMPBasinData basinData = null;
-
- if (checkBuddyFile(sourceSiteDataKey, huc, wfo, backDate)) {
- basinData = readLoaderBuddyFile(sourceSiteDataKey, huc, wfo,
- backDate);
-
- if (fdc == null) {
- fdc = new FFMPDataContainer(sourceSiteDataKey, hucs);
- }
- }
-
- if (basinData != null) {
- fdc.setBasinBuddyData(basinData, huc);
- }
- }
-
- if (fdc != null) {
- long time2 = System.currentTimeMillis();
- statusHandler.handle(Priority.DEBUG, "Loaded Source files: in "
- + (time2 - time) + " ms: source: " + sourceSiteDataKey);
- }
-
- return fdc;
- }
-
- /**
- * Load existing buddy file
- *
- * @param sourceSiteDataKey
- * @param huc
- * @param wfo
- * @return
- */
- private FFMPBasinData readLoaderBuddyFile(String sourceSiteDataKey,
- String huc, String wfo, Date backDate) {
-
- File file = new File(sharePath + wfo + "/" + sourceSiteDataKey + "-"
- + huc + ".bin");
- FFMPBasinData basinData = null;
-
- try {
- BufferedInputStream is = new BufferedInputStream(
- new FileInputStream(file));
- DynamicSerializationManager dsm = DynamicSerializationManager
- .getManager(SerializationType.Thrift);
- basinData = (FFMPBasinData) dsm.deserialize(is);
- is.close();
- } catch (SerializationException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return basinData;
-
- }
-
- /**
- * Write buddy file
- *
- * @param sourceSiteDataKey
- * @param huc
- * @param wfo
- * @return
- */
- public void writeLoaderBuddyFiles(FFMPDataContainer fdc) {
-
- // Write all huc levels in separate files
- File fileDir = new File("" + sharePath + config.getCWA());
- if (!fileDir.exists()) {
- fileDir.mkdir();
- }
-
- WriteFiles writer = new WriteFiles(fdc);
- writer.run();
- }
-
- /**
- * Inner class to thread writing of BuddyFiles
- *
- * @author dhladky
- *
- */
- private class WriteFiles implements Runnable {
-
- private FFMPDataContainer fdc;
-
- public void run() {
- try {
- long time = System.currentTimeMillis();
- write();
- long time2 = System.currentTimeMillis();
- statusHandler.handle(Priority.DEBUG,
- "Wrote loader files: in " + (time2 - time)
- + " ms");
- } catch (Exception e) {
- statusHandler.handle(Priority.ERROR,
- "WriteFile: removed " + e.getMessage());
- }
- }
-
- public WriteFiles(FFMPDataContainer fdc) {
- this.fdc = fdc;
- statusHandler.handle(Priority.DEBUG, "Created FileWriter");
- }
-
- /**
- * The actual work gets done here
- */
- public void write() throws Exception {
-
- try {
-
- String fileName = fdc.getFilePath();
- // lock for atomic write and read
- HashMap fileNames = new HashMap();
- File lockfile = new File(fileName + ".lock");
- lockfile.createNewFile();
-
- try {
-
- for (String huc : fdc.getKeys()) {
-
- FFMPBasinData fbd = fdc.getBasinData(huc);
-
- if (fbd.getBasins().size() > 0) {
-
- String tmpFilePath = fileName + "-" + huc + ".tmp";
- fileNames.put(tmpFilePath, fileName + "-" + huc
- + ".bin");
- BufferedOutputStream os = null;
-
- try {
- File file = new File(tmpFilePath);
- os = new BufferedOutputStream(
- new FileOutputStream(file));
- DynamicSerializationManager dsm = DynamicSerializationManager
- .getManager(SerializationType.Thrift);
- dsm.serialize(fbd, os);
- } catch (SerializationException e) {
- statusHandler.handle(Priority.ERROR,
- "Serialization Error Writing buddy file: "
- + e.getMessage());
- } catch (IOException e) {
- statusHandler.handle(
- Priority.ERROR,
- "IO Error Writing buddy file: "
- + e.getMessage());
- } finally {
- if (os != null) {
- os.close();
- }
- }
- }
- }
- } catch (Exception e) {
- statusHandler
- .handle(Priority.ERROR,
- "Error writing Buddy File group: "
- + e.getMessage());
- } finally {
- // rename the files to real path
- try {
- for (String tmpName : fileNames.keySet()) {
- File file = new File(tmpName);
- file.renameTo(new File(fileNames.get(tmpName)));
- }
-
- lockfile.delete();
-
- } catch (Exception e) {
- statusHandler.handle(
- Priority.ERROR,
- "IO Error Renaming buddy file: "
- + e.getMessage());
- }
- }
-
- } catch (Exception e) {
- statusHandler.handle(Priority.ERROR,
- "IO Error writing buddy files: " + e.getMessage());
- }
- }
- }
-
- /**
- * Load existing buddy file
- *
- * @param sourceSiteDataKey
- * @param huc
- * @param wfo
- * @return
- */
- public boolean checkBuddyFile(String sourceSiteDataKey, String huc,
- String wfo, Date backDate) {
-
- File file = new File(sharePath + wfo + "/" + sourceSiteDataKey + "-"
- + huc + ".bin");
-
- if (file.exists() && (file.lastModified() > backDate.getTime())) {
- // System.out.println("File update and exists..."+sourceSiteDataKey);
- return true;
- }
-
- return false;
-
- }
-
- @Override
- public synchronized void configChanged(MonitorConfigEvent fce) {
-
- boolean reload = false;
-
- if (fce.getSource() instanceof FFMPTemplateConfigurationManager) {
- statusHandler
- .handle(Priority.INFO,
- "Re-configuring FFMP & URI filters...Template Config change");
- reload = true;
- FFMPTemplateConfigurationManager ftcm = (FFMPTemplateConfigurationManager) fce
- .getSource();
- if (ftcm.isRegenerate()) {
- template.dumpTemplates();
- }
-
- tempConfig = null;
-
- } else if (fce.getSource() instanceof FFMPRunConfigurationManager) {
- statusHandler.handle(Priority.INFO,
- "Re-configuring FFMP & URI filters...Run Config change");
- reload = true;
- frcm = null;
- }
-
- else if (fce.getSource() instanceof FFMPSourceConfigurationManager) {
- statusHandler.handle(Priority.INFO,
- "Re-configuring FFMP & URI filters...Source Config change");
- reload = true;
- fscm = null;
- }
-
- if (reload) {
-
- ffgCheck = false;
- resetFilters();
-
- if (sourceBins != null) {
- sourceBins.clear();
- }
-
- loadedData.clear();
-
- DatMenuUtil dmu = new DatMenuUtil();
- dmu.setDatSite(PropertiesFactory.getInstance().getEnvProperties()
- .getEnvValue("SITENAME"));
- dmu.setOverride(true);
- dmu.createMenus();
- }
- }
-
- /**
- * FFTI data cache
- * @param ffti
- */
- public void addFFTIData(String fftiName, FFTIData ffti) {
- if (fftiData.containsKey(fftiName)) {
- fftiData.replace(fftiName, ffti);
- } else {
- fftiData.put(fftiName, ffti);
- }
- }
-
- /**
- * Get FFTI data cache
- * @param fftiName
- * @return
- */
- public FFTIData getFFTIData(String fftiName) {
- return fftiData.get(fftiName);
- }
-
- /**
- * Check existence
- * @param fftiName
- * @return
- */
- public boolean isFFTI(String fftiName) {
- return fftiData.containsKey(fftiName);
- }
-
- /**
- * get the whole container
- * @return
- */
- public ConcurrentHashMap getFFTIDataContainer() {
- return fftiData;
- }
-
-}
\ No newline at end of file
+ /** ffti finished processing **/
+ public boolean fftiDone = true;
+
+ /** products **/
+ private ConcurrentHashMap products = null;
+
+ /** Processes map **/
+ private ConcurrentHashMap processes = null;
+
+ /** array list of sources to evaluate **/
+ public ArrayList fftiSources = new ArrayList();
+
+ /** run configuration manager **/
+ public FFMPRunConfigurationManager frcm = null;
+
+ /** source configuration manager **/
+ public FFMPSourceConfigurationManager fscm = null;
+
+ /** temp cache **/
+ public ConcurrentHashMap ffmpData = new ConcurrentHashMap();
+
+ /** FFTI accum/ratio/diff cache **/
+ public ConcurrentHashMap fftiData = new ConcurrentHashMap();
+
+ /** checks for initial load **/
+ public ArrayList loadedData = new ArrayList();
+
+ /** thread the productkeys **/
+ public HashMap> productKeys = new HashMap>();
+
+ /** template config manager **/
+ public FFMPTemplateConfigurationManager tempConfig = null;
+
+ /** FFMPConfig object **/
+ public FFMPConfig config = null;
+
+ /** template **/
+ public FFMPTemplates template = null;
+
+ private IPathManager pathManager;
+
+ public static String sharePath = AppsDefaults.getInstance().getToken(
+ "apps_dir")
+ + File.separator + "ffmp" + File.separator;
+
+ /** source bins used for finding basin to data correlations **/
+ private HashMap sourceBins = new HashMap();
+
+ /** thread executor **/
+ public Executor processexecutor = null;
+
+ @Override
+ protected void configureFilters() {
+
+ this.pathManager = PathManagerFactory.getPathManager();
+
+ statusHandler.handle(Priority.DEBUG, getGeneratorName()
+ + " process Filter Config...");
+ domains = new ArrayList();
+ boolean configValid = getRunConfig().isPopulated();
+
+ if (configValid) {
+ for (FFMPRunXML run : getRunConfig().getFFMPRunners()) {
+ domains = run.getDomains();
+ }
+ } else {
+
+ /**
+ * Don't have one, so create an EDEX generated default
+ */
+ LocalizationContext commonStaticSite = pathManager.getContext(
+ LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
+
+ List sites = RadarsInUseUtil.getSite(null,
+ RadarsInUseUtil.LOCAL_CONSTANT);
+
+ FFMPRunXML runner = new FFMPRunXML();
+ ArrayList products = new ArrayList();
+ // these two are always there in default setups
+ ProductRunXML hpeProduct = new ProductRunXML();
+ hpeProduct.setProductName("DHRMOSAIC");
+ hpeProduct.setProductKey("hpe");
+ products.add(hpeProduct);
+
+ ProductRunXML biasHpeProduct = new ProductRunXML();
+ biasHpeProduct.setProductName("BDHRMOSAIC");
+ biasHpeProduct.setProductKey("bhpe");
+ products.add(biasHpeProduct);
+
+ ArrayList rfc = new ArrayList();
+
+ if (sites.isEmpty()) {
+ RadarStationDao dao = new RadarStationDao();
+ List stations = null;
+ try {
+ stations = dao.queryByWfo(PropertiesFactory.getInstance()
+ .getEnvProperties().getEnvValue("SITENAME"));
+ } catch (DataAccessLayerException e) {
+ statusHandler
+ .handle(Priority.ERROR,
+ "Unable to access data object for radar station table");
+ }
+
+ for (RadarStation station : stations) {
+ // this is just for a default
+ ProductRunXML dhrProduct = new ProductRunXML();
+ dhrProduct.setProductName("DHR");
+ dhrProduct.setProductKey(station.getRdaId().toLowerCase());
+ products.add(dhrProduct);
+
+ String newRfc = FFMPUtils
+ .getRFC(dhrProduct.getProductKey());
+ if (!rfc.contains(newRfc)) {
+ rfc.add(newRfc);
+ }
+
+ sites.add(station.getRdaId().toLowerCase());
+ }
+
+ } else {
+ for (String site : sites) {
+ // this is just for a default
+ ProductRunXML dhrProduct = new ProductRunXML();
+ dhrProduct.setProductName("DHR");
+ dhrProduct.setProductKey(site);
+ products.add(dhrProduct);
+
+ String newRfc = FFMPUtils
+ .getRFC(dhrProduct.getProductKey());
+ if (!rfc.contains(newRfc)) {
+ rfc.add(newRfc);
+ }
+ }
+ }
+
+ runner.setProducts(products);
+
+ // Apply site list to all QPE types
+ for (String source : getSourceConfig().getQPESources()) {
+ SourceXML qpeSource = getSourceConfig().getSource(source);
+ // Radar Derived sources use the primary source site keys for
+ // mosiac datakey
+ // Auto Config for any Radar derived sources
+ if (qpeSource.getDataType().equals(
+ DATA_TYPE.RADAR.getDataType())) {
+ SourceIngestConfigXML sicm = new SourceIngestConfigXML();
+ sicm.setSourceName(qpeSource.getSourceName());
+ sicm.setUriSubLocation(3);
+
+ for (String siteid : sites) {
+ sicm.addDataKey(siteid);
+ }
+
+ runner.addSourceIngest(sicm);
+ }
+ }
+
+ // We have a list of available RFC's, now find mosaic
+ // Apply this to all RFCFFG sources
+ for (String source : getSourceConfig().getGuidances()) {
+ SourceXML guidSource = getSourceConfig().getSource(source);
+
+ // Auto config for RFC sources
+ if (guidSource.isRfc()) {
+ // add a source mosaic config to the Run Config
+ SourceIngestConfigXML sicm = new SourceIngestConfigXML();
+ sicm.setSourceName(guidSource.getSourceName());
+ sicm.setUriSubLocation(3);
+
+ for (String dataKey : rfc) {
+ sicm.addDataKey(dataKey);
+ }
+
+ runner.addSourceIngest(sicm);
+ }
+ }
+
+ // Apply site list to all SCANQPF default
+ for (String source : getSourceConfig().getQPFSources()) {
+ SourceXML qpfSource = getSourceConfig().getSource(source);
+ // Radar Derived sources use the primary source site keys for
+ // mosiac datakey
+ // Auto Config for any Radar derived sources (QPFSCAN) for
+ // example
+ if (qpfSource.getSourceName().equals("QPFSCAN")) {
+ SourceIngestConfigXML sicm = new SourceIngestConfigXML();
+ sicm.setSourceName(qpfSource.getSourceName());
+ sicm.setUriSubLocation(3);
+
+ for (String siteid : sites) {
+ sicm.addDataKey(siteid);
+ }
+
+ runner.addSourceIngest(sicm);
+ }
+ }
+
+ DomainXML domain = new DomainXML();
+ domain.setPrimary(true);
+ domain.setCwa(commonStaticSite.getContextName());
+ runner.addDomain(domain);
+
+ getRunConfig().addFFMPRunner(runner);
+ getRunConfig().saveConfigXml();
+ getRunConfig().setPopulated(true);
+
+ domains.add(domain);
+ }
+
+ // kick off template generation
+ this.getExecutor().execute(new TemplateLoader(domains));
+ }
+
+ @Override
+ protected void createFilters() {
+ // do more here if you wish
+
+ ArrayList runners = getRunConfig().getFFMPRunners();
+ ArrayList tmp = new ArrayList(
+ runners.size());
+
+ for (FFMPRunXML runner : runners) {
+ DomainXML domain = runner.getPrimaryDomain();
+ try {
+ tmp.add(new FFMPURIFilter(getSiteString(runner) + ":"
+ + getRFCString(runner) + ":" + domain.getCwa()));
+
+ statusHandler.handle(Priority.INFO, "Created FFMP Filter.."
+ + " primary Domain: " + domain.getCwa());
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM,
+ "Couldn't create FFMP Filter.." + " primary Domain: "
+ + domain.getCwa()
+ + " this RUNNER is not a viable FFMP config.");
+ e.printStackTrace();
+ }
+ }
+
+ filters = tmp.toArray(new URIFilter[tmp.size()]);
+
+ }
+
+ /**
+ * Slight difference in the way ffmp operates as opposed to the URIFilter in
+ * general.
+ */
+ @Override
+ public void matchURIs(DataURINotificationMessage messages) {
+
+ if (messages instanceof DataURINotificationMessage) {
+ URIFilter[] filters = getFilters();
+ if (filters != null) {
+ for (int i = 0; i < filters.length; i++) {
+ if (filters[i] != null) {
+ FFMPURIFilter filter = (FFMPURIFilter) filters[i];
+
+ if (loaded) {
+
+ synchronized (filter) {
+
+ if (filter.isMatched(messages)) {
+
+ if (!ffgCheck) {
+
+ filter = getFFG(filter);
+ filter.setValidTime(filter
+ .getCurrentTime());
+ ffgCheck = true;
+ }
+
+ dispatch(filter);
+ }
+ }
+ } else {
+ statusHandler
+ .debug(getGeneratorName()
+ + ": templates not loaded yet. Skipping product");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void generateProduct(URIGenerateMessage genMessage) {
+ if (loaded) {
+ try {
+ long time = System.currentTimeMillis();
+ this.config = new FFMPConfig(
+ (FFMPURIGenerateMessage) genMessage, this);
+ products = new ConcurrentHashMap();
+ processes = new ConcurrentHashMap();
+ // read config updates, make sure we don't miss something
+ getRunConfig().readConfigXml();
+ getSourceConfig().readConfigXml();
+
+ if (config.getSources() != null) {
+ for (String source : config.getSources().keySet()) {
+ processes.put(source,
+ getSourceConfig().getSource(source));
+ }
+ }
+
+ // start threads
+
+ for (String source : processes.keySet()) {
+ this.getExecutor().execute(
+ new ProcessProduct(processes.get(source), this));
+ }
+
+ // count down latch
+ while (processes.size() > 0) {
+ // wait for all threads to finish before returning
+ try {
+ Thread.sleep(100);
+ statusHandler.handle(Priority.DEBUG,
+ "Checking status ..." + processes.size());
+ for (String source : processes.keySet()) {
+ statusHandler.handle(Priority.DEBUG,
+ "Still processing ..." + source);
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (products.size() > 0) {
+
+ // Do the FFTI evaluation, if we have FFTI sources
+ if (fftiSources.size() > 0) {
+ this.getExecutor().execute(new FFTI(this));
+ }
+
+ ArrayList records = new ArrayList