diff --git a/RadarServer/build.rcm/customTargets.xml b/RadarServer/build.rcm/customTargets.xml index 8394f04df5..3ec14fe57a 100644 --- a/RadarServer/build.rcm/customTargets.xml +++ b/RadarServer/build.rcm/customTargets.xml @@ -88,6 +88,7 @@ + diff --git a/RadarServer/com.raytheon.rcm.feature/feature.xml b/RadarServer/com.raytheon.rcm.feature/feature.xml index 1ab17e3d94..b01cdbfbe0 100644 --- a/RadarServer/com.raytheon.rcm.feature/feature.xml +++ b/RadarServer/com.raytheon.rcm.feature/feature.xml @@ -42,6 +42,13 @@ install-size="0" version="0.0.0" unpack="false"/> + + + + + + + diff --git a/cave/build/cave/customTargets.xml b/cave/build/cave/customTargets.xml index e3644b19ad..3d9b0e43c5 100644 --- a/cave/build/cave/customTargets.xml +++ b/cave/build/cave/customTargets.xml @@ -112,6 +112,11 @@ + + + + + diff --git a/cave/com.raytheon.uf.viz.alertviz/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.alertviz/META-INF/MANIFEST.MF index a01b3154bd..2ddef764b0 100644 --- a/cave/com.raytheon.uf.viz.alertviz/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.alertviz/META-INF/MANIFEST.MF @@ -13,7 +13,6 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.viz.core;visibility:=reexport, com.raytheon.uf.common.status, org.jep;bundle-version="1.0.0", - com.raytheon.uf.common.status, com.raytheon.uf.common.message;bundle-version="1.11.11", com.raytheon.uf.common.alertviz, javax.jms;bundle-version="1.0.0", diff --git a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF index 72674e0fd2..44d9595317 100644 --- a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF @@ -63,6 +63,8 @@ Export-Package: com.raytheon.uf.viz.core, com.raytheon.uf.viz.core.notification.jobs, com.raytheon.uf.viz.core.notification.observers, com.raytheon.uf.viz.core.preferences, + com.raytheon.uf.viz.core.presenter, + com.raytheon.uf.viz.core.presenter.components, com.raytheon.uf.viz.core.procedures, com.raytheon.uf.viz.core.requests, com.raytheon.uf.viz.core.rsc, diff --git a/cave/com.raytheon.uf.viz.core/META-INF/spring/viz.xml b/cave/com.raytheon.uf.viz.core/META-INF/spring/viz.xml index 1ba7778794..bd7cea4ab8 100644 --- a/cave/com.raytheon.uf.viz.core/META-INF/spring/viz.xml +++ b/cave/com.raytheon.uf.viz.core/META-INF/spring/viz.xml @@ -34,4 +34,5 @@ --> + \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/IGraphicsTarget.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/IGraphicsTarget.java index f685a10688..c936d755ce 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/IGraphicsTarget.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/IGraphicsTarget.java @@ -731,6 +731,8 @@ public interface IGraphicsTarget extends IImagingExtension { */ public IView getView(); + /** + /** * Use drawStrings(DrawableString parameters) */ diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/VizApp.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/VizApp.java index b5dae705bf..2794ef2c22 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/VizApp.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/VizApp.java @@ -48,13 +48,20 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 7/1/06 chammack Initial Creation. + * Sep 12, 2012 1167 djohnson Add datadelivery servers. * * * * @author chammack * */ -public class VizApp { +public final class VizApp { + + /** + * Disabled constructor. + */ + private VizApp() { + } private static final String USER_FLAG = "-u"; @@ -66,6 +73,12 @@ public class VizApp { private static String pypiesServer; + private static String dataDeliveryServer; + + private static String dataDeliveryLcmServer; + + private static String dataDeliveryQueryServer; + private static String serverDataDir; static { @@ -244,6 +257,50 @@ public class VizApp { VizApp.pypiesServer = pypiesServer; } + /** + * @return the dataDeliveryServer + */ + public static String getDataDeliveryServer() { + return dataDeliveryServer; + } + + /** + * @param dataDeliveryServer + * the dataDeliveryServer to set + */ + public static void setDataDeliveryServer(String dataDeliveryServer) { + VizApp.dataDeliveryServer = dataDeliveryServer; + } + /** + * @return the dataDeliveryLcmServer + */ + public static String getDataDeliveryLcmServer() { + return dataDeliveryLcmServer; + } + + /** + * @param dataDeliveryLcmServer + * the dataDeliveryLcmServer to set + */ + public static void setDataDeliveryLcmServer(String dataDeliveryLcmServer) { + VizApp.dataDeliveryLcmServer = dataDeliveryLcmServer; + } + + /** + * @return the dataDeliveryQueryServer + */ + public static String getDataDeliveryQueryServer() { + return dataDeliveryQueryServer; + } + + /** + * @param dataDeliveryQueryServer + * the dataDeliveryQueryServer to set + */ + public static void setDataDeliveryQueryServer(String dataDeliveryQueryServer) { + VizApp.dataDeliveryQueryServer = dataDeliveryQueryServer; + } + public static String getServerDataDir() { return VizApp.serverDataDir; } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/LocalizationInitializer.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/LocalizationInitializer.java index f4c6173d71..4fa546e591 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/LocalizationInitializer.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/LocalizationInitializer.java @@ -47,6 +47,7 @@ import com.raytheon.uf.viz.core.requests.ThriftClient; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Nov 5, 2009 mschenke Initial creation + * Sep 12, 2012 1167 djohnson Add datadelivery servers. * * * @@ -115,6 +116,8 @@ public class LocalizationInitializer { VizApp.setJmsServer(resp.getJmsServer()); VizApp.setPypiesServer(resp.getPypiesServer()); VizApp.setServerDataDir(resp.getServerDataDir()); - + VizApp.setDataDeliveryServer(resp.getDataDeliveryServer()); + VizApp.setDataDeliveryLcmServer(resp.getDataDeliveryLcmServer()); + VizApp.setDataDeliveryQueryServer(resp.getDataDeliveryQueryServer()); } } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/LocalizationManager.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/LocalizationManager.java index db9b88d243..2300b3c721 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/LocalizationManager.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/LocalizationManager.java @@ -90,7 +90,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient; * Jul 30, 2007 njensen Refactored. * Feb 12, 2008 chammack Removed base configuration * Mar 26, 2008 njensen Added rename() and getFileContents(). - * May 19, 2007 #1127 randerso Implemented error handling + * May 19, 2007 #1127 randerso Implemented error handling + * Sep 12, 2012 1167 djohnson Add datadelivery servers. * * * @@ -225,6 +226,10 @@ public class LocalizationManager implements IPropertyChangeListener { VizApp.setHttpServer(resp.getHttpServer()); VizApp.setJmsServer(resp.getJmsServer()); VizApp.setPypiesServer(resp.getPypiesServer()); + VizApp.setDataDeliveryServer(resp.getDataDeliveryServer()); + VizApp.setDataDeliveryLcmServer(resp.getDataDeliveryLcmServer()); + VizApp.setDataDeliveryQueryServer(resp + .getDataDeliveryQueryServer()); VizApp.setServerDataDir(resp.getServerDataDir()); } catch (VizException e) { statusHandler.handle(UFStatus.Priority.SIGNIFICANT, diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/IPresenterView.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/IPresenterView.java new file mode 100644 index 0000000000..0efc1bc753 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/IPresenterView.java @@ -0,0 +1,78 @@ +/** + * 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.viz.core.presenter; + +/** + * A view interface that defines methods all views should provide an + * implementation for. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012 0743       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public interface IPresenterView { + + /** + * Performs initialization of the view. + */ + void init(); + + /** + * Display a popup message. + * + * @param title + * the title + * @param message + * the message + */ + void displayPopup(String title, String message); + + /** + * Display an error popup message. + * + * @param title + * the title + * @param message + * the message + */ + void displayErrorPopup(String title, String message); + + /** + * Display a cancel/ok popup. + * + * @param title + * the title + * @param message + * the message + * + * @return boolean true if OK clicked, false if Cancel + */ + boolean displayOkCancelPopup(String title, String message); +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/ButtonConf.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/ButtonConf.java new file mode 100644 index 0000000000..9b55e191e7 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/ButtonConf.java @@ -0,0 +1,113 @@ +/** + * 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.viz.core.presenter.components; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +/** + * GUI implementation independent representation of a button. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 24, 2012    223     mpduff      Initial creation.
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class ButtonConf extends LabeledWidgetConf { + /** + * Button enabled flag; + */ + private final boolean enabled; + + /** + * Event handler for the button. + */ + private final Runnable onClickAction; + + /** + * Constructor. + * + * @param enabled + * @param displayText + * @param toolTipText + * @param onClickAction + */ + public ButtonConf(boolean enabled, String displayText, String toolTipText, + Runnable onClickAction) { + super(displayText, toolTipText); + + this.enabled = enabled; + this.onClickAction = onClickAction; + } + + /** + * @return the enabled + */ + public boolean isEnabled() { + return enabled; + } + + /** + * @return the onClickAction + */ + public Runnable getOnClickAction() { + return onClickAction; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(enabled); + builder.append(onClickAction); + builder.appendSuper(super.hashCode()); + + return builder.toHashCode(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof ButtonConf) { + ButtonConf other = (ButtonConf) obj; + + EqualsBuilder builder = new EqualsBuilder(); + builder.append(enabled, other.enabled); + builder.append(onClickAction, other.onClickAction); + builder.appendSuper(super.equals(obj)); + + return builder.isEquals(); + } + return super.equals(obj); + } +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/CheckBoxConf.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/CheckBoxConf.java new file mode 100644 index 0000000000..e9d67ceda3 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/CheckBoxConf.java @@ -0,0 +1,99 @@ +/** + * 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.viz.core.presenter.components; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +/** + * GUI implementation independent representation of a checkbox. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 15, 2012 0743       djohnson     Initial creation.
+ * Aug 29, 2012 0223       mpduff       Extend WidgetConf.
+ *
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public class CheckBoxConf extends LabeledWidgetConf { + private final boolean initiallyChecked; + + private final Runnable onCheckedChangeAction; + + public CheckBoxConf(String displayText, boolean initiallyChecked, + String toolTipText, Runnable onCheckedChangeAction) { + super(displayText, toolTipText); + + this.initiallyChecked = initiallyChecked; + this.onCheckedChangeAction = onCheckedChangeAction; + } + + /** + * @return the initiallyChecked + */ + public boolean isInitiallyChecked() { + return initiallyChecked; + } + + /** + * @return the onCheckedChangeAction + */ + public Runnable getOnCheckedChangeAction() { + return onCheckedChangeAction; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(initiallyChecked); + builder.append(onCheckedChangeAction); + builder.appendSuper(super.hashCode()); + + return builder.toHashCode(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof CheckBoxConf) { + CheckBoxConf other = (CheckBoxConf) obj; + + EqualsBuilder builder = new EqualsBuilder(); + builder.append(initiallyChecked, other.initiallyChecked); + builder.append(onCheckedChangeAction, other.onCheckedChangeAction); + builder.appendSuper(super.equals(obj)); + + return builder.isEquals(); + } + return super.equals(obj); + } +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/ComboBoxConf.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/ComboBoxConf.java new file mode 100644 index 0000000000..063b1ded5c --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/ComboBoxConf.java @@ -0,0 +1,114 @@ +/** + * 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.viz.core.presenter.components; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +/** + * GUI implementation independent representation of a combo box. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 16, 2012 0743       djohnson     Initial creation
+ * Aug 29, 2012 0223       mpduff       Extend WidgetConf.
+ * Sep 07, 2012 1102       djohnson     Add missing getter for toolTipText.
+ *
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ComboBoxConf extends WidgetConf { + public static final String SELECT_ONE = "Select One"; + + public static final String NONE_AVAILABLE = "None Available"; + + private final boolean readOnly; + + private final Runnable onSelectionAction; + + /** + * Constructor setting up configuration. + * + * @param readOnly + * whether or not the combo box should be read only + * @param toolTipText + * the tool tip text + * @param onSelectionAction + * on selection action + */ + public ComboBoxConf(boolean readOnly, String toolTipText, + Runnable onSelectionAction) { + super(toolTipText); + this.readOnly = readOnly; + this.onSelectionAction = onSelectionAction; + } + + /** + * @return the readOnly + */ + public boolean isReadOnly() { + return readOnly; + } + + /** + * @return the onSelectionAction + */ + public Runnable getOnSelectionAction() { + return onSelectionAction; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(readOnly); + builder.append(onSelectionAction); + builder.appendSuper(super.hashCode()); + + return builder.toHashCode(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof ComboBoxConf) { + ComboBoxConf other = (ComboBoxConf) obj; + + EqualsBuilder builder = new EqualsBuilder(); + builder.append(readOnly, other.readOnly); + builder.append(onSelectionAction, other.onSelectionAction); + builder.appendSuper(super.equals(obj)); + + return builder.isEquals(); + } + return super.equals(obj); + } +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/LabeledWidgetConf.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/LabeledWidgetConf.java new file mode 100644 index 0000000000..8a76f6522e --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/LabeledWidgetConf.java @@ -0,0 +1,92 @@ +/** + * 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.viz.core.presenter.components; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +/** + * Configuration object for SWT widgets that have displayed text. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 18, 2012   223      mpduff      Initial creation
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class LabeledWidgetConf extends WidgetConf { + /** Display text */ + protected String displayText; + + /** + * Constructor. + * + * @param displayText + * @param tooltipText + */ + public LabeledWidgetConf(String displayText, String toolTipText) { + super(toolTipText); + this.displayText = displayText; + } + + /** + * @return the displayText + */ + public String getDisplayText() { + return displayText; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(displayText); + builder.appendSuper(super.hashCode()); + + return builder.toHashCode(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof CheckBoxConf) { + CheckBoxConf other = (CheckBoxConf) obj; + + EqualsBuilder builder = new EqualsBuilder(); + builder.append(displayText, other.displayText); + builder.appendSuper(super.equals(obj)); + + return builder.isEquals(); + } + return super.equals(obj); + } +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/ListConf.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/ListConf.java new file mode 100644 index 0000000000..65f879d9b6 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/ListConf.java @@ -0,0 +1,136 @@ +/** + * 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.viz.core.presenter.components; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +/** + * Configuration object for org.eclipse.swt.widgets.List objects. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 12, 2012   223      mpduff      Initial creation
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class ListConf extends WidgetConf { + private String[] items; + + private boolean singleSelect = true; + + private final int width; + + private final int height; + + public ListConf(String toolTipText, String[] items, boolean singleSelect, int width, int height) { + super(toolTipText); + + this.items = items; + this.singleSelect = singleSelect; + this.width = width; + this.height = height; + } + + /** + * @param items the items to set + */ + public void setItems(String[] items) { + this.items = items; + } + + /** + * @return the items + */ + public String[] getItems() { + return items; + } + + /** + * @param singleSelect the singleSelect to set + */ + public void setSingleSelect(boolean singleSelect) { + this.singleSelect = singleSelect; + } + + /** + * @return the singleSelect + */ + public boolean isSingleSelect() { + return singleSelect; + } + + /** + * @return the width + */ + public int getWidth() { + return width; + } + + /** + * @return the height + */ + public int getHeight() { + return height; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(items); + builder.append(singleSelect); + builder.append(width); + builder.append(height); + builder.appendSuper(super.hashCode()); + + return builder.toHashCode(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof CheckBoxConf) { + ListConf other = (ListConf) obj; + + EqualsBuilder builder = new EqualsBuilder(); + builder.append(items, other.getItems()); + builder.append(singleSelect, other.isSingleSelect()); + builder.append(width, other.getWidth()); + builder.append(height, other.getHeight()); + builder.appendSuper(super.equals(obj)); + + return builder.isEquals(); + } + return super.equals(obj); + } +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/WidgetConf.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/WidgetConf.java new file mode 100644 index 0000000000..944b07999d --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/presenter/components/WidgetConf.java @@ -0,0 +1,88 @@ +/** + * 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.viz.core.presenter.components; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +/** + * Base class for the widget configuration classes. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 26, 2012   223      mpduff     Initial creation
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public abstract class WidgetConf { + public static final Runnable DO_NOTHING = new Runnable() { + @Override + public void run() { + } + }; + + protected String toolTipText; + + public WidgetConf(String toolTipText) { + this.toolTipText = toolTipText; + } + + /** + * @return the toolTipText + */ + public String getToolTipText() { + return toolTipText; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(toolTipText); + + return builder.toHashCode(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof WidgetConf) { + WidgetConf other = (WidgetConf) obj; + + EqualsBuilder builder = new EqualsBuilder(); + builder.append(toolTipText, other.toolTipText); + + return builder.isEquals(); + } + return super.equals(obj); + } +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java index 22bcb88135..71b0967b3c 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java @@ -17,6 +17,7 @@ import com.raytheon.uf.common.auth.resp.UserNotAuthorized; import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.comm.HttpClient; import com.raytheon.uf.common.comm.NetworkStatistics; +import com.raytheon.uf.common.serialization.ExceptionWrapper; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.serialization.comm.IServerRequest; @@ -24,7 +25,6 @@ import com.raytheon.uf.common.serialization.comm.RemoteServiceRequest; import com.raytheon.uf.common.serialization.comm.RequestWrapper; import com.raytheon.uf.common.serialization.comm.ServiceException; import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse; -import com.raytheon.uf.common.serialization.comm.util.ExceptionWrapper; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.auth.UserController; import com.raytheon.uf.viz.core.exception.VizCommunicationException; diff --git a/cave/com.raytheon.uf.viz.cots.feature/feature.xml b/cave/com.raytheon.uf.viz.cots.feature/feature.xml index d0caabd398..5117e262e7 100644 --- a/cave/com.raytheon.uf.viz.cots.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.cots.feature/feature.xml @@ -360,4 +360,18 @@ version="0.0.0" unpack="false"/> + + + + diff --git a/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml b/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml index a70d93f27b..93718150be 100644 --- a/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml +++ b/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml @@ -153,6 +153,13 @@ download-size="0" install-size="0" version="0.0.0"/> + + + + diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/CheckPermissions.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/CheckPermissions.java index 0e54e235b8..0a326b07f4 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/CheckPermissions.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/CheckPermissions.java @@ -56,7 +56,8 @@ public class CheckPermissions { public static boolean getAuthorization() { boolean authorized = false; IUser user = UserController.getUserObject(); - CheckPermissionsRequest request = new CheckPermissionsRequest(user); + CheckPermissionsRequest request = new CheckPermissionsRequest(); + request.setUser(user); try { ServerResponse obj = (ServerResponse) ThriftClient .sendRequest(request); @@ -66,7 +67,7 @@ public class CheckPermissions { authorized = false; } } catch (VizException e) { - statusHandler.error("Error checking permissions for: " + user); + statusHandler.error("Error checking permissions for: " + user, e); authorized = false; } return authorized; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/SiteActivationDlg.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/SiteActivationDlg.java index 832c052879..1de07839d5 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/SiteActivationDlg.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/SiteActivationDlg.java @@ -243,38 +243,45 @@ public class SiteActivationDlg extends CaveJFACEDialog implements private void doValidate() { String siteID = this.siteId.getText(); - ValidateConfigRequest request = new ValidateConfigRequest(siteID, "gfe"); - try { - String result = (String) ThriftClient.sendRequest(request); - appendToLog(result); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error processing site activation request", e); - + if (!siteID.isEmpty()) { + ValidateConfigRequest request = new ValidateConfigRequest(siteID, + "gfe"); + try { + String result = (String) ThriftClient.sendRequest(request); + appendToLog(result); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, + "Error processing site activation request", e); + } } } private void doActivate() { String siteID = this.siteId.getText(); - ActivateSiteRequest request = new ActivateSiteRequest(siteID, "gfe"); - try { - ThriftClient.sendRequest(request); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error processing site activation request", e); + if (!siteID.isEmpty()) { + ActivateSiteRequest request = new ActivateSiteRequest(siteID, "gfe"); + try { + ThriftClient.sendRequest(request); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, + "Error processing site activation request", e); + } } } private void doDeactivate() { String siteID = this.siteId.getText(); - DeactivateSiteRequest request = new DeactivateSiteRequest(siteID, "gfe"); - try { - ThriftClient.sendRequest(request); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error processing site deactivation request", e); + if (!siteID.isEmpty()) { + DeactivateSiteRequest request = new DeactivateSiteRequest(siteID, + "gfe"); + try { + ThriftClient.sendRequest(request); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, + "Error processing site deactivation request", e); + } } } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedTempResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedTempResource.java index 9a277fb097..4576a0fdce 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedTempResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PlotGriddedTempResource.java @@ -88,7 +88,7 @@ import com.vividsolutions.jts.geom.GeometryFactory; * Jun 30, 2009 2524 snaples Initial creation * Feb 29 2010 9909 lbousaidi changed the for loop for getting * the HRAP grid bin - * Apr 17, 2012 9602 mgamazaychikm Changed the HRAP grid j index for loop + * Apr 17, 2012 9602 mgamazaychikm Changed the HRAP grid j index for loop * * * @author snaples @@ -441,6 +441,8 @@ public class PlotGriddedTempResource extends @Override protected void paintInternal(IGraphicsTarget target, PaintProperties paintProps) throws VizException { + + target.setUseBuiltinColorbar(false); if (buf == null || DailyQcUtils.grids_flag != 1 || displayMgr.isMaxmin() != true) { return; diff --git a/cave/com.raytheon.viz.ui/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.ui/META-INF/MANIFEST.MF index 6b26c568d4..072d00907d 100644 --- a/cave/com.raytheon.viz.ui/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.ui/META-INF/MANIFEST.MF @@ -31,7 +31,8 @@ Export-Package: com.raytheon.viz.ui, com.raytheon.viz.ui.statusline, com.raytheon.viz.ui.tools, com.raytheon.viz.ui.views, - com.raytheon.viz.ui.widgets + com.raytheon.viz.ui.widgets, + com.raytheon.viz.ui.widgets.duallist Bundle-Vendor: Raytheon Import-Package: com.raytheon.uf.common.colormap, com.raytheon.uf.common.message.response diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/CaveSWTDialogBase.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/CaveSWTDialogBase.java index 26928a5584..7703329e18 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/CaveSWTDialogBase.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/CaveSWTDialogBase.java @@ -413,7 +413,7 @@ public abstract class CaveSWTDialogBase extends Dialog { * Returns if the dialog is disposed, a null dialog will not mean it is * disposed as it may not have been opened yet. * - * @return + * @return boolean */ public final boolean isDisposed() { return (shell != null && shell.isDisposed()); diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/ButtonImages.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/ButtonImages.java new file mode 100644 index 0000000000..dc14bad71d --- /dev/null +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/ButtonImages.java @@ -0,0 +1,397 @@ +/** + * 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.viz.ui.widgets.duallist; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +/** + * Images for the Add All, Add, Remove, Remove All, Move Up, and Move Down + * buttons. Reused from Data Delivery + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 31, 2012            mpduff     Initial creation
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class ButtonImages { + + /** + * Parent composite. + */ + private Composite parent; + + /** + * Parent display. + */ + private Display parentDisplay; + + /** + * Array of button images. + */ + private Image[] buttonArray; + + /** + * Button image enumeration that identifies which image to use. + */ + public enum ButtonImage { + AddAll, Add, Remove, RemoveAll, Up, Down + }; + + /** + * Constructor. + * + * @param parent + * Parent composite. + */ + public ButtonImages(Composite parent) { + this.parent = parent; + parentDisplay = parent.getDisplay(); + + addDisposeToParent(); + + createButtonImages(); + } + + /** + * Add a dispose listener to the parent composite. When the parent composite + * is disposed, the images will be disposed of. + */ + private void addDisposeToParent() { + parent.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + for (Image img : buttonArray) { + img.dispose(); + } + } + }); + } + + /** + * Create the button images. + */ + private void createButtonImages() { + int imgWidthSm = 12; + int imgWidth = 24; + int imgHeight = 12; + Image tmpImg; + + GC gc; + + buttonArray = new Image[ButtonImage.values().length]; + + for (int i = 0; i < ButtonImage.values().length; i++) { + if (ButtonImage.values()[i] == ButtonImage.Up || ButtonImage.values()[i] == ButtonImage.Down) { + buttonArray[i] = new Image(parentDisplay, imgWidthSm, imgHeight); + } + else { + buttonArray[i] = new Image(parentDisplay, imgWidth, imgHeight); + } + } + + /* + * Add all image + */ + tmpImg = new Image(parent.getDisplay(), imgWidth, imgHeight); + gc = new GC(tmpImg); + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_WHITE)); + gc.fillRectangle(0, 0, imgWidth, imgHeight); + gc.dispose(); + + ImageData idata = tmpImg.getImageData(); + + int whitePixel = idata.palette.getPixel(new RGB(255, 255, 255)); + idata.transparentPixel = whitePixel; + Image transparentIdeaImage = new Image(parent.getDisplay(), idata); + + gc = new GC(transparentIdeaImage); + drawAddAllImage(gc, imgWidth, imgHeight); + gc.dispose(); + + buttonArray[ButtonImage.AddAll.ordinal()] = transparentIdeaImage; + tmpImg.dispose(); + + /* + * Add image + */ + tmpImg = new Image(parent.getDisplay(), imgWidth, imgHeight); + gc = new GC(tmpImg); + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_WHITE)); + gc.fillRectangle(0, 0, imgWidth, imgHeight); + gc.dispose(); + + idata = tmpImg.getImageData(); + + whitePixel = idata.palette.getPixel(new RGB(255, 255, 255)); + idata.transparentPixel = whitePixel; + transparentIdeaImage = new Image(parent.getDisplay(), idata); + + gc = new GC(transparentIdeaImage); + drawAddImage(gc, imgWidth, imgHeight); + gc.dispose(); + + buttonArray[ButtonImage.Add.ordinal()] = transparentIdeaImage; + tmpImg.dispose(); + + /* + * Remove image + */ + tmpImg = new Image(parent.getDisplay(), imgWidth, imgHeight); + gc = new GC(tmpImg); + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_WHITE)); + gc.fillRectangle(0, 0, imgWidth, imgHeight); + gc.dispose(); + + idata = tmpImg.getImageData(); + + whitePixel = idata.palette.getPixel(new RGB(255, 255, 255)); + idata.transparentPixel = whitePixel; + transparentIdeaImage = new Image(parent.getDisplay(), idata); + + gc = new GC(transparentIdeaImage); + drawRemoveImage(gc, imgWidth, imgHeight); + gc.dispose(); + + buttonArray[ButtonImage.Remove.ordinal()] = transparentIdeaImage; + tmpImg.dispose(); + + /* + * Remove all image + */ + tmpImg = new Image(parent.getDisplay(), imgWidth, imgHeight); + gc = new GC(tmpImg); + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_WHITE)); + gc.fillRectangle(0, 0, imgWidth, imgHeight); + gc.dispose(); + + idata = tmpImg.getImageData(); + + whitePixel = idata.palette.getPixel(new RGB(255, 255, 255)); + idata.transparentPixel = whitePixel; + transparentIdeaImage = new Image(parent.getDisplay(), idata); + + gc = new GC(transparentIdeaImage); + drawRemoveAllImage(gc, imgWidth, imgHeight); + gc.dispose(); + + buttonArray[ButtonImage.RemoveAll.ordinal()] = transparentIdeaImage; + tmpImg.dispose(); + + /* + * Move up image + */ + tmpImg = new Image(parent.getDisplay(), imgWidthSm, imgHeight); + gc = new GC(tmpImg); + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_WHITE)); + gc.fillRectangle(0, 0, imgWidthSm, imgHeight); + gc.dispose(); + + idata = tmpImg.getImageData(); + + whitePixel = idata.palette.getPixel(new RGB(255, 255, 255)); + idata.transparentPixel = whitePixel; + transparentIdeaImage = new Image(parent.getDisplay(), idata); + + gc = new GC(transparentIdeaImage); + drawMoveUpImage(gc, imgWidthSm, imgHeight); + gc.dispose(); + + buttonArray[ButtonImage.Up.ordinal()] = transparentIdeaImage; + tmpImg.dispose(); + + /* + * Move down image + */ + tmpImg = new Image(parent.getDisplay(), imgWidthSm, imgHeight); + gc = new GC(tmpImg); + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_WHITE)); + gc.fillRectangle(0, 0, imgWidthSm, imgHeight); + gc.dispose(); + + idata = tmpImg.getImageData(); + + whitePixel = idata.palette.getPixel(new RGB(255, 255, 255)); + idata.transparentPixel = whitePixel; + transparentIdeaImage = new Image(parent.getDisplay(), idata); + + gc = new GC(transparentIdeaImage); + drawMoveDownImage(gc, imgWidthSm, imgHeight); + gc.dispose(); + + buttonArray[ButtonImage.Down.ordinal()] = transparentIdeaImage; + tmpImg.dispose(); + } + + /** + * Draw the "add all" image. + * + * @param gc + * Graphics context. + * @param imgWidth + * Image width. + * @param imgHeight + * Image height. + */ + private void drawAddAllImage(GC gc, int imgWidth, int imgHeight) { + gc.setAntialias(SWT.ON); + + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_BLACK)); + + // Draw the left arrow + int[] pointArray = new int[] { 10, 6, 1, 1, 1, 10, 10, 6 }; + gc.fillPolygon(pointArray); + + // Draw the right arrow + pointArray = new int[] { 22, 6, 13, 1, 13, 10, 22, 6 }; + gc.fillPolygon(pointArray); + } + + /** + * Draw the "add" image. + * + * @param gc + * Graphics context. + * @param imgWidth + * Image width. + * @param imgHeight + * Image height. + */ + private void drawAddImage(GC gc, int imgWidth, int imgHeight) { + gc.setAntialias(SWT.ON); + + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_BLACK)); + + // Draw the add arrow + int[] pointArray = new int[] { 17, 6, 8, 1, 8, 10, 17, 6 }; + gc.fillPolygon(pointArray); + } + + /** + * Draw the "remove" image. + * + * @param gc + * Graphics context. + * @param imgWidth + * Image width. + * @param imgHeight + * Image height. + */ + private void drawRemoveImage(GC gc, int imgWidth, int imgHeight) { + gc.setAntialias(SWT.ON); + + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_BLACK)); + + // Draw the add arrow + int[] pointArray = new int[] { 8, 6, 17, 1, 17, 10, 8, 6 }; + gc.fillPolygon(pointArray); + } + + /** + * Draw the "remove all" image. + * + * @param gc + * Graphics context. + * @param imgWidth + * Image width. + * @param imgHeight + * Image height. + */ + private void drawRemoveAllImage(GC gc, int imgWidth, int imgHeight) { + gc.setAntialias(SWT.ON); + + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_BLACK)); + + // Draw the left arrow + int[] pointArray = new int[] { 1, 6, 10, 1, 10, 10, 1, 6 }; + gc.fillPolygon(pointArray); + + // Draw the right arrow + pointArray = new int[] { 13, 6, 22, 1, 22, 10, 13, 6 }; + gc.fillPolygon(pointArray); + } + + /** + * Draw the "move up" image. + * + * @param gc + * Graphics context. + * @param imgWidth + * Image width. + * @param imgHeight + * Image height. + */ + private void drawMoveUpImage(GC gc, int imgWidth, int imgHeight) { + gc.setAntialias(SWT.ON); + + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_BLACK)); + + // Draw the add arrow + int[] pointArray = new int[] { 1, 10, 6, 1, 11, 10, 1, 10 }; + gc.fillPolygon(pointArray); + } + + /** + * Draw the "move down" image. + * + * @param gc + * Graphics context. + * @param imgWidth + * Image width. + * @param imgHeight + * Image height. + */ + private void drawMoveDownImage(GC gc, int imgWidth, int imgHeight) { + gc.setAntialias(SWT.ON); + + gc.setBackground(parentDisplay.getSystemColor(SWT.COLOR_BLACK)); + + // Draw the add arrow + int[] pointArray = new int[] { 1, 1, 6, 10, 11, 1, 1, 1 }; + gc.fillPolygon(pointArray); + } + + /** + * Get the image associated with the specified button image. + * + * @param bi + * Button image identifier. + * @return The associated button image. + */ + public Image getImage(ButtonImage bi) { + return this.buttonArray[bi.ordinal()]; + } +} diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualList.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualList.java new file mode 100644 index 0000000000..cda0de1e9b --- /dev/null +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualList.java @@ -0,0 +1,945 @@ +/** + * 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.viz.ui.widgets.duallist; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.TreeMap; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; + +import com.raytheon.viz.ui.widgets.duallist.ButtonImages.ButtonImage; + +/** + * SWT Dual List Widget. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 13, 2012            mpduff      Initial creation
+ * Feb 14, 2012            lvenable    Update code.
+ * Aug 08, 2012    863     jpiatt      Added checks for selection changes.
+ * Aug 10, 2012   1002     mpduff      Fixed sorting of numeric data on move left.
+ * Sep 07, 2012    684     mpduff      Deselect selection prior to selecting new items.
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class DualList extends Composite { + + /** + * Available List widget + */ + private List availableList; + + /** + * Selected List Widget + */ + private List selectedList; + + /** + * Dual List data/configuration object + */ + private DualListConfig config = new DualListConfig(); + + /** + * Button to move an item from the left list to the right list. + */ + private Button moveRightBtn; + + /** + * Button to move all items from the left list to the right list. + */ + private Button moveAllRightBtn; + + /** + * Button to move an item from the right list to the left list. + */ + private Button moveLeftBtn; + + /** + * Button to move all items from the right list to the left list. + */ + private Button moveAllLeftBtn; + + /** + * Move a selected item in the selected list up in the list. + */ + private Button moveUpBtn; + + /** + * Move a selected item in the selected list down in the list. + */ + private Button moveDownBtn; + + /** + * Callback when data has been selected or unselected. + */ + private IUpdate updateCallback = null; + + /** + * Number of columns. + */ + private int numberOfColumns = 3; + + /** + * Button Images. + */ + private ButtonImages btnImg; + + /** + * Button Height. + */ + private int buttonHeight = SWT.DEFAULT; + + /** + * Button Width. + */ + private final int buttonWidth = 45; + + /** + * Move left flag. + */ + boolean moveLeft = false; + + /** + * Move All flag. + */ + boolean moveAllLeft = false; + + /** + * Constructor + * + * @param parent + * Parent container + * @param style + * SWT Style + * @param config + * Data/Configuration object + */ + public DualList(Composite parent, int style, DualListConfig config) { + this(parent, style, config, null); + } + + /** + * Constructor + * + * @param parent + * Parent container + * @param style + * SWT Style + * @param config + * Data/Configuration object + * @param cb + * Update Callback + * + */ + public DualList(Composite parent, int style, DualListConfig config, + IUpdate cb) { + super(parent, style); + this.config = config; + this.updateCallback = cb; + init(); + } + + /** + * Initialize the controls. + */ + private void init() { + // Create the button image class + btnImg = new ButtonImages(this); + + if (config.getListHeight() <= 90) { + buttonHeight = 20; + } + + // Determine how many columns need to be on the layout. + // The default is three. + if (config.isShowUpDownBtns()) { + numberOfColumns = 4; + } + + GridLayout gl = new GridLayout(numberOfColumns, false); + gl.marginWidth = 2; + gl.marginHeight = 2; + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + this.setLayout(gl); + this.setLayoutData(gd); + + createListLabels(); + createAvailableListControl(); + createAddRemoveControls(); + createSelectedListControl(); + + if (config.isShowUpDownBtns()) { + createMoveUpDownControls(); + } + + populateLists(); + } + + /** + * Create the labels that will appear above the list controls. + */ + private void createListLabels() { + // Available label + GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, false, false); + gd.horizontalIndent = 3; + + Label availableLbl = new Label(this, SWT.NONE); + availableLbl.setText(config.getAvailableListText()); + availableLbl.setLayoutData(gd); + + new Label(this, SWT.NONE); + + // Selected label + gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false); + gd.horizontalIndent = 3; + + Label selectedLbl = new Label(this, SWT.NONE); + selectedLbl.setText(config.getSelectedListText()); + selectedLbl.setLayoutData(gd); + + if (numberOfColumns == 4) { + new Label(this, SWT.NONE); + } + + } + + /** + * Create the available list control. + */ + private void createAvailableListControl() { + + GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true); + listData.widthHint = config.getListWidth(); + listData.heightHint = config.getListHeight(); + availableList = new List(this, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL + | SWT.H_SCROLL); + availableList.setLayoutData(listData); + availableList.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (availableList.getSelectionCount() > 0) { + moveRightBtn.setEnabled(true); + } else { + moveRightBtn.setEnabled(false); + } + } + }); + + availableList.addMouseListener(new MouseAdapter() { + @Override + public void mouseDown(MouseEvent arg0) { + if (arg0.button == 3) { + if (config.getMenuData() != null + && config.getMenuData().isShowMenu()) { + showAvailableListMenu(); + } + } + } + }); + } + + /** + * Create the add and remove controls. + */ + private void createAddRemoveControls() { + /* + * Add and Remove Buttons + */ + GridData selectData = new GridData(SWT.DEFAULT, SWT.CENTER, false, true); + GridLayout selectLayout = new GridLayout(1, false); + selectLayout.verticalSpacing = 2; + + Composite selectComp = new Composite(this, SWT.NONE); + selectComp.setLayout(selectLayout); + selectComp.setLayoutData(selectData); + + // Left/Right buttons + GridData btnData = new GridData(buttonWidth, buttonHeight); + + moveAllRightBtn = new Button(selectComp, SWT.PUSH); + moveAllRightBtn.setImage(btnImg.getImage(ButtonImage.AddAll)); + moveAllRightBtn.setLayoutData(btnData); + moveAllRightBtn.setEnabled(false); + moveAllRightBtn.setToolTipText("Move all items right"); + moveAllRightBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleMoveAllRight(); + if (updateCallback != null) { + updateCallback.selectionChanged(); + } + } + }); + + btnData = new GridData(buttonWidth, buttonHeight); + moveRightBtn = new Button(selectComp, SWT.PUSH); + moveRightBtn.setImage(btnImg.getImage(ButtonImage.Add)); + moveRightBtn.setLayoutData(btnData); + moveRightBtn.setEnabled(false); + moveRightBtn.setToolTipText("Move selected item(s) right"); + moveRightBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleMoveRight(); + if (updateCallback != null) { + updateCallback.selectionChanged(); + } + } + }); + + btnData = new GridData(buttonWidth, buttonHeight); + moveLeftBtn = new Button(selectComp, SWT.PUSH); + moveLeftBtn.setImage(btnImg.getImage(ButtonImage.Remove)); + moveLeftBtn.setLayoutData(btnData); + moveLeftBtn.setEnabled(false); + moveLeftBtn.setToolTipText("Move selected item(s) left"); + moveLeftBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleMoveLeft(); + if (updateCallback != null) { + updateCallback.selectionChanged(); + } + } + }); + + btnData = new GridData(buttonWidth, buttonHeight); + moveAllLeftBtn = new Button(selectComp, SWT.PUSH); + moveAllLeftBtn.setImage(btnImg.getImage(ButtonImage.RemoveAll)); + moveAllLeftBtn.setLayoutData(btnData); + moveAllLeftBtn.setEnabled(false); + moveAllLeftBtn.setToolTipText("Move all items left"); + moveAllLeftBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleMoveAllLeft(true); + if (updateCallback != null) { + updateCallback.selectionChanged(); + } + } + }); + } + + /** + * Create the selected list control. + */ + private void createSelectedListControl() { + GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true); + listData.widthHint = config.getListWidth(); + listData.heightHint = config.getListHeight(); + + selectedList = new List(this, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL + | SWT.H_SCROLL); + selectedList.setLayoutData(listData); + selectedList.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (selectedList.getSelectionCount() > 0) { + moveLeftBtn.setEnabled(true); + } else { + moveLeftBtn.setEnabled(false); + } + + enableDisableUpDownButtons(); + } + }); + + selectedList.addMouseListener(new MouseAdapter() { + @Override + public void mouseDown(MouseEvent arg0) { + if (arg0.button == 3) { + if (config.getMenuData() != null + && config.getMenuData().isShowMenu()) { + showSelectedListMenu(); + } + } + } + }); + + } + + /** + * Create the move up/down controls + */ + private void createMoveUpDownControls() { + + GridData actionData = new GridData(SWT.DEFAULT, SWT.CENTER, false, true); + GridLayout actionLayout = new GridLayout(1, false); + Composite actionComp = new Composite(this, SWT.NONE); + actionComp.setLayout(actionLayout); + actionComp.setLayoutData(actionData); + + GridData btnData = new GridData(buttonWidth, buttonHeight); + + moveUpBtn = new Button(actionComp, SWT.PUSH); + moveUpBtn.setImage(btnImg.getImage(ButtonImage.Up)); + moveUpBtn.setLayoutData(btnData); + moveUpBtn.setEnabled(false); + moveUpBtn.setToolTipText("Move item up in the list"); + moveUpBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleMoveUp(); + } + }); + + btnData = new GridData(buttonWidth, buttonHeight); + moveDownBtn = new Button(actionComp, SWT.PUSH); + moveDownBtn.setImage(btnImg.getImage(ButtonImage.Down)); + moveDownBtn.setLayoutData(btnData); + moveDownBtn.setEnabled(false); + moveDownBtn.setToolTipText("Move item down in the list"); + moveDownBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleMoveDown(); + } + }); + } + + /** + * Set FullList. + * + * @param fullList + * all users listed in notification table + */ + public void setFullList(ArrayList fullList) { + config.setFullList(fullList); + populateLists(); + } + + /** + * Populate the available and selected list controls. + */ + private void populateLists() { + availableList.removeAll(); + selectedList.removeAll(); + + if (config.getFullList().size() == 0) { + return; + } + + if (config.getFullList() != null) { + for (String s : config.getFullList()) { + if (s == null) { + continue; + } + if (config.getSelectedList().contains(s) == false) { + availableList.add(s); + } + } + } + if (config.getSelectedList() != null) { + for (String s : config.getSelectedList()) { + selectedList.add(s); + } + } + + if (availableList.getItemCount() > 0) { + moveAllRightBtn.setEnabled(true); + } + + if (selectedList.getItemCount() > 0) { + moveAllLeftBtn.setEnabled(true); + } + + entriesUpdated(); + } + + /** + * Move down event handler + */ + private void handleMoveDown() { + if (selectedList.getSelectionCount() == 1 + && selectedList.getItemCount() > 1) { + int selectedIdx = selectedList.getSelectionIndex(); + String item = selectedList.getItem(selectedIdx); + + if (selectedIdx < selectedList.getItemCount() - 2) { + selectedList.remove(selectedIdx); + selectedList.add(item, selectedIdx + 1); + selectedList.select(selectedIdx + 1); + } else if (selectedIdx < selectedList.getItemCount() - 1) { + selectedList.remove(selectedIdx); + selectedList.add(item); + selectedList.select(selectedList.getItemCount() - 1); + } + enableDisableUpDownButtons(); + } + } + + /** + * Move left event handler + */ + private void handleMoveLeft() { + int[] selectionIndices = selectedList.getSelectionIndices(); + + moveLeft = true; + + if (selectionIndices.length == 0) { + return; + } + + int firstIndex = selectionIndices[0]; + + HashSet list = config.getIncludeList(); + + if (list.contains(selectedList.getItem(firstIndex))) { + + return; + } + + reloadAvailableList(); + + selectedList.remove(selectionIndices); + + if (selectedList.getItemCount() > 0) { + if (firstIndex < selectedList.getItemCount()) { + selectedList.setSelection(firstIndex); + } else { + selectedList.setSelection(selectedList.getItemCount() - 1); + } + } else { + moveLeftBtn.setEnabled(false); + } + + moveAllRightBtn.setEnabled(true); + + entriesUpdated(); + enableDisableUpDownButtons(); + } + + /** + * Move all left event handler + */ + private void handleMoveAllLeft(boolean callEntriesUpdated) { + + HashSet list = config.getIncludeList(); + moveAllLeft = true; + + for (String sl : selectedList.getItems()) { + + if (!list.contains(sl)) { + selectedList.remove(sl); + } + + } + + reloadAvailableList(); + moveLeftBtn.setEnabled(false); + moveAllLeftBtn.setEnabled(false); + moveAllRightBtn.setEnabled(true); + + if (callEntriesUpdated == true) { + entriesUpdated(); + } + + enableDisableUpDownButtons(); + } + + /** + * Move up event handler + */ + private void handleMoveUp() { + if (selectedList.getSelectionCount() == 1) { + int selectedIdx = selectedList.getSelectionIndex(); + String col = selectedList.getItem(selectedIdx); + + if (selectedIdx > 0) { + selectedList.remove(selectedIdx); + selectedList.add(col, selectedIdx - 1); + selectedList.select(selectedIdx - 1); + } + enableDisableUpDownButtons(); + } + } + + /** + * Move all right event handler + */ + private void handleMoveAllRight() { + String[] items = availableList.getItems(); + + if (items.length == 0) { + return; + } + + for (String item : items) { + selectedList.add(item); + } + + availableList.removeAll(); + moveRightBtn.setEnabled(false); + moveAllRightBtn.setEnabled(false); + moveAllLeftBtn.setEnabled(true); + + entriesUpdated(); + enableDisableUpDownButtons(); + } + + /** + * Move right event handler + */ + private void handleMoveRight() { + String[] items = availableList.getSelection(); + + if (items.length == 0) { + return; + } + + int firstIdxSelected = availableList.indexOf(items[0]); + + for (String item : items) { + selectedList.add(item); + } + + availableList.remove(availableList.getSelectionIndices()); + + if (availableList.getItemCount() == 0) { + moveRightBtn.setEnabled(false); + } else { + if (firstIdxSelected > availableList.getItemCount() - 1) { + availableList.select(availableList.getItemCount() - 1); + } else { + availableList.select(firstIdxSelected); + } + } + + moveAllLeftBtn.setEnabled(true); + + entriesUpdated(); + enableDisableUpDownButtons(); + } + + /** + * Convenience method to handle the enabling/disabling of the up and down + * buttons. This depends on how many items are in the list, how many items + * are selected, where the selected it is in the list. + */ + private void enableDisableUpDownButtons() { + // Return if the buttons are now even visible. + if (config.isShowUpDownBtns() == false) { + return; + } + + if (selectedList.getSelectionCount() > 1 + || selectedList.getSelectionCount() == 0) { + moveUpBtn.setEnabled(false); + moveDownBtn.setEnabled(false); + } else { + if (selectedList.getSelectionIndex() == 0 + || selectedList.getItemCount() == 0) { + moveUpBtn.setEnabled(false); + } else { + moveUpBtn.setEnabled(true); + } + + if (selectedList.getSelectionIndex() == selectedList.getItemCount() - 1 + || selectedList.getItemCount() == 0) { + moveDownBtn.setEnabled(false); + } else { + moveDownBtn.setEnabled(true); + } + } + } + + /** + * Reload the availableList data preserving the original order of the list. + */ + private void reloadAvailableList() { + + String[] selectedStrings = availableList.getSelection(); + ArrayList availableListNew = new ArrayList(); + String search = config.getSearchField(); + + String[] selectedItemArray = selectedList.getItems(); + ArrayList selectedItemList = new ArrayList(); + + for (String selectedItem : selectedItemArray) { + selectedItemList.add(selectedItem); + } + + // Check if search field text present + if (config.getSearchField() == null) { + + // If no search field text + if (moveAllLeft) { + + availableList.removeAll(); + + for (String s : config.getFullList()) { + if (!selectedItemList.contains(s)) { + availableList.add(s); + } + } + } else if (moveLeft) { + // Add selected item matching search field text to available + // list + for (String s : selectedList.getSelection()) { + availableList.add(s); + } + + // Sort the list(); + availableListNew = sortAvailable(availableList); + + availableList.removeAll(); + + for (String b : availableListNew) { + availableList.add(b); + } + + } + } else { + + if (moveAllLeft) { + + availableList.removeAll(); + + // Add all matching search field text to available list + for (String s : config.getFullList()) { + if (s.contains(search)) { + availableList.add(s); + } + } + + } else if (moveLeft) { + + // Add selected item matching search field text to available + // list + for (String s : selectedList.getSelection()) { + availableList.add(s); + } + + // Sort the list + availableListNew = sortAvailable(availableList); + + availableList.removeAll(); + + for (String b : availableListNew) { + availableList.add(b); + } + } + } + + moveAllLeft = false; + moveLeft = false; + + availableList.setSelection(selectedStrings); + } + + private void showAvailableListMenu() { + IMenuData menuData = config.getMenuData(); + if (menuData.isShowMenu() && availableList.getSelectionCount() > 0) { + menuData.setListSelection(availableList.getSelection()[0]); + menuData.showListMenu(getShell(), config.getMenuData() + .getMenuText()); + } + } + + private void showSelectedListMenu() { + IMenuData menuData = config.getMenuData(); + if (menuData.isShowMenu() && selectedList.getSelectionCount() > 0) { + menuData.setListSelection(selectedList.getSelection()[0]); + menuData.showListMenu(getShell(), config.getMenuData() + .getMenuText()); + } + } + + private ArrayList sortAvailable(List oldAvailableList) { + + ArrayList availableListsorted = new ArrayList(); + String[] arr = oldAvailableList.getItems(); + + // Put available list in order + if (config.isNumericData()) { + // If data are numeric then must sort on the numeric value + try { + Map map = new TreeMap(); + for (String a : arr) { + map.put(Integer.parseInt(a), a); + } + + for (Integer i : map.keySet()) { + availableListsorted.add(map.get(i)); + } + } catch (NumberFormatException e) { + // numeric data not all numeric, string sorting + availableListsorted = (ArrayList) Arrays.asList(arr); + Collections.sort(availableListsorted); + } + } else { + for (String a : arr) { + availableListsorted.add(a); + } + + Collections.sort(availableListsorted); + } + + return availableListsorted; + } + + /** + * Calls the callback method to notify something has changed. + */ + private void entriesUpdated() { + if (updateCallback != null) { + if (selectedList.getItemCount() == 0) { + updateCallback.hasEntries(false); + } else { + updateCallback.hasEntries(true); + } + } + } + + /** + * Clear all users. + */ + public void clearSelection() { + handleMoveAllLeft(false); + } + + /** + * Clear Available Users list. + * + * @param clearSelectionList + */ + public void clearAvailableList(boolean clearSelectionList) { + this.availableList.removeAll(); + + if (clearSelectionList == true) { + clearSelection(); + } + } + + /** + * Set the Available List items. + * + * @param items + * the list items. + */ + public void setAvailableItems(java.util.List items) { + this.availableList.setItems(items.toArray(new String[items.size()])); + } + + /** + * Get the number of items in the list. + * + * @return the number of items. + */ + public int getItemCount() { + return selectedList.getItemCount(); + } + + /** + * Get the Selected List items. + * + * @return the items in the selected list. + */ + public String[] getSelectedListItems() { + return selectedList.getItems(); + } + + /** + * Get the selection. + * + * @return the selections. + */ + public String[] getSelectedSelection() { + return selectedList.getSelection(); + } + + /** + * Get the configuration. + * + * @return items in available list. + */ + public String[] getAvailableListItems() { + return availableList.getItems(); + } + + /** + * Set the Selected List items. + * + * @param items + * the list items. + */ + public void setSelectedItems(String[] items) { + selectedList.setItems(items); + reloadAvailableList(); + } + + /** + * Selected User items. + * + * @param selection + * selected user items + */ + public void selectItems(String[] selection) { + availableList.deselectAll(); + int[] selectedIndices = new int[selection.length]; + for (int i = 0; i < selection.length; i++) { + selectedIndices[i] = availableList.indexOf(selection[i]); + } + + availableList.select(selectedIndices); + handleMoveRight(); + } + + /** + * Get the configuration. + * + * @return the configuration. + */ + public DualListConfig getConfig() { + return config; + } + + /** + * Set the configuration. + * + * @param config + * the configuration. + */ + public void setConfig(DualListConfig config) { + this.config = config; + } +} \ No newline at end of file diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualListConfig.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualListConfig.java new file mode 100644 index 0000000000..9f07b12469 --- /dev/null +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualListConfig.java @@ -0,0 +1,297 @@ +/** + * 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.viz.ui.widgets.duallist; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + + +/** + * Config file for DualList class. Reused from Data Delivery. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 31, 2012            mpduff      Initial creation.
+ * Aug 10, 2012  1002      mpduff      Added numeric flag for sorting.
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class DualListConfig { + + /** + * Available list text set to a default. + */ + private String availableListText = "Available:"; + + /** + * Selected list text set to a default. + */ + private String selectedListText = "Selected:"; + + /** + * Width of the list controls. + */ + private int listWidth = 100; + + /** + * Height of the list controls. + */ + private int listHeight = 125; + + /** + * Flag to determine if the up/down buttons should be shown. + */ + private boolean showUpDownBtns = false; + + /** + * List of items that should initially appear in the selected item list. + */ + private List selectedList = new ArrayList(); + + /** + * Full list of available items. + */ + private List fullList = new ArrayList(); + + /** + * The list to include. + */ + private HashSet includeList = new HashSet(); + + /** + * The search field. + */ + private String searchField = null; + + private IMenuData menuData; + + /** Flag for numeric data */ + private boolean numericData = false; + + /** + * Constructor. + */ + public DualListConfig() { + + } + + /** + * Get the include list. + * + * @return the include list. + */ + public HashSet getIncludeList() { + return includeList; + } + + /** + * Set the include list. + * + * @param includeList + * List to always include. + */ + public void setIncludeList(HashSet includeList) { + this.includeList = includeList; + } + + /** + * Get the available list header text. + * + * @return Available list header text. + */ + public String getAvailableListText() { + return availableListText; + } + + /** + * Set the available list header text. + * + * @param availableListLabel + * Available list header text. + */ + public void setAvailableListLabel(String availableListLabel) { + this.availableListText = availableListLabel; + } + + /** + * Get the selected list header text. + * + * @return Selected list header text. + */ + public String getSelectedListText() { + return selectedListText; + } + + /** + * Set the selected list header text. + * + * @param selectedListLabel + * Selected list header text. + */ + public void setSelectedListLabel(String selectedListLabel) { + this.selectedListText = selectedListLabel; + } + + /** + * Get the list control width. + * + * @return The list width. + */ + public int getListWidth() { + return listWidth; + } + + /** + * Set the width of the list control. + * + * @param listWidth + * Width of the list control. + */ + public void setListWidth(int listWidth) { + this.listWidth = listWidth; + } + + /** + * Get the height of the list control. + * + * @return The height of the list control. + */ + public int getListHeight() { + return listHeight; + } + + /** + * Set the height of the list control. + * + * @param listHeight + * The height of the list control. + */ + public void setListHeight(int listHeight) { + this.listHeight = listHeight; + } + + /** + * Check if the up/down buttons should be shown. + * + * @return True if the buttons are shown, false if hidden. + */ + public boolean isShowUpDownBtns() { + return showUpDownBtns; + } + + /** + * Set the show up/down button flag. + * + * @param showUpDownBtns + * True to show the buttons, false to not show the buttons. + */ + public void setShowUpDownBtns(boolean showUpDownBtns) { + this.showUpDownBtns = showUpDownBtns; + } + + /** + * Get an array of selected items. + * + * @return An array of selected items. + */ + public List getSelectedList() { + return selectedList; + } + + /** + * Set the array of selected items. + * + * @param selectedList + * Array of selected items. + */ + public void setSelectedList(List selectedList) { + this.selectedList = selectedList; + } + + /** + * Get an array of all of the available items. + * + * @return The array of all available items. + */ + public List getFullList() { + return fullList; + } + + /** + * Set the array of all of the available items. + * + * @param fullList + * The array of all available items. + */ + public void setFullList(List fullList) { + this.fullList = fullList; + } + + /** + * Get the search field text. + * + * @return the String + * the search field text. + */ + public String getSearchField() { + return searchField; + } + + /** + * Set the search field text. + * + * @param searchField + * the search field text. + */ + public void setSearchField(String searchField) { + this.searchField = searchField; + } + + public IMenuData getMenuData() { + return menuData; + } + + public void setMenuData(IMenuData menuData) { + this.menuData = menuData; + } + + /** + * @param numericData the numericData to set + */ + public void setNumericData(boolean numericData) { + this.numericData = numericData; + } + + /** + * @return the numericData + */ + public boolean isNumericData() { + return numericData; + } +} diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/IMenuData.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/IMenuData.java new file mode 100644 index 0000000000..0776cc1c8f --- /dev/null +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/IMenuData.java @@ -0,0 +1,71 @@ +/** + * 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.viz.ui.widgets.duallist; + + +import org.eclipse.swt.widgets.Shell; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 1, 2012            mpduff     Initial creation
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public interface IMenuData { + /** + * Show a popup menu on the list right click + * + * @param shell The shell + * @param menuText The menu text + */ + public void showListMenu(Shell shell, String menuText); + + /** + * Show a popup menu. + * + * @return true to show menu, false to not show a menu + */ + public boolean isShowMenu(); + + /** + * Get the list menu text. + * + * @return the menu text + */ + public String getMenuText(); + + /** + * Set the list selection. + * + * @param string The selection + */ + public void setListSelection(String string); +} diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/IUpdate.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/IUpdate.java new file mode 100644 index 0000000000..0c8916d9de --- /dev/null +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/IUpdate.java @@ -0,0 +1,54 @@ +/** + * 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.viz.ui.widgets.duallist; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 31, 2012            mpduff     Initial creation.
+ * Aug 08, 2012    863     jpiatt     Added selectedChange method for clean & dirty checks.
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public interface IUpdate { + /** + * Method called when a control has items or when the control becomes empty. + * + * @param entries + * Entries flag. True if there are entries, false if there are no + * entries. + */ + void hasEntries(boolean entries); + + /** + * Method called when a change in selection occurs. + */ + public void selectionChanged(); +} diff --git a/cave/ohd.hseb.common/.classpath b/cave/ohd.hseb.common/.classpath index 78fc66cee2..3385703d78 100644 --- a/cave/ohd.hseb.common/.classpath +++ b/cave/ohd.hseb.common/.classpath @@ -7,7 +7,6 @@ - diff --git a/cave/ohd.hseb.common/META-INF/MANIFEST.MF b/cave/ohd.hseb.common/META-INF/MANIFEST.MF index 0498cf6569..29524e817f 100644 --- a/cave/ohd.hseb.common/META-INF/MANIFEST.MF +++ b/cave/ohd.hseb.common/META-INF/MANIFEST.MF @@ -120,13 +120,6 @@ Export-Package: ChartDirector, org.apache.bsf.util.event.generator, org.apache.bsf.util.type, org.apache.taglibs.bsf, - org.jdom, - org.jdom.adapters, - org.jdom.filter, - org.jdom.input, - org.jdom.output, - org.jdom.transform, - org.jdom.xpath, org.postgresql, org.postgresql.core, org.postgresql.core.types, @@ -243,7 +236,6 @@ Bundle-ClassPath: externaljars/bsf.jar, externaljars/fldat.jar, externaljars/ihfsdb.jar, externaljars/jcchart.jar, - externaljars/jdom.jar, externaljars/junit.jar, externaljars/netcdfUI-2.2.22.jar, externaljars/nlog4j-1.2.21.jar, diff --git a/cave/ohd.hseb.common/externaljars/jdom.jar b/cave/ohd.hseb.common/externaljars/jdom.jar deleted file mode 100755 index 6d04bac92f..0000000000 Binary files a/cave/ohd.hseb.common/externaljars/jdom.jar and /dev/null differ diff --git a/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLDecoder.java b/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLDecoder.java index 3b53a81afc..e556764351 100644 --- a/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLDecoder.java +++ b/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLDecoder.java @@ -33,6 +33,7 @@ import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; import org.jdom.output.XMLOutputter; @@ -539,14 +540,13 @@ public class SacXMLDecoder public String toString() { StringWriter stringWriter = new StringWriter(); - XMLOutputter outputter = new XMLOutputter(); + Format format = Format.getPrettyFormat(); + format = format.setIndent(" "); + XMLOutputter outputter = new XMLOutputter(format); String returnValue = null; try { - outputter.setTextTrim( true ); - outputter.setIndent( " " ); - outputter.setNewlines( true ); outputter.output( _doc, stringWriter ); returnValue = stringWriter.toString(); } diff --git a/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLEncoder.java b/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLEncoder.java index 412dc41973..329605160f 100644 --- a/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLEncoder.java +++ b/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLEncoder.java @@ -30,6 +30,7 @@ import ohd.hseb.util.StringParser; import org.jdom.Document; import org.jdom.Element; +import org.jdom.output.Format; import org.jdom.output.XMLOutputter; public class SacXMLEncoder @@ -552,7 +553,9 @@ public class SacXMLEncoder private void writeXmlToFile(Document outputXmlDoc, String xmlFileName) { - XMLOutputter _xmlOutputter = new XMLOutputter(" ", true); + Format format = Format.getRawFormat(); + format.setIndent(" "); + XMLOutputter _xmlOutputter = new XMLOutputter(format); try { diff --git a/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLTester.java b/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLTester.java index 62994deaca..ae2616b90b 100644 --- a/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLTester.java +++ b/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SacXMLTester.java @@ -33,8 +33,9 @@ import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; +import org.jdom.output.Format.TextMode; import org.jdom.output.XMLOutputter; - +import org.jdom.output.Format; public class SacXMLTester { @@ -473,14 +474,13 @@ public class SacXMLTester public String toString() { StringWriter stringWriter = new StringWriter(); - XMLOutputter outputter = new XMLOutputter(); + Format format = Format.getPrettyFormat(); + format = format.setIndent(" "); + XMLOutputter outputter = new XMLOutputter(format); String returnValue = null; try { - outputter.setTextTrim( true ); - outputter.setIndent( " " ); - outputter.setNewlines( true ); outputter.output( _inputXMLDoc, stringWriter ); returnValue = stringWriter.toString(); } @@ -494,7 +494,9 @@ public class SacXMLTester private void writeXmlToFile(Document outputXmlDoc, String xmlFileName) { - XMLOutputter _xmlOutputter = new XMLOutputter(" ", true); + Format format = Format.getRawFormat(); + format.setIndent(" "); + XMLOutputter _xmlOutputter = new XMLOutputter(format); try { diff --git a/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SshpDataTransferMgr.java b/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SshpDataTransferMgr.java index 87257d166b..3c8505738f 100644 --- a/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SshpDataTransferMgr.java +++ b/cave/ohd.hseb.sshp/src/ohd/hseb/sshp/messaging/SshpDataTransferMgr.java @@ -20,6 +20,7 @@ import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; import org.jdom.output.XMLOutputter; /** @@ -37,7 +38,7 @@ public class SshpDataTransferMgr private Document _controlDoc = null; private SAXBuilder _builder = new SAXBuilder(); - private XMLOutputter _xmlOutputter = new XMLOutputter(" ", true); + private XMLOutputter _xmlOutputter = null; private FileLogger _logger = null; private String _logFilePath = null; @@ -59,6 +60,10 @@ public class SshpDataTransferMgr _logger = new FileLogger(_logFilePath); + Format format = Format.getRawFormat(); + format.setIndent(" "); + this._xmlOutputter = new XMLOutputter(format); + loadControlFile(); return; diff --git a/cots/com.google.guava/.settings/org.eclipse.jdt.core.prefs b/cots/com.google.guava/.settings/org.eclipse.jdt.core.prefs index 1386d17f43..9ea81993e4 100644 --- a/cots/com.google.guava/.settings/org.eclipse.jdt.core.prefs +++ b/cots/com.google.guava/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,11 @@ +<<<<<<< HEAD +#Wed Feb 15 11:40:52 CST 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +======= #Thu Mar 26 11:28:33 CDT 2009 eclipse.preferences.version=1 +>>>>>>> development org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error diff --git a/cots/net.jcip/.classpath b/cots/net.jcip/.classpath new file mode 100644 index 0000000000..10f492202b --- /dev/null +++ b/cots/net.jcip/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/cots/net.jcip/.project b/cots/net.jcip/.project new file mode 100644 index 0000000000..47f6994d3d --- /dev/null +++ b/cots/net.jcip/.project @@ -0,0 +1,28 @@ + + + net.jcip + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/cots/net.jcip/.settings/org.eclipse.jdt.core.prefs b/cots/net.jcip/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..503d44edbb --- /dev/null +++ b/cots/net.jcip/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Wed Jul 25 12:18:05 CDT 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/cots/net.jcip/META-INF/MANIFEST.MF b/cots/net.jcip/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..2aa0f158d4 --- /dev/null +++ b/cots/net.jcip/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Jcip Plugin +Bundle-SymbolicName: net.jcip +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ClassPath: jcip-annotations.jar, + . +Export-Package: net.jcip.annotations diff --git a/cots/net.jcip/build.properties b/cots/net.jcip/build.properties new file mode 100644 index 0000000000..61cb16eb3f --- /dev/null +++ b/cots/net.jcip/build.properties @@ -0,0 +1,4 @@ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + jcip-annotations.jar diff --git a/cots/net.jcip/jcip-annotations-src.jar b/cots/net.jcip/jcip-annotations-src.jar new file mode 100644 index 0000000000..bf52a507df Binary files /dev/null and b/cots/net.jcip/jcip-annotations-src.jar differ diff --git a/cots/net.jcip/jcip-annotations.jar b/cots/net.jcip/jcip-annotations.jar new file mode 100644 index 0000000000..ea263af054 Binary files /dev/null and b/cots/net.jcip/jcip-annotations.jar differ diff --git a/cots/org.geotools/.classpath b/cots/org.geotools/.classpath index 023e775466..bb04b154d2 100644 --- a/cots/org.geotools/.classpath +++ b/cots/org.geotools/.classpath @@ -2,7 +2,6 @@ - @@ -10,23 +9,51 @@ - - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cots/org.geotools/.settings/org.eclipse.jdt.core.prefs b/cots/org.geotools/.settings/org.eclipse.jdt.core.prefs index edef664082..1ffe2d7934 100644 --- a/cots/org.geotools/.settings/org.eclipse.jdt.core.prefs +++ b/cots/org.geotools/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,8 @@ -#Thu Mar 26 11:29:04 CDT 2009 +#Fri Jun 08 11:49:31 CDT 2012 eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/cots/org.geotools/META-INF/MANIFEST.MF b/cots/org.geotools/META-INF/MANIFEST.MF index 03b4ddf7c5..19df7a6c76 100644 --- a/cots/org.geotools/META-INF/MANIFEST.MF +++ b/cots/org.geotools/META-INF/MANIFEST.MF @@ -3,36 +3,61 @@ Bundle-ManifestVersion: 2 Bundle-Name: Geotools Plug-in Bundle-SymbolicName: org.geotools Bundle-Version: 2.6.4 -Bundle-Vendor: Raytheon-bundled OSS -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Eclipse-BuddyPolicy: registered, ext, global -Bundle-ClassPath: geoapi-2.3-M1.jar, - geoapi-pending-2.3-M1.jar, - gt-api-2.6.4.jar, - gt-coverage-2.6.4.jar, - gt-epsg-wkt-2.6.4.jar, - gt-geotiff-2.6.4.jar, - gt-graph-2.6.4.jar, - gt-gtopo30-2.6.4.jar, - gt-image-2.6.4.jar, - gt-main-2.6.4.jar, - gt-metadata-2.6.4.jar, - gt-referencing-2.6.4.jar, - gt-referencing3D-2.6.4.jar, - gt-shapefile-2.6.4.jar, - gt-postgis-2.6.4.jar, - jts-1.10.jar, +Bundle-ClassPath: common-2.2.1.jar, commons-beanutils-1.7.0.jar, commons-codec-1.2.jar, commons-collections-3.1.jar, commons-dbcp-1.2.2.jar, commons-jxpath-1.2.jar, commons-lang-2.3.jar, - commons-logging-1.1.1.jar, commons-pool-1.5.3.jar, - common-2.2.1.jar, - jdom-1.0.jar -Export-Package: com.vividsolutions.jts, + ecore-2.2.2.jar, + geoapi-2.3-M1.jar, + geoapi-pending-2.3-M1.jar, + gt-api-2.6.4-sources.jar, + gt-api-2.6.4.jar, + gt-coverage-2.6.4-sources.jar, + gt-coverage-2.6.4.jar, + gt-cql-2.6.4.jar, + gt-epsg-wkt-2.6.4-sources.jar, + gt-epsg-wkt-2.6.4.jar, + gt-geotiff-2.6.4-sources.jar, + gt-geotiff-2.6.4.jar, + gt-graph-2.6.4-sources.jar, + gt-graph-2.6.4.jar, + gt-gtopo30-2.6.4-sources.jar, + gt-gtopo30-2.6.4.jar, + gt-image-2.6.4-sources.jar, + gt-image-2.6.4.jar, + gt-main-2.6.4-sources.jar, + gt-main-2.6.4.jar, + gt-metadata-2.6.4-sources.jar, + gt-metadata-2.6.4.jar, + gt-referencing-2.6.4-sources.jar, + gt-referencing-2.6.4.jar, + gt-referencing3D-2.6.4-sources.jar, + gt-referencing3D-2.6.4.jar, + gt-render-2.6.4.jar, + gt-shapefile-2.6.4-sources.jar, + gt-shapefile-2.6.4.jar, + gt-xml-2.6.4.jar, + gt-xsd-core-2.6.4.jar, + gt-xsd-filter-2.6.4.jar, + gt-xsd-gml2-2.6.4.jar, + gt-xsd-gml3-2.6.4.jar, + gt-xsd-kml-2.6.4.jar, + gt-xsd-sld-2.6.4.jar, + jdom-1.0.jar, + gt-postgis-2.6.4.jar, + jts-1.10.jar, + picocontainer-1.2.jar, + xercesImpl-2.7.1.jar, + xml-apis-1.0.b2.jar, + xml-apis-xerces-2.7.1.jar, + xsd-2.2.2.jar +Bundle-Vendor: Raytheon-bundled OSS +Export-Package: ., + com.vividsolutions.jts, com.vividsolutions.jts.algorithm, com.vividsolutions.jts.algorithm.locate, com.vividsolutions.jts.geom, @@ -70,6 +95,17 @@ Export-Package: com.vividsolutions.jts, com.vividsolutions.jts.precision, com.vividsolutions.jts.simplify, com.vividsolutions.jts.util, + org.eclipse.emf.common, + org.eclipse.emf.common.archive, + org.eclipse.emf.common.command, + org.eclipse.emf.common.notify, + org.eclipse.emf.common.notify.impl, + org.eclipse.emf.common.util, + org.eclipse.xsd, + org.eclipse.xsd.ecore, + org.eclipse.xsd.impl, + org.eclipse.xsd.impl.type, + org.eclipse.xsd.util, org.geotools.console, org.geotools.coverage, org.geotools.coverage.grid, @@ -80,54 +116,228 @@ Export-Package: com.vividsolutions.jts, org.geotools.coverage.processing, org.geotools.coverage.processing.operation, org.geotools.data, + org.geotools.data.collection, org.geotools.data.crs, + org.geotools.data.memory, + org.geotools.data.ows, org.geotools.data.postgis, org.geotools.data.shapefile, org.geotools.data.shapefile.dbf, org.geotools.data.shapefile.indexed, + org.geotools.data.shapefile.indexed.attribute, + org.geotools.data.shapefile.prj, + org.geotools.data.shapefile.shp, + org.geotools.data.shapefile.shp.xml, + org.geotools.data.store, + org.geotools.data.view, org.geotools.factory, org.geotools.feature, + org.geotools.feature.collection, org.geotools.feature.simple, org.geotools.feature.type, + org.geotools.feature.visitor, org.geotools.filter, + org.geotools.filter.capability, + org.geotools.filter.expression, + org.geotools.filter.function, + org.geotools.filter.function.math, + org.geotools.filter.function.string, + org.geotools.filter.identity, + org.geotools.filter.spatial, + org.geotools.filter.v1_0, + org.geotools.filter.v1_0.capabilities, + org.geotools.filter.v1_1, + org.geotools.filter.v1_1.capabilities, + org.geotools.filter.visitor, org.geotools.gce.geotiff, + org.geotools.gce.geotiff.adapters, + org.geotools.gce.geotiff.codes, + org.geotools.gce.gtopo30, + org.geotools.gce.image, org.geotools.geometry, + org.geotools.geometry.coordinatesequence, org.geotools.geometry.jts, + org.geotools.geometry.jts.coordinatesequence, + org.geotools.geometry.text, + org.geotools.gml, + org.geotools.gml.producer, + org.geotools.gml2, + org.geotools.gml2.bindings, + org.geotools.gml3, + org.geotools.gml3.bindings, + org.geotools.gml3.bindings.smil, + org.geotools.gml3.smil, + org.geotools.gml3.v3_2, + org.geotools.gml3.v3_2.gco, + org.geotools.gml3.v3_2.gmd, + org.geotools.gml3.v3_2.gmx, + org.geotools.gml3.v3_2.gsr, + org.geotools.gml3.v3_2.gss, + org.geotools.gml3.v3_2.gts, + org.geotools.graph.build, + org.geotools.graph.build.basic, + org.geotools.graph.build.feature, + org.geotools.graph.build.line, + org.geotools.graph.build.opt, + org.geotools.graph.build.polygon, + org.geotools.graph.io, + org.geotools.graph.io.standard, + org.geotools.graph.path, + org.geotools.graph.structure, + org.geotools.graph.structure.basic, + org.geotools.graph.structure.line, + org.geotools.graph.structure.opt, + org.geotools.graph.traverse, + org.geotools.graph.traverse.basic, + org.geotools.graph.traverse.standard, + org.geotools.graph.util, + org.geotools.graph.util.delaunay, + org.geotools.graph.util.geom, + org.geotools.graph.util.graph, + org.geotools.image, + org.geotools.image.io, + org.geotools.image.jai, + org.geotools.image.palette, + org.geotools.index, + org.geotools.index.quadtree, + org.geotools.index.quadtree.fs, + org.geotools.io, + org.geotools.kml, + org.geotools.kml.bindings, + org.geotools.legend, + org.geotools.map, + org.geotools.map.event, org.geotools.math, + org.geotools.measure, + org.geotools.metadata, + org.geotools.metadata.iso, + org.geotools.metadata.iso.citation, + org.geotools.metadata.iso.constraint, + org.geotools.metadata.iso.content, + org.geotools.metadata.iso.distribution, + org.geotools.metadata.iso.extent, + org.geotools.metadata.iso.identification, + org.geotools.metadata.iso.lineage, + org.geotools.metadata.iso.maintenance, + org.geotools.metadata.iso.quality, + org.geotools.metadata.iso.spatial, + org.geotools.metadata.sql, + org.geotools.nature, + org.geotools.ows, org.geotools.parameter, org.geotools.referencing, org.geotools.referencing.crs, org.geotools.referencing.cs, org.geotools.referencing.datum, + org.geotools.referencing.factory, + org.geotools.referencing.factory.epsg, + org.geotools.referencing.factory.wms, org.geotools.referencing.operation, org.geotools.referencing.operation.builder, org.geotools.referencing.operation.matrix, org.geotools.referencing.operation.projection, org.geotools.referencing.operation.transform, + org.geotools.referencing.piecewise, org.geotools.referencing.wkt, + org.geotools.renderer, + org.geotools.renderer.crs, + org.geotools.renderer.i18n, + org.geotools.renderer.label, + org.geotools.renderer.lite, + org.geotools.renderer.lite.gridcoverage2d, + org.geotools.renderer.style, + org.geotools.renderer.style.shape, + org.geotools.resources, + org.geotools.resources.coverage, + org.geotools.resources.geometry, + org.geotools.resources.i18n, + org.geotools.resources.image, + org.geotools.sld, + org.geotools.sld.bindings, + org.geotools.styling, + org.geotools.styling.visitor, + org.geotools.util, org.geotools.util.logging, + org.geotools.xlink, + org.geotools.xml, + org.geotools.xml.filter, + org.geotools.xml.gml, + org.geotools.xml.handlers, + org.geotools.xml.handlers.xsi, + org.geotools.xml.impl, + org.geotools.xml.impl.jxpath, + org.geotools.xml.schema, + org.geotools.xml.schema.impl, + org.geotools.xml.styling, + org.geotools.xml.test, + org.geotools.xml.transform, + org.geotools.xml.xLink, + org.geotools.xml.xsi, + org.geotools.xs, + org.geotools.xs.bindings, + org.geotools.xs.facets, + org.jdom, + org.jdom.adapters, + org.jdom.filter, + org.jdom.input, + org.jdom.output, + org.jdom.transform, + org.jdom.xpath, + org.opengis.annotation, org.opengis.coverage, org.opengis.coverage.grid, + org.opengis.coverage.grid.quadrilateral, org.opengis.coverage.processing, + org.opengis.display.canvas, + org.opengis.display.container, + org.opengis.display.primitive, org.opengis.feature, org.opengis.feature.simple, org.opengis.feature.type, org.opengis.filter, + org.opengis.filter.capability, org.opengis.filter.expression, + org.opengis.filter.identity, + org.opengis.filter.sort, + org.opengis.filter.spatial, org.opengis.geometry, + org.opengis.geometry.aggregate, + org.opengis.geometry.complex, org.opengis.geometry.coordinate, + org.opengis.geometry.primitive, org.opengis.metadata, + org.opengis.metadata.citation, + org.opengis.metadata.constraint, + org.opengis.metadata.content, + org.opengis.metadata.distribution, + org.opengis.metadata.extent, + org.opengis.metadata.identification, + org.opengis.metadata.lineage, + org.opengis.metadata.maintenance, + org.opengis.metadata.quality, org.opengis.metadata.spatial, + org.opengis.observation, + org.opengis.observation.coverage, + org.opengis.observation.sampling, org.opengis.parameter, org.opengis.referencing, org.opengis.referencing.crs, org.opengis.referencing.cs, org.opengis.referencing.datum, org.opengis.referencing.operation, - org.opengis.util -Bundle-ActivationPolicy: lazy + org.opengis.sld, + org.opengis.style, + org.opengis.style.portrayal, + org.opengis.temporal, + org.opengis.util, + org.opengis.webservice, + org.opengis.webservice.capability, + org.opengis.webservice.feature Require-Bundle: javax.vecmath;bundle-version="1.3.1", javax.measure;bundle-version="1.0.0", org.apache.commons.logging, org.apache.log4j, org.postgres;bundle-version="1.0.0" +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Eclipse-BuddyPolicy: registered, ext, global +Bundle-ActivationPolicy: lazy diff --git a/cots/org.geotools/build.properties b/cots/org.geotools/build.properties index c720c23ace..f43f7c58a3 100644 --- a/cots/org.geotools/build.properties +++ b/cots/org.geotools/build.properties @@ -1,19 +1,50 @@ bin.includes = META-INF/,\ .,\ + common-2.2.1.jar,\ + commons-beanutils-1.7.0.jar,\ + commons-codec-1.2.jar,\ + commons-collections-3.1.jar,\ + commons-dbcp-1.2.2.jar,\ + commons-jxpath-1.2.jar,\ + commons-lang-2.3.jar,\ + commons-pool-1.5.3.jar,\ + ecore-2.2.2.jar,\ geoapi-2.3-M1.jar,\ geoapi-pending-2.3-M1.jar,\ + gt-api-2.6.4-sources.jar,\ gt-api-2.6.4.jar,\ + gt-coverage-2.6.4-sources.jar,\ gt-coverage-2.6.4.jar,\ + gt-cql-2.6.4.jar,\ + gt-epsg-wkt-2.6.4-sources.jar,\ gt-epsg-wkt-2.6.4.jar,\ + gt-geotiff-2.6.4-sources.jar,\ gt-geotiff-2.6.4.jar,\ + gt-graph-2.6.4-sources.jar,\ gt-graph-2.6.4.jar,\ + gt-gtopo30-2.6.4-sources.jar,\ gt-gtopo30-2.6.4.jar,\ + gt-image-2.6.4-sources.jar,\ gt-image-2.6.4.jar,\ + gt-main-2.6.4-sources.jar,\ gt-main-2.6.4.jar,\ + gt-metadata-2.6.4-sources.jar,\ gt-metadata-2.6.4.jar,\ + gt-referencing-2.6.4-sources.jar,\ gt-referencing-2.6.4.jar,\ + gt-referencing3D-2.6.4-sources.jar,\ gt-referencing3D-2.6.4.jar,\ + gt-render-2.6.4.jar,\ + gt-shapefile-2.6.4-sources.jar,\ gt-shapefile-2.6.4.jar,\ + gt-xml-2.6.4.jar,\ + gt-xsd-core-2.6.4.jar,\ + gt-xsd-filter-2.6.4.jar,\ + gt-xsd-gml2-2.6.4.jar,\ + gt-xsd-gml3-2.6.4.jar,\ + gt-xsd-kml-2.6.4.jar,\ + gt-xsd-sld-2.6.4.jar,\ + jdom-1.0.jar,\ jts-1.10.jar,\ commons-beanutils-1.7.0.jar,\ commons-codec-1.2.jar,\ @@ -26,4 +57,9 @@ bin.includes = META-INF/,\ jdom-1.0.jar,\ gt-postgis-2.6.4.jar,\ gt-jdbc-2.6.4.jar,\ - gt-jdbc-postgis-2.6.4.jar + gt-jdbc-postgis-2.6.4.jar,\ + picocontainer-1.2.jar,\ + xercesImpl-2.7.1.jar,\ + xml-apis-1.0.b2.jar,\ + xml-apis-xerces-2.7.1.jar,\ + xsd-2.2.2.jar \ No newline at end of file diff --git a/cots/org.geotools/ecore-2.2.2.jar b/cots/org.geotools/ecore-2.2.2.jar new file mode 100644 index 0000000000..d472c76b77 Binary files /dev/null and b/cots/org.geotools/ecore-2.2.2.jar differ diff --git a/cots/org.geotools/gt-cql-2.6.4.jar b/cots/org.geotools/gt-cql-2.6.4.jar new file mode 100644 index 0000000000..50cb35cb7f Binary files /dev/null and b/cots/org.geotools/gt-cql-2.6.4.jar differ diff --git a/cots/org.geotools/gt-render-2.6.4.jar b/cots/org.geotools/gt-render-2.6.4.jar new file mode 100644 index 0000000000..c6e0feb793 Binary files /dev/null and b/cots/org.geotools/gt-render-2.6.4.jar differ diff --git a/cots/org.geotools/gt-xml-2.6.4.jar b/cots/org.geotools/gt-xml-2.6.4.jar new file mode 100644 index 0000000000..4a089f7b0b Binary files /dev/null and b/cots/org.geotools/gt-xml-2.6.4.jar differ diff --git a/cots/org.geotools/gt-xsd-core-2.6.4.jar b/cots/org.geotools/gt-xsd-core-2.6.4.jar new file mode 100644 index 0000000000..a765c8c8af Binary files /dev/null and b/cots/org.geotools/gt-xsd-core-2.6.4.jar differ diff --git a/cots/org.geotools/gt-xsd-filter-2.6.4.jar b/cots/org.geotools/gt-xsd-filter-2.6.4.jar new file mode 100644 index 0000000000..5e0785b99f Binary files /dev/null and b/cots/org.geotools/gt-xsd-filter-2.6.4.jar differ diff --git a/cots/org.geotools/gt-xsd-gml2-2.6.4.jar b/cots/org.geotools/gt-xsd-gml2-2.6.4.jar new file mode 100644 index 0000000000..d76751cd40 Binary files /dev/null and b/cots/org.geotools/gt-xsd-gml2-2.6.4.jar differ diff --git a/cots/org.geotools/gt-xsd-gml3-2.6.4.jar b/cots/org.geotools/gt-xsd-gml3-2.6.4.jar new file mode 100644 index 0000000000..7a60845970 Binary files /dev/null and b/cots/org.geotools/gt-xsd-gml3-2.6.4.jar differ diff --git a/cots/org.geotools/gt-xsd-kml-2.6.4.jar b/cots/org.geotools/gt-xsd-kml-2.6.4.jar new file mode 100644 index 0000000000..8dcf45eea8 Binary files /dev/null and b/cots/org.geotools/gt-xsd-kml-2.6.4.jar differ diff --git a/cots/org.geotools/gt-xsd-sld-2.6.4.jar b/cots/org.geotools/gt-xsd-sld-2.6.4.jar new file mode 100644 index 0000000000..22cf6802b1 Binary files /dev/null and b/cots/org.geotools/gt-xsd-sld-2.6.4.jar differ diff --git a/cots/org.geotools/picocontainer-1.2.jar b/cots/org.geotools/picocontainer-1.2.jar new file mode 100644 index 0000000000..fbb1c925b8 Binary files /dev/null and b/cots/org.geotools/picocontainer-1.2.jar differ diff --git a/cots/org.geotools/xercesImpl-2.7.1.jar b/cots/org.geotools/xercesImpl-2.7.1.jar new file mode 100644 index 0000000000..0b100e14b8 Binary files /dev/null and b/cots/org.geotools/xercesImpl-2.7.1.jar differ diff --git a/cots/org.geotools/xml-apis-1.0.b2.jar b/cots/org.geotools/xml-apis-1.0.b2.jar new file mode 100644 index 0000000000..ad33a5afa6 Binary files /dev/null and b/cots/org.geotools/xml-apis-1.0.b2.jar differ diff --git a/cots/org.geotools/xml-apis-xerces-2.7.1.jar b/cots/org.geotools/xml-apis-xerces-2.7.1.jar new file mode 100644 index 0000000000..243eaeaeb2 Binary files /dev/null and b/cots/org.geotools/xml-apis-xerces-2.7.1.jar differ diff --git a/cots/org.geotools/xsd-2.2.2.jar b/cots/org.geotools/xsd-2.2.2.jar new file mode 100644 index 0000000000..23487367f3 Binary files /dev/null and b/cots/org.geotools/xsd-2.2.2.jar differ diff --git a/cots/org.hibernate/.classpath b/cots/org.hibernate/.classpath index d4f85314f6..a49aca05d1 100644 --- a/cots/org.hibernate/.classpath +++ b/cots/org.hibernate/.classpath @@ -1,9 +1,11 @@ + + - + diff --git a/cots/org.hibernate/.settings/org.eclipse.jdt.core.prefs b/cots/org.hibernate/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..4443c832ba --- /dev/null +++ b/cots/org.hibernate/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Fri Jun 08 11:53:01 CDT 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/cots/org.hibernate/META-INF/MANIFEST.MF b/cots/org.hibernate/META-INF/MANIFEST.MF index 8e39131001..fa6dd0f32e 100644 --- a/cots/org.hibernate/META-INF/MANIFEST.MF +++ b/cots/org.hibernate/META-INF/MANIFEST.MF @@ -3,10 +3,13 @@ Bundle-ManifestVersion: 2 Bundle-Name: Hibernate Plug-in Bundle-SymbolicName: org.hibernate Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: hibernate-spatial-1.0.jar, + hibernate-spatial-postgis-1.0.jar, + hibernate3.5.0-Final.jar, + javassist-3.9.0.GA.jar, + jta-1.1.jar Bundle-Vendor: Hibernate -Require-Bundle: org.slf4j -Export-Package: - org.hibernate, +Export-Package: org.hibernate, org.hibernate.action, org.hibernate.annotations, org.hibernate.annotations.common, @@ -171,7 +174,14 @@ Export-Package: org.hibernate.tuple.entity, org.hibernate.type, org.hibernate.usertype, - org.hibernate.util -Bundle-ClassPath: hibernate3.5.0-Final.jar, - javassist-3.9.0.GA.jar, - jta-1.1.jar + org.hibernate.util, + org.hibernatespatial, + org.hibernatespatial.cfg, + org.hibernatespatial.criterion, + org.hibernatespatial.helper, + org.hibernatespatial.mgeom, + org.hibernatespatial.pojo, + org.hibernatespatial.postgis, + org.hibernatespatial.readers, + org.hibernatespatial.spi +Require-Bundle: org.slf4j diff --git a/cots/org.hibernate/build.properties b/cots/org.hibernate/build.properties index 3fada6b622..802fa8462a 100644 --- a/cots/org.hibernate/build.properties +++ b/cots/org.hibernate/build.properties @@ -1,4 +1,6 @@ bin.includes = META-INF/,\ + hibernate-spatial-1.0.jar,\ + hibernate-spatial-postgis-1.0.jar,\ hibernate3.5.0-Final.jar,\ javassist-3.9.0.GA.jar,\ jta-1.1.jar diff --git a/cots/org.hibernate/hibernate-spatial-1.0.jar b/cots/org.hibernate/hibernate-spatial-1.0.jar new file mode 100644 index 0000000000..8d410502cb Binary files /dev/null and b/cots/org.hibernate/hibernate-spatial-1.0.jar differ diff --git a/cots/org.hibernate/hibernate-spatial-postgis-1.0.jar b/cots/org.hibernate/hibernate-spatial-postgis-1.0.jar new file mode 100644 index 0000000000..930f1e49c2 Binary files /dev/null and b/cots/org.hibernate/hibernate-spatial-postgis-1.0.jar differ diff --git a/cots/org.junit/.classpath b/cots/org.junit/.classpath index bd39c93d4e..7363c566f4 100644 --- a/cots/org.junit/.classpath +++ b/cots/org.junit/.classpath @@ -2,11 +2,14 @@ - - - + + + + + + diff --git a/cots/org.junit/META-INF/MANIFEST.MF b/cots/org.junit/META-INF/MANIFEST.MF index c448390ddc..7f2d8e6aba 100644 --- a/cots/org.junit/META-INF/MANIFEST.MF +++ b/cots/org.junit/META-INF/MANIFEST.MF @@ -3,25 +3,48 @@ Bundle-ManifestVersion: 2 Bundle-Name: Junit Plug-in Bundle-SymbolicName: org.junit Bundle-Version: 1.0.0.qualifier -Bundle-ClassPath: junit-4.3.1.jar, - hamcrest-api-1.0.jar, - hamcrest-library-1.0.jar, - jmock-2.0.0.jar, +Bundle-ClassPath: jmock-2.0.0.jar, jmock-junit3-2.0.0.jar, - jmock-junit4-2.0.0.jar -Export-Package: junit.extensions, + jmock-junit4-2.0.0.jar, + cglib-nodep-2.2.jar, + javassist-3.16.1-GA.jar, + mockito-all-1.9.0.jar, + objenesis-1.2.jar, + powermock-mockito-1.4.12-full.jar, + junit-4.10.jar +Export-Package: javassist, + javassist.bytecode, + javassist.bytecode.analysis, + javassist.bytecode.annotation, + javassist.bytecode.stackmap, + javassist.compiler, + javassist.compiler.ast, + javassist.convert, + javassist.expr, + javassist.runtime, + javassist.scopedpool, + javassist.tools, + javassist.tools.reflect, + javassist.tools.rmi, + javassist.tools.web, + javassist.util, + javassist.util.proxy, + junit.extensions, junit.framework, junit.runner, junit.textui, + net.sf.cglib.asm, + net.sf.cglib.asm.signature, + net.sf.cglib.beans, + net.sf.cglib.core, + net.sf.cglib.proxy, + net.sf.cglib.reflect, + net.sf.cglib.transform, + net.sf.cglib.transform.impl, + net.sf.cglib.util, org.hamcrest, - org.hamcrest.beans, - org.hamcrest.collection, org.hamcrest.core, org.hamcrest.internal, - org.hamcrest.number, - org.hamcrest.object, - org.hamcrest.text, - org.hamcrest.xml, org.jmock, org.jmock.api, org.jmock.example.qcon, @@ -35,11 +58,147 @@ Export-Package: junit.extensions, org.jmock.lib.action, org.jmock.syntax, org.junit, + org.junit.experimental, + org.junit.experimental.categories, + org.junit.experimental.max, + org.junit.experimental.results, + org.junit.experimental.runners, + org.junit.experimental.theories, + org.junit.experimental.theories.internal, + org.junit.experimental.theories.suppliers, org.junit.internal, + org.junit.internal.builders, + org.junit.internal.matchers, org.junit.internal.requests, org.junit.internal.runners, + org.junit.internal.runners.model, + org.junit.internal.runners.rules, + org.junit.internal.runners.statements, + org.junit.matchers, + org.junit.rules, org.junit.runner, org.junit.runner.manipulation, org.junit.runner.notification, - org.junit.runners + org.junit.runners, + org.junit.runners.model, + org.mockito, + org.mockito.asm, + org.mockito.asm.signature, + org.mockito.asm.tree, + org.mockito.asm.tree.analysis, + org.mockito.asm.util, + org.mockito.cglib.beans, + org.mockito.cglib.core, + org.mockito.cglib.proxy, + org.mockito.cglib.reflect, + org.mockito.cglib.transform, + org.mockito.cglib.transform.impl, + org.mockito.cglib.util, + org.mockito.configuration, + org.mockito.exceptions, + org.mockito.exceptions.base, + org.mockito.exceptions.misusing, + org.mockito.exceptions.verification, + org.mockito.exceptions.verification.junit, + org.mockito.internal, + org.mockito.internal.configuration, + org.mockito.internal.configuration.injection, + org.mockito.internal.configuration.injection.filter, + org.mockito.internal.creation, + org.mockito.internal.creation.cglib, + org.mockito.internal.creation.jmock, + org.mockito.internal.debugging, + org.mockito.internal.exceptions, + org.mockito.internal.exceptions.base, + org.mockito.internal.exceptions.util, + org.mockito.internal.invocation, + org.mockito.internal.invocation.finder, + org.mockito.internal.invocation.realmethod, + org.mockito.internal.listeners, + org.mockito.internal.matchers, + org.mockito.internal.matchers.apachecommons, + org.mockito.internal.progress, + org.mockito.internal.reporting, + org.mockito.internal.runners, + org.mockito.internal.runners.util, + org.mockito.internal.stubbing, + org.mockito.internal.stubbing.answers, + org.mockito.internal.stubbing.defaultanswers, + org.mockito.internal.util, + org.mockito.internal.util.junit, + org.mockito.internal.util.reflection, + org.mockito.internal.verification, + org.mockito.internal.verification.api, + org.mockito.internal.verification.argumentmatching, + org.mockito.internal.verification.checkers, + org.mockito.invocation, + org.mockito.listeners, + org.mockito.runners, + org.mockito.stubbing, + org.mockito.stubbing.answers, + org.mockito.verification, + org.objenesis, + org.objenesis.instantiator, + org.objenesis.instantiator.basic, + org.objenesis.instantiator.gcj, + org.objenesis.instantiator.jrockit, + org.objenesis.instantiator.perc, + org.objenesis.instantiator.sun, + org.objenesis.strategy, + org.powermock.api.extension.listener, + org.powermock.api.extension.proxyframework, + org.powermock.api.mockito, + org.powermock.api.mockito.expectation, + org.powermock.api.mockito.internal, + org.powermock.api.mockito.internal.configuration, + org.powermock.api.mockito.internal.expectation, + org.powermock.api.mockito.internal.invocationcontrol, + org.powermock.api.mockito.internal.mockcreation, + org.powermock.api.mockito.internal.verification, + org.powermock.api.mockito.mockpolicies, + org.powermock.api.mockito.powermocklistener, + org.powermock.api.mockito.verification, + org.powermock.api.support, + org.powermock.api.support.membermodification, + org.powermock.api.support.membermodification.strategy, + org.powermock.api.support.membermodification.strategy.impl, + org.powermock.classloading, + org.powermock.classloading.spi, + org.powermock.core, + org.powermock.core.classloader, + org.powermock.core.classloader.annotations, + org.powermock.core.spi, + org.powermock.core.spi.listener, + org.powermock.core.spi.support, + org.powermock.core.spi.testresult, + org.powermock.core.spi.testresult.impl, + org.powermock.core.testlisteners, + org.powermock.core.transformers, + org.powermock.core.transformers.impl, + org.powermock.mockpolicies, + org.powermock.mockpolicies.impl, + org.powermock.mockpolicies.support, + org.powermock.modules.junit3, + org.powermock.modules.junit3.internal, + org.powermock.modules.junit3.internal.impl, + org.powermock.modules.junit4, + org.powermock.modules.junit4.common.internal, + org.powermock.modules.junit4.common.internal.impl, + org.powermock.modules.junit4.internal.impl, + org.powermock.modules.junit4.internal.impl.testcaseworkaround, + org.powermock.modules.junit4.legacy, + org.powermock.modules.junit4.legacy.internal.impl, + org.powermock.modules.junit4.legacy.internal.impl.testcaseworkaround, + org.powermock.modules.testng, + org.powermock.modules.testng.internal, + org.powermock.reflect, + org.powermock.reflect.exceptions, + org.powermock.reflect.internal, + org.powermock.reflect.internal.matcherstrategies, + org.powermock.reflect.internal.primitivesupport, + org.powermock.reflect.matching, + org.powermock.reflect.proxyframework, + org.powermock.reflect.spi, + org.powermock.tests.utils, + org.powermock.tests.utils.impl Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/cots/org.junit/build.properties b/cots/org.junit/build.properties index 93e6e60d4c..da97b1e7e3 100644 --- a/cots/org.junit/build.properties +++ b/cots/org.junit/build.properties @@ -1,7 +1,11 @@ bin.includes = META-INF/,\ - junit-4.3.1.jar,\ - hamcrest-api-1.0.jar,\ - hamcrest-library-1.0.jar,\ jmock-2.0.0.jar,\ jmock-junit3-2.0.0.jar,\ - jmock-junit4-2.0.0.jar + jmock-junit4-2.0.0.jar,\ + cglib-nodep-2.2.jar,\ + javassist-3.16.1-GA.jar,\ + junit-4.8.2.jar,\ + mockito-all-1.9.0.jar,\ + objenesis-1.2.jar,\ + powermock-mockito-1.4.12-full.jar,\ + junit-4.10.jar diff --git a/cots/org.junit/cglib-nodep-2.2.jar b/cots/org.junit/cglib-nodep-2.2.jar new file mode 100644 index 0000000000..ed07cb507f Binary files /dev/null and b/cots/org.junit/cglib-nodep-2.2.jar differ diff --git a/cots/org.junit/hamcrest-api-1.0.jar b/cots/org.junit/hamcrest-api-1.0.jar deleted file mode 100644 index 5df3f19d92..0000000000 Binary files a/cots/org.junit/hamcrest-api-1.0.jar and /dev/null differ diff --git a/cots/org.junit/hamcrest-library-1.0.jar b/cots/org.junit/hamcrest-library-1.0.jar deleted file mode 100644 index e0b275f049..0000000000 Binary files a/cots/org.junit/hamcrest-library-1.0.jar and /dev/null differ diff --git a/cots/org.junit/javassist-3.16.1-GA.jar b/cots/org.junit/javassist-3.16.1-GA.jar new file mode 100644 index 0000000000..c29da0fae0 Binary files /dev/null and b/cots/org.junit/javassist-3.16.1-GA.jar differ diff --git a/cots/org.junit/junit-4.10-src.jar b/cots/org.junit/junit-4.10-src.jar new file mode 100644 index 0000000000..1449d28b5b Binary files /dev/null and b/cots/org.junit/junit-4.10-src.jar differ diff --git a/cots/org.junit/junit-4.10.jar b/cots/org.junit/junit-4.10.jar new file mode 100644 index 0000000000..bf5c0b9c6a Binary files /dev/null and b/cots/org.junit/junit-4.10.jar differ diff --git a/cots/org.junit/junit-4.3.1.jar b/cots/org.junit/junit-4.3.1.jar deleted file mode 100644 index ff5d1888fc..0000000000 Binary files a/cots/org.junit/junit-4.3.1.jar and /dev/null differ diff --git a/cots/org.junit/mockito-all-1.9.0.jar b/cots/org.junit/mockito-all-1.9.0.jar new file mode 100644 index 0000000000..273fd50feb Binary files /dev/null and b/cots/org.junit/mockito-all-1.9.0.jar differ diff --git a/cots/org.junit/objenesis-1.2.jar b/cots/org.junit/objenesis-1.2.jar new file mode 100644 index 0000000000..fb04d7fa64 Binary files /dev/null and b/cots/org.junit/objenesis-1.2.jar differ diff --git a/cots/org.junit/powermock-mockito-1.4.12-full.jar b/cots/org.junit/powermock-mockito-1.4.12-full.jar new file mode 100644 index 0000000000..b70358d164 Binary files /dev/null and b/cots/org.junit/powermock-mockito-1.4.12-full.jar differ diff --git a/edexOsgi/build.edex/basebuilds/component_deploy_base.xml b/edexOsgi/build.edex/basebuilds/component_deploy_base.xml index f3c63463fb..cb10f40ded 100644 --- a/edexOsgi/build.edex/basebuilds/component_deploy_base.xml +++ b/edexOsgi/build.edex/basebuilds/component_deploy_base.xml @@ -34,9 +34,10 @@ - - - + + + + - + @@ -113,6 +113,19 @@ + + + + + + + + + + + + + &substitute-targets; diff --git a/edexOsgi/build.edex/build.xml b/edexOsgi/build.edex/build.xml index 67890ae773..c2778ad940 100644 --- a/edexOsgi/build.edex/build.xml +++ b/edexOsgi/build.edex/build.xml @@ -74,10 +74,14 @@
- - - + + + + + + diff --git a/edexOsgi/build.edex/deploy-common/deploy-esb-configuration.xml b/edexOsgi/build.edex/deploy-common/deploy-esb-configuration.xml index 6eb7c9897c..b4e273d6fa 100644 --- a/edexOsgi/build.edex/deploy-common/deploy-esb-configuration.xml +++ b/edexOsgi/build.edex/deploy-common/deploy-esb-configuration.xml @@ -7,5 +7,6 @@ overwrite="${esb.overwrite}"> + \ No newline at end of file diff --git a/edexOsgi/build.edex/deploy-common/deploy-esb.xml b/edexOsgi/build.edex/deploy-common/deploy-esb.xml index 9be780fe87..d72aa33d4b 100644 --- a/edexOsgi/build.edex/deploy-common/deploy-esb.xml +++ b/edexOsgi/build.edex/deploy-common/deploy-esb.xml @@ -1,7 +1,7 @@ - - + + - + @@ -124,6 +124,9 @@ + - \ No newline at end of file + diff --git a/edexOsgi/build.edex/deploy-common/plugin-methods.xml b/edexOsgi/build.edex/deploy-common/plugin-methods.xml index 2c6e2aaed9..cb78f8c732 100644 --- a/edexOsgi/build.edex/deploy-common/plugin-methods.xml +++ b/edexOsgi/build.edex/deploy-common/plugin-methods.xml @@ -115,35 +115,21 @@ - - - + + - - - - - - - - - - - - - - + + + + + @@ -301,4 +287,4 @@ - \ No newline at end of file + diff --git a/edexOsgi/build.edex/edex/customAssembly.xml b/edexOsgi/build.edex/edex/customAssembly.xml index c98e962f8c..e7f98600ab 100755 --- a/edexOsgi/build.edex/edex/customAssembly.xml +++ b/edexOsgi/build.edex/edex/customAssembly.xml @@ -20,15 +20,15 @@ - - - - - - + + + + + + diff --git a/edexOsgi/build.edex/edex/customTargets.xml b/edexOsgi/build.edex/edex/customTargets.xml index b6b66a6e18..af024f7a62 100644 --- a/edexOsgi/build.edex/edex/customTargets.xml +++ b/edexOsgi/build.edex/edex/customTargets.xml @@ -149,13 +149,13 @@ - - - - - - - + + + + + + + diff --git a/edexOsgi/build.edex/esb/bin/linux-x86-32/wrapper.conf b/edexOsgi/build.edex/esb/bin/linux-x86-32/wrapper.conf index 5edfea661d..8a72330191 100644 --- a/edexOsgi/build.edex/esb/bin/linux-x86-32/wrapper.conf +++ b/edexOsgi/build.edex/esb/bin/linux-x86-32/wrapper.conf @@ -21,6 +21,7 @@ # Wrapper Properties #******************************************************************** +wrapper.java.classpath.6=%EDEX_HOME%/conf/resources/ # Java Library Path (location of Wrapper.DLL or libwrapper.so) wrapper.java.library.path.1=%EDEX_HOME%/bin/linux-x86-32/ wrapper.java.library.path.4=%EDEX_HOME%/lib/dependencies/org.jep.linux32/ diff --git a/edexOsgi/build.edex/esb/bin/setup.env b/edexOsgi/build.edex/esb/bin/setup.env index 35f7a55d63..5c23461186 100644 --- a/edexOsgi/build.edex/esb/bin/setup.env +++ b/edexOsgi/build.edex/esb/bin/setup.env @@ -22,12 +22,20 @@ export BROKER_ADDR=localhost # setup hdf5 connection if pypies is enabled export PYPIES_SERVER=http://localhost:9582 +# data delivery specific variables, used below in the localization section +export DATADELIVERY_HOST=localhost +export DATADELIVERY_PORT=9588 +export DATADELIVERY_SOAP_PORT=10144 + # moved here from environment.xml # these values are returned to clients that contact the localization service export HTTP_PORT=9581 export HTTP_SERVER=http://localhost:${HTTP_PORT}/services export JMS_SERVER=tcp://localhost:5672 export RADAR_SERVER=tcp://localhost:8813 +export DATADELIVERY_SERVER=http://${DATADELIVERY_HOST}:${DATADELIVERY_PORT}/services/thrift +export DATADELIVERY_LCM_SERVER=http://${DATADELIVERY_HOST}:${DATADELIVERY_SOAP_PORT}/lcm?WSDL +export DATADELIVERY_QUERY_SERVER=http://${DATADELIVERY_HOST}:${DATADELIVERY_SOAP_PORT}/query?WSDL # set the AWIPS II shared directory export SHARE_DIR=/awips2/edex/data/share @@ -42,4 +50,4 @@ export SITE_IDENTIFIER=${AW_SITE_IDENTIFIER} # set Fax environment variables pointing to ldad@ls1 export LDAD_EXTERNAL_HOME=/ldad -export LDAD_EXTERNAL_PUBLIC=/data/ldad/public \ No newline at end of file +export LDAD_EXTERNAL_PUBLIC=/data/ldad/public diff --git a/edexOsgi/build.edex/esb/bin/wrapper.conf b/edexOsgi/build.edex/esb/bin/wrapper.conf index 125d07fa05..2a62a5102f 100644 --- a/edexOsgi/build.edex/esb/bin/wrapper.conf +++ b/edexOsgi/build.edex/esb/bin/wrapper.conf @@ -46,6 +46,7 @@ wrapper.java.classpath.2=%EDEX_HOME%/lib/plugins/com.raytheon.uf.edex.esb.camel. wrapper.java.classpath.3=%EDEX_HOME%/conf/ wrapper.java.classpath.4=%EDEX_HOME%/conf/cache/ wrapper.java.classpath.5=%EDEX_HOME%/conf/spring/ +wrapper.java.classpath.6=%EDEX_HOME%/conf/resources/ # set the umask for file/directory creation by the Java process wrapper.java.umask=0002 @@ -114,16 +115,20 @@ wrapper.java.additional.36=-Dlog4j.configuration=%LOG4J_CONF% # moved these from environment.xml to setup.env wrapper.java.additional.37=-Dhttp.server=%HTTP_SERVER% wrapper.java.additional.38=-Djms.server=%JMS_SERVER% +wrapper.java.additional.39=-Ddatadelivery.server=%DATADELIVERY_SERVER% +wrapper.java.additional.40=-Ddatadelivery.lcm.server=%DATADELIVERY_LCM_SERVER% +wrapper.java.additional.41=-Ddatadelivery.query.server=%DATADELIVERY_QUERY_SERVER% -wrapper.java.additional.39=-DHighMem=%HIGH_MEM_FLAG% -wrapper.java.additional.40=-Dmanagement.port=%MGMT_PORT% +wrapper.java.additional.42=-DHighMem=%HIGH_MEM_FLAG% +wrapper.java.additional.43=-Dmanagement.port=%MGMT_PORT% -wrapper.java.additional.41=-Dqpid.dest_syntax=BURL -wrapper.java.additional.42=-Dweb.port=8080 -wrapper.java.additional.43=-Dconfidential.port=8443 -wrapper.java.additional.44=-Dhttp.port=%HTTP_PORT% -wrapper.java.additional.45=-Dedex.arch=%EDEX_ARCH% -wrapper.java.additional.46=-Dedex.tmp=%TEMP_DIR% +wrapper.java.additional.44=-Dqpid.dest_syntax=BURL +wrapper.java.additional.45=-Dweb.port=8080 +wrapper.java.additional.46=-Dconfidential.port=8443 +wrapper.java.additional.47=-Dhttp.port=%HTTP_PORT% +wrapper.java.additional.48=-Dedex.arch=%EDEX_ARCH% +wrapper.java.additional.49=-Dedex.tmp=%TEMP_DIR% +wrapper.java.additional.50=-Dawips.registrymanager.debug=%AWIPS_REGISTRYMANAGER_DEBUG% # Initial Java Heap Size (in MB) wrapper.java.initmemory=%INIT_MEM% diff --git a/edexOsgi/build.edex/esb/conf/cache/ehcache.xml b/edexOsgi/build.edex/esb/conf/cache/ehcache.xml new file mode 100644 index 0000000000..8a614278af --- /dev/null +++ b/edexOsgi/build.edex/esb/conf/cache/ehcache.xml @@ -0,0 +1,37 @@ + + + + + + + + \ No newline at end of file diff --git a/edexOsgi/build.edex/esb/conf/db/hibernateConfig/ebxml/hibernate.cfg.xml b/edexOsgi/build.edex/esb/conf/db/hibernateConfig/ebxml/hibernate.cfg.xml new file mode 100644 index 0000000000..cc625521ca --- /dev/null +++ b/edexOsgi/build.edex/esb/conf/db/hibernateConfig/ebxml/hibernate.cfg.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + org.postgresql.Driver + + + org.hibernate.dialect.PostgreSQLDialect + + + jdbc:postgresql://${db.addr}:${db.port}/ebxml + + awips + awips + + after_transaction + + 100 + + + + + false + + + false + + + false + + + org.hibernate.connection.C3P0ConnectionProvider + + + + 60 + 1800 + 10 + 5 + ${db.metadata.pool.min} + ${db.metadata.pool.max} + + true + org.hibernate.transaction.JDBCTransactionFactory + thread + + net.sf.ehcache.hibernate.EhCacheProvider + true + true + true + + + \ No newline at end of file diff --git a/edexOsgi/build.edex/esb/conf/db/hibernateConfig/metadata/hibernate.cfg.xml b/edexOsgi/build.edex/esb/conf/db/hibernateConfig/metadata/hibernate.cfg.xml index 3ba6bcbfc9..1c918cfac5 100644 --- a/edexOsgi/build.edex/esb/conf/db/hibernateConfig/metadata/hibernate.cfg.xml +++ b/edexOsgi/build.edex/esb/conf/db/hibernateConfig/metadata/hibernate.cfg.xml @@ -69,6 +69,7 @@ false false + false false diff --git a/edexOsgi/build.edex/esb/conf/log4j-datadelivery.xml b/edexOsgi/build.edex/esb/conf/log4j-datadelivery.xml new file mode 100644 index 0000000000..526ea6dcb6 --- /dev/null +++ b/edexOsgi/build.edex/esb/conf/log4j-datadelivery.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/build.edex/esb/conf/log4j-dataprovideragent.xml b/edexOsgi/build.edex/esb/conf/log4j-dataprovideragent.xml new file mode 100644 index 0000000000..d716071732 --- /dev/null +++ b/edexOsgi/build.edex/esb/conf/log4j-dataprovideragent.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/build.edex/esb/conf/log4j-registry.xml b/edexOsgi/build.edex/esb/conf/log4j-registry.xml new file mode 100644 index 0000000000..57a9087cf7 --- /dev/null +++ b/edexOsgi/build.edex/esb/conf/log4j-registry.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/build.edex/esb/conf/modes.xml b/edexOsgi/build.edex/esb/conf/modes.xml index 38b3028de9..ab9be0a2a7 100644 --- a/edexOsgi/build.edex/esb/conf/modes.xml +++ b/edexOsgi/build.edex/esb/conf/modes.xml @@ -32,33 +32,114 @@ are compatible with Java's Pattern class. If you provide no tag for a particular mode, the include defaults to .*. --> + .*request.* .*common.* - + excludeDpaAndOgc + purgeutil-request.xml - + + ebxml.*\.xml + event-ingest.xml + + + registry + datadeliverytemplate + + .*datadelivery-registry.* + + .*datadelivery-standalone.* + + + manualIngest* + time-common.xml + distribution-spring.xml + persist-ingest.xml + auth-common.xml + + grib-common.xml + grib-distribution.xml + grib-datadelivery.xml + level-common.xml + + pointdata-common.xml + obs-common.xml + obs-datadelivery.xml + + .*dpa.* + + .*ogc.* + + fssobs-common + + + ebxml.*\.xml .*request.* - grib-ingest.xml - ncgrib-ingest.xml - - aww-ingest.xml - ncairep-ingest.xml - ncccfp-ingest.xml - ncgrib-distribution.xml - ncep-util-on-edex-ingest - ncep-util-on-edex-ingestGrib - ncscd-ingest.xml - ncpafm-ingest.xml - ncpirep-ingest.xml - nctaf-ingest.xml - nctext-ingest.xml - ncuair-ingest.xml - + grib-ingest.xml + ncgrib-ingest.xml + .*datadelivery.* + .*bandwidth.* + excludeDpaAndOgc + + aww-ingest.xml + ncairep-ingest.xml + ncccfp-ingest.xml + ncgrib-distribution.xml + ncep-util-on-edex-ingest + ncep-util-on-edex-ingestGrib + ncscd-ingest.xml + ncpafm-ingest.xml + ncpirep-ingest.xml + nctaf-ingest.xml + nctext-ingest.xml + ncuair-ingest.xml + + ffmp-ingest.xml scan-ingest.xml cwat-ingest.xml @@ -68,31 +149,33 @@ qpf-ingest.xml fssobs-ingest.xml cpgsrv-spring.xml + stats-ingest.xml - time-common.xml - grib-common.xml - grib-ingest.xml - level-common.xml + time-common.xml + grib-common.xml + grib-ingest.xml + level-common.xml grid-common.xml gridcoverage-common.xml parameter-common.xml - persist-ingest.xml - management-common.xml + persist-ingest.xml + management-common.xml database-common.xml - auth-common.xml - - ncgrib-common.xml - ncgrib-ingest.xml - ncep-util-on-edex-ingestGrib - h5uair-ingest.xml - h5uair-common.xml - h5scd-ingest.xml - + auth-common.xml + + ncgrib-common.xml + ncgrib-ingest.xml + ncep-util-on-edex-ingestGrib + h5uair-ingest.xml + h5uair-common.xml + h5scd-ingest.xml + + excludeDpaAndOgc - time-common.xml + time-common.xml ffmp-ingest.xml ffmp-common.xml scan-ingest.xml @@ -108,7 +191,7 @@ qpf-ingest.xml qpf-common.xml cpgsrv-spring.xml - persist-ingest.xml + persist-ingest.xml binlightning-common.xml parameter-common.xml gridcoverage-common.xml @@ -126,30 +209,32 @@ obs-common.xml fssobs-ingest.xml fssobs-common.xml - ldadmesonet-common.xml + ldadmesonet-common.xml ncgrib-common.xml - nctext-common.xml + nctext-common.xml + excludeDpaAndOgc - - - grib-common.xml - grib-ingest.xml + + + + grib-common.xml + grib-ingest.xml grib-distribution.xml - level-common.xml - persist-ingest.xml + level-common.xml + persist-ingest.xml distribution-spring.xml manualIngest-spring.xml - - - text-.* - textdb-.* - textdbsrv-.* + + + text-.* + textdb-.* + textdbsrv-.* uengine-request.xml - auth-request.xml - distribution-spring.xml + auth-request.xml + distribution-spring.xml manualIngest-spring.xml - + .*gfe.* serialize-request.xml @@ -159,14 +244,15 @@ manualIngest-spring.xml + ebxml.*\.xml alarmWhfs-spring.xml arealffgGenerator-spring.xml - dpaDecoder-spring.xml + DPADecoder-spring.xml dqcPreprocessor-spring.xml floodArchiver-spring.xml hpeDHRDecoder-spring.xml ohd.*.xml - ihfsDbPurge-spring.xml + ihfsDbPurge-spring.xml logFilePurger-spring.xml mpeFieldgen-spring.xml mpeHpeFilePurge-spring.xml @@ -174,10 +260,39 @@ ohdSetupService-spring.xml pointDataRetrievel-spring.xml q2FileProcessor-spring.xml - satpre-spring.xml + satpre-spring.xml auth-request.xml utility-request.xml - \ No newline at end of file + + .*datadelivery-standalone.* + .*datadelivery-registry.* + datadeliverytemplate + + + .*datadelivery.* + .*bandwidth.* + time-common.xml + grib-common.xml + grid-common.xml + gridcoverage-common.xml + parameter-common.xml + pointdata-common.xml + obs-common.xml + level-common.xml + persist-ingest.xml + management-common.xml + database-common.xml + auth-common.xml + stats-common.xml + event-ingest.xml + + + + .*dpa.* + + .*ogc.* + + diff --git a/edexOsgi/build.edex/esb/etc/datadelivery.sh b/edexOsgi/build.edex/esb/etc/datadelivery.sh new file mode 100644 index 0000000000..9259fd5029 --- /dev/null +++ b/edexOsgi/build.edex/esb/etc/datadelivery.sh @@ -0,0 +1,34 @@ +#!/bin/bash +## +# 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. +## + +export INIT_MEM=512 # in Meg + +if [ $HIGH_MEM_FLAG == "on" ]; then + export MAX_MEM=1536 # in Meg +else + export MAX_MEM=896 # in Meg +fi + +export METADATA_POOL_MIN=10 +export EDEX_DEBUG_PORT=5009 +export EDEX_JMX_PORT=1620 +export LOG4J_CONF=log4j-datadelivery.xml +export MGMT_PORT=9605 diff --git a/edexOsgi/build.edex/esb/etc/datadeliveryonly.sh b/edexOsgi/build.edex/esb/etc/datadeliveryonly.sh new file mode 100644 index 0000000000..9259fd5029 --- /dev/null +++ b/edexOsgi/build.edex/esb/etc/datadeliveryonly.sh @@ -0,0 +1,34 @@ +#!/bin/bash +## +# 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. +## + +export INIT_MEM=512 # in Meg + +if [ $HIGH_MEM_FLAG == "on" ]; then + export MAX_MEM=1536 # in Meg +else + export MAX_MEM=896 # in Meg +fi + +export METADATA_POOL_MIN=10 +export EDEX_DEBUG_PORT=5009 +export EDEX_JMX_PORT=1620 +export LOG4J_CONF=log4j-datadelivery.xml +export MGMT_PORT=9605 diff --git a/edexOsgi/build.edex/esb/etc/dataprovideragent.sh b/edexOsgi/build.edex/esb/etc/dataprovideragent.sh new file mode 100644 index 0000000000..5f1627d854 --- /dev/null +++ b/edexOsgi/build.edex/esb/etc/dataprovideragent.sh @@ -0,0 +1,34 @@ +#!/bin/bash +## +# 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. +## + +export INIT_MEM=512 # in Meg + +if [ $HIGH_MEM_FLAG == "on" ]; then + export MAX_MEM=1536 # in Meg +else + export MAX_MEM=896 # in Meg +fi +export METADATA_POOL_MIN=10 +export EDEX_DEBUG_PORT=5010 +export EDEX_JMX_PORT=1621 +export LOG4J_CONF=log4j-dataprovideragent.xml +export MGMT_PORT=9606 + diff --git a/edexOsgi/build.edex/esb/etc/registry.sh b/edexOsgi/build.edex/esb/etc/registry.sh new file mode 100644 index 0000000000..1f3a9a7d2a --- /dev/null +++ b/edexOsgi/build.edex/esb/etc/registry.sh @@ -0,0 +1,34 @@ +#!/bin/bash +## +# 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. +## + +export INIT_MEM=512 # in Meg + +if [ $HIGH_MEM_FLAG == "on" ]; then + export MAX_MEM=1536 # in Meg +else + export MAX_MEM=896 # in Meg +fi +export METADATA_POOL_MIN=10 +export EDEX_DEBUG_PORT=5011 +export EDEX_JMX_PORT=1622 +export LOG4J_CONF=log4j-registry.xml +export MGMT_PORT=9607 + diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/WebConsoleStarter.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/WebConsoleStarter.class deleted file mode 100644 index 607b30e0e7..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/WebConsoleStarter.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CopyMessage.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CopyMessage.class deleted file mode 100644 index cecd3d5461..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CopyMessage.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateDestination.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateDestination.class deleted file mode 100644 index dc8d92abeb..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateDestination.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateSubscriber.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateSubscriber.class deleted file mode 100644 index d6d03f6c9d..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateSubscriber.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteDestination.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteDestination.class deleted file mode 100644 index a0c9a3c219..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteDestination.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteMessage.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteMessage.class deleted file mode 100644 index 17cc728253..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteMessage.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteSubscriber.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteSubscriber.class deleted file mode 100644 index 686b49dc20..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteSubscriber.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/MoveMessage.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/MoveMessage.class deleted file mode 100644 index bc60a24659..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/MoveMessage.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/PurgeDestination.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/PurgeDestination.class deleted file mode 100644 index 525f442ed6..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/PurgeDestination.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/SendMessage.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/SendMessage.class deleted file mode 100644 index feca1ffadc..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/SendMessage.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$1.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$1.class deleted file mode 100644 index 7d4cbe9219..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$1.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$2.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$2.class deleted file mode 100644 index 3cc7c96226..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$2.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter.class deleted file mode 100644 index 6f9f1d10f4..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter.class and /dev/null differ diff --git a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/handler/BindingBeanNameUrlHandlerMapping.class b/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/handler/BindingBeanNameUrlHandlerMapping.class deleted file mode 100644 index bde8039ac2..0000000000 Binary files a/edexOsgi/build.edex/esb/webapps/admin/WEB-INF/classes/org/apache/activemq/web/handler/BindingBeanNameUrlHandlerMapping.class and /dev/null differ diff --git a/edexOsgi/build.edex/opt/db/ddl/ebxml/createEbxml.sql b/edexOsgi/build.edex/opt/db/ddl/ebxml/createEbxml.sql new file mode 100644 index 0000000000..e0f673869b --- /dev/null +++ b/edexOsgi/build.edex/opt/db/ddl/ebxml/createEbxml.sql @@ -0,0 +1,25 @@ +/** + * 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. + **/ +\set ON_ERROR_STOP 1 +DROP DATABASE IF EXISTS ebxml; +DROP TABLESPACE IF EXISTS ebxml_data; +CREATE TABLESPACE ebxml_data OWNER awips LOCATION '%{database_files_home}%/ebxml'; +COMMENT ON TABLESPACE ebxml_data IS 'EBXML Registry Database tablespace'; +CREATE DATABASE ebxml OWNER awips TABLESPACE ebxml_data; diff --git a/edexOsgi/build.edex/opt/db/ddl/events/createEventsSchema.sql b/edexOsgi/build.edex/opt/db/ddl/events/createEventsSchema.sql new file mode 100644 index 0000000000..750b1d3499 --- /dev/null +++ b/edexOsgi/build.edex/opt/db/ddl/events/createEventsSchema.sql @@ -0,0 +1,22 @@ +/** + * 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. + **/ +\set ON_ERROR_STOP 1 +\connect metadata; +CREATE SCHEMA events AUTHORIZATION awips; diff --git a/edexOsgi/build.edex/opt/db/ddl/setup/pg_hba.conf b/edexOsgi/build.edex/opt/db/ddl/setup/pg_hba.conf index 73e509c222..84b7146f88 100644 --- a/edexOsgi/build.edex/opt/db/ddl/setup/pg_hba.conf +++ b/edexOsgi/build.edex/opt/db/ddl/setup/pg_hba.conf @@ -72,6 +72,7 @@ local maps all trust local hmdb all trust local postgres all trust local ncep all trust +local ebxml all trust # IPv4 local connections: host fxatext all 127.0.0.1/32 trust host fxatext all 147.18.136.0/24 trust @@ -105,5 +106,9 @@ host ncep all 127.0.0.1/32 md5 host ncep all 147.18.136.0/24 md5 host ncep all 147.18.139.0/24 md5 host ncep all 162.0.0.0/8 md5 +host ebxml all 127.0.0.1/32 trust +host ebxml all 147.18.136.0/24 trust +host ebxml all 147.18.139.0/24 trust +host ebxml all 162.0.0.0/8 trust # IPv6 local connections: host all all ::1/128 md5 diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/ScriptRunner.java b/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/ScriptRunner.java index 3ac8ef7566..078b137764 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/ScriptRunner.java +++ b/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/ScriptRunner.java @@ -45,6 +45,7 @@ import com.raytheon.uf.common.message.Header; import com.raytheon.uf.common.message.Message; import com.raytheon.uf.common.message.Property; import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.util.ReflectionUtil; import com.raytheon.uf.edex.core.EdexException; /** @@ -182,8 +183,9 @@ public class ScriptRunner { PluginDataObject[] pdos = (PluginDataObject[]) event; for (PluginDataObject pdo : pdos) { try { - String prodID = (String) Util.getFieldValue(pdo, - pdo.getClass(), "productId"); + String prodID = ReflectionUtil.getter(String.class, + pdo, + "productId"); if (logger.isDebugEnabled()) { logger.debug("Processing trigger: " + prodID + ", class = " @@ -198,8 +200,8 @@ public class ScriptRunner { } else if (event instanceof PluginDataObject) { PluginDataObject pdo = (PluginDataObject) event; try { - String prodID = (String) Util.getFieldValue(pdo, - pdo.getClass(), "productId"); + String prodID = ReflectionUtil.getter(String.class, + pdo, "productId"); if (logger.isDebugEnabled()) { logger.debug("Processing trigger: " + prodID + ", class = " diff --git a/edexOsgi/com.raytheon.edex.common/res/ehcache.xml b/edexOsgi/com.raytheon.edex.common/res/ehcache.xml index fcb3dc0e84..8a614278af 100644 --- a/edexOsgi/com.raytheon.edex.common/res/ehcache.xml +++ b/edexOsgi/com.raytheon.edex.common/res/ehcache.xml @@ -1,54 +1,6 @@ - - - - - - - - - + - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/util/Util.java b/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/util/Util.java index ad9b10f493..f6c4e96371 100644 --- a/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/util/Util.java +++ b/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/util/Util.java @@ -161,35 +161,6 @@ public final class Util { return "[" + (obj == null ? "null" : obj.toString()) + "]"; } - /** - * Obtains the value of the specified field from the object. - * - * @param object - * the object containing the field - * @param classObj - * the class of the object - * @param name - * the name of the field - * - * @return the value of the field - * - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException - */ - @SuppressWarnings("unchecked") - public static Object getFieldValue(Object object, Class classObj, - String name) throws NoSuchMethodException, - InvocationTargetException, IllegalAccessException { - Object obj = null; - StringBuffer getter = new StringBuffer("get").append( - name.substring(0, 1).toUpperCase()).append(name.substring(1)); - Method worker = classObj.getMethod(getter.toString(), (Class[]) null); - obj = worker.invoke(object, (Object[]) null); - return obj; - - } - /** * Invokes the setter for the specified field on an object. *

@@ -971,8 +942,7 @@ public final class Util { * * @return the converted object */ - @SuppressWarnings("unchecked") - public static Object getObjForStr(String string, Class aClass) { + public static Object getObjForStr(String string, Class aClass) { Object retValue = null; diff --git a/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/utility/EDEXLocalizationAdapter.java b/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/utility/EDEXLocalizationAdapter.java index 75684652dd..50eb0cc65a 100644 --- a/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/utility/EDEXLocalizationAdapter.java +++ b/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/utility/EDEXLocalizationAdapter.java @@ -119,7 +119,7 @@ public class EDEXLocalizationAdapter implements ILocalizationAdapter { } } - private String getSiteName() { + protected String getSiteName() { String site = PropertiesFactory.getInstance().getEnvProperties() .getEnvValue("SITENAME"); @@ -176,12 +176,7 @@ public class EDEXLocalizationAdapter implements ILocalizationAdapter { @Override public File getPath(LocalizationContext context, String fileName) { - String baseDir = null; - - EnvProperties env = PropertiesFactory.getInstance().getEnvProperties(); - - String utilityDir = new File(env.getEnvValue("UTILITYDIR")) - .getAbsolutePath(); + File utilityDir = getUtilityDir(); if (context.getLocalizationLevel() == LocalizationLevel.UNKNOWN) { throw new IllegalArgumentException( @@ -191,11 +186,11 @@ public class EDEXLocalizationAdapter implements ILocalizationAdapter { // TODO: Check for invalid type / level combinations // Change the above condition and add invalid type / level checking // if needed - } else { - baseDir = utilityDir + File.separator + context.toPath(); } - return new File(baseDir + File.separator + fileName); + File baseDir = new File(utilityDir, context.toPath()); + + return new File(baseDir, fileName); } /* @@ -212,6 +207,17 @@ public class EDEXLocalizationAdapter implements ILocalizationAdapter { return type; } + /** + * Get the file reference to the utility directory. + * + * @return the file reference to the utility directory + */ + protected File getUtilityDir() { + EnvProperties env = PropertiesFactory.getInstance().getEnvProperties(); + + return new File(env.getEnvValue("UTILITYDIR")); + } + /** * Create ListResponse metadata *

diff --git a/edexOsgi/com.raytheon.edex.common/unit-test/com/raytheon/edex/subscription/TestSubscriptionManager.java b/edexOsgi/com.raytheon.edex.common/unit-test/com/raytheon/edex/subscription/TestSubscriptionManager.java deleted file mode 100644 index 030daa352d..0000000000 --- a/edexOsgi/com.raytheon.edex.common/unit-test/com/raytheon/edex/subscription/TestSubscriptionManager.java +++ /dev/null @@ -1,157 +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.edex.subscription; - -import static com.raytheon.edex.subscription.AddScriptAction.addScript; -import static com.raytheon.edex.subscription.DeleteScriptAction.deleteScript; -import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.integration.junit4.JMock; -import org.jmock.integration.junit4.JUnit4Mockery; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.raytheon.edex.db.dao.ISubscriber; -import com.raytheon.edex.exception.SubscriptionException; -import com.raytheon.uf.edex.database.DataAccessLayerException; - - - -/** - * - *

- *
- * SOFTWARE HISTORY
- *
- * Date       	Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * 	
- * 
- * 
- * - * @author mfegan - * @version 1 - */ -@RunWith(JMock.class) -public class TestSubscriptionManager { - Mockery context = new JUnit4Mockery(); - /* the test fixture */ - SubscriptionManager manager; - String goodKey = "/.+?/METAR/KDBN/.+"; - String badKey = "/.+?/METAR/KQKQ/.+"; - String scriptID1 = "TEST 1"; - String scriptID2 = "TEST 2"; - StringBuffer script1 = new StringBuffer("This is test script 1"); - StringBuffer script2 = new StringBuffer("This is test script 2"); - String subNotFound = "No subscriptions exist for requested URI"; - String[] subscriptions = {goodKey}; - Subscription goodScript; - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - manager = new SubscriptionManager(); - final ISubscriber dataLayer = context.mock(ISubscriber.class); - goodScript = new Subscription(goodKey,scriptID1,script1); - // expections - context.checking(new Expectations() {{ - allowing (dataLayer).getSubscriptions(); - will(returnValue(subscriptions)); - allowing (dataLayer).getSubscription(goodKey); - will(returnValue(goodScript)); - allowing (dataLayer).getSubscription(badKey); - will(throwException(new DataAccessLayerException(subNotFound))); - allowing (dataLayer).manageSubscriptions(with(instanceOf(Subscription.class)), - with(equal(ISubscriber.SUBSCRIBE_MODE_SAVE))); - will(addScript(goodScript,scriptID2,script2)); - allowing (dataLayer).manageSubscriptions(with(instanceOf(Subscription.class)), - with(equal(ISubscriber.SUBSCRIBE_MODE_DELETE))); - will(deleteScript(goodScript,scriptID2)); - allowing (dataLayer).manageSubscriptions(with(instanceOf(Subscription.class)), - with(equal(ISubscriber.SUBSCRIBE_MODE_UPDATE))); - will(returnValue(null)); - }}); - // manager.setDataLayer(dataLayer); - - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - manager = null; - - - } - - /** - * Test method for {@link com.raytheon.edex.subscription.SubscriptionManager#subscribe(java.lang.String, java.lang.String, java.lang.Object)}. - */ - @Test - public void testSubscribe() throws SubscriptionException { - manager.subscribe(goodKey, scriptID2, script2); - Subscription s = manager.getSubscription(goodKey); - assertNotNull("Checking Subscription retrieval - good subscription",s); - assertEquals("Checking Subscription script count",2,s.getCount()); - Script t = s.getScript(scriptID1); - assertSame("Checkin script 1",script1,t.getScript()); - t = s.getScript(scriptID2); - assertSame("Checking script 2",script2,t.getScript()); - } - - /** - * Test method for {@link com.raytheon.edex.subscription.SubscriptionManager#subscribe(java.lang.String, java.lang.String, java.lang.Object)}. - */ - @Test(expected=SubscriptionException.class) - public void testSubscribe_bad() throws SubscriptionException { - manager.subscribe(goodKey, scriptID1, script1); - } - - /** - * Test method for {@link com.raytheon.edex.subscription.SubscriptionManager#getSubscription(java.lang.String)}. - */ - @Test - public void testGetSubscription() { - Subscription s = manager.getSubscription(goodKey); - assertNotNull("Checking Subscription retrieval - good subscription",s); - assertEquals("Checking Subscription script count",1,s.getCount()); - - - } - /** - * Test method for {@link com.raytheon.edex.subscription.SubscriptionManager#getSubscription(java.lang.String)}. - */ - @Test - public void testGetSubscription_error() { - Subscription s = manager.getSubscription(badKey); - assertNull("Checking Subscription retrieval - bad subscription",s); - } -} diff --git a/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml b/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml index 4fb553e514..aadba52a15 100644 --- a/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml +++ b/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml @@ -103,4 +103,5 @@ + diff --git a/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/PersistSrv.java b/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/PersistSrv.java index 48d4218703..94c796eb55 100644 --- a/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/PersistSrv.java +++ b/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/PersistSrv.java @@ -53,55 +53,55 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory; */ public class PersistSrv { - private Log logger = LogFactory.getLog(getClass()); + private Log logger = LogFactory.getLog(getClass()); - private static final PersistSrv instance = new PersistSrv(); + private static final PersistSrv instance = new PersistSrv(); - public static PersistSrv getInstance() { - return instance; - } + public static PersistSrv getInstance() { + return instance; + } - private PersistSrv() { - } + private PersistSrv() { + } - @SuppressWarnings("unchecked") - public PluginDataObject[] persist(PluginDataObject[] pdo) { + @SuppressWarnings("unchecked") + public PluginDataObject[] persist(PluginDataObject[] pdo) { - if (pdo == null || pdo.length == 0) { - return new PluginDataObject[0]; - } + if (pdo == null || pdo.length == 0) { + return new PluginDataObject[0]; + } - Set pdoList = new HashSet(); - EDEXUtil.checkPersistenceTimes(pdo); + Set pdoList = new HashSet(); + EDEXUtil.checkPersistenceTimes(pdo); - try { - PluginDao dao = PluginFactory.getInstance().getPluginDao( - pdo[0].getPluginName()); - StorageStatus ss = dao.persistToHDF5(pdo); - StorageException[] se = ss.getExceptions(); - pdoList.addAll(Arrays.asList(pdo)); - if (se != null) { - Map pdosThatFailed = new HashMap(); - for (StorageException s : se) { - IDataRecord rec = s.getRecord(); + try { + PluginDao dao = PluginFactory.getInstance().getPluginDao( + pdo[0].getPluginName()); + StorageStatus ss = dao.persistToHDF5(pdo); + StorageException[] se = ss.getExceptions(); + pdoList.addAll(Arrays.asList(pdo)); + if (se != null) { + Map pdosThatFailed = new HashMap(); + for (StorageException s : se) { + IDataRecord rec = s.getRecord(); - if (rec != null) { - // If we have correlation info and it's a pdo, use that - // for the error message... - Object corrObj = rec.getCorrelationObject(); - if (corrObj != null - && corrObj instanceof PluginDataObject) { - pdosThatFailed.put((PluginDataObject) corrObj, s); - } else { - // otherwise, do the best we can with the group - // information - logger.error("Persisting record " + rec.getGroup() - + "/" + rec.getName() + " failed.", s); - } - } else { - // All we know is something bad happened. - logger.error("Persistence error occurred: ", s); - } + if (rec != null) { + // If we have correlation info and it's a pdo, use that + // for the error message... + Object corrObj = rec.getCorrelationObject(); + if (corrObj != null + && corrObj instanceof PluginDataObject) { + pdosThatFailed.put((PluginDataObject) corrObj, s); + } else { + // otherwise, do the best we can with the group + // information + logger.error("Persisting record " + rec.getGroup() + + "/" + rec.getName() + " failed.", s); + } + } else { + // All we know is something bad happened. + logger.error("Persistence error occurred: ", s); + } } // Produce error messages for each pdo that failed @@ -134,17 +134,26 @@ public class PersistSrv { } } - } catch (Throwable e1) { - logger.error( - "Critical persistence error occurred. Individual records that failed will be logged separately.", - e1); - for (PluginDataObject p : pdo) { - logger.error("Record " - + p - + " failed persistence due to critical error logged above."); - } - } + } catch (Throwable e1) { + logger.error( + "Critical persistence error occurred. Individual records that failed will be logged separately.", + e1); + for (PluginDataObject p : pdo) { + logger.error("Record " + + p + + " failed persistence due to critical error logged above."); + } + } - return pdoList.toArray(new PluginDataObject[pdoList.size()]); - } + return pdoList.toArray(new PluginDataObject[pdoList.size()]); + } + + public PluginDataObject[] removeRawData(PluginDataObject[] pdos) { + if (pdos != null) { + for (PluginDataObject pdo : pdos) { + pdo.setMessageData(null); + } + } + return pdos; + } } diff --git a/edexOsgi/com.raytheon.edex.meteolib/unit-test/com/raytheon/edex/meteoLib/Test.class b/edexOsgi/com.raytheon.edex.meteolib/unit-test/com/raytheon/edex/meteoLib/Test.class deleted file mode 100644 index 63a5989344..0000000000 Binary files a/edexOsgi/com.raytheon.edex.meteolib/unit-test/com/raytheon/edex/meteoLib/Test.class and /dev/null differ diff --git a/edexOsgi/com.raytheon.edex.plugin.airep/unit-test/test/airep/TestAIREPParser.java b/edexOsgi/com.raytheon.edex.plugin.airep/unit-test/test/airep/TestAIREPParser.java index ecc7038967..c661c21a91 100644 --- a/edexOsgi/com.raytheon.edex.plugin.airep/unit-test/test/airep/TestAIREPParser.java +++ b/edexOsgi/com.raytheon.edex.plugin.airep/unit-test/test/airep/TestAIREPParser.java @@ -267,20 +267,20 @@ public class TestAIREPParser { // Winds with "KT" p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT=", c); assertNotNull(p); - assertEquals(110, p.getWindDirection()); - assertEquals(10, p.getWindSpeed()); + assertEquals(110, p.getWindDirection().intValue()); + assertEquals(10, p.getWindSpeed().intValue()); // Winds with "KTS" p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 265/010KTS TB LGT=", c); assertNotNull(p); - assertEquals(265, p.getWindDirection()); - assertEquals(10, p.getWindSpeed()); + assertEquals(265, p.getWindDirection().intValue()); + assertEquals(10, p.getWindSpeed().intValue()); // Winds with no units - assume knots p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 265/010 TB LGT=", c); assertNotNull(p); - assertEquals(265, p.getWindDirection()); - assertEquals(10, p.getWindSpeed()); + assertEquals(265, p.getWindDirection().intValue()); + assertEquals(10, p.getWindSpeed().intValue()); } diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/svcbu/CheckPermissionsRequestHandler.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/svcbu/CheckPermissionsRequestHandler.java index be73865352..93cd3cee0d 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/svcbu/CheckPermissionsRequestHandler.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/svcbu/CheckPermissionsRequestHandler.java @@ -23,7 +23,8 @@ import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil; import com.raytheon.uf.common.auth.user.IUser; import com.raytheon.uf.common.dataplugin.gfe.request.CheckPermissionsRequest; import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; -import com.raytheon.uf.common.serialization.comm.IRequestHandler; +import com.raytheon.uf.common.plugin.nwsauth.exception.AuthorizationException; +import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler; import com.raytheon.uf.edex.auth.resp.AuthorizationResponse; /** @@ -43,11 +44,13 @@ import com.raytheon.uf.edex.auth.resp.AuthorizationResponse; * @version 1.0 */ -public class CheckPermissionsRequestHandler implements IRequestHandler{ +public class CheckPermissionsRequestHandler extends + AbstractPrivilegedRequestHandler { + @Override public Object handleRequest(CheckPermissionsRequest request) throws Exception { - AuthorizationResponse response = authorized(request.getUser()); + AuthorizationResponse response = authorized(request.getUser(), request); ServerResponse sr = new ServerResponse(); if (!response.isAuthorized()) { sr.addMessage(response.getResponseMessage()); @@ -55,7 +58,10 @@ public class CheckPermissionsRequestHandler implements IRequestHandler * @@ -63,9 +66,11 @@ public class SvcBackupUtil { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(SvcBackupUtil.class); - public static String OPERATION_FAIL = "Failure"; + private static final String LOCALIZATION = "Localization"; - public static String OPERATION_SUCCESS = "Success"; + public static final String OPERATION_FAIL = "Failure"; + + public static final String OPERATION_SUCCESS = "Success"; /** The logger instance */ protected static transient Log logger = LogFactory @@ -181,7 +186,7 @@ public class SvcBackupUtil { FileInputStream fis = null; try { fis = new FileInputStream( - System.getProperty("edex.home") + EDEXUtil.EDEX_HOME + "/../GFESuite/ServiceBackup/configuration/svcbu.properties"); svcbuProperties.load(fis); } catch (Exception e) { @@ -235,21 +240,25 @@ public class SvcBackupUtil { "LOCK_DIR") + File.separator; lockDir = lockDir.replace("${GFESUITE_HOME}", - System.getProperty("edex.home") + "/../GFESuite" + EDEXUtil.EDEX_HOME + "/../GFESuite" + File.separator); return lockDir; } - public static AuthorizationResponse authorizeWithLocalization(IUser user) { + public static AuthorizationResponse authorizeWithLocalization( +IUser user, + AbstractGfePrivilegedRequest request) + throws AuthorizationException { AuthManager manager = AuthManagerFactory.getInstance().getManager(); IRoleStorage roles = manager.getRoleStorage(); - String roleId = "com.raytheon.localization.site/common_static/gfe"; - IRole role = roles.lookupRole(roleId); - if (role != null && role.validForUser(user)) { + String roleId = request.getRoleId(); + if (roles + .isAuthorized(roleId, user.uniqueId().toString(), LOCALIZATION)) { return new AuthorizationResponse(true); } - return new AuthorizationResponse(false, "User, " + user.uniqueId() + + return new AuthorizationResponse(false, "User, " + user + ", is not authorized to perform request needing role: " + roleId); } diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.grib/META-INF/MANIFEST.MF index 930a981c93..b3a607e5f4 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.grib/META-INF/MANIFEST.MF @@ -45,6 +45,7 @@ Import-Package: com.raytheon.edex.exception, org.apache.camel Export-Package: com.raytheon.edex.objects.hibernate.grib, com.raytheon.edex.plugin.grib, + com.raytheon.edex.plugin.grib.exception, com.raytheon.edex.plugin.grib.notify, com.raytheon.edex.plugin.grib.spatial, com.raytheon.edex.plugin.grib.topo, diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-ingest.xml b/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-ingest.xml index 0d2737e935..673ed30eef 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-ingest.xml +++ b/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-ingest.xml @@ -134,7 +134,6 @@ - diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/Grib1Decoder.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/Grib1Decoder.java index 745aad5f68..5ba42ab9bd 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/Grib1Decoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/Grib1Decoder.java @@ -90,6 +90,7 @@ import com.raytheon.uf.common.time.TimeRange; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 3/11/10 4758 bphillip Initial Creation + * 6/12/12 0609 djohnson Use EDEXUtil for EDEX_HOME. * * * diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java index 859b4829d2..76c46e1bd9 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java @@ -32,6 +32,7 @@ import com.raytheon.uf.common.dataplugin.grid.GridRecord; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.python.decoder.PythonDecoder; /** @@ -121,5 +122,4 @@ public class GribDecoder { } return records; } - } diff --git a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarPointDataTransform.java b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarPointDataTransform.java index b9eb534f49..321cd92ecb 100644 --- a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarPointDataTransform.java +++ b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarPointDataTransform.java @@ -65,115 +65,115 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools; public class MetarPointDataTransform { - private static final String ALTIMETER = "altimeter"; + public static final String ALTIMETER = "altimeter"; - private static final String SEA_LEVEL_PRESS = "seaLevelPress"; + public static final String SEA_LEVEL_PRESS = "seaLevelPress"; - private static final String PRESS_CHANGE3_HOUR = "pressChange3Hour"; + public static final String PRESS_CHANGE3_HOUR = "pressChange3Hour"; - private static final String PRESS_CHANGE_CHAR = "pressChangeChar"; + public static final String PRESS_CHANGE_CHAR = "pressChangeChar"; // ALTIMETER, SEA_LEVEL_PRESS, PRESS_CHANGE3_HOUR, PRESS_CHANGE_CHAR, // ------------------ - private static final String PRECIP24_HOUR = "precip24Hour"; + public static final String PRECIP24_HOUR = "precip24Hour"; - private static final String PRECIP6_HOUR = "precip6Hour"; + public static final String PRECIP6_HOUR = "precip6Hour"; - private static final String PRECIP3_HOUR = "precip3Hour"; + public static final String PRECIP3_HOUR = "precip3Hour"; - private static final String PRECIP1_HOUR = "precip1Hour"; + public static final String PRECIP1_HOUR = "precip1Hour"; // PRECIP24_HOUR, PRECIP6_HOUR, PRECIP3_HOUR, PRECIP1_HOUR // ------------------ - private static final String WIND_GUST = "windGust"; + public static final String WIND_GUST = "windGust"; - private static final String WIND_SPEED = "windSpeed"; + public static final String WIND_SPEED = "windSpeed"; - private static final String WIND_DIR_STR = "windDirStr"; + public static final String WIND_DIR_STR = "windDirStr"; // WIND_GUST, WIND_SPEED, WIND_DIR_STR, // ------------------ - private static final String PK_WND_SPD = "pkwndSpeed"; + public static final String PK_WND_SPD = "pkwndSpeed"; - private static final String PK_WND_DIR = "pkwndDir"; + public static final String PK_WND_DIR = "pkwndDir"; - private static final String PK_WND_TIME = "pkwndTime"; + public static final String PK_WND_TIME = "pkwndTime"; // PK_WND_SPD, PK_WND_DIR, PK_WND_TIME // ------------------ - private static final String TEMPERATURE = "temperature"; + public static final String TEMPERATURE = "temperature"; - private static final String TEMP_FROM_TENTHS = "tempFromTenths"; + public static final String TEMP_FROM_TENTHS = "tempFromTenths"; - private static final String DEWPOINT = "dewpoint"; + public static final String DEWPOINT = "dewpoint"; - private static final String DP_FROM_TENTHS = "dpFromTenths"; + public static final String DP_FROM_TENTHS = "dpFromTenths"; // TEMPERATURE, TEMP_FROM_TENTHS, DEWPOINT, DP_FROM_TENTHS, // ------------------ - private static final String MAX_TEMP24_HOUR = "maxTemp24Hour"; + public static final String MAX_TEMP24_HOUR = "maxTemp24Hour"; - private static final String MIN_TEMP24_HOUR = "minTemp24Hour"; + public static final String MIN_TEMP24_HOUR = "minTemp24Hour"; - private static final String MAX_TEMP6_HOUR = "maxTemp6Hour"; + public static final String MAX_TEMP6_HOUR = "maxTemp6Hour"; - private static final String MIN_TEMP6_HOUR = "minTemp6Hour"; + public static final String MIN_TEMP6_HOUR = "minTemp6Hour"; // MAX_TEMP24_HOUR, MIN_TEMP24_HOUR, MAX_TEMP6_HOUR, MIN_TEMP6_HOUR, // ------------------ - private static final String SNOW_DEPTH = "snowDepth"; + public static final String SNOW_DEPTH = "snowDepth"; - private static final String SNOW_WATER = "snowWater"; + public static final String SNOW_WATER = "snowWater"; - private static final String SNOWFALL6_HOUR = "snowfall6Hour"; + public static final String SNOWFALL6_HOUR = "snowfall6Hour"; - private static final String SUNSHINE = "sunshine"; + public static final String SUNSHINE = "sunshine"; // SNOW_DEPTH, SNOW_WATER, SNOWFALL6_HOUR, SUNSHINE, // ------------------ - private static final String PRES_WEATHER = "presWeather"; + public static final String PRES_WEATHER = "presWeather"; - private static final String VISIBILITY = "visibility"; + public static final String VISIBILITY = "visibility"; - private static final String VERT_VISIBILITY = "vertVisibility"; + public static final String VERT_VISIBILITY = "vertVisibility"; // PRES_WEATHER, VISIBILITY_STR, VISIBILITY, VERT_VISIBILITY, // ------------------ - private static final String STATION_NAME = "stationName"; + public static final String STATION_NAME = "stationName"; - private static final String STATION_ID = "stationId"; + public static final String STATION_ID = "stationId"; - private static final String AUTO_STATION_TYPE = "autoStationType"; + public static final String AUTO_STATION_TYPE = "autoStationType"; - private static final String REPORT_TYPE = "reportType"; + public static final String REPORT_TYPE = "reportType"; - private static final String TIME_OBS = "timeObs"; + public static final String TIME_OBS = "timeObs"; // STATION_NAME, STATION_ID, AUTO_STATION_TYPE, REPORT_TYPE, TIME_OBS, // ------------------ - private static final String LONGITUDE = "longitude"; + public static final String LONGITUDE = "longitude"; - private static final String LATITUDE = "latitude"; + public static final String LATITUDE = "latitude"; - private static final String ELEVATION = "elevation"; + public static final String ELEVATION = "elevation"; // LONGITUDE, LATITUDE, ELEVATION, // ------------------ - private static final String RAW_METAR = "rawMETAR"; + public static final String RAW_METAR = "rawMETAR"; - private static final String CORRECTION = "correction"; + public static final String CORRECTION = "correction"; - private static final String DATAURI = "dataURI"; + public static final String DATAURI = "dataURI"; // RAW_METAR, CORRECTION, DATAURI, // ------------------ - private static final String SKY_LAYER_BASE = "skyLayerBase"; + public static final String SKY_LAYER_BASE = "skyLayerBase"; - private static final String SKY_COVER = "skyCover"; + public static final String SKY_COVER = "skyCover"; - private static final String SKY_COVER_TYPE = "skyCoverType"; + public static final String SKY_COVER_TYPE = "skyCoverType"; - private static final String SKY_COVER_GENUS = "skyCoverGenus"; + public static final String SKY_COVER_GENUS = "skyCoverGenus"; // SKY_LAYER_BASE, SKY_COVER, SKY_COVER_TYPE, SKY_COVER_GENUS, // ------------------ @@ -183,7 +183,7 @@ public class MetarPointDataTransform { * keep this up to date or risk breaking backwards compatibility * */ - private static final String[] ALL_PARAMS = { ALTIMETER, SEA_LEVEL_PRESS, + public static final String[] ALL_PARAMS = { ALTIMETER, SEA_LEVEL_PRESS, PRESS_CHANGE3_HOUR, PRESS_CHANGE_CHAR, PRECIP24_HOUR, PRECIP6_HOUR, PRECIP3_HOUR, PRECIP1_HOUR, WIND_GUST, WIND_SPEED, WIND_DIR_STR, PK_WND_SPD, PK_WND_DIR, PK_WND_TIME, TEMPERATURE, TEMP_FROM_TENTHS, diff --git a/edexOsgi/com.raytheon.edex.plugin.shef/unit-test/test/edex/transform/shef/TestM2SOptions.java b/edexOsgi/com.raytheon.edex.plugin.shef/unit-test/test/edex/transform/shef/TestM2SOptions.java index 75aa20bc49..fc18416ea2 100644 --- a/edexOsgi/com.raytheon.edex.plugin.shef/unit-test/test/edex/transform/shef/TestM2SOptions.java +++ b/edexOsgi/com.raytheon.edex.plugin.shef/unit-test/test/edex/transform/shef/TestM2SOptions.java @@ -19,13 +19,16 @@ **/ package test.edex.transform.shef; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; +import org.junit.Test; + import com.raytheon.edex.transform.shef.obs.ObsToSHEFOptions; /** @@ -86,7 +89,7 @@ public class TestM2SOptions { } } - assertEquals(40, options.getPCReset("KOMA")); + assertEquals(40, options.getPCReset("KOMA").intValue()); assertFalse(options.checkName("KSAT")); assertTrue(options.isOptZeroAuto1HourPrecip()); assertFalse(options.isOptTypeSrcV()); diff --git a/edexOsgi/com.raytheon.edex.utilitysrv/.classpath b/edexOsgi/com.raytheon.edex.utilitysrv/.classpath index 1fa3e6803d..69cf8ac476 100644 --- a/edexOsgi/com.raytheon.edex.utilitysrv/.classpath +++ b/edexOsgi/com.raytheon.edex.utilitysrv/.classpath @@ -3,5 +3,6 @@ + diff --git a/edexOsgi/com.raytheon.edex.utilitysrv/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.utilitysrv/META-INF/MANIFEST.MF index ed49f2c602..6b450d0935 100644 --- a/edexOsgi/com.raytheon.edex.utilitysrv/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.utilitysrv/META-INF/MANIFEST.MF @@ -9,10 +9,12 @@ Require-Bundle: org.apache.commons.logging, com.raytheon.uf.common.localization, com.raytheon.uf.common.serialization.comm;bundle-version="1.0.0", com.raytheon.uf.edex.auth, - com.raytheon.uf.common.status;bundle-version="1.12.1130" + com.raytheon.uf.common.status;bundle-version="1.12.1130", + com.raytheon.uf.common.plugin.nwsauth Export-Package: com.raytheon.edex.services Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.raytheon.uf.common.auth.req, com.raytheon.uf.common.auth.user, + com.raytheon.uf.common.plugin.nwsauth.exception, com.raytheon.uf.edex.auth.req, com.raytheon.uf.edex.auth.resp diff --git a/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/AbstractPrivilegedLocalizationRequestHandler.java b/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/AbstractPrivilegedLocalizationRequestHandler.java index 4e7e1659db..bb8976d477 100644 --- a/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/AbstractPrivilegedLocalizationRequestHandler.java +++ b/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/AbstractPrivilegedLocalizationRequestHandler.java @@ -19,16 +19,18 @@ **/ package com.raytheon.edex.services; +import java.io.File; + import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest; import com.raytheon.uf.common.auth.user.IUser; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; +import com.raytheon.uf.common.plugin.nwsauth.exception.AuthorizationException; +import com.raytheon.uf.common.plugin.nwsauth.roles.IRoleStorage; import com.raytheon.uf.edex.auth.AuthManager; import com.raytheon.uf.edex.auth.AuthManagerFactory; import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler; import com.raytheon.uf.edex.auth.resp.AuthorizationResponse; -import com.raytheon.uf.edex.auth.roles.IRole; -import com.raytheon.uf.edex.auth.roles.IRoleStorage; /** * Abstract privileged request handler for localization requests @@ -39,8 +41,8 @@ import com.raytheon.uf.edex.auth.roles.IRoleStorage; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jul 6, 2011 mschenke Initial creation - * + * Jul 6, 2011 mschenke Initial creation + * Jul 8, 2012 719 mpduff Fix order of checks * * * @author mschenke @@ -49,10 +51,13 @@ import com.raytheon.uf.edex.auth.roles.IRoleStorage; */ public abstract class AbstractPrivilegedLocalizationRequestHandler extends AbstractPrivilegedRequestHandler { + + private static final String APPLICATION = "Localization"; protected AuthorizationResponse getAuthorizationResponse(IUser user, LocalizationContext context, LocalizationLevel level, - String fileName, String myContextName) { + String fileName, String myContextName) + throws AuthorizationException { String contextName = context.getContextName(); if (level.isSystemLevel()) { @@ -68,15 +73,15 @@ public abstract class AbstractPrivilegedLocalizationRequestHandler 0) { if (contextName != null) { roleId += "." + contextName; @@ -85,43 +90,50 @@ public abstract class AbstractPrivilegedLocalizationRequestHandler.(.)/type/path/name/ + int minIndex = roleId.length(); + roleId += File.separator + fileName; + int index = roleId.length(); + + while (index > minIndex) { + roleId = roleId.substring(0, index); + + if (roleStorage.isAuthorized(roleId, user.uniqueId().toString(), APPLICATION)) { + return new AuthorizationResponse(true); + } + + index = roleId.lastIndexOf(File.separator, index - 1); + } + + roleId = "com.raytheon.localization." + + context.getLocalizationLevel().name(); + if (i > 0) { + if (contextName != null) { + roleId += "." + contextName; + } else { + // We already checked this case + break; + } + } + // com.raytheon.localization..() - if (checkRole(roles, roleId, user)) { + if (roleStorage.isAuthorized(roleId, user.uniqueId().toString(), APPLICATION)) { return new AuthorizationResponse(true); } // com.raytheon.localization..(.)/type roleId += "/" + context.getLocalizationType().name(); - if (checkRole(roles, roleId, user)) { + + if (roleStorage.isAuthorized(roleId, user.uniqueId().toString(), APPLICATION)) { return new AuthorizationResponse(true); } - - // check most specific to least specific - // com.raytheon.localization..(.)/type/path/name/ - int minIndex = roleId.length(); - roleId += "/" + fileName; - int index = roleId.length(); - while (index > minIndex && isValid) { - roleId = roleId.substring(0, index); - IRole role = roles.lookupRole(roleId); - index = roleId.lastIndexOf("/", index - 1); - if (role.validForUser(user)) { - return new AuthorizationResponse(true); - } else if (!roles.isDefaultRole(role)) { - // if not valid for user and is not default role then not - // authorized. - isValid = false; - } - } + } - + return new AuthorizationResponse(false, "User, " + user.uniqueId() + ", is not authorized to perform request needing role: " + roleId); } - - private boolean checkRole(IRoleStorage roles, String roleId, IUser user) { - IRole role = roles.lookupRole(roleId); - return (role != null && role.validForUser(user)); - } } diff --git a/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/GetServersHandler.java b/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/GetServersHandler.java index ce5d246eb6..4af2822c42 100644 --- a/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/GetServersHandler.java +++ b/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/GetServersHandler.java @@ -37,6 +37,7 @@ import com.raytheon.uf.edex.core.props.PropertiesFactory; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 6, 2009 mschenke Initial creation + * Sep 12, 2012 1167 djohnson Add datadelivery servers. * * * @@ -55,10 +56,19 @@ public class GetServersHandler implements IRequestHandler { String httpServer = System.getProperty("http.server"); String jmsServer = System.getProperty("jms.server"); String pypiesServer = System.getProperty("pypies.server"); + String dataDeliveryServer = System + .getProperty("datadelivery.server"); + String dataDeliveryLcmServer = System + .getProperty("datadelivery.lcm.server"); + String dataDeliveryQueryServer = System + .getProperty("datadelivery.query.server"); logger.info("http.server=" + httpServer); logger.info("jms.server=" + jmsServer); logger.info("pypies.server=" + pypiesServer); + logger.info("datadelivery.server=" + dataDeliveryServer); + logger.info("datadelivery.lcm.server=" + dataDeliveryLcmServer); + logger.info("datadelivery.query.server=" + dataDeliveryQueryServer); String hdf5DataDir = PropertiesFactory.getInstance().getEnvProperties() .getEnvValue("HDF5DIR"); @@ -66,6 +76,9 @@ public class GetServersHandler implements IRequestHandler { response.setHttpServer(httpServer); response.setJmsServer(jmsServer); response.setPypiesServer(pypiesServer); + response.setDataDeliveryServer(dataDeliveryServer); + response.setDataDeliveryLcmServer(dataDeliveryLcmServer); + response.setDataDeliveryQueryServer(dataDeliveryQueryServer); response.setServerDataDir(hdf5DataDir); return response; } diff --git a/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/LocalizationStreamHandler.java b/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/LocalizationStreamHandler.java index 07432fde50..2470a4733e 100644 --- a/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/LocalizationStreamHandler.java +++ b/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/LocalizationStreamHandler.java @@ -37,6 +37,7 @@ import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.localization.stream.AbstractLocalizationStreamRequest; import com.raytheon.uf.common.localization.stream.LocalizationStreamGetRequest; import com.raytheon.uf.common.localization.stream.LocalizationStreamPutRequest; +import com.raytheon.uf.common.plugin.nwsauth.exception.AuthorizationException; import com.raytheon.uf.edex.auth.resp.AuthorizationResponse; import com.raytheon.uf.edex.core.EDEXUtil; @@ -270,7 +271,8 @@ public class LocalizationStreamHandler @Override public AuthorizationResponse authorized(IUser user, - AbstractLocalizationStreamRequest request) { + AbstractLocalizationStreamRequest request) + throws AuthorizationException { if (request instanceof LocalizationStreamGetRequest) { // All gets are authorized return new AuthorizationResponse(true); diff --git a/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/PrivilegedUtilityHandler.java b/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/PrivilegedUtilityHandler.java index 414130fc8f..3f42e3a805 100644 --- a/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/PrivilegedUtilityHandler.java +++ b/edexOsgi/com.raytheon.edex.utilitysrv/src/com/raytheon/edex/services/PrivilegedUtilityHandler.java @@ -11,6 +11,7 @@ import com.raytheon.uf.common.localization.msgs.AbstractUtilityResponse; import com.raytheon.uf.common.localization.msgs.DeleteUtilityCommand; import com.raytheon.uf.common.localization.msgs.PrivilegedUtilityRequestMessage; import com.raytheon.uf.common.localization.msgs.UtilityResponseMessage; +import com.raytheon.uf.common.plugin.nwsauth.exception.AuthorizationException; import com.raytheon.uf.edex.auth.resp.AuthorizationResponse; import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.core.props.PropertiesFactory; @@ -66,7 +67,8 @@ public class PrivilegedUtilityHandler @Override public AuthorizationResponse authorized(IUser user, - PrivilegedUtilityRequestMessage request) { + PrivilegedUtilityRequestMessage request) + throws AuthorizationException { AbstractPrivilegedUtilityCommand[] commands = request.getCommands(); for (AbstractPrivilegedUtilityCommand abstractUtilityCommand : commands) { diff --git a/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/src/gov/noaa/nws/ncep/viz/ui/perspectives/PreferencesHandler.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfePrivilegedRequest.java similarity index 50% rename from ncep/gov.noaa.nws.ncep.viz.ui.perspectives/src/gov/noaa/nws/ncep/viz/ui/perspectives/PreferencesHandler.java rename to edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfePrivilegedRequest.java index 398e12f64b..685679e75e 100644 --- a/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/src/gov/noaa/nws/ncep/viz/ui/perspectives/PreferencesHandler.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfePrivilegedRequest.java @@ -17,48 +17,54 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ +package com.raytheon.uf.common.dataplugin.gfe.request; -package gov.noaa.nws.ncep.viz.ui.perspectives; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.ui.dialogs.PreferencesUtil; +import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; /** - * Opens the preference window + * Privilege request for GFE for a given role Id. * *
  * 
  * SOFTWARE HISTORY
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Apr 11, 2007            chammack    Initial Creation.
+ * Sep 19, 2012            bgonzale     Initial creation
  * 
  * 
* - * @author chammack + * @author bgonzale * @version 1.0 */ -public class PreferencesHandler extends AbstractHandler { - /* - * (non-Javadoc) +public class AbstractGfePrivilegedRequest extends AbstractPrivilegedRequest { + private final static String DEFAULT_ROLEID = "com.raytheon.localization.site/common_static/gfe"; + + @DynamicSerializeElement + private String roleId; + + /** * - * @see - * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands - * .ExecutionEvent) */ - @Override - public Object execute(ExecutionEvent arg0) throws ExecutionException { - - String prefPageId = "gov.noaa.nws.ncep.ui.pgen.Preferences"; - - PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( - null, prefPageId, new String[] { prefPageId }, null); - dialog.open(); - return null; + public AbstractGfePrivilegedRequest() { + roleId = DEFAULT_ROLEID; + } + + /** + * @return the roleId + */ + public String getRoleId() { + return roleId; + } + + /** + * @param roleId + * the roleId to set + */ + public void setRoleId(String roleId) { + this.roleId = roleId; } } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/CheckPermissionsRequest.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/CheckPermissionsRequest.java index 53a110b3e7..bc93c7a4f0 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/CheckPermissionsRequest.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/CheckPermissionsRequest.java @@ -19,9 +19,7 @@ **/ package com.raytheon.uf.common.dataplugin.gfe.request; -import com.raytheon.uf.common.auth.user.IUser; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; -import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; /** * TODO Add Description @@ -41,31 +39,9 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; */ @DynamicSerialize -public class CheckPermissionsRequest extends AbstractGfeRequest { - - @DynamicSerializeElement - private IUser user; +public class CheckPermissionsRequest extends AbstractGfePrivilegedRequest { public CheckPermissionsRequest() { } - public CheckPermissionsRequest(IUser user) { - this.user = user; - } - - /** - * @return the user - */ - public IUser getUser() { - return user; - } - - /** - * @param user - * the user to set - */ - public void setUser(IUser user) { - this.user = user; - } - } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/ExportConfRequest.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/ExportConfRequest.java index 339e341ba4..2530314a07 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/ExportConfRequest.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/ExportConfRequest.java @@ -19,7 +19,6 @@ **/ package com.raytheon.uf.common.dataplugin.gfe.request; -import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest; import com.raytheon.uf.common.auth.user.IUser; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -42,7 +41,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; */ @DynamicSerialize -public class ExportConfRequest extends AbstractPrivilegedRequest { +public class ExportConfRequest extends AbstractGfePrivilegedRequest { @DynamicSerializeElement private String site; @@ -71,5 +70,4 @@ public class ExportConfRequest extends AbstractPrivilegedRequest { this.site = site; } - } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.grib/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.dataplugin.grib/META-INF/MANIFEST.MF index 004ced58e9..b037b91337 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.grib/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.grib/META-INF/MANIFEST.MF @@ -26,5 +26,6 @@ Import-Package: com.raytheon.uf.common.dataplugin.grid, com.raytheon.uf.common.gridcoverage.exception, com.raytheon.uf.common.parameter Export-Package: com.raytheon.uf.common.dataplugin.grib, - com.raytheon.uf.common.dataplugin.grib.request + com.raytheon.uf.common.dataplugin.grib.request, + com.raytheon.uf.common.dataplugin.grib.subgrid Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/GribRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/GribRecord.java index dc13c6cad0..6ee04be5fc 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/GribRecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/GribRecord.java @@ -22,6 +22,8 @@ package com.raytheon.uf.common.dataplugin.grib; import java.util.Arrays; import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -38,6 +40,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import com.raytheon.uf.common.dataplugin.IDecoderGettable; +import com.raytheon.uf.common.dataplugin.IPrecomputedRange; import com.raytheon.uf.common.dataplugin.annotations.DataURI; import com.raytheon.uf.common.dataplugin.persist.IHDFFilePathProvider; import com.raytheon.uf.common.dataplugin.persist.IPersistable; @@ -69,7 +72,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize public class GribRecord extends PersistablePluginDataObject implements - IPersistable, ISpatialEnabled { + IPersistable, ISpatialEnabled, IPrecomputedRange { private static final long serialVersionUID = 1L; @@ -171,6 +174,16 @@ public class GribRecord extends PersistablePluginDataObject implements @DynamicSerializeElement private Integer resCompFlags; + @Column + @XmlAttribute + @DynamicSerializeElement + private double dataMin; + + @Column + @XmlAttribute + @DynamicSerializeElement + private double dataMax; + /** * Creates an empty GribRecord */ @@ -240,6 +253,22 @@ public class GribRecord extends PersistablePluginDataObject implements return null; } + @Override + public Date getPersistenceTime() { + Calendar c = getInsertTime(); + if (c == null) + return null; + + return c.getTime(); + } + + @Override + public void setPersistenceTime(Date persistTime) { + Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + c.setTime(persistTime); + setInsertTime(c); + } + @Override public ISpatialObject getSpatialObject() { return modelInfo.getLocation(); @@ -475,11 +504,42 @@ public class GribRecord extends PersistablePluginDataObject implements this.resCompFlags = resCompFlags; } - @Override public void setId(int id) { this.id = id; } + /** + * @return the dataMin + */ + @Override + public double getDataMin() { + return dataMin; + } + + /** + * @param dataMin + * the dataMin to set + */ + public void setDataMin(double dataMin) { + this.dataMin = dataMin; + } + + /** + * @return the dataMax + */ + @Override + public double getDataMax() { + return dataMax; + } + + /** + * @param dataMax + * the dataMax to set + */ + public void setDataMax(double dataMax) { + this.dataMax = dataMax; + } + @Override public int hashCode() { final int prime = 31; @@ -506,15 +566,12 @@ public class GribRecord extends PersistablePluginDataObject implements @Override public boolean equals(Object obj) { - if (this == obj) { + if (this == obj) return true; - } - if (obj == null) { + if (obj == null) return false; - } - if (getClass() != obj.getClass()) { + if (getClass() != obj.getClass()) return false; - } GribRecord other = (GribRecord) obj; if (!this.dataTime.getRefTimeAsCalendar().equals( other.getDataTime().getRefTimeAsCalendar())) { @@ -527,59 +584,42 @@ public class GribRecord extends PersistablePluginDataObject implements return false; } - if (gridVersion != other.gridVersion) { + if (gridVersion != other.gridVersion) return false; - } - if (!Arrays.equals(hybridCoordList, other.hybridCoordList)) { + if (!Arrays.equals(hybridCoordList, other.hybridCoordList)) return false; - } - if (hybridGrid != other.hybridGrid) { + if (hybridGrid != other.hybridGrid) return false; - } - if (isVector != other.isVector) { + if (isVector != other.isVector) return false; - } - if (!Arrays.equals(localSection, other.localSection)) { + if (!Arrays.equals(localSection, other.localSection)) return false; - } - if (localSectionUsed != other.localSectionUsed) { + if (localSectionUsed != other.localSectionUsed) return false; - } - if (localTableVersion != other.localTableVersion) { + if (localTableVersion != other.localTableVersion) return false; - } - if (masterTableVersion != other.masterTableVersion) { + if (masterTableVersion != other.masterTableVersion) return false; - } if (modelInfo == null) { - if (other.modelInfo != null) { + if (other.modelInfo != null) return false; - } - } else if (!modelInfo.equals(other.modelInfo)) { + } else if (!modelInfo.equals(other.modelInfo)) return false; - } - if (processedDataType != other.processedDataType) { + if (processedDataType != other.processedDataType) return false; - } - if (productionStatus != other.productionStatus) { + if (productionStatus != other.productionStatus) return false; - } - if (refTimeSignificance != other.refTimeSignificance) { + if (refTimeSignificance != other.refTimeSignificance) return false; - } if (resCompFlags == null) { - if (other.resCompFlags != null) { + if (other.resCompFlags != null) return false; - } - } else if (!resCompFlags.equals(other.resCompFlags)) { + } else if (!resCompFlags.equals(other.resCompFlags)) return false; - } - if (thinnedGrid != other.thinnedGrid) { + if (thinnedGrid != other.thinnedGrid) return false; - } - if (!Arrays.equals(thinnedPts, other.thinnedPts)) { + if (!Arrays.equals(thinnedPts, other.thinnedPts)) return false; - } return true; } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/src/com/raytheon/uf/common/dataplugin/grid/GridInfoRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/src/com/raytheon/uf/common/dataplugin/grid/GridInfoRecord.java index 5b6f3c02b7..70457c8047 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/src/com/raytheon/uf/common/dataplugin/grid/GridInfoRecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/src/com/raytheon/uf/common/dataplugin/grid/GridInfoRecord.java @@ -60,7 +60,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @Table(name = "grid_info") @SequenceGenerator(name = "GRIDINFO_GENERATOR", sequenceName = "gridinfo_seq", allocationSize = 1) @DynamicSerialize -public class GridInfoRecord extends PersistableDataObject { +public class GridInfoRecord extends PersistableDataObject { private static final long serialVersionUID = 1L; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/.classpath b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/.classpath index ad32c83a78..1fa3e6803d 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/.classpath +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/.classpath @@ -1,6 +1,6 @@ - + diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/IPrecomputedRange.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/IPrecomputedRange.java new file mode 100644 index 0000000000..edea697211 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/IPrecomputedRange.java @@ -0,0 +1,39 @@ +/* + * The following software products were developed by Raytheon: + * + * ADE (AWIPS Development Environment) software + * CAVE (Common AWIPS Visualization Environment) software + * EDEX (Environmental Data Exchange) software + * uFrameâ„¢ (Universal Framework) software + * + * Copyright (c) 2010 Raytheon Co. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/epl-v10.php + * + * + * Contractor Name: Raytheon Company + * Contractor Address: + * 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + */ +package com.raytheon.uf.common.dataplugin; + +/** + * This interface can be implemented to indicate that a particular + * PluginDataObject has a pre-computed data range + * + * @author ekladstrup + * + */ +public interface IPrecomputedRange { + + public double getDataMin(); + + public double getDataMax(); + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/convert/ConvertUtil.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/convert/ConvertUtil.java index 8b0fc37f44..0986863af2 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/convert/ConvertUtil.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/convert/ConvertUtil.java @@ -19,6 +19,12 @@ **/ package com.raytheon.uf.common.dataplugin.convert; +import java.lang.reflect.Field; +import java.util.Calendar; +import java.util.Date; + +import javax.xml.bind.DatatypeConverter; + import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.Converter; @@ -86,7 +92,58 @@ public class ConvertUtil { if (value.equals("null")) { return null; } + if (desiredClass.equals(Calendar.class)) { + try { + // see if string is in ISO 8601 + return DatatypeConverter.parseDateTime(value); + } catch (Exception e) { + // let convertUtils try + } + } + if (desiredClass.equals(Date.class)) { + try { + // see if string is in ISO 8601 + return DatatypeConverter.parseDateTime(value).getTime(); + } catch (Exception e) { + // let convertUtils try + } + } return ConvertUtils.convert(value, desiredClass); } + public static String toString(Object obj) { + return ConvertUtils.convert(obj); + } + + public static Object convertAsType(String value, Class entity, + String fieldName) throws SecurityException, NoSuchFieldException { + Field field = getField(fieldName, entity); + return convertObject(value, field.getType()); + } + + public static Object convertAsType(String value, Class entity, + String[] fieldPath) throws SecurityException, NoSuchFieldException { + Field f = getField(fieldPath[0], entity); + for (int i = 1; i < fieldPath.length; ++i) { + f = getField(fieldPath[i], f.getType()); + } + return convertObject(value, f.getType()); + } + + protected static Field getField(String fieldName, Class c) + throws SecurityException, NoSuchFieldException { + Field rval; + try { + rval = c.getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + Class parent = c.getSuperclass(); + if (parent.isInstance(Object.class)) { + throw e; + } else { + rval = getField(fieldName, c.getSuperclass()); + } + } + return rval; + } + } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/IPersistableDataObject.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/IPersistableDataObject.java index 8751913ce4..17bb9f2503 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/IPersistableDataObject.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/IPersistableDataObject.java @@ -35,17 +35,19 @@ package com.raytheon.uf.common.dataplugin.persist; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 20Aug2007 393 MW Fegan Initial creation - * + * Oct 10, 2012 1261 djohnson Add generic for identifier. + * * + * * @author mfegan * @version 1 - * + * */ -public interface IPersistableDataObject { +public interface IPersistableDataObject { /** * Returns an object representing the identifier. * * @return the identifier */ - public Object getIdentifier(); + IDENTIFIER_TYPE getIdentifier(); } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistableDataObject.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistableDataObject.java index 435d79492c..eb55100ec0 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistableDataObject.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistableDataObject.java @@ -49,6 +49,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * ------------ ---------- ----------- -------------------------- * 7/24/07 353 bphillip Initial Check in * 20080408 1039 jkorman Added traceId for tracing data. + * Oct 10, 2012 1261 djohnson Add generic for identifier. * * * @@ -57,16 +58,19 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; */ @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public abstract class PersistableDataObject implements IPersistableDataObject, +public abstract class PersistableDataObject implements + IPersistableDataObject, Serializable, ISerializableObject { + private static final long serialVersionUID = -6747395152869923909L; + /** * Object used as the unique identifier. Intended to be used as the primary * key for the associated database table. */ @XmlElement @DynamicSerializeElement - protected Object identifier; + protected IDENTIFIER_TYPE identifier; private String traceId = ""; @@ -96,7 +100,8 @@ public abstract class PersistableDataObject implements IPersistableDataObject, * * @return The identifier */ - public Object getIdentifier() { + @Override + public IDENTIFIER_TYPE getIdentifier() { return identifier; } @@ -106,7 +111,7 @@ public abstract class PersistableDataObject implements IPersistableDataObject, * @param identifier * The identifier */ - public void setIdentifier(Object identifier) { + public void setIdentifier(IDENTIFIER_TYPE identifier) { this.identifier = identifier; } diff --git a/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/MapUtil.java b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/MapUtil.java index f71f344d93..5d9e57d475 100644 --- a/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/MapUtil.java +++ b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/MapUtil.java @@ -545,6 +545,33 @@ public class MapUtil { return LATLON_PROJECTION; } + public static ProjectedCRS contructLambertAzimuthalEqualArea( + double majorAxis, double minorAxis, double latOfOrigin, + double centralMeridian, double falseEasting, double falseNorthing) { + + try { + ParameterValueGroup parameters = dmtFactory + .getDefaultParameters("Lambert_Azimuthal_Equal_Area"); + + parameters.parameter("semi_major").setValue(majorAxis); + parameters.parameter("semi_minor").setValue(minorAxis); + parameters.parameter("latitude_of_center").setValue(latOfOrigin); + parameters.parameter("longitude_of_center").setValue( + centralMeridian); + parameters.parameter("false_easting").setValue(falseEasting); + parameters.parameter("false_northing").setValue(falseNorthing); + + String name = "Equidistant_Cylindrical (LO: " + latOfOrigin + + ", CM: " + centralMeridian + ")"; + + return constructProjection(name, parameters); + } catch (Exception e) { + statusHandler.handle(Priority.WARN, e.getLocalizedMessage(), e); + return null; + } + + } + /** * Construct a lambert conformal crs * @@ -1502,4 +1529,42 @@ public class MapUtil { (int) (sizes[1]) }), newEnv); return newTarget; } + + public static ReferencedEnvelope getBoundingEnvelope( + CoordinateReferenceSystem crs, Polygon crs84Shape) { + try { + // the polygons aren't truly projected, they are just the projected + // points + Coordinate[] coords = crs84Shape.getExteriorRing().getCoordinates(); + MathTransform mt = CRS.findMathTransform(MapUtil.LATLON_PROJECTION, + crs); + // here we project the points back to the native crs + + double maxX = Double.NEGATIVE_INFINITY; + double maxY = Double.NEGATIVE_INFINITY; + double minX = Double.POSITIVE_INFINITY; + double minY = Double.POSITIVE_INFINITY; + for (int i = 0; i < coords.length; ++i) { + DirectPosition2D to = new DirectPosition2D(); + mt.transform(new DirectPosition2D(coords[i].x, coords[i].y), to); + maxX = Math.max(maxX, to.x); + maxY = Math.max(maxY, to.y); + minX = Math.min(minX, to.x); + minY = Math.min(minY, to.y); + } + + return new ReferencedEnvelope(minX, maxX, minY, maxY, crs); + } catch (Exception e) { + statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e); + // FIXME actually handle error + throw new RuntimeException(e); + } + } + + public static ReferencedEnvelope getNativeEnvelope(ISpatialObject spatial) + throws FactoryException { + CoordinateReferenceSystem crs = spatial.getCrs(); + Geometry geom = spatial.getGeometry(); + return MapUtil.getBoundingEnvelope(crs, (Polygon) geom); + } } diff --git a/edexOsgi/com.raytheon.uf.common.gridcoverage/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.gridcoverage/META-INF/MANIFEST.MF index e0a1d1420f..d925f249b7 100644 --- a/edexOsgi/com.raytheon.uf.common.gridcoverage/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.gridcoverage/META-INF/MANIFEST.MF @@ -30,4 +30,5 @@ Export-Package: com.raytheon.uf.common.gridcoverage, com.raytheon.uf.common.gridcoverage.lookup, com.raytheon.uf.common.gridcoverage.request, com.raytheon.uf.common.gridcoverage.subgrid -Require-Bundle: org.geotools;bundle-version="2.6.4" +Require-Bundle: org.geotools;bundle-version="2.6.4", + com.raytheon.uf.common.serialization diff --git a/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/GridCoverage.java b/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/GridCoverage.java index 2a58e2ee33..13127baf65 100644 --- a/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/GridCoverage.java +++ b/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/GridCoverage.java @@ -38,6 +38,7 @@ import javax.persistence.Transient; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.commons.lang.builder.HashCodeBuilder; import org.geotools.coverage.grid.GridGeometry2D; @@ -53,6 +54,7 @@ import com.raytheon.uf.common.geospatial.ISpatialObject; import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException; import com.raytheon.uf.common.gridcoverage.subgrid.SubGrid; +import com.raytheon.uf.common.serialization.adapters.GeometryAdapter; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.vividsolutions.jts.geom.Geometry; @@ -67,6 +69,7 @@ import com.vividsolutions.jts.geom.Geometry; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 4/7/09 1994 bphillip Initial Creation + * Sep 07, 2012 1102 djohnson Add missing JAXB annotations. * 09/10/2012 DR 15270 D. Friedman Fix subgrid model name handling. * * @@ -111,11 +114,13 @@ public abstract class GridCoverage extends PersistableDataObject implements /** Geometry object holding the corner points of the grid */ @Column(name = "the_geom", columnDefinition = "geometry") @Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType") + @XmlJavaTypeAdapter(value = GeometryAdapter.class) @DynamicSerializeElement protected Geometry geometry; /** The CRS as a WKT String */ @Column(name = "crs", length = 2047) + @XmlElement @DynamicSerializeElement protected String crsWKT; @@ -208,7 +213,7 @@ public abstract class GridCoverage extends PersistableDataObject implements @Override public String toString() { - if (id == 0) { + if (id == null) { return "Coverage Information Not Specified yet"; } else { return Integer.toString(id); @@ -266,10 +271,12 @@ public abstract class GridCoverage extends PersistableDataObject implements */ public abstract GridCoverage trim(SubGrid subGrid); + @Override public Geometry getGeometry() { return geometry; } + @Override public CoordinateReferenceSystem getCrs() { if (crs == null) { try { @@ -428,6 +435,7 @@ public abstract class GridCoverage extends PersistableDataObject implements this.firstGridPointCorner = firstGridPointCorner; } + @Override public Integer getNx() { return nx; } @@ -436,6 +444,7 @@ public abstract class GridCoverage extends PersistableDataObject implements this.nx = nx; } + @Override public Integer getNy() { return ny; } @@ -582,6 +591,14 @@ public abstract class GridCoverage extends PersistableDataObject implements if ("degree".equals(spacingUnit)) { // lower left is cell center, we want cell corners. double minLat = getLowerLeftLat() - dy / 2; + // This commented out if block can probably be removed. It was added + // for WA 5 Data Delivery, but nobody can remember exactly why. + // Commented out 11/01/2012, if you are in this file messing with + // something at some reasonable point in the future (especially if + // Michael J. Fox is with you), then feel free to delete it. + // if (ny * dy < 180) { + // minLat = MapUtil.correctLat(getLowerLeftLat()) - dy / 2; + // } double maxLat = minLat + dy * ny; double minLon = getLowerLeftLon() - dx / 2; if (dx * nx <= 360) { diff --git a/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/subgrid/SubGrid.java b/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/subgrid/SubGrid.java index 60c3ac5572..24521cb9a4 100644 --- a/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/subgrid/SubGrid.java +++ b/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/subgrid/SubGrid.java @@ -36,6 +36,9 @@ package com.raytheon.uf.common.gridcoverage.subgrid; */ public class SubGrid { + /** The model name */ + private String modelName; + /** the upper left x the subgrid will start with */ private int upperLeftX; @@ -124,4 +127,19 @@ public class SubGrid { this.upperRightLon = upperRightLon; } + /** + * @return the modelName + */ + public String getModelName() { + return modelName; + } + + /** + * @param modelName + * the modelName to set + */ + public void setModelName(String modelName) { + this.modelName = modelName; + } + } \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/PathManagerFactory.java b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/PathManagerFactory.java index ecc55ba737..a9cb3c0073 100644 --- a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/PathManagerFactory.java +++ b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/PathManagerFactory.java @@ -49,7 +49,7 @@ public class PathManagerFactory { private static final String EDEX_ADAPTER_CLASS = "com.raytheon.edex.utility.EDEXLocalizationAdapter"; - private static IPathManager pathManager; + static IPathManager pathManager; private static ILocalizationAdapter adapter; diff --git a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/msgs/GetServersResponse.java b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/msgs/GetServersResponse.java index f791f8bf6c..5a31051484 100644 --- a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/msgs/GetServersResponse.java +++ b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/msgs/GetServersResponse.java @@ -33,6 +33,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 6, 2009 mschenke Initial creation + * Sep 12, 2012 1167 djohnson Add datadelivery servers. * * * @@ -54,6 +55,15 @@ public class GetServersResponse implements ISerializableObject { @DynamicSerializeElement private String serverDataDir; + @DynamicSerializeElement + private String dataDeliveryServer; + + @DynamicSerializeElement + private String dataDeliveryLcmServer; + + @DynamicSerializeElement + private String dataDeliveryQueryServer; + public String getHttpServer() { return httpServer; } @@ -86,4 +96,48 @@ public class GetServersResponse implements ISerializableObject { this.serverDataDir = serverDataDir; } + /** + * @param dataDeliveryServer + * the dataDeliveryServer to set + */ + public void setDataDeliveryServer(String dataDeliveryServer) { + this.dataDeliveryServer = dataDeliveryServer; + } + + /** + * @return the dataDeliveryServer + */ + public String getDataDeliveryServer() { + return dataDeliveryServer; + } + + /** + * @return the dataDeliveryLcmServer + */ + public String getDataDeliveryLcmServer() { + return dataDeliveryLcmServer; + } + + /** + * @param dataDeliveryLcmServer + * the dataDeliveryLcmServer to set + */ + public void setDataDeliveryLcmServer(String dataDeliveryLcmServer) { + this.dataDeliveryLcmServer = dataDeliveryLcmServer; + } + + /** + * @return the dataDeliveryQueryServer + */ + public String getDataDeliveryQueryServer() { + return dataDeliveryQueryServer; + } + + /** + * @param dataDeliveryQueryServer + * the dataDeliveryQueryServer to set + */ + public void setDataDeliveryQueryServer(String dataDeliveryQueryServer) { + this.dataDeliveryQueryServer = dataDeliveryQueryServer; + } } diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/META-INF/MANIFEST.MF index 368c4c8c6e..d01dff6413 100644 --- a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/META-INF/MANIFEST.MF @@ -5,8 +5,13 @@ Bundle-SymbolicName: com.raytheon.uf.common.plugin.nwsauth Bundle-Version: 1.12.1174.qualifier Bundle-Vendor: RAYTHEON Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization -Eclipse-BuddyPolicy: registered, ext, global Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Import-Package: com.raytheon.uf.common.auth.user -Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.2" -Export-Package: com.raytheon.uf.common.plugin.nwsauth.user +Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.2", + com.raytheon.uf.common.auth;bundle-version="1.12.1174", + com.raytheon.uf.common.status;bundle-version="1.12.1174", + com.raytheon.uf.common.localization;bundle-version="1.12.1174" +Export-Package: com.raytheon.uf.common.plugin.nwsauth.exception, + com.raytheon.uf.common.plugin.nwsauth.roles, + com.raytheon.uf.common.plugin.nwsauth.user, + com.raytheon.uf.common.plugin.nwsauth.xml +Import-Package: com.raytheon.uf.common.plugin.nwsauth.exception diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject index 84750500ee..dcdb98d253 100644 --- a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -1 +1,5 @@ -com.raytheon.uf.common.plugin.nwsauth.user.UserId \ No newline at end of file +com.raytheon.uf.common.plugin.nwsauth.user.UserId +com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData +com.raytheon.uf.common.plugin.nwsauth.xml.PermissionXML +com.raytheon.uf.common.plugin.nwsauth.xml.RoleXML +com.raytheon.uf.common.plugin.nwsauth.xml.UserXML diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/exception/AuthorizationException.java b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/exception/AuthorizationException.java new file mode 100644 index 0000000000..c6a68eef3a --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/exception/AuthorizationException.java @@ -0,0 +1,71 @@ +/** + * 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.plugin.nwsauth.exception; + +/** + * Base exception for access authorization. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 19, 2012            bgonzale     Initial creation
+ * 
+ * 
+ * + * @author bgonzale + * @version 1.0 + */ + +public class AuthorizationException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * + */ + public AuthorizationException() { + } + + /** + * @param message + */ + public AuthorizationException(String message) { + super(message); + } + + /** + * @param cause + */ + public AuthorizationException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public AuthorizationException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/exception/RoleApplicationNotFoundException.java b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/exception/RoleApplicationNotFoundException.java new file mode 100644 index 0000000000..4c317cb05a --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/exception/RoleApplicationNotFoundException.java @@ -0,0 +1,71 @@ +/** + * 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.plugin.nwsauth.exception; + +/** + * Exception when the application id for a role is not found. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 18, 2012            bgonzale     Initial creation
+ * 
+ * 
+ * + * @author bgonzale + * @version 1.0 + */ + +public class RoleApplicationNotFoundException extends AuthorizationException { + + private static final long serialVersionUID = 1L; + + /** + * + */ + public RoleApplicationNotFoundException() { + } + + /** + * @param message + */ + public RoleApplicationNotFoundException(String message) { + super(message); + } + + /** + * @param cause + */ + public RoleApplicationNotFoundException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public RoleApplicationNotFoundException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/roles/IRole.java b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/roles/IRole.java similarity index 96% rename from edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/roles/IRole.java rename to edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/roles/IRole.java index 2246d4bcf0..e8cb749336 100644 --- a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/roles/IRole.java +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/roles/IRole.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.auth.roles; +package com.raytheon.uf.common.plugin.nwsauth.roles; import com.raytheon.uf.common.auth.user.IUser; diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/roles/IRoleStorage.java b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/roles/IRoleStorage.java new file mode 100644 index 0000000000..e479bf4573 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/roles/IRoleStorage.java @@ -0,0 +1,71 @@ +/** + * 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.plugin.nwsauth.roles; + +import com.raytheon.uf.common.plugin.nwsauth.exception.AuthorizationException; + +/** + * Storage class for roles. NOTE, ALL ROLES IDS SHOULD BE TREATED AS + * CASE-INSENSITIVE + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 18, 2010            mschenke     Initial creation
+ * 
+ * 
+ * + * @author mschenke + * @version 1.0 + */ + +public interface IRoleStorage { + + /** + * Determine if the permission is valid for the user in the application. + * + * @param permission + * The permissions id + * @param user + * The user id + * @param application + * The application + * + * @return true if the permission is authorized for the user in the + * specified application + * @throws AuthorizationException + */ + public boolean isAuthorized(String permission, String user, + String application) throws AuthorizationException; + + /** + * Get all the defined permissions for this application. + * + * @param application + * The application + * + * @return String[] of permissions + * @throws AuthorizationException + */ + public String[] getAllDefinedPermissions(String application) + throws AuthorizationException; +} diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/NwsRoleData.java b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/NwsRoleData.java new file mode 100644 index 0000000000..6dd1df05b6 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/NwsRoleData.java @@ -0,0 +1,305 @@ +package com.raytheon.uf.common.plugin.nwsauth.xml; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlRootElement; + +import com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +@XmlRootElement(name = "nwsRoleData") +@XmlAccessorType(XmlAccessType.NONE) +@DynamicSerialize +public class NwsRoleData implements ISerializableObject { + @DynamicSerializeElement + @XmlElement(name = "application") + private String application; + + @DynamicSerializeElement + @XmlElements({ @XmlElement(name = "permission", type = PermissionXML.class) }) + private List permissionList = new ArrayList(); + + @DynamicSerializeElement + @XmlElements({ @XmlElement(name = "role", type = RoleXML.class) }) + private List roleList = new ArrayList(); + + @DynamicSerializeElement + @XmlElements({ @XmlElement(name = "user", type = UserXML.class) }) + private List userList = new ArrayList(); + + /** Map of user to all permissions */ + private transient Map> permissionMap = new HashMap>(); + + /** + * @return the permissionList + */ + public List getPermissionList() { + return permissionList; + } + + /** + * @param permissionList + * the permissionList to set + */ + public void setPermissionList(List permissionList) { + this.permissionList = permissionList; + } + + /** + * @return the roleList + */ + public List getRoleList() { + return roleList; + } + + /** + * @param roleList + * the roleList to set + */ + public void setRoleList(List roleList) { + this.roleList = roleList; + } + + /** + * @return the userList + */ + public List getUserList() { + return userList; + } + + /** + * @param userList + * the userList to set + */ + public void setUserList(List userList) { + this.userList = userList; + } + + /** + * @return the application + */ + public String getApplication() { + return application; + } + + /** + * @param application + * the application to set + */ + public void setApplication(String application) { + this.application = application; + } + + public String[] getPermissions() { + ArrayList perms = new ArrayList(); + for (PermissionXML p : this.permissionList) { + perms.add(p.getId()); + } + Collections.sort(perms); + + return perms.toArray(new String[perms.size()]); + } + + public String[] getRoles() { + ArrayList roles = new ArrayList(); + for (RoleXML r : this.roleList) { + roles.add(r.getRoleId()); + } + Collections.sort(roles); + + return roles.toArray(new String[roles.size()]); + } + + public String[] getUsers() { + ArrayList users = new ArrayList(); + for (UserXML r : this.userList) { + users.add(r.getUserId()); + } + Collections.sort(users); + + return users.toArray(new String[users.size()]); + } + + public void addUser(String user) { + if (user != null && user.length() > 0) { + UserXML userXml = new UserXML(); + userXml.setUserId(user); + this.userList.add(userXml); + } + } + + public void addRole(String role, String description) { + if (role != null && description != null && role.length() > 0 && description.length() > 0) { + RoleXML roleXml = new RoleXML(); + roleXml.setRoleDescription(description); + roleXml.setRoleId(role); + this.roleList.add(roleXml); + } + } + + /** + * Add a permission. This should only be used for + * Localization permissions, which are directory access + * permissions. + * + * @param permission + */ + public void addPermission(String permission) { + if (permission != null && permission.length() > 0) { + PermissionXML pXml = new PermissionXML(); + pXml.setId(permission); + this.permissionList.add(pXml); + } + } + + /** + * Get the user's permissions + * + * @param userId id of the user + * @return String[] of permissions + */ + public String[] getUserPermissions(String userId) { + ArrayList userPermissions = new ArrayList(); + + for (UserXML userXml : this.userList) { + if (userXml.getUserId().equals(userId)) { + for (String permission : userXml.getPermissionList()) { + userPermissions.add(permission); + } + break; + } + } + Collections.sort(userPermissions); + + return userPermissions.toArray(new String[userPermissions.size()]); + } + + /** + * Get an array of all defined permissions + * + * @return String[] of all defined permissions + */ + public String[] getAllDefinedPermissions() { + ArrayList permissions = new ArrayList(); + for (PermissionXML p: this.permissionList) { + permissions.add(p.getId()); + } + + return permissions.toArray(new String[permissions.size()]); + } + + public String[] getRolePermissions(String roleId) { + ArrayList rolePermissions = new ArrayList(); + + for (RoleXML roleXml : this.roleList) { + if (roleXml.getRoleId().equals(roleId)) { + for (String permission : roleXml.getPermissionList()) { + rolePermissions.add(permission); + } + break; + } + } + Collections.sort(rolePermissions); + + return rolePermissions.toArray(new String[rolePermissions.size()]); + } + + public String[] getUserRoles(String userId) { + ArrayList userRoles = new ArrayList(); + + for (UserXML userXml : this.userList) { + if (userXml.getUserId().equals(userId)) { + for (String role : userXml.getRoleList()) { + userRoles.add(role); + } + break; + } + } + Collections.sort(userRoles); + + return userRoles.toArray(new String[userRoles.size()]); + } + + public String[] getRoleIdList() { + ArrayList roleIdList = new ArrayList(); + for (RoleXML rx : this.roleList) { + roleIdList.add(rx.getRoleId()); + } + Collections.sort(roleIdList); + + return roleIdList.toArray(new String[roleIdList.size()]); + } + + /** + * Get a list of all permissions for this user. + * + * @param user + * The user + * + * @return Set of all permissions + */ + private Set getAuthorizedPermissions(String user) { + if (!permissionMap.containsKey(user)) { + Set permSet = new HashSet(); + + for (String p : this.getUserPermissions(user)) { + permSet.add(p); + } + + String[] roles = this.getUserRoles(user); + + for (RoleXML roleXml : roleList) { + for (String role : roles) { + if (roleXml.getRoleId().equals(role)) { + for (String p: roleXml.getPermissionList()) { + permSet.add(p); + } + } + } + } + + permissionMap.put(user, permSet); + } + + return permissionMap.get(user); + } + + /** + * If the user has the permission then the user is authorized. + * + * @param permission + * the permission id + * @param user + * the user id + * @return true if the user has the permission + */ + public boolean isAuthorized(String permission, String user) { + Set authorizedPermissions = this.getAuthorizedPermissions(user); + Set allAuthorizedPermissions = this.getAuthorizedPermissions("ALL"); + + for (String perm: authorizedPermissions) { + if (perm.equalsIgnoreCase(permission)) { + return true; + } + } + + for (String perm: allAuthorizedPermissions) { + if (perm.equalsIgnoreCase(permission)) { + return true; + } + } + + return false; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/NwsRoleStorage.java b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/NwsRoleStorage.java new file mode 100644 index 0000000000..776f137d7e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/NwsRoleStorage.java @@ -0,0 +1,139 @@ +package com.raytheon.uf.common.plugin.nwsauth.xml; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.LocalizationContext; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; +import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.plugin.nwsauth.exception.AuthorizationException; +import com.raytheon.uf.common.plugin.nwsauth.exception.RoleApplicationNotFoundException; +import com.raytheon.uf.common.plugin.nwsauth.roles.IRoleStorage; +import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; + +/** + * Implementation of IRoleStorage + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 25, 2010            rgeorge     Initial creation
+ * 
+ * 
+ * + * @author rgeorge + * @version 1.0 + */ +public class NwsRoleStorage implements IRoleStorage { + private static NwsRoleStorage instance = null; + + private Map lastUsedFileMap = new HashMap(); + + private Map lastModificationTimeMap = new HashMap(); + + private Map applicationRoleMap = new HashMap(); + + /** + * This is called from the CAVE side for the User Administration dialogs. Do + * not call this from EDEX, use AuthManager instead + * + * @return Instance of NwsRoleStorage + */ + public static NwsRoleStorage getInstance() { + if (instance == null) { + instance = new NwsRoleStorage(); + } + + return instance; + } + + private NwsRoleStorage() { + getRoleDataFiles(); + } + + private synchronized void getRoleDataFiles() { + IPathManager pm = PathManagerFactory.getPathManager(); + + // Check COMMON_STATIC base and site levels + LocalizationContext[] contexts = new LocalizationContext[2]; + contexts[0] = pm.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.BASE); + contexts[1] = pm.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.SITE); + + String[] extensions = new String[] { ".xml" }; + LocalizationFile[] localizationFiles = + PathManagerFactory.getPathManager().listFiles(contexts, "roles", extensions, true, true); + + File file = null; + for (LocalizationFile locFile : localizationFiles) { + NwsRoleData roleData = new NwsRoleData(); + if (locFile.exists()) { + file = locFile.getFile(); + + if (lastUsedFileMap.get(locFile.getName()) == null + || (file != null && (file.equals(lastUsedFileMap.get(locFile.getName())) == false || file + .lastModified() > lastModificationTimeMap.get(locFile.getName())))) { + // First time we found a role file, or we have a different + // file to + // use or we were modified since our last check + lastUsedFileMap.put(locFile.getName(), file); + try { + roleData = (NwsRoleData) SerializationUtil.jaxbUnmarshalFromXmlFile(file.getAbsolutePath()); + applicationRoleMap.put(roleData.getApplication(), roleData); + } catch (Exception e) { + UFStatus.getHandler().handle(Priority.PROBLEM, "Error loading file: " + file.getName(), e); + } + + lastModificationTimeMap.put(locFile.getName(), file.lastModified()); + } + } + } + } + + /** + * Get the role/permission data for the application specified. + * + * @param application + * The application + * + * @return the NWSRoleData object for that application. + */ + public NwsRoleData getRoleData(String application) + throws AuthorizationException { + getRoleDataFiles(); + NwsRoleData roleData = applicationRoleMap.get(application); + if (roleData == null) { + throw new RoleApplicationNotFoundException("Application name, \"" + + application + + "\", was not found in the authorization configuration."); + } + return roleData; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.common.plugin.nwsauth.roles.IRoleStorage#isAuthorized + * (java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public boolean isAuthorized(String permission, String user, + String application) throws AuthorizationException { + NwsRoleData roleData = getRoleData(application); + return roleData.isAuthorized(permission, user); + } + + @Override + public String[] getAllDefinedPermissions(String application) + throws AuthorizationException { + return getRoleData(application).getAllDefinedPermissions(); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/PermissionXML.java b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/PermissionXML.java new file mode 100644 index 0000000000..824f9af8de --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/PermissionXML.java @@ -0,0 +1,97 @@ +/** + * 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.plugin.nwsauth.xml; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; + +import com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * Permission Element + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 18, 2012            mpduff     Initial creation.
+ * Oct  2, 2012   1237     jpiatt     Allow for null description.
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ +@XmlAccessorType(XmlAccessType.NONE) +@DynamicSerialize +public class PermissionXML implements ISerializableObject { + + @DynamicSerializeElement + @XmlAttribute(name = "id") + private String id; + + @DynamicSerializeElement + @XmlElement(name = "description", type = String.class) + private String description; + + /** + * Get the permission id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Set the permission id. + * + * @param id + * the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * Get the permission description. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Set the permission description. + * + * @param description + * the description to set + */ + public void setDescription(String description) { + this.description = (description == null) ? null : description.trim(); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/RoleXML.java b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/RoleXML.java new file mode 100644 index 0000000000..e7837915a3 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/RoleXML.java @@ -0,0 +1,120 @@ +/** + * 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.plugin.nwsauth.xml; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElements; + +import com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * Role element + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 18, 2012            mpduff     Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ +@XmlAccessorType(XmlAccessType.NONE) +@DynamicSerialize +public class RoleXML implements ISerializableObject { + @DynamicSerializeElement + @XmlAttribute(name = "roleId") + private String roleId; + + @DynamicSerializeElement + @XmlElement(name = "roleDescription", type = String.class) + private String roleDescription = null; + + @DynamicSerializeElement + @XmlElements({ @XmlElement(name = "rolePermission", type = String.class) }) + private List permissionList = new ArrayList(); + + /** + * @return the roleId + */ + public String getRoleId() { + return roleId; + } + + /** + * @param roleId + * the roleId to set + */ + public void setRoleId(String roleId) { + this.roleId = roleId; + } + + /** + * @return the description + */ + public String getRoleDescription() { + return roleDescription.trim(); + } + + /** + * @param roleDescription + * the description to set + */ + public void setRoleDescription(String roleDescription) { + this.roleDescription = roleDescription.trim(); + } + + /** + * @return the permissionList + */ + public List getPermissionList() { + return permissionList; + } + + /** + * @param permissionList + * the permissionList to set + */ + public void setPermissionList(List permissionList) { + this.permissionList = permissionList; + } + + /** + * Add a permission + * + * @param permission + * The permission to add + */ + public void addPermission(String permission) { + this.permissionList.add(permission); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/UserXML.java b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/UserXML.java new file mode 100644 index 0000000000..aa8089901e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.nwsauth/src/com/raytheon/uf/common/plugin/nwsauth/xml/UserXML.java @@ -0,0 +1,175 @@ +/** + * 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.plugin.nwsauth.xml; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElements; + +import com.raytheon.uf.common.auth.user.IAuthenticationData; +import com.raytheon.uf.common.auth.user.IUser; +import com.raytheon.uf.common.auth.user.IUserId; +import com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * User element + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 18, 2012            mpduff     Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ +@XmlAccessorType(XmlAccessType.NONE) +@DynamicSerialize +public class UserXML implements IUser, ISerializableObject { + @DynamicSerializeElement + @XmlAttribute(name = "userId") + private String userId; + + @DynamicSerializeElement + @XmlElements({ @XmlElement(name = "userPermission", type = String.class) }) + private List permissionList = new ArrayList(); + + @DynamicSerializeElement + @XmlElements({ @XmlElement(name = "userRole", type = String.class) }) + private List roleList = new ArrayList(); + + /** + * @return the userId + */ + public String getUserId() { + return userId; + } + + /** + * @param iduserId + * the userId to set + */ + public void setUserId(String userId) { + this.userId = userId; + } + + /** + * @return the permissionList + */ + public List getPermissionList() { + return permissionList; + } + + /** + * @param permissionList + * the permissionList to set + */ + public void setPermissionList(List permissionList) { + this.permissionList = permissionList; + } + + /** + * Add a permission + * + * @param permission + * The permission to add + */ + public void addPermission(String permission) { + if (!this.permissionList.contains(permission)) { + this.permissionList.add(permission); + } + } + + /** + * @return the roleList + */ + public List getRoleList() { + return roleList; + } + + /** + * @param roleList + * the roleList to set + */ + public void setRoleList(List roleList) { + this.roleList = roleList; + } + + public void addRole(String role) { + if (!this.roleList.contains(role)) { + this.roleList.add(role); + } + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + final String nl = "\n"; + StringBuilder sb = new StringBuilder(); + sb.append(this.getUserId()).append(nl); + + for (String role : this.roleList) { + sb.append(" ").append(role).append(nl); + } + + for (String perm : permissionList) { + sb.append(" ").append(perm).append(nl); + } + + return sb.toString(); + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.common.auth.user.IUser#uniqueId() + */ + @Override + public IUserId uniqueId() { + // TODO Auto-generated method stub + return null; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.common.auth.user.IUser#authenticationData() + */ + @Override + public IAuthenticationData authenticationData() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.serialization.comm/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.serialization.comm/META-INF/MANIFEST.MF index 4bdb30baf4..f4bc07e2d6 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization.comm/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.serialization.comm/META-INF/MANIFEST.MF @@ -8,8 +8,7 @@ Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization Eclipse-BuddyPolicy: registered, ext, global Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: com.raytheon.uf.common.serialization.comm, - com.raytheon.uf.common.serialization.comm.response, - com.raytheon.uf.common.serialization.comm.util + com.raytheon.uf.common.serialization.comm.response Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.11.12", net.sf.cglib;bundle-version="2.1.3", com.raytheon.uf.common.status diff --git a/edexOsgi/com.raytheon.uf.common.serialization/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.serialization/META-INF/MANIFEST.MF index 92942f1f33..c45eeae5b7 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.serialization/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ Require-Bundle: com.facebook.thrift, javax.persistence, org.geotools, javax.measure;resolution:=optional, - com.raytheon.uf.common.util + com.raytheon.uf.common.util, + org.apache.commons.codec;bundle-version="1.4.0" Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.adapters, diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/BaseSerializationContext.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/BaseSerializationContext.java new file mode 100644 index 0000000000..9d9b72d483 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/BaseSerializationContext.java @@ -0,0 +1,72 @@ +/** + * 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.serialization; + + +/** + * Provides reusable functionality among {@link ISerializationContext} + * implementations. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 14, 2012 1169       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public abstract class BaseSerializationContext implements + ISerializationContext, IDeserializationContext { + protected final DynamicSerializationManager serializationManager; + + /** + * Constructor. + * + * @param serializationManager + * the serialization manager + */ + public BaseSerializationContext( + DynamicSerializationManager serializationManager) { + this.serializationManager = serializationManager; + } + + /** + * {@inheritDoc} + */ + @Override + public Object readObject() throws SerializationException { + return this.serializationManager.deserialize(this); + } + + /** + * {@inheritDoc} + * + * @throws SerializationException + */ + @Override + public void writeObject(Object obj) throws SerializationException { + this.serializationManager.serialize(this, obj); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/BuiltInTypeSupport.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/BuiltInTypeSupport.java index 9aa034d9ef..8f694f3a35 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/BuiltInTypeSupport.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/BuiltInTypeSupport.java @@ -20,11 +20,19 @@ package com.raytheon.uf.common.serialization; import java.math.BigDecimal; +import java.math.BigInteger; import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.TimeZone; +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + /** * Provides serialization support for certain Java built-in classes * @@ -32,7 +40,11 @@ import java.util.TimeZone; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 3, 2008 #1448 chammack Initial creation + * Sep 03, 2008 #1448 chammack Initial creation + * Mar 27, 2012 #428 dgilling Add support for built-in + * classes used by data delivery's + * registry service. + * Sep 14, 2012 #1169 djohnson Add {@link ThrowableSerializer}. * * * @author chammack @@ -130,6 +142,45 @@ public class BuiltInTypeSupport { } } + /** + * Serialization for {@link javax.xml.datatype.XMLGregorianCalendar} + * + * + * @author dgilling + * @version 1.0 + */ + public static class XMLGregorianCalendarSerializer implements + ISerializationTypeAdapter { + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.edex.esb.serialize.ISerializationFactory#deserialize + * (com.raytheon.edex.esb.serialize.ISerializer) + */ + @Override + public XMLGregorianCalendar deserialize(IDeserializationContext arg0) + throws SerializationException { + try { + long t = arg0.readI64(); + GregorianCalendar c = new GregorianCalendar( + TimeZone.getTimeZone("GMT")); + c.setTimeInMillis(t); + return DatatypeFactory.newInstance().newXMLGregorianCalendar(c); + } catch (DatatypeConfigurationException e) { + throw new SerializationException(e); + } + } + + @Override + public void serialize(ISerializationContext arg0, + XMLGregorianCalendar arg1) throws SerializationException { + long t = arg1.toGregorianCalendar().getTimeInMillis(); + arg0.writeI64(t); + } + } + public static class SqlDateSerializer implements ISerializationTypeAdapter { @@ -183,4 +234,126 @@ public class BuiltInTypeSupport { } } + + public static class BigIntegerSerializer implements + ISerializationTypeAdapter { + + /* + * (non-Javadoc) + * + * @seecom.raytheon.uf.common.serialization.ISerializationTypeAdapter# + * deserialize + * (com.raytheon.uf.common.serialization.IDeserializationContext) + */ + @Override + public BigInteger deserialize(IDeserializationContext deserializer) + throws SerializationException { + return new BigInteger(deserializer.readBinary()); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.common.serialization.ISerializationTypeAdapter#serialize + * (com.raytheon.uf.common.serialization.ISerializationContext, + * java.lang.Object) + */ + @Override + public void serialize(ISerializationContext serializer, + BigInteger object) throws SerializationException { + serializer.writeBinary(object.toByteArray()); + } + } + + /** + * Serialization for {@link javax.xml.datatype.Duration} + * + * + * @author dgilling + * @version 1.0 + */ + public static class DurationSerializer implements + ISerializationTypeAdapter { + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.edex.esb.serialize.ISerializationFactory#deserialize + * (com.raytheon.edex.esb.serialize.ISerializer) + */ + @Override + public Duration deserialize(IDeserializationContext arg0) + throws SerializationException { + try { + String durationStr = arg0.readString(); + return DatatypeFactory.newInstance().newDuration(durationStr); + } catch (DatatypeConfigurationException e) { + throw new SerializationException(e); + } + } + + @Override + public void serialize(ISerializationContext arg0, Duration arg1) + throws SerializationException { + arg0.writeString(arg1.toString()); + } + } + + /** + * Serialization for {@link javax.xml.namespace.QName} + * + * + * @author dgilling + * @version 1.0 + */ + public static class QNameSerializer implements + ISerializationTypeAdapter { + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.edex.esb.serialize.ISerializationFactory#deserialize + * (com.raytheon.edex.esb.serialize.ISerializer) + */ + @Override + public QName deserialize(IDeserializationContext arg0) + throws SerializationException { + return QName.valueOf(arg0.readString()); + } + + @Override + public void serialize(ISerializationContext arg0, QName arg1) + throws SerializationException { + arg0.writeString(arg1.toString()); + } + } + + /** + * Serializes a {@link Throwable} and deserializes it into a + * {@link Throwable}. + * + * NOTE: The deserialized object is NOT an instance of the original + * throwable type, rather it is an instance of + * {@link SerializableExceptionWrapper} whose toString() and getMessage() + * methods will return the same value as the original. + */ + public static class ThrowableSerializer implements + ISerializationTypeAdapter { + @Override + public void serialize(ISerializationContext serializer, Throwable object) + throws SerializationException { + serializer.writeObject(ExceptionWrapper.wrapThrowable(object)); + } + + @Override + public Throwable deserialize(IDeserializationContext deserializer) + throws SerializationException { + return ExceptionWrapper + .unwrapThrowable(SerializableExceptionWrapper.class + .cast(deserializer.readObject())); + } + } } diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/DynamicSerializationManager.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/DynamicSerializationManager.java index f2e5ddc33b..e19b127938 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/DynamicSerializationManager.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/DynamicSerializationManager.java @@ -26,6 +26,7 @@ import java.io.OutputStream; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.math.BigDecimal; +import java.math.BigInteger; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.FloatBuffer; @@ -42,6 +43,9 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import javax.xml.datatype.Duration; +import javax.xml.namespace.QName; + import net.sf.cglib.beans.BeanMap; import org.geotools.coverage.grid.GeneralGridGeometry; @@ -67,9 +71,13 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeTypeAdap import com.raytheon.uf.common.serialization.thrift.ThriftSerializationContext; import com.raytheon.uf.common.serialization.thrift.ThriftSerializationContextBuilder; import com.raytheon.uf.common.util.ByteArrayOutputStreamPool; +import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.MultiPolygon; +import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.geom.Polygon; /** * Dynamic Serialization Manager provides a serialization capability that runs @@ -77,9 +85,13 @@ import com.vividsolutions.jts.geom.Geometry; * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Aug 13, 2008	#1448		chammack	Initial creation
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Aug 13, 2008 #1448       chammack    Initial creation
+ * Mar 27, 2012 #428        dgilling    Add support for built-in
+ *                                      classes used by data delivery's
+ *                                      registry service.
+ * Sep 28, 2012 #1195       djohnson    Add ability to specify adapter at field level.
  * Oct 08, 2012 #1251       dgilling    Ensure type registered with
  *                                      serialization adapter is encoded
  *                                      in serialization stream.
@@ -113,6 +125,7 @@ public class DynamicSerializationManager {
         // TODO: Can the registration of adapters that require dependencies be
         // moved to a separate plugin somehow?
         registerAdapter(GregorianCalendar.class, new CalendarSerializer());
+        registerAdapter(XMLGregorianCalendarImpl.class, new BuiltInTypeSupport.XMLGregorianCalendarSerializer());
         registerAdapter(Date.class, new DateSerializer());
         registerAdapter(Timestamp.class, new TimestampSerializer());
         registerAdapter(java.sql.Date.class,
@@ -121,12 +134,20 @@ public class DynamicSerializationManager {
         registerAdapter(Coordinate.class, new CoordAdapter());
         registerAdapter(BigDecimal.class,
                 new BuiltInTypeSupport.BigDecimalSerializer());
+        registerAdapter(BigInteger.class,
+                new BuiltInTypeSupport.BigIntegerSerializer());
         registerAdapter(Geometry.class, new GeometryTypeAdapter());
+        registerAdapter(Polygon.class, new GeometryTypeAdapter());
+        registerAdapter(MultiPolygon.class, new GeometryTypeAdapter());
+        registerAdapter(Point.class, new GeometryTypeAdapter());
         registerAdapter(Envelope.class, new JTSEnvelopeAdapter());
         registerAdapter(GridGeometry2D.class, new GridGeometry2DAdapter());
         registerAdapter(GeneralGridGeometry.class, new GridGeometryAdapter());
         registerAdapter(EnumSet.class, new EnumSetAdapter());
         registerAdapter(StackTraceElement.class, new StackTraceElementAdapter());
+        registerAdapter(Duration.class, new BuiltInTypeSupport.DurationSerializer());
+        registerAdapter(QName.class, new BuiltInTypeSupport.QNameSerializer());
+        registerAdapter(Throwable.class, new BuiltInTypeSupport.ThrowableSerializer());
         // These two are OBE by BufferAdapter and should be deleted sometime
         registerAdapter(ByteBuffer.class, new ByteBufferAdapter());
         registerAdapter(FloatBuffer.class, new FloatBufferAdapter());
@@ -256,7 +277,7 @@ public class DynamicSerializationManager {
             throws SerializationException {
         return ((ThriftSerializationContext) ctx).deserializeMessage();
     }
-
+    
     public static  void registerAdapter(Class clazz,
             ISerializationTypeAdapter adapter) {
         SerializationMetadata md = new SerializationMetadata();
@@ -269,7 +290,7 @@ public class DynamicSerializationManager {
         }
         serializedAttributes.put(md.adapterStructName, md);
     }
-
+    
     /**
      * Inspect a class and return the metadata for the object
      * 
@@ -281,6 +302,7 @@ public class DynamicSerializationManager {
      *            the class
      * @return the metadata
      */
+    @SuppressWarnings("rawtypes")
     public static SerializationMetadata inspect(Class c) {
 
         // Check for base types
@@ -370,17 +392,30 @@ public class DynamicSerializationManager {
                     if (annotation != null) {
                         String fieldName = field.getName();
 
-                        attribs.serializedAttributes.add(field.getName());
+                        attribs.serializedAttributes.add(fieldName);
+
+                        // Can be specified at field or class level
+                        Class fieldAdapter = null;
                         if (serializeAdapterTag == null) {
-                            serializeAdapterTag = field.getType()
+                            // Adapter specified at field level
+                            if (annotation.value() != ISerializationTypeAdapter.class) {
+                                fieldAdapter = annotation.value();
+                            } else {
+                                // Adapter specified at class level
+                                serializeAdapterTag = field
+                                        .getType()
                                     .getAnnotation(
                                             DynamicSerializeTypeAdapter.class);
+                                if (serializeAdapterTag != null) {
+                                    fieldAdapter = serializeAdapterTag
+                                            .factory();
+                                }
+                            }
                         }
-                        if (serializeAdapterTag != null) {
+                        if (fieldAdapter != null) {
                             try {
                                 attribs.attributesWithFactories.put(fieldName,
-                                        serializeAdapterTag.factory()
-                                                .newInstance());
+                                        fieldAdapter.newInstance());
                             } catch (Exception e) {
                                 throw new RuntimeException(
                                         "Factory could not be instantiated", e);
diff --git a/edexOsgi/com.raytheon.uf.common.serialization.comm/src/com/raytheon/uf/common/serialization/comm/util/ExceptionWrapper.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/ExceptionWrapper.java
similarity index 94%
rename from edexOsgi/com.raytheon.uf.common.serialization.comm/src/com/raytheon/uf/common/serialization/comm/util/ExceptionWrapper.java
rename to edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/ExceptionWrapper.java
index 6b460f8c6b..da8527f8bb 100644
--- a/edexOsgi/com.raytheon.uf.common.serialization.comm/src/com/raytheon/uf/common/serialization/comm/util/ExceptionWrapper.java
+++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/ExceptionWrapper.java
@@ -17,9 +17,7 @@
  * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
  * further licensing information.
  **/
-package com.raytheon.uf.common.serialization.comm.util;
-
-import com.raytheon.uf.common.serialization.SerializableExceptionWrapper;
+package com.raytheon.uf.common.serialization;
 
 /**
  * Class used to wrap/unwrap throwables in a serializable form to be transported
@@ -31,6 +29,7 @@ import com.raytheon.uf.common.serialization.SerializableExceptionWrapper;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Aug 10, 2009            mschenke     Initial creation
+ * Sep 14, 2012 1169       djohnson     Moved to com.raytheon.uf.common.serialization
  * 
  * 
* diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/IDeserializationContext.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/IDeserializationContext.java index 5e546f9200..8acfd9ed24 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/IDeserializationContext.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/IDeserializationContext.java @@ -24,9 +24,10 @@ package com.raytheon.uf.common.serialization; * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
+ * Date	        Ticket#     Engineer    Description
  * ------------	----------	-----------	--------------------------
- * Aug 12, 2008				chammack	Initial creation
+ * Aug 12, 2008             chammack    Initial creation
+ * Sep 14, 2012 1169        djohnson    Added readObject().
  * 
  * 
* @@ -41,7 +42,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract boolean readBool() throws SerializationException; + boolean readBool() throws SerializationException; /** * Read a byte @@ -49,7 +50,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract byte readByte() throws SerializationException; + byte readByte() throws SerializationException; /** * Read a short @@ -57,7 +58,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract short readI16() throws SerializationException; + short readI16() throws SerializationException; /** * Read an int @@ -65,7 +66,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract int readI32() throws SerializationException; + int readI32() throws SerializationException; /** * Read a long @@ -73,7 +74,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract long readI64() throws SerializationException; + long readI64() throws SerializationException; /** * Read a double @@ -81,7 +82,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract double readDouble() throws SerializationException; + double readDouble() throws SerializationException; /** * Read a double array @@ -89,7 +90,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract double[] readDoubleArray() throws SerializationException; + double[] readDoubleArray() throws SerializationException; /** * Read a float @@ -97,7 +98,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract float readFloat() throws SerializationException; + float readFloat() throws SerializationException; /** * Read a string @@ -105,7 +106,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract String readString() throws SerializationException; + String readString() throws SerializationException; /** * Read a binary blob @@ -113,7 +114,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract byte[] readBinary() throws SerializationException; + byte[] readBinary() throws SerializationException; /** * Read a float array @@ -121,7 +122,7 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract float[] readFloatArray() throws SerializationException; + float[] readFloatArray() throws SerializationException; /** * Read a message header @@ -129,13 +130,21 @@ public interface IDeserializationContext { * @return * @throws SerializationException */ - public abstract String readMessageStart() throws SerializationException; + String readMessageStart() throws SerializationException; /** * Read a message footer * * @throws SerializationException */ - public abstract void readMessageEnd() throws SerializationException; + void readMessageEnd() throws SerializationException; + /** + * Read an object. + * + * @return the read object + * + * @throws SerializationException + */ + Object readObject() throws SerializationException; } diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/ISerializationContext.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/ISerializationContext.java index 5fda8c537a..2ea75e5a18 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/ISerializationContext.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/ISerializationContext.java @@ -24,9 +24,10 @@ package com.raytheon.uf.common.serialization; * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Aug 7, 2008				chammack	Initial creation
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Aug 07, 2008             chammack    Initial creation
+ * Sep 14, 2012 1169        djohnson    Added writeObject(OBject).
  * 
  * 
* @@ -42,7 +43,7 @@ public interface ISerializationContext { * @param b * @throws SerializationException */ - public abstract void writeBool(boolean b) throws SerializationException; + void writeBool(boolean b) throws SerializationException; /** * Write a byte @@ -50,7 +51,7 @@ public interface ISerializationContext { * @param b * @throws SerializationException */ - public abstract void writeByte(byte b) throws SerializationException; + void writeByte(byte b) throws SerializationException; /** * Write a short @@ -58,7 +59,7 @@ public interface ISerializationContext { * @param i16 * @throws SerializationException */ - public abstract void writeI16(short i16) throws SerializationException; + void writeI16(short i16) throws SerializationException; /** * Write an int @@ -66,7 +67,7 @@ public interface ISerializationContext { * @param i32 * @throws SerializationException */ - public abstract void writeI32(int i32) throws SerializationException; + void writeI32(int i32) throws SerializationException; /** * Write a long @@ -74,7 +75,7 @@ public interface ISerializationContext { * @param i64 * @throws SerializationException */ - public abstract void writeI64(long i64) throws SerializationException; + void writeI64(long i64) throws SerializationException; /** * Write a double @@ -82,7 +83,7 @@ public interface ISerializationContext { * @param dub * @throws SerializationException */ - public abstract void writeDouble(double dub) throws SerializationException; + void writeDouble(double dub) throws SerializationException; /** * Write a double array @@ -90,7 +91,7 @@ public interface ISerializationContext { * @param dub * @throws SerializationException */ - public abstract void writeDoubleArray(double[] dubs) + void writeDoubleArray(double[] dubs) throws SerializationException; /** @@ -99,7 +100,7 @@ public interface ISerializationContext { * @param flt * @throws SerializationException */ - public abstract void writeFloat(float flt) throws SerializationException; + void writeFloat(float flt) throws SerializationException; /** * Write a string @@ -107,7 +108,7 @@ public interface ISerializationContext { * @param str * @throws SerializationException */ - public abstract void writeString(String str) throws SerializationException; + void writeString(String str) throws SerializationException; /** * Write a binary blob @@ -115,7 +116,7 @@ public interface ISerializationContext { * @param bin * @throws SerializationException */ - public abstract void writeBinary(byte[] bin) throws SerializationException; + void writeBinary(byte[] bin) throws SerializationException; /** * Write a float array @@ -123,7 +124,7 @@ public interface ISerializationContext { * @param floats * @throws SerializationException */ - public abstract void writeFloatArray(float[] floats) + void writeFloatArray(float[] floats) throws SerializationException; /** @@ -132,7 +133,7 @@ public interface ISerializationContext { * @param messageName * @throws SerializationException */ - public abstract void writeMessageStart(String messageName) + void writeMessageStart(String messageName) throws SerializationException; /** @@ -140,6 +141,14 @@ public interface ISerializationContext { * * @throws SerializationException */ - public abstract void writeMessageEnd() throws SerializationException; + void writeMessageEnd() throws SerializationException; + /** + * Write another object. + * + * @param obj + * the object + * @throws SerializationException + */ + void writeObject(Object obj) throws SerializationException; } diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/MapEntryType.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/MapEntryType.java new file mode 100644 index 0000000000..1fbc74d1a2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/MapEntryType.java @@ -0,0 +1,77 @@ +/** + * 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.serialization; + +import java.util.Map; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * Used by Jaxb to represent a {@link Map.Entry}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 31, 2012 955        djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +@XmlAccessorType(XmlAccessType.NONE) +public class MapEntryType { + + @XmlElement + private K key; + + @XmlElement + private V value; + + public MapEntryType() { + } + + public MapEntryType(Map.Entry e) { + key = e.getKey(); + value = e.getValue(); + } + + public K getKey() { + return key; + } + + public void setKey(K key) { + this.key = key; + } + + public V getValue() { + return value; + } + + public void setValue(V value) { + this.value = value; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/MapType.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/MapType.java new file mode 100644 index 0000000000..f70e7fb1fb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/MapType.java @@ -0,0 +1,62 @@ +/** + * 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.serialization; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Used by Jaxb to represent a {@link Map}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 31, 2012 955        djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class MapType { + private List> entry = new ArrayList>(); + + public MapType() { + } + + public MapType(Map map) { + for (Map.Entry mapEntry : map.entrySet()) { + entry.add(new MapEntryType(mapEntry)); + } + } + + public List> getEntry() { + return entry; + } + + public void setEntry(List> entry) { + this.entry = entry; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializableExceptionWrapper.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializableExceptionWrapper.java index 2cf2293699..4463489d51 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializableExceptionWrapper.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializableExceptionWrapper.java @@ -32,6 +32,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 10, 2009 mschenke Initial creation + * Sep 14, 2012 1169 djohnson Moved to com.raytheon.uf.common.serialization * * * diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializableManager.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializableManager.java index 8e66da2368..fd973cd298 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializableManager.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializableManager.java @@ -37,6 +37,7 @@ import java.util.Set; import javax.persistence.Embeddable; import javax.persistence.Entity; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRegistry; import com.raytheon.uf.common.serialization.jaxb.JaxbDummyObject; @@ -298,7 +299,8 @@ public class SerializableManager { Class c = (Class) Class .forName(clazz, true, cl); boolean added = false; - if (c.getAnnotation(XmlAccessorType.class) != null) { + if (c.getAnnotation(XmlAccessorType.class) != null + || c.getAnnotation(XmlRegistry.class) != null) { addToClazzSet(c); added = true; } diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializationUtil.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializationUtil.java index 2cd17e7efd..c853ad84e1 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializationUtil.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/SerializationUtil.java @@ -40,6 +40,9 @@ import com.raytheon.uf.common.serialization.DynamicSerializationManager.Serializ * ------------ ---------- ----------- -------------------------- * Sep 24, 2008 chammack Initial creation * Nov 13, 2008 njensen Added thrift methods + * Sep 07, 2012 1102 djohnson Overload jaxbUnmarshall and transformFromThrift methods + * to accept class parameter, deprecate old versions. Improve performance + * of getJaxbManager(). * * * @@ -47,43 +50,79 @@ import com.raytheon.uf.common.serialization.DynamicSerializationManager.Serializ * @version 1.0 */ -public class SerializationUtil { +public final class SerializationUtil { - private static JAXBManager jaxbManager = null; + // @VisibleForTesting + static volatile JAXBManager jaxbManager; private SerializationUtil() { } - public static synchronized JAXBManager getJaxbManager() - throws JAXBException { - if (jaxbManager == null) { - List> jaxbClasses = SerializableManager - .getInstance().getJaxbables(); - jaxbManager = new JAXBManager( - jaxbClasses.toArray(new Class[jaxbClasses.size()])); - } - return jaxbManager; - } + /** + * Retrieve the {@link JAXBManager} instance. Lazily-initialized using + * proper double-checked locking. This version performs better than + * synchronizing the entire method. + * + * @return the {@link JAXBManager} + * @see http://en.wikipedia.org/wiki/Double-checked_locking + * @throws JAXBException + */ + public static JAXBManager getJaxbManager() throws JAXBException { + JAXBManager result = jaxbManager; + if (result == null) { + synchronized (SerializationUtil.class) { + result = jaxbManager; + if (result == null) { + List> jaxbClasses = SerializableManager + .getInstance().getJaxbables(); + jaxbManager = result = new JAXBManager( + jaxbClasses.toArray(new Class[jaxbClasses.size()])); + + } + } + } + return result; + } public static JAXBContext getJaxbContext() throws JAXBException { return getJaxbManager().getJaxbContext(); } - /** - * Instantiates an object from the XML representation in a string. Uses - * JAXB. - * - * @param xml - * The XML representation - * @return A new instance from the XML representation - * @throws JAXBException - */ + /** + * Instantiates an object from the XML representation in a string. Uses + * JAXB. + * + * @param xml + * The XML representation + * @return A new instance from the XML representation + * @throws JAXBException + * @deprecated Use {@link #unmarshalFromXml(Class, String)} which performs + * the cast for you, and wraps any {@link ClassCastException}s + * in a serialization exception + */ + @Deprecated public static Object unmarshalFromXml(String xml) throws JAXBException { - return getJaxbManager().unmarshalFromXml(xml); + return unmarshalFromXml(Object.class, xml); } + /** + * Instantiates an object from the XML representation in a string. Uses + * JAXB. + * + * @param clazz + * the class object of the result type + * @param xml + * The XML representation + * @return A new instance from the XML representation + * @throws JAXBException + */ + public static T unmarshalFromXml(Class clazz, String xml) + throws JAXBException { + return clazz.cast(getJaxbManager().unmarshalFromXml(xml)); + } + /** * Convert an instance of a class to an XML representation in a string. Uses * JAXB. @@ -117,58 +156,123 @@ public class SerializationUtil { } - /** - * Instantiates an object from the XML representation in a File. Uses JAXB. - * - * @param filePath - * The path to the XML file - * @return A new instance from the XML representation - * @throws SerializationException - */ + /** + * Instantiates an object from the XML representation in a File. Uses JAXB. + * + * @param filePath + * The path to the XML file + * @return A new instance from the XML representation + * @throws SerializationException + * @deprecated Use {@link #jaxbUnmarshalFromXmlFile(Class, String)} which + * performs the cast for you, and wraps any + * {@link ClassCastException}s in a serialization exception + */ + @Deprecated public static Object jaxbUnmarshalFromXmlFile(String filePath) throws SerializationException { - try { - return getJaxbManager().jaxbUnmarshalFromXmlFile(filePath); - } catch (JAXBException e) { - throw new SerializationException(e); - } + return jaxbUnmarshalFromXmlFile(Object.class, filePath); } - /** - * Instantiates an object from the XML representation in a File. Uses JAXB. - * - * @param filePath - * The XML file - * @return A new instance from the XML representation - * @throws SerializationException - */ + /** + * Instantiates an object from the XML representation in a File. Uses JAXB. + * + * @param clazz + * the result type class + * @param filePath + * The path to the XML file + * @return A new instance from the XML representation + * @throws SerializationException + * + */ + public static T jaxbUnmarshalFromXmlFile(Class clazz, String filePath) + throws SerializationException { + try { + return clazz.cast(getJaxbManager().jaxbUnmarshalFromXmlFile( + filePath)); + } catch (JAXBException e) { + throw new SerializationException(e); + } + } + + /** + * Instantiates an object from the XML representation in a File. Uses JAXB. + * + * @param filePath + * The XML file + * @return A new instance from the XML representation + * @throws SerializationException + * @deprecated Use {@link #jaxbUnmarshalFromXmlFile(Class, File)} which + * performs the cast for you, and wraps any + * {@link ClassCastException}s in a serialization exception + */ + @Deprecated public static Object jaxbUnmarshalFromXmlFile(File file) throws SerializationException { - try { - return getJaxbManager().jaxbUnmarshalFromXmlFile(file); - } catch (Exception e) { - throw new SerializationException(e.getLocalizedMessage(), e); - } + return jaxbUnmarshalFromXmlFile(Object.class, file); } - /** - * Instantiates an object from the XML representation in a stream. Uses - * JAXB. - * - * @param is - * The input stream. The stream will be closed by this operation. - * @return A new instance from the XML representation - * @throws SerializationException - */ + /** + * Instantiates an object from the XML representation in a File. Uses JAXB. + * + * @param clazz + * the clazz object used to dynamically cast the result + * @param filePath + * The XML file + * @return A new instance from the XML representation + * @throws SerializationException + * if JAXB encounters an exception, or a + * {@link ClassCastException} occurs + */ + public static T jaxbUnmarshalFromXmlFile(Class clazz, File file) + throws SerializationException { + try { + return clazz.cast(getJaxbManager().jaxbUnmarshalFromXmlFile(file)); + } catch (Exception e) { + throw new SerializationException(e.getLocalizedMessage(), e); + } + } + + /** + * Instantiates an object from the XML representation in a stream. Uses + * JAXB. + * + * @param is + * The input stream. The stream will be closed by this operation. + * @return A new instance from the XML representation + * @throws SerializationException + * @deprecated Use {@link #jaxbUnmarshalFromInputStream(Class, InputStream)} + * which performs the cast for you, and wraps any + * {@link ClassCastException}s in a serialization exception + */ + @Deprecated public static Object jaxbUnmarshalFromInputStream(InputStream is) throws SerializationException { - try { - return getJaxbManager().jaxbUnmarshalFromInputStream(is); - } catch (Exception e) { - throw new SerializationException(e.getLocalizedMessage(), e); - } + return jaxbUnmarshalFromInputStream(Object.class, is); } + /** + * Instantiates an object from the XML representation in a stream. Uses + * JAXB. + * + * @param clazz + * the class object of the result type + * @param is + * The input stream. The stream will be closed by this operation. + * @return A new instance from the XML representation + * @throws SerializationException + * + */ + public static T jaxbUnmarshalFromInputStream(Class clazz, + InputStream is) + throws SerializationException { + try { + return clazz + .cast(getJaxbManager().jaxbUnmarshalFromInputStream(is)); + } catch (Exception e) { + throw new SerializationException(e.getLocalizedMessage(), e); + } + } + /** * Transforms an object to the thrift protocol using DynamicSerialize. The * object will exist in memory 3 times during this process: once in its @@ -207,32 +311,52 @@ public class SerializationUtil { dsm.serialize(obj, os); } - /** - * Transforms a byte array from the thrift protocol to an object using - * DynamicSerialize - * - * @param bytes - * the object as bytes - * @return the Java object - * @throws SerializationException - */ - public static Object transformFromThrift(byte[] bytes) + /** + * Transforms a byte array from the thrift protocol to an object using + * DynamicSerialize + * + * @param bytes + * the object as bytes + * @return the Java object + * @throws SerializationException + * @deprecated Use {@link #transformFromThrift(Class, byte[]) which performs + * the cast for you, and wraps any {@link ClassCastException}s + * in a serialization exception + */ + @Deprecated + public static Object transformFromThrift(byte[] bytes) throws SerializationException { - DynamicSerializationManager dsm = DynamicSerializationManager - .getManager(SerializationType.Thrift); - ByteArrayInputStream bais = null; - try { - bais = new ByteArrayInputStream(bytes); - return dsm.deserialize(bais); - } finally { - if (bais != null) { - try { - bais.close(); - } catch (IOException e) { - // ignore - } - } - } + return transformFromThrift(Object.class, bytes); } + /** + * Transforms a byte array from the thrift protocol to an object using + * DynamicSerialize + * + * @param bytes + * the object as bytes + * @return the Java object + * @throws SerializationException + * if a serialization or class cast exception occurs + */ + public static T transformFromThrift(Class clazz, byte[] bytes) + throws SerializationException { + DynamicSerializationManager dsm = DynamicSerializationManager + .getManager(SerializationType.Thrift); + ByteArrayInputStream bais = null; + try { + bais = new ByteArrayInputStream(bytes); + return clazz.cast(dsm.deserialize(bais)); + } catch (ClassCastException cce) { + throw new SerializationException(cce); + } finally { + if (bais != null) { + try { + bais.close(); + } catch (IOException e) { + // ignore + } + } + } + } } diff --git a/edexOsgi/com.raytheon.uf.common.serialization.comm/src/com/raytheon/uf/common/serialization/comm/util/WrappedException.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/WrappedException.java similarity index 88% rename from edexOsgi/com.raytheon.uf.common.serialization.comm/src/com/raytheon/uf/common/serialization/comm/util/WrappedException.java rename to edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/WrappedException.java index 14dc344932..21d09ef066 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization.comm/src/com/raytheon/uf/common/serialization/comm/util/WrappedException.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/WrappedException.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.common.serialization.comm.util; +package com.raytheon.uf.common.serialization; /** * Wrapped exception, prints the original exception @@ -27,7 +27,8 @@ package com.raytheon.uf.common.serialization.comm.util; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jul 9, 2010 mschenke Initial creation + * Jul 09, 2010 mschenke Initial creation + * Sep 14, 2012 1169 djohnson Moved to com.raytheon.uf.common.serialization * * * @@ -39,7 +40,7 @@ public class WrappedException extends Exception { private static final long serialVersionUID = 1L; - private String exceptionClass; + private final String exceptionClass; /** * @param message diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/XmlGenericMapAdapter.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/XmlGenericMapAdapter.java new file mode 100644 index 0000000000..d124696c39 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/XmlGenericMapAdapter.java @@ -0,0 +1,69 @@ +/** + * 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.serialization; + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +/** + * Handles the conversion between Java {@link Map} classes to Jaxb usable + * {@link MapType} classes. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 31, 2012 955        djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public class XmlGenericMapAdapter extends + XmlAdapter, Map> { + + @Override + public Map unmarshal(MapType serialized) throws Exception { + HashMap map = new HashMap(); + + for (MapEntryType mapEntryType : serialized.getEntry()) { + map.put(mapEntryType.getKey(), mapEntryType.getValue()); + } + return map; + } + + @Override + public MapType marshal(Map unserialized) throws Exception { + MapType mapType = new MapType(); + + for (Map.Entry entry : unserialized.entrySet()) { + MapEntryType mapEntryType = new MapEntryType(); + mapEntryType.setKey(entry.getKey()); + mapEntryType.setValue(entry.getValue()); + mapType.getEntry().add(mapEntryType); + } + return mapType; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/annotations/DynamicSerializeElement.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/annotations/DynamicSerializeElement.java index e6c3845e51..37012bcc31 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/annotations/DynamicSerializeElement.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/annotations/DynamicSerializeElement.java @@ -25,6 +25,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import com.raytheon.uf.common.serialization.ISerializationTypeAdapter; + /** * An annotation that indicates that a class should have this element * serialized. @@ -32,11 +34,15 @@ import java.lang.annotation.Target; * The annotation should be added to the field itself. The assumption is made * that setters and getters are available for this property. * + * If the {@link #value()} specifies an {@link ISerializationTypeAdapter}, the + * factory will be used to serialize/deserialize the value. + * *
  * SOFTWARE HISTORY
  * Date			Ticket#		Engineer	Description
  * ------------	----------	-----------	--------------------------
- * Aug 7, 2008				chammack	Initial creation
+ * Aug 07, 2008             chammack    Initial creation
+ * Sep 28, 2012 1195        djohnson    Add value() to specify a type adapter.
  * 
  * 
* @@ -48,4 +54,6 @@ import java.lang.annotation.Target; @Target(ElementType.FIELD) @Documented public @interface DynamicSerializeElement { + @SuppressWarnings("rawtypes") + Class value() default ISerializationTypeAdapter.class; } diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/thrift/ThriftSerializationContext.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/thrift/ThriftSerializationContext.java index 6a96c50acc..c1458a4661 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/thrift/ThriftSerializationContext.java +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/thrift/ThriftSerializationContext.java @@ -42,11 +42,10 @@ import com.facebook.thrift.protocol.TMessage; import com.facebook.thrift.protocol.TSet; import com.facebook.thrift.protocol.TStruct; import com.facebook.thrift.protocol.TType; +import com.raytheon.uf.common.serialization.BaseSerializationContext; import com.raytheon.uf.common.serialization.DynamicSerializationManager; import com.raytheon.uf.common.serialization.DynamicSerializationManager.EnclosureType; import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationMetadata; -import com.raytheon.uf.common.serialization.IDeserializationContext; -import com.raytheon.uf.common.serialization.ISerializationContext; import com.raytheon.uf.common.serialization.ISerializationTypeAdapter; import com.raytheon.uf.common.serialization.SerializationCache; import com.raytheon.uf.common.serialization.SerializationException; @@ -62,8 +61,10 @@ import com.raytheon.uf.common.serialization.SerializationException; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 12, 2008 #1448 chammack Initial creation - * Jun 17, 2010 #5091 njensen Optimized primitive arrays - * Mar 1, 2011 njensen Restructured deserializeArray() + * Jun 17, 2010 #5091 njensen Optimized primitive arrays + * Mar 01, 2011 njensen Restructured deserializeArray() + * Sep 14, 2012 #1169 djohnson Add ability to write another object into the stream directly. + * Sep 28, 2012 #1195 djohnson Add ability to specify adapter at field level. * * * @@ -72,17 +73,14 @@ import com.raytheon.uf.common.serialization.SerializationException; */ // Warnings are suppressed in this class because generics cause issues with the // extensive use of reflection. The erased objects are used instead. -@SuppressWarnings("unchecked") -public class ThriftSerializationContext implements ISerializationContext, - IDeserializationContext { +@SuppressWarnings({ "unchecked", "rawtypes" }) +public class ThriftSerializationContext extends BaseSerializationContext { /** The tag that is used to indicate the value of an enumeration */ private static final String ENUM_VALUE_TAG = "__enumValue__"; private final SelfDescribingBinaryProtocol protocol; - private final DynamicSerializationManager serializationManager; - private static Map, Byte> types; private static Map> fieldClass = new ConcurrentHashMap>(); @@ -115,8 +113,9 @@ public class ThriftSerializationContext implements ISerializationContext, */ public ThriftSerializationContext(SelfDescribingBinaryProtocol protocol, DynamicSerializationManager serializationManager) { + super(serializationManager); + this.protocol = protocol; - this.serializationManager = serializationManager; } /* @@ -718,11 +717,10 @@ public class ThriftSerializationContext implements ISerializationContext, field.name = keyStr; protocol.writeFieldBegin(field); - // if (adapter != null) { - // // If there is an adapter, use it to serialize - // adapter.serialize(this, val); - // } else - if (type != TType.VOID) { + if (adapter != null) { + // If there is an adapter, use it to serialize + adapter.serialize(this, val); + } else if (type != TType.VOID) { // Otherwise, as long as it's not void, use basic type serialization serializeType(val, valClass, type); } @@ -852,8 +850,8 @@ public class ThriftSerializationContext implements ISerializationContext, TField field = protocol.readFieldBegin(); // System.out.println(field.type); - // ISerializationTypeAdapter factory = md.attributesWithFactories - // .get(field.name); + ISerializationTypeAdapter factory = md.attributesWithFactories + .get(field.name); Object obj = null; if (field.type == TType.STOP) { @@ -861,12 +859,12 @@ public class ThriftSerializationContext implements ISerializationContext, } if (field.type != TType.VOID) { - // if (factory != null) { - // obj = factory.deserialize(this); - // } else { - obj = deserializeType(field.type, o.getClass(), fc, field.name, + if (factory != null) { + obj = factory.deserialize(this); + } else { + obj = deserializeType(field.type, o.getClass(), fc, field.name, EnclosureType.FIELD); - // } + } if (field.type == TType.STRING) { Class fieldClass = findFieldClass(o.getClass(), field.name); if (fieldClass != null && fieldClass.isEnum()) { @@ -895,7 +893,6 @@ public class ThriftSerializationContext implements ISerializationContext, * @return * @throws SerializationException */ - @SuppressWarnings("rawtypes") private Object deserializeType(byte type, Class clazz, FastClass fclazz, String fieldName, EnclosureType enclosureType) throws SerializationException { @@ -1102,7 +1099,6 @@ public class ThriftSerializationContext implements ISerializationContext, * @return * @throws SerializationException */ - @SuppressWarnings("rawtypes") private Object deserializeArray(FastClass fclazz, String fieldName) throws SerializationException { try { @@ -1363,5 +1359,4 @@ public class ThriftSerializationContext implements ISerializationContext, throw new SerializationException(e); } } - } \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/notify/ClusterActivationNotification.java b/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/notify/ClusterActivationNotification.java index cb3f933d4a..038c03c5e0 100644 --- a/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/notify/ClusterActivationNotification.java +++ b/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/notify/ClusterActivationNotification.java @@ -71,23 +71,23 @@ public class ClusterActivationNotification extends SiteActivationNotification { } public String toString() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); if (isActivation()) { if (isFailure()) { - buffer.append(this.getModifiedSite() - + " has failed to activate on some or all cluster memebers. See logs for details"); + buffer.append(this.getModifiedSite()); + buffer.append(" has failed to activate on some or all cluster members. See logs for details"); } else { - buffer.append(this.getModifiedSite() - + " has been successfully activated on all cluster members"); + buffer.append(this.getModifiedSite()); + buffer.append(" has been successfully activated on all cluster members"); } } else{ if (isFailure()) { - buffer.append(this.getModifiedSite() - + " has failed to deactivate on some or all cluster memebers. See logs for details"); + buffer.append(this.getModifiedSite()); + buffer.append(" has failed to deactivate on some or all cluster members. See logs for details"); } else { - buffer.append(this.getModifiedSite() - + " has been successfully deactivated on all cluster members"); + buffer.append(this.getModifiedSite()); + buffer.append(" has been successfully deactivated on all cluster members"); } } return buffer.toString(); diff --git a/edexOsgi/com.raytheon.uf.common.time/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.time/META-INF/MANIFEST.MF index 96e2aa7ccb..1d8d912e33 100644 --- a/edexOsgi/com.raytheon.uf.common.time/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.time/META-INF/MANIFEST.MF @@ -5,7 +5,9 @@ Bundle-SymbolicName: com.raytheon.uf.common.time Bundle-Version: 1.12.1174.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: net.sf.cglib +Require-Bundle: net.sf.cglib, + net.jcip;bundle-version="1.0.0", + com.raytheon.uf.common.status;bundle-version="1.12.1174" Import-Package: com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.adapters, com.raytheon.uf.common.serialization.annotations, diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/SimulatedTime.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/SimulatedTime.java index 32c1cc5306..fd0fc26a70 100644 --- a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/SimulatedTime.java +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/SimulatedTime.java @@ -32,9 +32,11 @@ import java.util.TimeZone; * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Jul 16, 2008				randerso	Initial creation
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 16, 2008            randerso    Initial creation
+ * Aug 24, 2012 0743       djohnson    Add option to use milliseconds for operations, change to singleton.
  * 
  * 
* @@ -42,7 +44,7 @@ import java.util.TimeZone; * @version 1.0 */ -public class SimulatedTime { +public final class SimulatedTime { /** * The system global simulated time instance */ @@ -95,7 +97,7 @@ public class SimulatedTime { * Creates a simulated time that matches real time. * */ - public SimulatedTime() { + private SimulatedTime() { setRealTime(); } @@ -111,8 +113,24 @@ public class SimulatedTime { * @param isFrozen * true to freeze time */ - public SimulatedTime(Date date, double scale, boolean isFrozen) { - setTime(date); + private SimulatedTime(Date date, double scale, boolean isFrozen) { + this(date.getTime(), scale, isFrozen); + } + + /** + * Creates a simulated time starting at the specified time with + * acceleration/deceleration, optionally frozen. + * + * @param millis + * starting time in milliseconds + * @param scale + * 1.0 for normal time rate, >1.0 for accelerated time < 1.0 for + * decelerated time. If negative time will run backward. + * @param isFrozen + * true to freeze time + */ + public SimulatedTime(long millis, double scale, boolean isFrozen) { + setTime(millis); this.scale = scale; this.isFrozen = isFrozen; } @@ -142,11 +160,14 @@ public class SimulatedTime { * @return current simulated time */ public Date getTime() { + return new Date(getMillis()); + } + + public long getMillis() { if (isFrozen) { - return new Date(frozenTime); + return frozenTime; } else { - return new Date(Math.round((now() - baseTime) * scale) + baseTime - + offset); + return Math.round((now() - baseTime) * scale) + baseTime + offset; } } @@ -156,11 +177,20 @@ public class SimulatedTime { * @param date */ public void setTime(Date date) { + setTime(date.getTime()); + } + + /** + * Set the current simulated time + * + * @param millis + */ + public void setTime(long millis) { if (isFrozen) { - frozenTime = date.getTime(); + frozenTime = millis; } else { baseTime = now(); - offset = date.getTime() - baseTime; + offset = millis - baseTime; } } @@ -206,7 +236,7 @@ public class SimulatedTime { } if (isFrozen) { - frozenTime = getTime().getTime(); + frozenTime = getMillis(); } else { baseTime = now(); offset = frozenTime - baseTime; diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/AbstractTimer.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/AbstractTimer.java new file mode 100644 index 0000000000..284831f894 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/AbstractTimer.java @@ -0,0 +1,108 @@ +package com.raytheon.uf.common.time.util; + +import net.jcip.annotations.NotThreadSafe; + +/** + * + * Provides the basic {@link ITimer} implementation, such as the state machine + * functionality. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 16, 2012 0743       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +@NotThreadSafe +abstract class AbstractTimer implements ITimer { + private long start; + + private long stop; + + private long elapsedTime; + + /** + * {@inheritDoc} + */ + @Override + public void start() { + if (isTimerStopped()) { + elapsedTime += (stop - start); + stop = 0; + } else if (isTimerStarted()) { + throw new IllegalStateException( + "A timer that is running must be stopped before start() is called again!"); + } + this.start = getCurrentTime(); + } + + /** + * {@inheritDoc} + */ + @Override + public void stop() { + if (!isTimerStarted()) { + throw new IllegalStateException( + "Timer must be started before it can be stopped!"); + } + // If the timer has already been stopped, don't change the time + if (!isTimerStopped()) { + this.stop = getCurrentTime(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public long getElapsedTime() { + long currentOrStopTime = (isTimerRunning()) ? getCurrentTime() : stop; + return (currentOrStopTime - start) + elapsedTime; + } + + /** + * {@inheritDoc} + */ + @Override + public void reset() { + start = 0; + stop = 0; + elapsedTime = 0; + } + + protected abstract long getCurrentTime(); + + /** + * Check whether the timer is actively running. + * + * @return true if the timer is running + */ + private boolean isTimerRunning() { + return isTimerStarted() && !isTimerStopped(); + } + + /** + * Check whether the timer was started. + * + * @return true if the timer was started + */ + private boolean isTimerStarted() { + return start > 0; + } + + /** + * Check whether the timer is stopped. + * + * @return true if the timer is stopped + */ + private boolean isTimerStopped() { + return stop > 0; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ITimeStrategy.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ITimeStrategy.java new file mode 100644 index 0000000000..c2f55698e1 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ITimeStrategy.java @@ -0,0 +1,28 @@ +package com.raytheon.uf.common.time.util; + +/** + * + * Denotes a strategy to retrieve the current time. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 16, 2012 0743       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +interface ITimeStrategy { + + /** + * Retrieves the current time in milliseconds. + * + * @return the current time in milliseconds + */ + long currentTimeMillis(); +} \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ITimer.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ITimer.java new file mode 100644 index 0000000000..0a028176ad --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ITimer.java @@ -0,0 +1,50 @@ +package com.raytheon.uf.common.time.util; + +/** + * + * Defines a timer that can be started and stopped. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 16, 2012 0743       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public interface ITimer { + + /** + * Start the time on the timer. + * + * @throws IllegalStateException + * if the timer is already running, or has been stopped and not + * reset + */ + void start() throws IllegalStateException; + + /** + * Stop the time on the timer. + * + * @throws IllegalStateException + * if the timer hasn't been started + */ + void stop() throws IllegalStateException; + + /** + * Get the elapsed time, in milliseconds. + * + * @return the elapsed time in milliseconds + */ + long getElapsedTime(); + + /** + * Reset the timer. + */ + void reset(); +} diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ImmutableDate.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ImmutableDate.java new file mode 100644 index 0000000000..eb18ca0520 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ImmutableDate.java @@ -0,0 +1,203 @@ +/** + * 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.time.util; + +import java.util.Date; + +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import net.jcip.annotations.Immutable; + +import com.raytheon.uf.common.serialization.IDeserializationContext; +import com.raytheon.uf.common.serialization.ISerializationContext; +import com.raytheon.uf.common.serialization.ISerializationTypeAdapter; +import com.raytheon.uf.common.serialization.SerializationException; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeTypeAdapter; +import com.raytheon.uf.common.time.SimulatedTime; + +/** + * An {@link Immutable} version of {@link Date}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 15, 2012 0743       djohnson     Initial creation
+ * Sep 19, 2012 0726       jspinks      Added XmlJavaTypeAdaptor annotation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +@XmlJavaTypeAdapter(value=ImmutableDateAdapter.class) +@Immutable +@DynamicSerialize +@DynamicSerializeTypeAdapter(factory = ImmutableDate.class) +public final class ImmutableDate extends Date implements + ISerializationTypeAdapter { + + private static final long serialVersionUID = -4228048757897650258L; + + private static final String IMMUTABLE_MSG = "This version of date is immutable."; + + private static final String IMMUTABLE_AND_DEPRECATED_MSG = IMMUTABLE_MSG + + " In addition, this method is deprecated."; + + private final int hashCode; + + /** + * Construct an {@link ImmutableDate} from the current time. + */ + public ImmutableDate() { + this(SimulatedTime.getSystemTime().getMillis()); + } + + + /** + * Construct an {@link ImmutableDate} from a {@link Date} object. + * + * @param date + * the date + */ + public ImmutableDate(Date date) { + this(date.getTime()); + } + + /** + * Construct an {@link ImmutableDate} from the specified time in + * milliseconds. + * + * @param time + * the millliseconds + */ + public ImmutableDate(long time) { + super(time); + + this.hashCode = super.hashCode(); + } + + /** + * Overridden to throw {@link UnsupportedOperationException}. + * + * @param year + * @throws UnsupportedOperationException + */ + @Override + public void setYear(int year) { + throw new UnsupportedOperationException( + IMMUTABLE_AND_DEPRECATED_MSG); + } + + /** + * Overridden to throw {@link UnsupportedOperationException}. + * + * @param month + * @throws UnsupportedOperationException + */ + @Override + public void setMonth(int month) { + throw new UnsupportedOperationException(IMMUTABLE_AND_DEPRECATED_MSG); + } + + /** + * Overridden to throw {@link UnsupportedOperationException}. + * + * @param date + * @throws UnsupportedOperationException + */ + @Override + public void setDate(int date) { + throw new UnsupportedOperationException(IMMUTABLE_AND_DEPRECATED_MSG); + } + + /** + * Overridden to throw {@link UnsupportedOperationException}. + * + * @param hours + * @throws UnsupportedOperationException + */ + @Override + public void setHours(int hours) { + throw new UnsupportedOperationException(IMMUTABLE_AND_DEPRECATED_MSG); + } + + /** + * Overridden to throw {@link UnsupportedOperationException}. + * + * @param minutes + * @throws UnsupportedOperationException + */ + @Override + public void setMinutes(int minutes) { + throw new UnsupportedOperationException(IMMUTABLE_AND_DEPRECATED_MSG); + } + + /** + * Overridden to throw {@link UnsupportedOperationException}. + * + * @param seconds + * @throws UnsupportedOperationException + */ + @Override + public void setSeconds(int seconds) { + throw new UnsupportedOperationException(IMMUTABLE_AND_DEPRECATED_MSG); + } + + /** + * Overridden to throw {@link UnsupportedOperationException}. + * + * @param time + * @throws UnsupportedOperationException + */ + @Override + public void setTime(long time) { + throw new UnsupportedOperationException(IMMUTABLE_MSG); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return hashCode; + } + + /** + * {@inheritDoc} + */ + @Override + public void serialize(ISerializationContext serializer, ImmutableDate object) + throws SerializationException { + serializer.writeI64(object.getTime()); + } + + /** + * {@inheritDoc} + */ + @Override + public ImmutableDate deserialize(IDeserializationContext deserializer) + throws SerializationException { + return new ImmutableDate(deserializer.readI64()); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ImmutableDateAdapter.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ImmutableDateAdapter.java new file mode 100644 index 0000000000..f54ef4e241 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/ImmutableDateAdapter.java @@ -0,0 +1,38 @@ +package com.raytheon.uf.common.time.util; + +import java.util.Date; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +/** + * An {@link XmlAdapter} version that allows JABX marshaling/unmarshaling + * of {@link ImmutableDate}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 19, 2012 726        jspinks     Initial creation
+ * 
+ * 
+ * + * @version 1.0 + */ +public class ImmutableDateAdapter extends XmlAdapter { + + @Override + public ImmutableDate unmarshal(Date date) throws Exception { + return new ImmutableDate(date); + } + + /** + * + * @return + */ + @Override + public Date marshal(ImmutableDate immutableDate) throws Exception { + return immutableDate; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java index f137f1813f..45edd79a05 100644 --- a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java @@ -25,6 +25,10 @@ import java.util.Calendar; import java.util.Date; import java.util.TimeZone; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.SimulatedTime; + /** * Utilities for time, some extracted from Util. * @@ -33,7 +37,8 @@ import java.util.TimeZone; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Feb 2, 2009 njensen Initial creation + * Feb 02, 2009 njensen Initial creation + * Sep 11, 2012 1154 djohnson Add MILLIS constants and isNewerDay(). * * * @@ -43,8 +48,54 @@ import java.util.TimeZone; public class TimeUtil { + /** + * A clock that does not really return the current time. Useful when you + * only want to keep track of times in a conditional sense, such as if a + * logging priority is enabled. This is an example of the Null Object + * pattern. + * + * @see http://en.wikipedia.org/wiki/Null_Object_pattern + * + * @author djohnson + * + */ + private static class NullClock extends AbstractTimer { + @Override + protected long getCurrentTime() { + return 1; + } + } + + /** + * Delegates the retrieval of the current time to the system clock. + * Production code will always use this. + * + * @author djohnson + * + */ + private static class SystemTimeStrategy implements ITimeStrategy { + @Override + public long currentTimeMillis() { + return System.currentTimeMillis(); + } + } + public static final String DATE_STRING = "(\\d{4})-(\\d{2})-(\\d{2})[ _](\\d{2}):(\\d{2}):(\\d{2})\\.(\\d{1,3})"; + // Util.java has a few of these constants, but that is located in an EDEX + // plugin and this is a more appropriate place for them anyways + public static final long MILLIS_PER_SECOND = 1000; + + public static final long MILLIS_PER_MINUTE = MILLIS_PER_SECOND * 60; + + public static final long MILLIS_PER_HOUR = MILLIS_PER_MINUTE * 60; + + public static final long MILLIS_PER_DAY = MILLIS_PER_HOUR * 24; + + public static final long MILLIS_PER_WEEK = MILLIS_PER_DAY * 7; + + public static final long MILLIS_PER_YEAR = 3600 * 24 * 1000 * 365; + // create instance of simple date format on class load, as instantiating it // is expensive the SimpleDateFormat class is not thread-safe, // so calling methods use synchronized @@ -58,6 +109,73 @@ public class TimeUtil { sqlSdf.setTimeZone(TimeZone.getTimeZone("GMT")); } + static final ITimeStrategy SYSTEM_TIME_STRATEGY = new SystemTimeStrategy(); + + static final ITimer NULL_CLOCK = new NullClock(); + + /** + * The strategy to retrieve the "current time" value from. + */ + static ITimeStrategy timeStrategy = SYSTEM_TIME_STRATEGY; + + /** + * Converts a Calendar in the local time zone to a GMT date + * + * @param cal + * A Calendar object in the local time zone + * @return The GMT date + */ + public static Date calendarToGMT(Calendar cal) { + Date dt = null; + synchronized (sdf) { + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + String str = formatCalendar(cal); + sdf.setTimeZone(TimeZone.getDefault()); + try { + dt = sdf.parse(str); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return dt; + } + + /** + * Retrieve the current time in milliseconds. This method should be used + * instead of {@link System#currentTimeMillis()}. This method DOES NOT use + * {@link SimulatedTime} and therefore should be isolated to duration + * checks, and logging type statements. If the desired result is the + * currently configured system time, e.g. CAVE sessions where the user has + * configured the system to a specific time. Those purposes are handled by + * the {@link SimulatedTime} class. The {@link Date} and {@link Calendar} + * returning methods in this class will delegate to {@link SimulatedTime}. + * + * @see {@link SimulatedTime} + * @return the current time in milliseconds + */ + public static long currentTimeMillis() { + return timeStrategy.currentTimeMillis(); + } + + /** + * Formats a calendar object into the following format yyyy-MM-dd_HH:mm:ss.S + * + * @param cal + * The calendar to format + * @return The formatted result + */ + public static String formatCalendar(Calendar cal) { + String format = null; + + synchronized (sdf) { + sdf.setTimeZone(cal.getTimeZone()); + format = sdf.format(cal.getTime()); + } + return format; + } + /** * Retrieve date as a string in the index standard format: yyyy-MM-dd * kk:mm:ss.SSS @@ -84,47 +202,6 @@ public class TimeUtil { return formatCalendar(cal); } - /** - * Formats a calendar object into the following format yyyy-MM-dd_HH:mm:ss.S - * - * @param cal - * The calendar to format - * @return The formatted result - */ - public static String formatCalendar(Calendar cal) { - String format = null; - - synchronized (sdf) { - sdf.setTimeZone(cal.getTimeZone()); - format = sdf.format(cal.getTime()); - } - return format; - } - - /** - * Converts a Calendar in the local time zone to a GMT date - * - * @param cal - * A Calendar object in the local time zone - * @return The GMT date - */ - public static Date calendarToGMT(Calendar cal) { - Date dt = null; - synchronized (sdf) { - sdf.setTimeZone(TimeZone.getTimeZone("GMT")); - String str = formatCalendar(cal); - sdf.setTimeZone(TimeZone.getDefault()); - try { - dt = sdf.parse(str); - } catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - return dt; - } - public static long formattedDateToLong(String formattedDate) { long retVal = 0; try { @@ -141,4 +218,109 @@ public class TimeUtil { } } + /** + * Retrieve a {@link ITimer} instance that will only actually keep track of + * time if the specified priority level is enabled. This allows efficient + * use of system resources, while calling code need not change. + * + * @param handler + * the handler to use to check for a priority level being enabled + * @param priority + * the priority level + * @return the {@link ITimer} instance + */ + public static ITimer getPriorityEnabledTimer(IUFStatusHandler handler, + Priority priority) { + return handler.isPriorityEnabled(priority) ? getTimer() : NULL_CLOCK; + } + + /** + * Retrieve a {@link ITimer} that allows the demarcation of arbitrary start + * and stop times. + * + * @return a {@link ITimer} + */ + public static ITimer getTimer() { + return new TimerImpl(); + } + + /** + * Check whether the time represented by a {@link Date} is a new day + * compared to another {@link Date} object. + * + * @param earlierDate + * the earlier date + * @param laterDate + * the later date + * @param timeZone + * the timeZone to use when determining what date it is for the + * specified time + * @return true if the laterDate is a new day compared to earlierDate + */ + public static boolean isNewerDay(Date earlierDate, Date laterDate, + TimeZone timeZone) { + Calendar earlierCal = TimeUtil.newCalendar(timeZone); + earlierCal.setTime(earlierDate); + + Calendar laterCal = TimeUtil.newCalendar(timeZone); + laterCal.setTime(laterDate); + + return laterCal.get(Calendar.DAY_OF_YEAR) > earlierCal + .get(Calendar.DAY_OF_YEAR) + || laterCal.get(Calendar.YEAR) > earlierCal.get(Calendar.YEAR); + } + + /** + * Return a new {@link Calendar} instance. This method delegates to the + * {@link SimulatedTime} class to determine the currently configured system + * time. + * + * @see {@link SimulatedTime} + * @return the calendar + */ + public static Calendar newCalendar() { + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(SimulatedTime.getSystemTime().getMillis()); + return cal; + } + + /** + * Return a new {@link Calendar} instance for the specified {@link TimeZone} + * . This method delegates to the {@link SimulatedTime} class to determine + * the currently configured system time. + * + * @param timeZone + * the time zone + * @see {@link SimulatedTime} + * @return the calendar + */ + public static Calendar newCalendar(TimeZone timeZone) { + Calendar cal = Calendar.getInstance(timeZone); + cal.setTimeInMillis(SimulatedTime.getSystemTime().getMillis()); + return cal; + } + + /** + * Return a new {@link Date} instance. This method delegates to the + * {@link SimulatedTime} class to determine the currently configured system + * time. + * + * @see {@link SimulatedTime} + * @return the current {@link Date} + */ + public static Date newDate() { + return SimulatedTime.getSystemTime().getTime(); + } + + /** + * Return a new ImmutableDate. This method delegates to the + * {@link SimulatedTime} class to determine the currently configured system + * time. + * + * @see {@link SimulatedTime} + * @return an immutable date for the current time + */ + public static ImmutableDate newImmutableDate() { + return new ImmutableDate(SimulatedTime.getSystemTime().getMillis()); + } } diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimerImpl.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimerImpl.java new file mode 100644 index 0000000000..6614625b3c --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimerImpl.java @@ -0,0 +1,34 @@ +package com.raytheon.uf.common.time.util; + +import net.jcip.annotations.NotThreadSafe; + +/** + * + * A default {@link ITimer} implementation that will use + * {@link TimeUtil#currentTimeMillis()} to keep track of time. It is good for + * use inside both production code and tests. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 16, 2012 0743       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +@NotThreadSafe +class TimerImpl extends AbstractTimer { + + /** + * {@inheritDoc} + */ + @Override + protected long getCurrentTime() { + return TimeUtil.currentTimeMillis(); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF index d4b62e6588..698f935620 100644 --- a/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF @@ -5,9 +5,12 @@ Bundle-SymbolicName: com.raytheon.uf.common.util Bundle-Version: 1.12.1174.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.junit;bundle-version="1.0.0" +Require-Bundle: org.junit;bundle-version="1.0.0", + org.apache.commons.beanutils;bundle-version="1.8.3", + com.raytheon.uf.common.status;bundle-version="1.12.1174" Export-Package: com.raytheon.uf.common.util, com.raytheon.uf.common.util.cache, com.raytheon.uf.common.util.header, - com.raytheon.uf.common.util.registry + com.raytheon.uf.common.util.registry, + com.raytheon.uf.common.util.session Import-Package: org.apache.commons.lang diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/CollectionUtil.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/CollectionUtil.java new file mode 100644 index 0000000000..c9b21378ae --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/CollectionUtil.java @@ -0,0 +1,84 @@ +/** + * 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.util; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + + +/** + * Utility class for collection types. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 13, 2012 740        djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public final class CollectionUtil { + + private CollectionUtil() { + + } + + /** + * Check whether an array is null or empty. + * + * @param array + * the array + * @return true if the array is null or empty + */ + public static boolean isNullOrEmpty(T[] array) { + return array == null || array.length == 0; + } + + /** + * Check whether a collection is null or empty. + * + * @param coll + * the collection + * @return true if the collection is null or empty + */ + public static boolean isNullOrEmpty(Collection coll) { + return coll == null || coll.isEmpty(); + } + + /** + * Create a set from the specified items. Assumes the items can be stored in + * a {@link HashSet}. + * + * @param items + * the items + * @return the set + */ + public static Set asSet(T... items) { + return new HashSet(Arrays.asList(items)); + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/roles/IRoleStorage.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/ExceptionUtil.java similarity index 59% rename from edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/roles/IRoleStorage.java rename to edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/ExceptionUtil.java index 783c32b7b0..9deebf6dca 100644 --- a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/roles/IRoleStorage.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/ExceptionUtil.java @@ -17,42 +17,45 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.auth.roles; +package com.raytheon.uf.common.util; /** - * Storage class for roles. Should have a concept of a default role which all - * users get by default and the ability to lookup a role given an id. NOTE, ALL - * ROLES IDS SHOULD BE TREATED AS CASE-INSENSITIVE + * Utilities for working with {@link Exception}s. * *
  * 
  * SOFTWARE HISTORY
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * May 18, 2010            mschenke     Initial creation
+ * Jul 5, 2012  740        djohnson     Initial creation
  * 
  * 
* - * @author mschenke + * @author djohnson * @version 1.0 */ -public interface IRoleStorage { +public final class ExceptionUtil { + + private ExceptionUtil() { + } /** - * Given the (case insensitive) role id, return the role object + * Retrieve the root cause of a {@link Throwable} chain. * - * @param roleId - * @return + * @param t + * the throwable + * @return the root cause */ - public IRole lookupRole(String roleId); + public static Throwable getRootCause(Throwable t) { + Throwable result = t; - /** - * Given the role, determine if it is the default role - * - * @param role - * @return - */ - public boolean isDefaultRole(IRole role); + while (result.getCause() != null) { + result = result.getCause(); + } + + return result; + } } diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java index d96e390326..1c606eb9e8 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java @@ -49,7 +49,7 @@ import java.util.zip.GZIPOutputStream; * return false when unable to * obtain directory listing. * Sep 16, 2008 1250 jelkins Added join function - * - AWIPS2 Baseline Repository -------- + * Jun 28, 2012 0819 djohnson Add write method. * Jul 06, 2012 798 jkorman Added more robust {@link #copyFile}. Added methods * to create temporary directories and files. * @@ -619,6 +619,24 @@ public class FileUtil { public static boolean isValidFilename(String fileName) { return VALID_FILENAME.matcher(fileName).matches(); } + + /** + * Write the contents of an input stream to a file. + * + * @param is + * the input stream to read from + * @param file + * the file to write to + * @throws IOException + */ + public static void write(InputStream is, File file) throws IOException { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + + int read = 0; + while ((read = is.read()) != -1) { + os.write(read); + } + } /** * Copy a file from one location to another. The file copy may begin at some diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/PropertiesUtil.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/PropertiesUtil.java new file mode 100644 index 0000000000..3f2dc3db28 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/PropertiesUtil.java @@ -0,0 +1,107 @@ +/** + * 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.util; + +import java.io.Closeable; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.Properties; + +/** + * Utility class to work with {@link Properties}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 28, 2012 819        djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public final class PropertiesUtil { + + /** + * Prevent instantiation. + */ + private PropertiesUtil() { + } + + /** + * Read an input stream to load a {@link Properties} instance. + * + * @param is + * the input stream + * @return the Properties + * @throws IOException + * on error reading the {@link InputStream} + */ + public static Properties read(InputStream is) throws IOException { + Reader reader = null; + try { + reader = new InputStreamReader(is); + + Properties properties = new Properties(); + properties.load(reader); + + return properties; + } finally { + close(reader); + } + } + + /** + * Read a {@link File} to load a {@link Properties} instance. + * + * @param file + * the file to read + * @return the Properties + * @throws IOException + * on error reading the {@link File} + */ + public static Properties read(File file) throws IOException { + InputStream is = null; + try { + is = new FileInputStream(file); + return read(is); + } finally { + close(is); + } + } + + public static void close(Closeable closeable) { + if (closeable != null) { + try { + closeable.close(); + } catch (IOException e) { + // Nothing to do, closing... + } + } + } +} diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/ReflectionException.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/ReflectionException.java new file mode 100644 index 0000000000..30d12bd487 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/ReflectionException.java @@ -0,0 +1,58 @@ +/** + * 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.util; + +/** + * A wrapper runtime exception for problems that occur with reflection. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 10, 2012 634        djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ReflectionException extends RuntimeException { + + private static final long serialVersionUID = -6622684607744047392L; + + public ReflectionException() { + super(); + } + + public ReflectionException(String message, Throwable cause) { + super(message, cause); + } + + public ReflectionException(String message) { + super(message); + } + + public ReflectionException(Throwable cause) { + super(cause); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/ReflectionUtil.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/ReflectionUtil.java new file mode 100644 index 0000000000..ca1c59b811 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/ReflectionUtil.java @@ -0,0 +1,228 @@ +/** + * 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.util; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.apache.commons.beanutils.PropertyUtils; + +/** + * Reflection utilities. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 10, 2012 634        djohnson     Initial creation
+ * Jul 10, 2012 455        djohnson     Move in methods from RegistryUtil, 
+ *                                      fix setter method to use parameter types.
+ * Sep 28, 2012 1195       djohnson     Add {@link #forName(String)}.
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public final class ReflectionUtil { + + private static ConcurrentMap, List> classFields = new ConcurrentHashMap, List>(); + + private ReflectionUtil() { + // Utility class + } + + public static T newInstanceOfAssignableType(Class assignableClass, + String className) { + try { + @SuppressWarnings("unchecked") + Class clazz = (Class) Class + .forName(className); + return newInstanceOfAssignableType(assignableClass, clazz); + } catch (ClassCastException cce) { + throw new ReflectionException(String.format( + "%s is not assignable to a field of type %s", className, + assignableClass.getName()), cce); + } catch (ClassNotFoundException e) { + throw new ReflectionException(e); + } + } + + public static T newInstanceOfAssignableType(Class assignableClass, + Class clazz) { + try { + return assignableClass.cast(newInstance(clazz)); + } catch (ClassCastException cce) { + throw new ReflectionException(String.format( + "%s is not assignable to a field of type %s", + clazz.getName(), assignableClass.getName()), cce); + } + } + + public static Object getter(Object object, String name) + throws ReflectionException { + // Assume camel cased names - capitalize first letter... + String method = Character.toUpperCase(name.charAt(0)) + + name.substring(1); + try { + Method m; + try { + // Try common 'get' first... + m = object.getClass().getMethod("get" + method); + } catch (NoSuchMethodException e) { + // Try 'is' as a prefix + m = object.getClass().getMethod("is" + method); + } + + return m.invoke(object, (Object[]) null); + } catch (Exception e) { + throw new ReflectionException(e); + } + } + + public static T getter(Class resultType, Object obj, String name) { + Object result = null; + try { + result = getter(obj, name); + return resultType.cast(result); + } catch (ClassCastException cce) { + throw new ReflectionException(String.format( + "%s is not assignable to a field of type %s", result + .getClass().getName(), resultType.getName()), cce); + } + } + + public static void setter(Object object, String name, Object... parameters) + throws ReflectionException { + try { + String method = "set" + Character.toUpperCase(name.charAt(0)) + + name.substring(1); + + Class[] parameterTypes = new Class[parameters.length]; + for (int i = 0; i < parameters.length; i++) { + parameterTypes[i] = parameters[i].getClass(); + } + + Method m = object.getClass().getMethod(method, parameterTypes); + m.invoke(object, parameters); + } catch (Exception e) { + throw new ReflectionException(e); + } + } + + /** + * Constructs a new instance of the specified class. + * + * @param clazz + * the class to construct + * @return the constructed instance + * @throws ReflectionException + * on error constructing the instance + */ + public static Object newInstance(Class clazz) throws ReflectionException { + try { + return clazz.newInstance(); + } catch (Exception e) { + throw new ReflectionException(String.format( + "Unable to construct an object of type %s!", + clazz.getName()), e); + } + } + + /** + * Gets all fields for a given class. Fields from the superclass are also + * included + * + * @param fields + * The list used to hold the fields + * @param type + * The class type to look at + * @return The complete list of all fields including inherited fields + */ + public static List getAllFields(Class type) { + List storedFields = classFields.get(type); + if (storedFields != null) { + return storedFields; + } + List fields = new ArrayList(); + for (Field field : type.getDeclaredFields()) { + fields.add(field); + } + if (type.getSuperclass() != null) { + fields.addAll(getAllFields(type.getSuperclass())); + } + classFields.putIfAbsent(type, fields); + return fields; + } + + /** + * Checks the fields of a class to see if the desired annotation is present + * on any fields. If the annotation is found, the value of the field is + * returned + * + * @param obj + * The object to check + * @param annotation + * The annotation class to look for + * @return The value of the annotated field + * @throws ReflectionException + * If reflection errors occur + */ + public static String getAnnotatedField(Object obj, + Class annotation) throws ReflectionException { + List fields = getAllFields(obj.getClass()); + + for (Field field : fields) { + Annotation ann = field.getAnnotation(annotation); + if (ann != null) { + try { + return PropertyUtils.getProperty(obj, field.getName()) + .toString(); + } catch (Exception e) { + throw new ReflectionException( + "Error getting annotated field value", e); + } + } + } + return null; + } + + /** + * Create a class instance from its name. + * + * @param className + * the class name + * @return the class + */ + public static Class forName(String className) { + try { + return Class.forName(className); + } catch (ClassNotFoundException e) { + throw new ReflectionException(e); + } + } +} diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/StringUtil.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/StringUtil.java index 4895600367..f5c66575ed 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/StringUtil.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/StringUtil.java @@ -20,6 +20,7 @@ package com.raytheon.uf.common.util; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import org.apache.commons.lang.StringUtils; @@ -34,13 +35,18 @@ import org.apache.commons.lang.StringUtils; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Oct 20, 2011 rferrel Initial creation + * Jul 13, 2012 740 djohnson Add join. * * * * @author rferrel * @version 1.0 */ -public class StringUtil { +public final class StringUtil { + + private StringUtil() { + + } /** * Splits a string using given separator characters; strings are trimmed and @@ -75,4 +81,56 @@ public class StringUtil { } return result; } + + /** + * Concatenate an array of object into a single string with each array + * element's toString() value separated by the joinCharacter. + * + * @param portions + * the array of objects + * @param joinCharacter + * the character to join them with + * @return the concatenated string + */ + public static String join(final T[] portions, final char joinCharacter) { + StringBuilder stringBuilder = new StringBuilder(); + + if (CollectionUtil.isNullOrEmpty(portions)) { + return null; + } + + for (T portion : portions) { + stringBuilder.append(portion); + stringBuilder.append(joinCharacter); + } + stringBuilder.deleteCharAt(stringBuilder.length() - 1); + + return stringBuilder.toString(); + } + + /** + * Concatenate a collection of objects into a single string with each + * object's toString() value separated by the joinCharacter. + * + * @param portions + * the collections of objects + * @param joinCharacter + * the character to join them with + * @return the concatenated string + */ + public static String join(final Collection portions, final char joinCharacter) { + StringBuilder stringBuilder = new StringBuilder(); + + if (CollectionUtil.isNullOrEmpty(portions)) { + return null; + } + + for (T portion : portions) { + stringBuilder.append(portion); + stringBuilder.append(joinCharacter); + } + stringBuilder.deleteCharAt(stringBuilder.length() - 1); + + return stringBuilder.toString(); + } } diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/session/SessionContext.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/session/SessionContext.java new file mode 100644 index 0000000000..bb06d78335 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/session/SessionContext.java @@ -0,0 +1,53 @@ +/** + * 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.util.session; + +/** + * This interface should be implemented for each session management type. For + * example, in a persistence session the extension class could hold the + * transaction. Each thread is given a single {@link SessionContext}, therefore + * the implementors do not need to be thread-safe. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 26, 2012 1195       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public interface SessionContext { + /** + * Open the context, called by {@link SessionManager} when the context is + * initially created for a thread. + */ + void open(); + + /** + * Close the context, called by {@link SessionManager} when the context is + * destroyed for a thread. + */ + void close(); +} diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/session/SessionManager.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/session/SessionManager.java new file mode 100644 index 0000000000..556b9f81e2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/session/SessionManager.java @@ -0,0 +1,182 @@ +/** + * 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.util.session; + +import java.util.HashMap; +import java.util.Map; + +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.util.ReflectionUtil; + +/** + * Provides the functionality to manage a 'session'. Each thread has its own + * instance of the context. 1..N open requests can be made, and once the Nth + * close request comes in the session is closed. All data related to the session + * is stored in the sub-class of {@link SessionContext}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 26, 2012 1195       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public final class SessionManager { + + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(SessionManager.class); + + /** + * Inner-class used to hold the SessionContext tracking data. + */ + private static class SessionContextTracker { + private int openRequests; + private final SessionContext sessionContext; + + /** + * Constructor. + * + * @param sessionContext + * the session context to track + */ + private SessionContextTracker(SessionContext sessionContext) { + this.sessionContext = sessionContext; + } + } + + /** + * Kept in a ThreadLocal to avoid synchronization expenditures. + */ + private static final ThreadLocal> context = new ThreadLocal>() { + + /** + * {@inheritDoc} + */ + @Override + protected Map initialValue() { + return new HashMap(); + } + }; + + /** + * Opens a session and binds the context to a thread, if not already open. + * + * @param contextClass + * the context class for the session type + */ + public static T openSession( + Class contextClass) { + final Map map = context.get(); + final String key = contextClass.getName(); + + SessionContextTracker ctxTracker = map.get(key); + if (ctxTracker == null) { + SessionContext ctx = ReflectionUtil.newInstanceOfAssignableType( + SessionContext.class, contextClass); + ctx.open(); + + ctxTracker = new SessionContextTracker(ctx); + map.put(key, ctxTracker); + } + + ctxTracker.openRequests++; + + if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { + statusHandler.debug(String.format( + " context [%s] openRequests [%s]", contextClass.getName(), + ctxTracker.openRequests)); + } + + return contextClass.cast(ctxTracker.sessionContext); + } + + /** + * Closes the session currently bound to this thread, if the last open + * requester has signaled it should be closed. + * + * @param contextClass + * the context class for the session type + * @throws IllegalStateException + * if the session is not open + */ + public static void closeSession( + Class contextClass) { + final Map map = context.get(); + final String key = contextClass.getName(); + + SessionContextTracker ctxTracker = map.get(key); + + if (ctxTracker == null) { + throw new IllegalStateException( + "Unable to close a session that is not opened! " + + "Please be sure to pair the closeSession() request with a prior openSession() request."); + } + + ctxTracker.openRequests--; + + // If the last open request finally checked in, close it down + if (ctxTracker.openRequests < 1) { + if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { + statusHandler.debug(String.format( + "context [%s] closing, openRequests [%s]", + contextClass.getName(), ctxTracker.openRequests)); + } + + SessionContext ctx = ctxTracker.sessionContext; + ctx.close(); + map.remove(key); + } else if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { + statusHandler.debug(String.format( + "context [%s] not closing, openRequests [%s]", + contextClass.getName(), ctxTracker.openRequests)); + } + } + + /** + * Retrieve the session context class for an open session. + * + * @param contextClass + * the context class for the session type + * @return + * @throws IllegalStateException + * if the session is not open + */ + public static T getSessionContext( + Class contextClass) { + final Map map = context.get(); + final String key = contextClass.getName(); + + SessionContextTracker ctxTracker = map.get(key); + if (ctxTracker == null) { + throw new IllegalStateException("No session is currently open!"); + } + + return contextClass.cast(ctxTracker.sessionContext); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/CollectionUtilTest.java b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/CollectionUtilTest.java new file mode 100644 index 0000000000..bf8a31f492 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/CollectionUtilTest.java @@ -0,0 +1,83 @@ +/** + * 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.util; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +import org.junit.Test; + +/** + * Test {@link CollectionUtil}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 13, 2012 740        djohnson     Initial creation
+ * Jul 26, 2012 955        djohnson     Add isNullOrEmpty for {@link Collection}s.
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class CollectionUtilTest { + + @Test + public void testIsNullOrEmptyReturnsTrueForNullArray() { + String[] array = null; + assertTrue(CollectionUtil.isNullOrEmpty(array)); + } + + @Test + public void testIsNullOrEmptyReturnsTrueForEmptyArray() { + String[] array = new String[0]; + assertTrue(CollectionUtil.isNullOrEmpty(array)); + } + + @Test + public void testIsNullOrEmptyReturnsFalseForNonEmptyArray() { + String[] array = new String[] { "" }; + assertFalse(CollectionUtil.isNullOrEmpty(array)); + } + + @Test + public void testIsNullOrEmptyReturnsTrueForNullCollection() { + assertTrue(CollectionUtil.isNullOrEmpty((Collection) null)); + } + + @Test + public void testIsNullOrEmptyReturnsTrueForEmptyCollection() { + assertTrue(CollectionUtil.isNullOrEmpty(Collections.emptyList())); + } + + @Test + public void testIsNullOrEmptyReturnsFalseForNonEmptyCollection() { + assertFalse(CollectionUtil.isNullOrEmpty(Arrays.asList("not empty"))); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/ExceptionUtilTest.java b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/ExceptionUtilTest.java new file mode 100644 index 0000000000..35ea8d6d30 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/ExceptionUtilTest.java @@ -0,0 +1,64 @@ +/** + * 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.util; + +import static org.junit.Assert.assertSame; + +import java.io.FileNotFoundException; + +import org.junit.Test; + +/** + * Test {@link ExceptionUtil}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 5, 2012  740        djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class ExceptionUtilTest { + + @Test + public void testGettingRootCauseGoesNLevelsDeep() { + final FileNotFoundException root = new FileNotFoundException("root"); + final Throwable t = new Throwable(new IllegalArgumentException( + new IllegalStateException(root))); + + assertSame("Didn't get the correct exception for the root cause!", + root, ExceptionUtil.getRootCause(t)); + } + + @Test + public void testGettingRootCauseWillReturnParameterIfNoCauseFound() { + final FileNotFoundException root = new FileNotFoundException(); + + assertSame("Didn't get the correct exception for the root cause!", + root, ExceptionUtil.getRootCause(root)); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/PropertiesUtilTest.java b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/PropertiesUtilTest.java new file mode 100644 index 0000000000..8397b32dcc --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/PropertiesUtilTest.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.util; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.junit.Test; + +/** + * Test {@link PropertiesUtil}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 28, 2012 819        djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class PropertiesUtilTest { + + private static final Class CLASS = PropertiesUtilTest.class; + + @Test + public void testCanReadPropertiesInputStream() throws IOException { + InputStream is = null; + try { + is = CLASS.getResourceAsStream(CLASS.getSimpleName() + + ".properties"); + Properties properties = PropertiesUtil.read(is); + + assertFalse( + "The properties should not be empty after reading an InputStream!", + properties.isEmpty()); + } finally { + PropertiesUtil.close(is); + } + } + + @Test + public void testCanReadPropertiesFile() throws IOException { + File fileToRead = File.createTempFile( + PropertiesUtilTest.class.getSimpleName(), null); + + InputStream is = null; + try { + is = CLASS.getResourceAsStream(CLASS.getSimpleName() + + ".properties"); + + FileUtil.write(is, fileToRead); + + assertTrue("The file to read should exist!", fileToRead.isFile()); + } finally { + PropertiesUtil.close(is); + } + + Properties properties = PropertiesUtil.read(fileToRead); + assertFalse("The properties should not be empty after reading a file!", + properties.isEmpty()); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/PropertiesUtilTest.properties b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/PropertiesUtilTest.properties new file mode 100644 index 0000000000..f51889fddc --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/PropertiesUtilTest.properties @@ -0,0 +1,2 @@ +string.property=value +integer.property=10 \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/ReflectionUtilTest.java b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/ReflectionUtilTest.java new file mode 100644 index 0000000000..c3288f93ec --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/ReflectionUtilTest.java @@ -0,0 +1,132 @@ +/** + * 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.util; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + +import org.junit.Test; + +/** + * Test {@link ReflectionUtil}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 10, 2012 634        djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public class ReflectionUtilTest { + + private static final String NON_EXISTANT = "nonExistant"; + + @Test + public void testNewInstanceOfAssignableTypeWithInterface() { + List list = ReflectionUtil.newInstanceOfAssignableType(List.class, + ArrayList.class.getName()); + assertTrue(list instanceof ArrayList); + } + + @Test(expected = ReflectionException.class) + public void testNewInstanceOfAssignableTypeThrowsReflectionExceptionOnIncompatibleCast() { + ReflectionUtil.newInstanceOfAssignableType(List.class, + HashSet.class.getName()); + } + + @Test(expected = ReflectionException.class) + public void testNewInstanceOfAssignableTypeThrowsReflectionExceptionOnInvalidClassname() { + ReflectionUtil.newInstanceOfAssignableType(List.class, NON_EXISTANT); + } + + @Test + public void testGetterRetrievesGetPrefixedValue() { + byte[] expected = new byte[] { 't', 'e', 's', 't' }; + String value = new String(expected); + + byte[] actual = (byte[]) ReflectionUtil.getter(value, "bytes"); + + assertArrayEquals( + "Did not receive the expected value from the getter!", + expected, actual); + } + + @Test + public void testGetterWithCastResult() { + byte[] expected = new byte[] { 't', 'e', 's', 't' }; + String value = new String(expected); + + byte[] actual = ReflectionUtil.getter(byte[].class, value, "bytes"); + + assertArrayEquals( + "Did not receive the expected value from the getter!", + expected, actual); + } + + @Test + public void testGetterRetrievesIsPrefixedValue() { + List list = Collections.emptyList(); + + boolean value = (Boolean) ReflectionUtil.getter(list, "empty"); + + assertTrue( + "Incorrect value retrieved from the getter using an is prefix!", + value); + } + + @Test(expected = ReflectionException.class) + public void testGetterThrowsReflectionExceptionOnNoSuchMethod() { + byte[] expected = new byte[] { 't', 'e', 's', 't' }; + String value = new String(expected); + + ReflectionUtil.getter(value, NON_EXISTANT); + } + + @Test + public void testSetterCanSetValueOnProperlyNamedMethod() { + final String name = "blah"; + + Thread thread = new Thread(); + ReflectionUtil.setter(thread, "name", name); + + assertEquals("Setter did not set the correct value!", name, + thread.getName()); + } + + @Test(expected = ReflectionException.class) + public void testSetterThrowsReflectionExceptionOnNoSuchMethod() { + String string = "blah"; + + Thread thread = new Thread(); + ReflectionUtil.setter(thread, string, NON_EXISTANT); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/StringUtilTest.java b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/StringUtilTest.java new file mode 100644 index 0000000000..d79ecf9729 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/unit-test/com/raytheon/uf/common/util/StringUtilTest.java @@ -0,0 +1,64 @@ +/** + * 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.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +/** + * Test {@link StringUtil}. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 13, 2012 740        djohnson     Initial creation
+ * Aug 20, 2012 0743       djohnson     Disambiguate method call.
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public class StringUtilTest { + + @Test + public void testJoinedStringsUseJoinCharacter() + { + assertEquals("1,2,3", + StringUtil.join(new String[] { "1", "2", "3" }, ',')); + } + + @Test + public void testJoinReturnsNullForNullArrayOfStrings() { + assertNull(StringUtil.join((Object[]) null, ',')); + } + + @Test + public void testJoinReturnsNullForZeroLengthArray() { + assertNull(StringUtil.join(new String[0], ',')); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.auth/.classpath b/edexOsgi/com.raytheon.uf.edex.auth/.classpath index ad32c83a78..b614cf5821 100644 --- a/edexOsgi/com.raytheon.uf.edex.auth/.classpath +++ b/edexOsgi/com.raytheon.uf.edex.auth/.classpath @@ -3,5 +3,6 @@ +
diff --git a/edexOsgi/com.raytheon.uf.edex.auth/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.auth/META-INF/MANIFEST.MF index 9b94d8d0cb..f8af623847 100644 --- a/edexOsgi/com.raytheon.uf.edex.auth/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.auth/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.11.31", com.raytheon.uf.common.serialization.comm;bundle-version="1.11.31", com.raytheon.uf.common.auth;bundle-version="1.0.0", com.raytheon.edex.common;bundle-version="1.11.31", - com.raytheon.uf.common.status;bundle-version="1.11.31" + com.raytheon.uf.common.status;bundle-version="1.11.31", + com.raytheon.uf.common.plugin.nwsauth;bundle-version="1.12.1174" Export-Package: com.raytheon.uf.edex.auth, com.raytheon.uf.edex.auth.authentication, com.raytheon.uf.edex.auth.req, diff --git a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/AuthManager.java b/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/AuthManager.java index 248986367d..bc0abae9b7 100644 --- a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/AuthManager.java +++ b/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/AuthManager.java @@ -19,9 +19,9 @@ **/ package com.raytheon.uf.edex.auth; +import com.raytheon.uf.common.plugin.nwsauth.roles.IRoleStorage; import com.raytheon.uf.edex.auth.authentication.IAuthenticationStorage; import com.raytheon.uf.edex.auth.authentication.IAuthenticator; -import com.raytheon.uf.edex.auth.roles.IRoleStorage; /** * Authentication Manager class, contains classes for storing and retrieving diff --git a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/RemoteRequestRouteWrapper.java b/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/RemoteRequestRouteWrapper.java index 832be233f8..772f270245 100644 --- a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/RemoteRequestRouteWrapper.java +++ b/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/RemoteRequestRouteWrapper.java @@ -21,12 +21,12 @@ package com.raytheon.uf.edex.auth; import com.raytheon.uf.common.auth.AuthException; import com.raytheon.uf.common.auth.resp.AuthServerErrorResponse; +import com.raytheon.uf.common.serialization.ExceptionWrapper; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.serialization.comm.IServerRequest; import com.raytheon.uf.common.serialization.comm.RequestWrapper; import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse; -import com.raytheon.uf.common.serialization.comm.util.ExceptionWrapper; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.util.SizeUtil; diff --git a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/RemoteRequestServer.java b/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/RemoteRequestServer.java index d735acef38..1573df4e7e 100644 --- a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/RemoteRequestServer.java +++ b/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/RemoteRequestServer.java @@ -97,7 +97,7 @@ public class RemoteRequestServer { // check handler if user has authorization AuthorizationResponse authResp = privHandler.authorized(user, privReq); - if (authResp != null && !authResp.isAuthorized()) { + if (authResp != null && !authResp.isAuthorized() && authResp.getResponseMessage() != null) { return ResponseFactory.constructNotAuthorized(privReq, authResp.getResponseMessage()); } diff --git a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/req/AbstractPrivilegedRequestHandler.java b/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/req/AbstractPrivilegedRequestHandler.java index 643cdca6a7..c881ea310f 100644 --- a/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/req/AbstractPrivilegedRequestHandler.java +++ b/edexOsgi/com.raytheon.uf.edex.auth/src/com/raytheon/uf/edex/auth/req/AbstractPrivilegedRequestHandler.java @@ -21,6 +21,7 @@ package com.raytheon.uf.edex.auth.req; import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest; import com.raytheon.uf.common.auth.user.IUser; +import com.raytheon.uf.common.plugin.nwsauth.exception.AuthorizationException; import com.raytheon.uf.common.serialization.comm.IRequestHandler; import com.raytheon.uf.edex.auth.resp.AuthorizationResponse; @@ -50,7 +51,9 @@ public abstract class AbstractPrivilegedRequestHandler * * @author chammack @@ -63,6 +64,11 @@ import com.raytheon.uf.edex.core.props.PropertiesFactory; */ public class EDEXUtil implements ApplicationContextAware { + public static final String EDEX_HOME = System.getProperty("edex.home"); + + public static final String EDEX_BIN = EDEX_HOME + File.separatorChar + + "bin"; + static Log logger = LogFactory.getLog(EDEXUtil.class); private static ApplicationContext CONTEXT; @@ -89,6 +95,7 @@ public class EDEXUtil implements ApplicationContextAware { return serverId; } + @Override public void setApplicationContext(ApplicationContext context) throws BeansException { CONTEXT = context; diff --git a/edexOsgi/com.raytheon.uf.edex.cots.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.cots.feature/feature.xml index ed07815a5d..2213282a06 100644 --- a/edexOsgi/com.raytheon.uf.edex.cots.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.cots.feature/feature.xml @@ -312,4 +312,31 @@ install-size="0" version="0.0.0"/> + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.database/.classpath b/edexOsgi/com.raytheon.uf.edex.database/.classpath index ad32c83a78..1fa3e6803d 100644 --- a/edexOsgi/com.raytheon.uf.edex.database/.classpath +++ b/edexOsgi/com.raytheon.uf.edex.database/.classpath @@ -1,6 +1,6 @@ - + diff --git a/edexOsgi/com.raytheon.uf.edex.database/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.database/META-INF/MANIFEST.MF index 95e019caac..e21e63f2d6 100644 --- a/edexOsgi/com.raytheon.uf.edex.database/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.database/META-INF/MANIFEST.MF @@ -28,6 +28,7 @@ Export-Package: com.raytheon.uf.edex.database, com.raytheon.uf.edex.database.plugin, com.raytheon.uf.edex.database.purge, com.raytheon.uf.edex.database.query, + com.raytheon.uf.edex.database.spatial, com.raytheon.uf.edex.database.status, com.raytheon.uf.edex.database.tasks Import-Package: com.raytheon.uf.common.message, diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/CoreDao.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/CoreDao.java index 5c795c662e..5d493a29a2 100644 --- a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/CoreDao.java +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/CoreDao.java @@ -47,7 +47,6 @@ import net.sf.ehcache.management.ManagementService; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; -import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.DetachedCriteria; @@ -64,6 +63,7 @@ import org.springframework.transaction.support.TransactionCallbackWithoutResult; import org.springframework.transaction.support.TransactionTemplate; import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.dataplugin.persist.IPersistableDataObject; import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; import com.raytheon.uf.common.dataquery.db.QueryParam; import com.raytheon.uf.common.dataquery.db.QueryResult; @@ -71,7 +71,6 @@ import com.raytheon.uf.common.dataquery.db.QueryResultRow; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.query.DatabaseQuery; @@ -83,7 +82,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; *

* Data types which must be persisted to the database must have an associated * dao which extends this class. Each class needing a dao must also extend the - * PersistableDataObject class. + * PersistableDataObject class. *

* NOTE: Direct instantiation of this class is discouraged. Use * DaoPool.getInstance().borrowObject() for retrieving all data access objects @@ -96,6 +95,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * ------------ ---------- ----------- -------------------------- * 7/24/07 353 bphillip Initial Check in * 5/14/08 1076 brockwoo Fix for distinct with multiple properties + * Oct 10, 2012 1261 djohnson Incorporate changes to DaoConfig, add generic to {@link IPersistableDataObject}. * * * @@ -103,7 +103,9 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * @version 1 */ public class CoreDao extends HibernateDaoSupport { - protected static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(CoreDao.class); + protected static final IUFStatusHandler statusHandler = UFStatus + .getHandler(CoreDao.class); + /** * The Hibernate transaction manager. Methods do not directly use this * class. Instead, use the Transaction template @@ -113,11 +115,6 @@ public class CoreDao extends HibernateDaoSupport { /** The convenience wrapper for the Hibernate transaction manager */ protected final TransactionTemplate txTemplate; - /** - * The cache region to store query - */ - private final String QUERY_CACHE_REGION = "Queries"; - /** The class associated with this dao */ protected Class daoClass; @@ -132,16 +129,11 @@ public class CoreDao extends HibernateDaoSupport { * has been assigned */ public CoreDao(DaoConfig config) { - txManager = (HibernateTransactionManager) EDEXUtil - .getESBComponent(config.getTxManagerName()); + this.txManager = config.getTxManager(); txTemplate = new TransactionTemplate(txManager); - // SessionFactory sf = ((DatabaseSessionFactoryBean) - // EDEXUtil.getESBComponent("&" + config - // .getSessionFactoryName())).getMoreBetterSessionFactory(); - setSessionFactory((SessionFactory) EDEXUtil.getESBComponent(config - .getSessionFactoryName())); + setSessionFactory(config.getSessionFactory()); - daoClass = config.getDaoClassName(); + this.daoClass = config.getDaoClass(); getHibernateTemplate().setCacheQueries(true); } @@ -192,7 +184,7 @@ public class CoreDao extends HibernateDaoSupport { * @param obj * The object to be persisted to the database */ - public void saveOrUpdate(final PersistableDataObject obj) { + public void saveOrUpdate(final PersistableDataObject obj) { txTemplate.execute(new TransactionCallbackWithoutResult() { @Override public void doInTransactionWithoutResult(TransactionStatus status) { @@ -223,7 +215,7 @@ public class CoreDao extends HibernateDaoSupport { * @param obj * The object to be persisted to the database */ - public void update(final PersistableDataObject obj) { + public void update(final PersistableDataObject obj) { txTemplate.execute(new TransactionCallbackWithoutResult() { @Override public void doInTransactionWithoutResult(TransactionStatus status) { @@ -265,15 +257,15 @@ public class CoreDao extends HibernateDaoSupport { private static final String mergeSqlFormat = "select id from awips.%s where dataURI=:dataURI"; - public List mergeAll( - final List obj) { - List duplicates = new ArrayList(); + public List> mergeAll( + final List> obj) { + List> duplicates = new ArrayList>(); Session s = this.getHibernateTemplate().getSessionFactory() .openSession(); Transaction tx = s.beginTransaction(); try { Map pluginQueryMap = new HashMap(); - for (PersistableDataObject pdo : obj) { + for (PersistableDataObject pdo : obj) { if (pdo == null) { logger.error("Attempted to insert null PersistableDataObject"); continue; @@ -291,11 +283,8 @@ public class CoreDao extends HibernateDaoSupport { if (!pdo.isOverwriteAllowed()) { duplicates.add(pdo); } else { - statusHandler.handle( - Priority.DEBUG, - "Overwriting " - + ((PersistableDataObject) pdo) - .getIdentifier()); + statusHandler.handle(Priority.DEBUG, "Overwriting " + + pdo.getIdentifier()); } } } @@ -310,43 +299,6 @@ public class CoreDao extends HibernateDaoSupport { } } return duplicates; - - // return (List) txTemplate - // .execute(new TransactionCallback() { - // @Override - // public List doInTransaction( - // TransactionStatus arg0) { - // Session s = getHibernateTemplate().getSessionFactory() - // .getCurrentSession(); - // List duplicates = new - // ArrayList(); - // Map pluginQueryMap = new HashMap(); - // for (PersistableDataObject pdo : obj) { - // if (pdo == null) { - // logger - // .error("Attempted to insert null PersistableDataObject"); - // continue; - // } - // String plugin = ((PluginDataObject) pdo) - // .getPluginName(); - // Query q = pluginQueryMap.get(plugin); - // if (q == null) { - // q = s.createSQLQuery(String.format( - // mergeSqlFormat, plugin)); - // pluginQueryMap.put(plugin, q); - // } - // q - // .setString("dataURI", (String) pdo - // .getIdentifier()); - // if (q.list().size() == 0) { - // s.persist(pdo); - // } else { - // duplicates.add(pdo); - // } - // } - // return duplicates; - // } - // }); } /** @@ -355,7 +307,7 @@ public class CoreDao extends HibernateDaoSupport { * @param obj * The object to delete */ - public void delete(final PersistableDataObject obj) { + public void delete(final PersistableDataObject obj) { txTemplate.execute(new TransactionCallbackWithoutResult() { @Override public void doInTransactionWithoutResult(TransactionStatus status) { @@ -373,12 +325,14 @@ public class CoreDao extends HibernateDaoSupport { * @return The object with the matching id.
* Null if not found */ - public PersistableDataObject queryById(final Serializable id) { - PersistableDataObject retVal = (PersistableDataObject) txTemplate + public PersistableDataObject queryById(final Serializable id) { + @SuppressWarnings("unchecked") + PersistableDataObject retVal = (PersistableDataObject) txTemplate .execute(new TransactionCallback() { - public PersistableDataObject doInTransaction( + @Override + public PersistableDataObject doInTransaction( TransactionStatus status) { - return (PersistableDataObject) getHibernateTemplate() + return (PersistableDataObject) getHibernateTemplate() .get(daoClass, id); } }); @@ -392,10 +346,12 @@ public class CoreDao extends HibernateDaoSupport { * The id * @return The object */ - public PersistableDataObject queryById(final PluginDataObject id) { - PersistableDataObject retVal = (PersistableDataObject) txTemplate + public PersistableDataObject queryById(final PluginDataObject id) { + @SuppressWarnings("unchecked") + PersistableDataObject retVal = (PersistableDataObject) txTemplate .execute(new TransactionCallback() { - public PersistableDataObject doInTransaction( + @Override + public PersistableDataObject doInTransaction( TransactionStatus status) { DetachedCriteria criteria = DetachedCriteria.forClass( id.getClass()) @@ -425,11 +381,12 @@ public class CoreDao extends HibernateDaoSupport { * @return A list of similar objects */ @SuppressWarnings("unchecked") - public List queryByExample( - final PersistableDataObject obj, final int maxResults) { - List retVal = (List) txTemplate + public List> queryByExample( + final PersistableDataObject obj, final int maxResults) { + List> retVal = (List>) txTemplate .execute(new TransactionCallback() { - public List doInTransaction( + @Override + public List> doInTransaction( TransactionStatus status) { return getHibernateTemplate().findByExample(obj, 0, maxResults); @@ -448,7 +405,8 @@ public class CoreDao extends HibernateDaoSupport { * The partially populated object * @return A list of similar objects */ - public List queryByExample(PersistableDataObject obj) { + public List> queryByExample( + PersistableDataObject obj) { return queryByExample(obj, -1); } @@ -468,6 +426,7 @@ public class CoreDao extends HibernateDaoSupport { // Get a session and create a new criteria instance rowsDeleted = (Integer) txTemplate .execute(new TransactionCallback() { + @Override public Integer doInTransaction(TransactionStatus status) { String queryString = query.createHQLDelete(); Query hibQuery = getSession(false).createQuery( @@ -504,6 +463,7 @@ public class CoreDao extends HibernateDaoSupport { // Get a session and create a new criteria instance queryResult = (List) txTemplate .execute(new TransactionCallback() { + @Override public List doInTransaction(TransactionStatus status) { String queryString = query.createHQLQuery(); Query hibQuery = getSession(false).createQuery( @@ -531,6 +491,15 @@ public class CoreDao extends HibernateDaoSupport { return queryResult; } + public void deleteAll(final List objs) { + txTemplate.execute(new TransactionCallbackWithoutResult() { + @Override + public void doInTransactionWithoutResult(TransactionStatus status) { + getHibernateTemplate().deleteAll(objs); + } + }); + } + /** * * @param fields @@ -723,6 +692,7 @@ public class CoreDao extends HibernateDaoSupport { QueryResult result = (QueryResult) txTemplate .execute(new TransactionCallback() { + @Override public QueryResult doInTransaction(TransactionStatus status) { Query hibQuery = getSession(false) .createQuery(hqlQuery); @@ -776,6 +746,7 @@ public class CoreDao extends HibernateDaoSupport { int queryResult = (Integer) txTemplate .execute(new TransactionCallback() { + @Override public Integer doInTransaction(TransactionStatus status) { Query hibQuery = getSession(false).createQuery(hqlStmt); // hibQuery.setCacheMode(CacheMode.NORMAL); @@ -800,6 +771,7 @@ public class CoreDao extends HibernateDaoSupport { long start = System.currentTimeMillis(); List queryResult = (List) txTemplate .execute(new TransactionCallback() { + @Override public List doInTransaction(TransactionStatus status) { return getSession(false).createSQLQuery(sql).list(); } @@ -814,6 +786,7 @@ public class CoreDao extends HibernateDaoSupport { long start = System.currentTimeMillis(); List queryResult = (List) txTemplate .execute(new TransactionCallback() { + @Override public List doInTransaction(TransactionStatus status) { Criteria crit = getSession(false).createCriteria( @@ -848,6 +821,7 @@ public class CoreDao extends HibernateDaoSupport { long start = System.currentTimeMillis(); int updateResult = (Integer) txTemplate .execute(new TransactionCallback() { + @Override public Integer doInTransaction(TransactionStatus status) { return getSession(false).createSQLQuery(sql) .executeUpdate(); @@ -1143,13 +1117,4 @@ public class CoreDao extends HibernateDaoSupport { return getSessionFactory().getClassMetadata(daoClass); } } - - public void deleteAll(final List objs) { - txTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - getHibernateTemplate().deleteAll(objs); - } - }); - } } diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/DaoConfig.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/DaoConfig.java index 98486c5b91..a02bdaed73 100644 --- a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/DaoConfig.java +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/DaoConfig.java @@ -20,6 +20,11 @@ package com.raytheon.uf.edex.database.dao; +import org.hibernate.SessionFactory; +import org.springframework.orm.hibernate3.HibernateTransactionManager; + +import com.raytheon.uf.edex.core.EDEXUtil; + /** * Configuration settings for a data access object.
* This object contains the required information to correctly instantiate a @@ -31,14 +36,15 @@ package com.raytheon.uf.edex.database.dao; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * 12/11/07 600 bphillip Initial Check in - * + * 12/11/07 600 bphillip Initial Check in + * Oct 10, 2012 1261 djohnson Add ability for test overriding of bean lookups. + * * * * @author bphillip * @version 1 */ -public class DaoConfig { +public abstract class DaoConfig { /** The default database name */ public static final String DEFAULT_DB_NAME = "metadata"; @@ -49,6 +55,21 @@ public class DaoConfig { /** The transaction manager suffix */ private static final String TX_MANAGER = "TxManager"; + // @VisibleForTesting + static SpringBeanLocator DEFAULT_LOCATOR = new SpringBeanLocator() { + @Override + public T lookupBean(Class resultClass, String beanName) { + return resultClass.cast(EDEXUtil.getESBComponent(beanName)); + } + }; + + /** + * Used to locate Spring beans. By default, uses EDEXUtil to look them up. + * Package-level access for testing purposes. + */ + // @VisibleForTesting + static SpringBeanLocator locator = DEFAULT_LOCATOR; + /** * The default data access object configuration. This configuration * specifies the metadata database @@ -56,69 +77,27 @@ public class DaoConfig { public static final DaoConfig DEFAULT = DaoConfig .forDatabase(DEFAULT_DB_NAME); - /** The database to connect to */ - private String dbName; - - /** The class for which the desired data access object is to be used for */ - private Class daoClassName; - - /** The name of the Hibernate session factory to use */ - private String sessionFactoryName; - - /** The name of the Hibernate transaction manager to use */ - private String txManagerName; - /** - * Default constructor. - */ - private DaoConfig() { - this.dbName = DEFAULT_DB_NAME; - this.sessionFactoryName = DEFAULT_DB_NAME + SESSION_FACTORY; - this.txManagerName = DEFAULT_DB_NAME + TX_MANAGER; - } - - /** - * Constructs a DaoConfig object using the specified class name, default - * session factory, and the default transaction manager + * Retrieve the transaction manager. * - * @param className - * The class object + * @return the transaction manager */ - private DaoConfig(Class className) { - this.daoClassName = className; - this.dbName = DEFAULT_DB_NAME; - this.sessionFactoryName = DEFAULT_DB_NAME + SESSION_FACTORY; - this.txManagerName = DEFAULT_DB_NAME + TX_MANAGER; - } + public abstract HibernateTransactionManager getTxManager(); /** - * Constructs a DaoConfig object for the specified database using the - * specified class name. The appropriate session factory and transaction - * manager will be determined from the database name. + * Retrieve the session factory. * - * @param dbName - * The database name - * @param className - * The class object + * @return the session factory */ - private DaoConfig(String dbName, Class className) { - this.daoClassName = className; - this.dbName = dbName; - this.sessionFactoryName = dbName + SESSION_FACTORY; - this.txManagerName = dbName + TX_MANAGER; - } + public abstract SessionFactory getSessionFactory(); /** - * Constructs a DaoConfig object for the specified database. + * Retrieve the class type this DAO manages. * - * @param dbName - * The database name + * @return the class type */ - private DaoConfig(String dbName) { - this.dbName = dbName; - this.sessionFactoryName = dbName + SESSION_FACTORY; - this.txManagerName = dbName + TX_MANAGER; - } + public abstract Class getDaoClass(); + /** * Gets a DaoConfig object for the specified class using the default session @@ -130,7 +109,7 @@ public class DaoConfig { * factory and default transaction manager. */ public static DaoConfig forClass(Class className) { - return new DaoConfig(className); + return new SpringLookupDaoConfig(className); } /** @@ -146,8 +125,8 @@ public class DaoConfig { */ public static DaoConfig forClass(String className) throws ClassNotFoundException { - return new DaoConfig(DaoConfig.class.getClassLoader().loadClass( - ((String) className).trim())); + return new SpringLookupDaoConfig(DaoConfig.class.getClassLoader().loadClass( + (className).trim())); } /** @@ -161,7 +140,7 @@ public class DaoConfig { * name */ public static DaoConfig forClass(String dbName, Class className) { - return new DaoConfig(dbName, className); + return new SpringLookupDaoConfig(dbName, className); } /** @@ -178,8 +157,8 @@ public class DaoConfig { */ public static DaoConfig forClass(String dbName, String className) throws ClassNotFoundException { - return new DaoConfig(dbName, DaoConfig.class.getClassLoader() - .loadClass(((String) className).trim())); + return new SpringLookupDaoConfig(dbName, DaoConfig.class.getClassLoader() + .loadClass((className).trim())); } /** @@ -188,39 +167,87 @@ public class DaoConfig { * @return */ public static DaoConfig forDatabase(String dbName) { - return new DaoConfig(dbName); + return new SpringLookupDaoConfig(dbName); } - /** - * Gets the database name - * @return The database name - */ - public String getDbName() { - return dbName; - } + private static class SpringLookupDaoConfig extends DaoConfig { - /** - * Gets the dao class name - * @return The dao class name - */ - public Class getDaoClassName() { - return daoClassName; - } + /** The class for which the desired data access object is to be used for */ + private final Class daoClass; - /** - * Gets the session factory name - * @return The session factory name - */ - public String getSessionFactoryName() { - return sessionFactoryName; - } + /** The name of the Hibernate session factory to use */ + private final String sessionFactoryName; - /** - * Gets the transaction manager name - * @return The transaction manager name - */ - public String getTxManagerName() { - return txManagerName; - } + /** The name of the Hibernate transaction manager to use */ + private final String txManagerName; + /** + * Default constructor. + */ + private SpringLookupDaoConfig() { + this((Class) null); + } + + /** + * Constructs a DaoConfig object using the specified class name, default + * session factory, and the default transaction manager + * + * @param className + * The class object + */ + private SpringLookupDaoConfig(Class className) { + this(DEFAULT_DB_NAME, className); + } + + /** + * Constructs a DaoConfig object for the specified database. + * + * @param dbName + * The database name + */ + private SpringLookupDaoConfig(String dbName) { + this(dbName, null); + } + + /** + * Constructs a DaoConfig object for the specified database using the + * specified class name. The appropriate session factory and transaction + * manager will be determined from the database name. + * + * @param dbName + * The database name + * @param daoClass + * The class object + */ + private SpringLookupDaoConfig(String dbName, Class daoClass) { + this.daoClass = daoClass; + this.sessionFactoryName = dbName + SESSION_FACTORY; + this.txManagerName = dbName + TX_MANAGER; + } + + /** + * {@inheritDoc} + */ + @Override + public HibernateTransactionManager getTxManager() { + return locator.lookupBean(HibernateTransactionManager.class, + txManagerName); + } + + /** + * {@inheritDoc} + */ + @Override + public SessionFactory getSessionFactory() { + return locator.lookupBean(SessionFactory.class, sessionFactoryName); + } + + /** + * {@inheritDoc} + */ + @Override + public Class getDaoClass() { + return daoClass; + } + } } diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/SpringBeanLocator.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/SpringBeanLocator.java new file mode 100644 index 0000000000..bd3fc6e0fe --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/dao/SpringBeanLocator.java @@ -0,0 +1,52 @@ +/** + * 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.database.dao; + +/** + * Defines a strategy for looking up Spring beans. + * + *

+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 10, 2012 1261       djohnson     Initial creation
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public interface SpringBeanLocator { + + /** + * Lookup a Spring bean by its name. + * + * @param + * the result type + * @param resultClass + * the result class type + * @param beanName + * the bean name + * @return the looked up bean, or null, if not found + */ + T lookupBean(Class resultClass, String beanName); +} diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/plugin/PluginDao.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/plugin/PluginDao.java index dfe4f3618f..3ae6d3c559 100644 --- a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/plugin/PluginDao.java +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/plugin/PluginDao.java @@ -34,6 +34,10 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.geotools.coverage.grid.GridCoverage2D; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.referencing.FactoryException; +import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallbackWithoutResult; @@ -50,7 +54,13 @@ import com.raytheon.uf.common.datastorage.IDataStore.StoreOp; import com.raytheon.uf.common.datastorage.Request; import com.raytheon.uf.common.datastorage.StorageException; import com.raytheon.uf.common.datastorage.StorageStatus; +import com.raytheon.uf.common.datastorage.records.ByteDataRecord; +import com.raytheon.uf.common.datastorage.records.FloatDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.datastorage.records.IntegerDataRecord; +import com.raytheon.uf.common.geospatial.ISpatialEnabled; +import com.raytheon.uf.common.geospatial.ISpatialObject; +import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; @@ -70,6 +80,12 @@ import com.raytheon.uf.edex.database.purge.PurgeLogger; import com.raytheon.uf.edex.database.purge.PurgeRule; import com.raytheon.uf.edex.database.purge.PurgeRuleSet; import com.raytheon.uf.edex.database.query.DatabaseQuery; +import com.raytheon.uf.edex.database.spatial.DataReprojector; +import com.raytheon.uf.edex.database.spatial.ReferencedDataRecord; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.Polygon; /** * Abstract implementation of a Plugin data access object @@ -85,6 +101,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * 2/6/09 1990 bphillip Initial creation * 6/29/12 #828 dgilling Force getPurgeRulesForPlugin() * to search only COMMON_STATIC. + * Oct 10, 2012 1261 djohnson Add some generics wildcarding. * * * @author bphillip @@ -173,13 +190,14 @@ public abstract class PluginDao extends CoreDao { persistToDatabase(records); } + @SuppressWarnings("unchecked") public PluginDataObject[] persistToDatabase(PluginDataObject... records) { - List toPersist = new ArrayList(); + List> toPersist = new ArrayList>(); for (PluginDataObject record : records) { toPersist.add(record); } - List duplicates = mergeAll(toPersist); - for (PersistableDataObject pdo : duplicates) { + List> duplicates = mergeAll(toPersist); + for (PersistableDataObject pdo : duplicates) { logger.info("Discarding duplicate: " + ((PluginDataObject) (pdo)).getDataURI()); toPersist.remove(pdo); @@ -1468,4 +1486,130 @@ public abstract class PluginDao extends CoreDao { return (List) this.queryByCriteria(dbQuery); } + + public double getHDF5Value(PluginDataObject pdo, + CoordinateReferenceSystem crs, Coordinate coord, + double defaultReturn) throws Exception { + IDataStore store = getDataStore((IPersistable) pdo); + // TODO a cache would probably be good here + double rval = defaultReturn; + if (pdo instanceof ISpatialEnabled) { + ISpatialObject spat = getSpatialObject(pdo); + DataReprojector reprojector = getDataReprojector(store); + ReferencedEnvelope nativeEnv = getNativeEnvelope(spat); + IDataRecord data = reprojector.getProjectedPoints(pdo.getDataURI(), + spat, nativeEnv, crs, new Coordinate[] { coord }); + Double res = extractSingle(data); + if (res != null) { + rval = res; + } + } + return rval; + } + + /** + * @param record + * @param crs + * target crs for projected data + * @param envelope + * bounding box in target crs + * @return null if envelope is disjoint with data bounds + * @throws Exception + */ + public ReferencedDataRecord getProjected(PluginDataObject record, + CoordinateReferenceSystem crs, Envelope envelope) throws Exception { + ReferencedEnvelope targetEnv = new ReferencedEnvelope( + envelope.getMinX(), envelope.getMaxX(), envelope.getMinY(), + envelope.getMaxY(), crs); + return getProjected(record, targetEnv); + } + + /** + * @param record + * @param crs + * target crs for projected data + * @param envelope + * bounding box in target crs + * @return null if envelope is disjoint with data bounds + * @throws Exception + */ + public GridCoverage2D getProjectedCoverage(PluginDataObject record, + CoordinateReferenceSystem crs, Envelope envelope) throws Exception { + ReferencedEnvelope targetEnv = new ReferencedEnvelope( + envelope.getMinX(), envelope.getMaxX(), envelope.getMinY(), + envelope.getMaxY(), crs); + return getProjectedCoverage(record, targetEnv); + } + + /** + * @param record + * @param targetEnvelope + * bounding box in target crs + * @return null if envelope is disjoint with data bounds + * @throws Exception + */ + public ReferencedDataRecord getProjected(PluginDataObject record, + ReferencedEnvelope targetEnvelope) throws Exception { + ISpatialObject spatial = getSpatialObject(record); + IDataStore store = getDataStore((IPersistable) record); + DataReprojector reprojector = getDataReprojector(store); + ReferencedEnvelope nativeEnvelope = getNativeEnvelope(spatial); + return reprojector.getReprojected(record.getDataURI(), spatial, + nativeEnvelope, targetEnvelope); + } + + /** + * @param record + * @param targetEnvelope + * bounding box in target crs + * @return null if envelope is disjoint with data bounds + * @throws Exception + */ + public GridCoverage2D getProjectedCoverage(PluginDataObject record, + ReferencedEnvelope envelope) throws Exception { + ISpatialObject spatial = getSpatialObject(record); + IDataStore store = getDataStore((IPersistable) record); + DataReprojector reprojector = getDataReprojector(store); + ReferencedEnvelope nativeEnvelope = getNativeEnvelope(spatial); + return reprojector.getReprojectedCoverage(record.getDataURI(), spatial, + nativeEnvelope, envelope); + } + + protected ISpatialObject getSpatialObject(PluginDataObject record) + throws Exception { + if (record instanceof ISpatialEnabled) { + return ((ISpatialEnabled) record).getSpatialObject(); + } else { + throw new Exception(record.getClass() + " is not spatially enabled"); + } + } + + protected DataReprojector getDataReprojector(IDataStore dataStore) { + return new DataReprojector(dataStore); + } + + protected ReferencedEnvelope getNativeEnvelope(ISpatialObject spatial) + throws FactoryException { + CoordinateReferenceSystem crs = spatial.getCrs(); + Geometry geom = spatial.getGeometry(); + return MapUtil.getBoundingEnvelope(crs, (Polygon) geom); + } + + public Double extractSingle(IDataRecord record) { + Double rval = null; + if (record == null) { + return rval; + } + if (record instanceof ByteDataRecord) { + byte[] data = ((ByteDataRecord) record).getByteData(); + rval = (double) data[0]; + } else if (record instanceof FloatDataRecord) { + float[] data = ((FloatDataRecord) record).getFloatData(); + rval = (double) data[0]; + } else if (record instanceof IntegerDataRecord) { + int[] data = ((IntegerDataRecord) record).getIntData(); + rval = (double) data[0]; + } + return rval; + } } diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/purge/PurgeRuleSet.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/purge/PurgeRuleSet.java index b1b6532c25..f199b49244 100644 --- a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/purge/PurgeRuleSet.java +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/purge/PurgeRuleSet.java @@ -20,7 +20,7 @@ package com.raytheon.uf.edex.database.purge; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; @@ -63,7 +63,7 @@ public class PurgeRuleSet implements ISerializableObject { * List of purge rules for/from the XML. */ @XmlElements({ @XmlElement(name = "rule", type = PurgeRule.class) }) - private ArrayList rules; + private List rules; private PurgeRuleTree purgeTree = null; @@ -88,11 +88,11 @@ public class PurgeRuleSet implements ISerializableObject { * * @return */ - public ArrayList getRules() { - return rules; + public List getRules() { + return (rules == null) ? Collections. emptyList() : rules; } - public void setRules(ArrayList rules) { + public void setRules(List rules) { this.rules = rules; } diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/purge/PurgeRuleTree.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/purge/PurgeRuleTree.java index caadc1ee75..97ba76bc4d 100644 --- a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/purge/PurgeRuleTree.java +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/purge/PurgeRuleTree.java @@ -19,7 +19,6 @@ */ package com.raytheon.uf.edex.database.purge; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -49,7 +48,7 @@ public class PurgeRuleTree { public PurgeRuleTree(PurgeRuleSet ruleSet) { root = new PurgeNode(); root.setRule(ruleSet.getDefaultRule()); - ArrayList rules = ruleSet.getRules(); + List rules = ruleSet.getRules(); if (rules != null) { for (PurgeRule rule : rules) { PurgeNode curNode = root; diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/AbstractDataReprojector.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/AbstractDataReprojector.java new file mode 100644 index 0000000000..12cb58776c --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/AbstractDataReprojector.java @@ -0,0 +1,150 @@ +/* + * The following software products were developed by Raytheon: + * + * ADE (AWIPS Development Environment) software + * CAVE (Common AWIPS Visualization Environment) software + * EDEX (Environmental Data Exchange) software + * uFrameâ„¢ (Universal Framework) software + * + * Copyright (c) 2010 Raytheon Co. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/epl-v10.php + * + * + * Contractor Name: Raytheon Company + * Contractor Address: + * 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Jun 15, 2011 bclement Initial creation + * + */ +package com.raytheon.uf.edex.database.spatial; + +import java.awt.image.DataBuffer; +import java.awt.image.WritableRaster; + +import javax.media.jai.RasterFactory; + +import org.geotools.coverage.grid.GridCoverage2D; +import org.geotools.coverage.grid.GridCoverageFactory; +import org.geotools.geometry.jts.ReferencedEnvelope; + +import com.raytheon.uf.common.datastorage.Request; +import com.raytheon.uf.common.datastorage.records.IDataRecord; + +/** + * + * @author bclement + * @version 1.0 + */ +public abstract class AbstractDataReprojector { + + public static class RequestWrapper { + public Request req; + public ReferencedEnvelope env; + } + + /** + * Copy data record into geotools grid coverage object + * + * @param dataRecord + * datset + * @param env + * geographics bounds for dataset + * @return + * @throws Exception + */ + protected abstract GridCoverage2D getGridCoverage(IDataRecord dataRecord, + ReferencedEnvelope env) throws Exception; + + /** + * Copy data record into geotools grid coverage object + * + * @param dataRecord + * datset + * @param env + * geographics bounds for dataset + * @return + * @throws Exception + */ + protected abstract GridCoverage2D getMaskCoverage(IDataRecord dataRecord, + ReferencedEnvelope env) throws Exception; + + /** + * Extract data from geotools coverage object into data record object + * + * @param coverage + * @return + */ + protected abstract T extractData(GridCoverage2D coverage); + + /** + * Extract data from geotools coverage object into data record object with a + * mask for covering the non-data area. + * + * @param coverage + * @param maskCoverage + * @return + */ + protected abstract T extractData(GridCoverage2D coverage, + GridCoverage2D maskCoverage); + + /** + * Apply slab request to data record, returning result in a new data record + * object. + * + * @param dataRecord + * @param req + * @return + */ + protected abstract T getDataSlice(IDataRecord dataRecord, Request req); + + /** + * @param dataRecord + * @return true if this object can operate on native type of data record + */ + protected abstract boolean compatible(IDataRecord dataRecord); + + /** + * Apply point request to data record, returning result in a new data record + * object. + * + * @param record + * @param req + * @return + */ + protected abstract IDataRecord getDataPoints(IDataRecord record, Request req); + + /** + * Construct a new geotools grid coverage object using data buffer + * + * @param name + * name of coverage + * @param data + * raw data + * @param width + * @param height + * @param env + * geographic bounds of coverage + * @return + * @throws Exception + */ + public static GridCoverage2D constructGridCoverage(String name, + DataBuffer data, int width, int height, ReferencedEnvelope env) + throws Exception { + WritableRaster raster = RasterFactory.createBandedRaster(data, width, + height, width, new int[] { 0 }, new int[] { 0 }, null); + return new GridCoverageFactory().create(name, raster, env); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/ByteDataReprojector.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/ByteDataReprojector.java new file mode 100644 index 0000000000..e54ccb96b9 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/ByteDataReprojector.java @@ -0,0 +1,238 @@ +/* + * The following software products were developed by Raytheon: + * + * ADE (AWIPS Development Environment) software + * CAVE (Common AWIPS Visualization Environment) software + * EDEX (Environmental Data Exchange) software + * uFrameâ„¢ (Universal Framework) software + * + * Copyright (c) 2010 Raytheon Co. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/epl-v10.php + * + * + * Contractor Name: Raytheon Company + * Contractor Address: + * 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * May 18, 2011 bclement Initial creation + * + */ +package com.raytheon.uf.edex.database.spatial; + +import java.awt.Point; +import java.awt.image.DataBufferByte; +import java.awt.image.Raster; +import java.awt.image.RenderedImage; +import java.util.Arrays; + +import org.geotools.coverage.grid.GridCoverage2D; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.raytheon.uf.common.datastorage.Request; +import com.raytheon.uf.common.datastorage.records.ByteDataRecord; +import com.raytheon.uf.common.datastorage.records.IDataRecord; + +/** + * + * @author bclement + * @version 1.0 + */ +public class ByteDataReprojector extends + AbstractDataReprojector { + + protected byte fill = 0; + + protected byte dataMaskValue = -1; + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getGridCoverage + * (com.raytheon.uf.common.datastorage.records.IDataRecord, + * org.opengis.referencing.crs.CoordinateReferenceSystem, + * org.opengis.geometry.Envelope) + */ + @Override + protected GridCoverage2D getGridCoverage(IDataRecord record, + ReferencedEnvelope env) + throws Exception { + ByteDataRecord dataRecord = (ByteDataRecord) record; + byte[] data = dataRecord.getByteData(); + DataBufferByte buff = new DataBufferByte(data, data.length); + int x = (int) dataRecord.getSizes()[0]; + int y = (int) dataRecord.getSizes()[1]; + CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem(); + return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getMaskCoverage + * (com.raytheon.uf.common.datastorage.records.IDataRecord, + * org.opengis.referencing.crs.CoordinateReferenceSystem, + * org.opengis.geometry.Envelope) + */ + @Override + protected GridCoverage2D getMaskCoverage(IDataRecord record, + ReferencedEnvelope env) throws Exception { + int x = (int) record.getSizes()[0]; + int y = (int) record.getSizes()[1]; + byte[] mask = new byte[x * y]; + Arrays.fill(mask, dataMaskValue); + DataBufferByte buff = new DataBufferByte(mask, mask.length); + CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem(); + return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#extractData(org + * .geotools.coverage.grid.GridCoverage2D) + */ + @Override + protected ByteDataRecord extractData(GridCoverage2D coverage) { + RenderedImage image = coverage.getRenderedImage(); + Raster raster; + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer(); + byte[] data = dataBuffer.getData(); + int height = raster.getHeight(); + int width = raster.getWidth(); + return new ByteDataRecord("", "", data, 2, new long[] { width, height }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#extractData(org + * .geotools.coverage.grid.GridCoverage2D, + * org.geotools.coverage.grid.GridCoverage2D) + */ + @Override + protected ByteDataRecord extractData(GridCoverage2D coverage, + GridCoverage2D maskCoverage) { + RenderedImage image = coverage.getRenderedImage(); + Raster raster; + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer(); + byte[] data = dataBuffer.getData(); + + // Extract mask + image = maskCoverage.getRenderedImage(); + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + dataBuffer = (DataBufferByte) raster.getDataBuffer(); + byte[] mask = dataBuffer.getData(); + + if (mask.length == data.length) { + for (int i = 0; i < data.length; ++i) { + if (mask[i] != dataMaskValue) { + data[i] = fill; + } + } + } + + int height = raster.getHeight(); + int width = raster.getWidth(); + return new ByteDataRecord("", "", data, 2, new long[] { width, height }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getDataSlice(com + * .raytheon.uf.common.datastorage.records.IDataRecord, + * com.raytheon.uf.common.datastorage.Request) + */ + @Override + protected ByteDataRecord getDataSlice(IDataRecord record, Request req) { + ByteDataRecord dataRecord = (ByteDataRecord) record; + int[] max = req.getMaxIndexForSlab(); + int[] min = req.getMinIndexForSlab(); + int toWidth = max[0] - min[0]; + int toHeight = max[1] - min[1]; + byte[] from = dataRecord.getByteData(); + int fromWidth = (int) dataRecord.getSizes()[0]; + byte[] to = new byte[toWidth * toHeight]; + for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) { + int toRow = toY * toWidth; + int fromRow = fromY * fromWidth; + for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) { + to[toRow + toX] = from[fromRow + fromX]; + } + } + long[] sizes = { toWidth, toHeight }; + return new ByteDataRecord("", "", to, 2, sizes); + } + + public byte getFill() { + return fill; + } + + public void setFill(byte fill) { + this.fill = fill; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.AbstractDataReprojector#compatible + * (com.raytheon.uf.common.datastorage.records.IDataRecord) + */ + @Override + protected boolean compatible(IDataRecord dataRecord) { + return dataRecord instanceof ByteDataRecord; + } + + @Override + protected IDataRecord getDataPoints(IDataRecord record, Request req) { + ByteDataRecord dataRecord = (ByteDataRecord) record; + byte[] from = dataRecord.getByteData(); + int fromWidth = (int) dataRecord.getSizes()[0]; + Point[] points = req.getPoints(); + byte[] to = new byte[points.length]; + for (int i = 0; i < to.length; ++i) { + Point p = points[i]; + to[i] = from[p.y * fromWidth + p.x]; + } + return new ByteDataRecord("", "", to, 1, new long[] { to.length }); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/DataReprojector.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/DataReprojector.java new file mode 100644 index 0000000000..450e6ee17d --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/DataReprojector.java @@ -0,0 +1,624 @@ +/* + * The following software products were developed by Raytheon: + * + * ADE (AWIPS Development Environment) software + * CAVE (Common AWIPS Visualization Environment) software + * EDEX (Environmental Data Exchange) software + * uFrameâ„¢ (Universal Framework) software + * + * Copyright (c) 2010 Raytheon Co. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/epl-v10.php + * + * + * Contractor Name: Raytheon Company + * Contractor Address: + * 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * May 18, 2011 bclement Initial creation + * + */ +package com.raytheon.uf.edex.database.spatial; + +import java.awt.Point; +import java.io.FileNotFoundException; +import java.util.Iterator; +import java.util.Set; + +import javax.media.jai.Interpolation; + +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.geotools.coverage.grid.GeneralGridEnvelope; +import org.geotools.coverage.grid.GridCoordinates2D; +import org.geotools.coverage.grid.GridCoverage2D; +import org.geotools.coverage.grid.GridGeometry2D; +import org.geotools.coverage.grid.ViewType; +import org.geotools.coverage.processing.Operations; +import org.geotools.geometry.DirectPosition2D; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.geometry.DirectPosition; +import org.opengis.geometry.MismatchedDimensionException; +import org.opengis.metadata.spatial.PixelOrientation; +import org.opengis.referencing.FactoryException; +import org.opengis.referencing.ReferenceIdentifier; +import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.referencing.operation.MathTransform2D; +import org.opengis.referencing.operation.TransformException; + +import com.raytheon.uf.common.dataplugin.PluginException; +import com.raytheon.uf.common.datastorage.IDataStore; +import com.raytheon.uf.common.datastorage.Request; +import com.raytheon.uf.common.datastorage.StorageException; +import com.raytheon.uf.common.datastorage.records.ByteDataRecord; +import com.raytheon.uf.common.datastorage.records.FloatDataRecord; +import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.datastorage.records.IntegerDataRecord; +import com.raytheon.uf.common.datastorage.records.ShortDataRecord; +import com.raytheon.uf.common.geospatial.ISpatialObject; +import com.raytheon.uf.common.geospatial.MapUtil; +import com.raytheon.uf.edex.database.spatial.AbstractDataReprojector.RequestWrapper; +import com.raytheon.uf.edex.database.spatial.KeyLocker.KeyLock; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Envelope; + +/** + * + * @author bclement + * @version 1.0 + */ +public class DataReprojector { + + protected IDataStore dataStore; + + protected String dataSetBase = "Data-"; + + protected String dataSet = "Data"; + + private AbstractDataReprojector _typeProjector; + + protected static Log log = LogFactory.getLog(DataReprojector.class); + + protected static KeyLocker locker = new KeyLocker(); + + public DataReprojector(IDataStore dataStore) { + this.dataStore = dataStore; + } + + /** + * @param group + * name of the datastore group that contains requested dataset + * @param spatial + * spatial object tied to requested dataset + * @param nativeEnv + * native bounds of dataset + * @param crs + * desired crs of returned data + * @param coords + * coordinates of requested data in requested crs + * @return null if any of the coordinates are out of the bounds of the grid + * geometry + * @throws Exception + */ + public IDataRecord getProjectedPoints(String group, ISpatialObject spatial, + ReferencedEnvelope nativeEnv, CoordinateReferenceSystem crs, + Coordinate[] coords) throws Exception { + // get envelope in requested projection + ReferencedEnvelope targetEnv = nativeEnv.transform(crs, true); + // get target grid geometry + GridGeometry2D geom = getGridGeometry(targetEnv, spatial.getNx(), + spatial.getNy()); + Point[] points = new Point[coords.length]; + for (int i = 0; i < points.length; ++i) { + Coordinate coord = coords[i]; + GridCoordinates2D point = getGridPoint(geom, coord); + int nx = spatial.getNx(); + int ny = spatial.getNy(); + // coordinate was out of bounds, bail + if (point.x < 0 || point.x > nx || point.y < 0 || point.y > ny) { + return null; + } + // need to repackage point due to pypies not knowing about + // gridcoordinates2d + points[i] = new Point(point); + } + String reprojectedDataset = buildDatasetName(crs); + Request req = Request.buildPointRequest(points); + return getDataRecordWithReproject(group, reprojectedDataset, spatial, + crs, req); + } + + /** + * @param group + * name of the datastore group that contains requested dataset + * @param reprojectedDataset + * dataset name for reprojected data + * @param spatial + * spatial object tied to requested dataset + * @param crs + * desired crs of returned data + * @param req + * datastore request object + * @return + * @throws Exception + */ + protected IDataRecord getDataRecordWithReproject(String group, + String reprojectedDataset, ISpatialObject spatial, + CoordinateReferenceSystem crs, Request req) throws Exception { + IDataRecord dataRecord; + // check if data has already been reprojected + if (!datasetExists(group, reprojectedDataset)) { + // it hasn't lock and reproject + dataRecord = reprojectLocked(group, reprojectedDataset, spatial, + crs, req); + } else { + // it has, just request the data + dataRecord = getDataRecord(group, reprojectedDataset, req); + } + return dataRecord; + } + + /** + * @param group + * name of the datastore group that contains requested dataset + * @param reprojectedDataset + * dataset name for reprojected data + * @param spatial + * spatial object tied to requested dataset + * @param crs + * desired crs of returned data + * @param req + * datastore request object + * @return + * @throws Exception + */ + protected IDataRecord reprojectLocked(String group, + String reprojectedDataset, ISpatialObject spatial, + CoordinateReferenceSystem crs, Request req) throws Exception { + KeyLock lock = null; + IDataRecord dataRecord; + try { + // get reproject lock + lock = locker.getLock(group + reprojectedDataset); + lock.lock(); + // recheck that dataset still doesn't exist + if (!datasetExists(group, reprojectedDataset)) { + // still not there, reproject + dataRecord = reprojectAndStore(spatial, group, crs, req); + } else { + // another thread created it, just grab it + dataRecord = getDataRecord(group, reprojectedDataset, req); + } + lock.unlock(); + return dataRecord; + } finally { + if (lock != null) { + lock.release(); + } + } + } + + /** + * @param group + * @param dataset + * @return true if dataset exists in datastore + * @throws FileNotFoundException + * @throws StorageException + */ + protected boolean datasetExists(String group, String dataset) + throws FileNotFoundException, StorageException { + String[] datasets = dataStore.getDatasets(group); + return ArrayUtils.contains(datasets, dataset); + } + + /** + * @param geom + * Grid geometry + * @param coord + * desired geographic coordinate + * @return grid point for coordinate + * @throws PluginException + */ + public static GridCoordinates2D getGridPoint(GridGeometry2D geom, + Coordinate coord) throws PluginException { + DirectPosition src = new DirectPosition2D(coord.x, coord.y); + DirectPosition inGrid = new DirectPosition2D(); + try { + MathTransform2D crsToGrid2D = geom + .getCRSToGrid2D(PixelOrientation.UPPER_LEFT); + crsToGrid2D.transform(src, inGrid); + } catch (Exception e) { + throw new PluginException("Unable to get grid point for geometry", + e); + } + // floor of grid points should be upper left of pixel + int x = (int) Math.floor(inGrid.getOrdinate(0)); + int y = (int) Math.floor(inGrid.getOrdinate(1)); + GridCoordinates2D rval = new GridCoordinates2D(x, y); + return rval; + } + + /** + * @param group + * name of the datastore group that contains requested dataset + * @param spatial + * spatial object tied to requested dataset + * @param nativeEnv + * native bounds of dataset + * @param targetEnv + * bounds of requested data + * @return null if target envelope is out of bounds for dataset + * @throws Exception + */ + public GridCoverage2D getReprojectedCoverage(String group, + ISpatialObject spatial, ReferencedEnvelope nativeEnv, + ReferencedEnvelope targetEnv) + throws Exception { + ReferencedDataRecord rep = getReprojected(group, spatial, nativeEnv, + targetEnv); + if (rep == null) { + return null; + } + ReferencedEnvelope re = rep.getEnvelope(); + IDataRecord record = rep.getRecord(); + return getTypeProjector(record).getGridCoverage(rep.getRecord(), re); + } + + /** + * @param group + * name of the datastore group that contains requested dataset + * @param spatial + * spatial object tied to requested dataset + * @param nativeEnvelope + * native bounds of dataset + * @param targetEnvelope + * bounds of requested data + * @return null if target envelope is out of bounds for dataset + * @throws Exception + */ + public ReferencedDataRecord getReprojected(String group, + ISpatialObject spatial, ReferencedEnvelope nativeEnvelope, + ReferencedEnvelope targetEnvelope) + throws Exception { + RequestWrapper req = getRequest(spatial, nativeEnvelope, targetEnvelope); + if (req == null) { + return null; + } + CoordinateReferenceSystem targetCrs = targetEnvelope + .getCoordinateReferenceSystem(); + String reprojectedDataset = buildDatasetName(targetCrs); + IDataRecord dataRecord = getDataRecordWithReproject(group, + reprojectedDataset, spatial, targetCrs, req.req); + return new ReferencedDataRecord(dataRecord, req.env); + } + + /** + * @param group + * name of the datastore group that contains requested dataset + * @param targetDataset + * dataset name for requested data + * @param req + * datastore request object + * @return + * @throws Exception + */ + protected IDataRecord getDataRecord(String group, String targetDataset, + Request req) throws Exception { + IDataRecord rval = dataStore.retrieve(group, targetDataset, req); + return rval; + } + + /** + * Get a projector that is compatible with record + * + * @param record + * @return + * @throws Exception + */ + protected AbstractDataReprojector getTypeProjector( + IDataRecord record) throws Exception { + if (_typeProjector == null || !_typeProjector.compatible(record)) { + if (record instanceof ByteDataRecord) { + _typeProjector = new ByteDataReprojector(); + } else if (record instanceof FloatDataRecord) { + _typeProjector = new FloatDataReprojector(); + } else if (record instanceof ShortDataRecord) { + _typeProjector = new ShortDataReprojector(); + } else if (record instanceof IntegerDataRecord) { + _typeProjector = new IntDataReprojector(); + } else { + throw new Exception("Unsupported data store type"); + } + } + return _typeProjector; + } + + /** + * Gets the entire coverage from the store and reprojects it. Reprojected + * coverage is then stored under a name derived from the projected crs. + * + * @param spatial + * spatial object tied to requested dataset + * @param group + * name of the datastore group that contains requested dataset + * @param targetCRS + * desired crs of returned data + * @param req + * datastore request object + * @return datarecord as per the request object + * @throws Exception + */ + protected IDataRecord reprojectAndStore(ISpatialObject spatial, + String group, CoordinateReferenceSystem targetCRS, Request req) + throws Exception { + GridGeometry2D geom = MapUtil.getGridGeometry(spatial); + IDataRecord original = getDataRecord(group, dataSet, Request.ALL); + ReferencedEnvelope env = new ReferencedEnvelope(geom.getEnvelope()); + AbstractDataReprojector typeProjector = getTypeProjector(original); + GridCoverage2D cov = typeProjector.getGridCoverage(original, env); + GridCoverage2D reprojected = MapUtil.reprojectCoverage(cov, targetCRS); + IDataRecord rval; + + if (typeProjector instanceof FloatDataReprojector) { + // TODO So far, the problem that this fixes has only appeared with + // float data. If it happens with other data we can change this. + GridCoverage2D maskCov = typeProjector.getMaskCoverage(original, + env); + GridCoverage2D reprojectedMask = (GridCoverage2D) Operations.DEFAULT + .resample(maskCov.view(ViewType.GEOPHYSICS), targetCRS, + null, Interpolation + .getInstance(Interpolation.INTERP_NEAREST)); + rval = typeProjector.extractData(reprojected, reprojectedMask); + } else { + rval = typeProjector.extractData(reprojected); + } + + rval.setGroup(group); + rval.setName(buildDatasetName(targetCRS)); + dataStore.addDataRecord(rval); + dataStore.store(); + return getDataPerReq(rval, req); + } + + /** + * @param record + * data record containing full coverage + * @param req + * datastore request object + * @return result of applying request object to data record + * @throws Exception + */ + protected IDataRecord getDataPerReq(IDataRecord record, Request req) + throws Exception { + AbstractDataReprojector typeProjector = getTypeProjector(record); + IDataRecord rval; + switch (req.getType()) { + case ALL: + rval = record; + break; + case POINT: + rval = typeProjector.getDataPoints(record, req); + break; + case SLAB: + rval = typeProjector.getDataSlice(record, req); + break; + case XLINE: + case YLINE: + default: + throw new Exception("Data reprojector " + req.getType() + + " not implemented"); + } + return rval; + } + + /** + * @param env + * geographic bounds of data + * @param nx + * length of x axis + * @param ny + * length of y axis + * @return + */ + public static GridGeometry2D getGridGeometry(ReferencedEnvelope env, + int nx, int ny) { + // TODO cache + GridGeometry2D mapGeom = null; + mapGeom = new GridGeometry2D(new GeneralGridEnvelope( + new int[] { 0, 0 }, new int[] { nx, ny }, false), env); + return mapGeom; + } + + /** + * Build up slice request for reprojected dataset + * + * @param record + * @param crs + * @param targetEnvelope + * bbox in crs + * @return null if envelope is outside of data bounds + * @throws TransformException + * @throws MismatchedDimensionException + * @throws FactoryException + */ + protected RequestWrapper getRequest(ISpatialObject spatial, + ReferencedEnvelope nativeEnv, ReferencedEnvelope targetEnvelope) + throws MismatchedDimensionException, + TransformException, FactoryException { + RequestWrapper rval = null; + CoordinateReferenceSystem targetCrs = targetEnvelope + .getCoordinateReferenceSystem(); + // get full bounds of reprojected dataset + ReferencedEnvelope dataEnv = nativeEnv.transform(targetCrs, true); + if (!dataEnv.intersects((Envelope) targetEnvelope)) { + // request and data envelopes are disjoint, return null + return null; + } + // get grid geometry for reprojected dataset + GridGeometry2D geom = getGridGeometry(dataEnv, spatial.getNx(), + spatial.getNy()); + int[] dims = { spatial.getNx(), spatial.getNy() }; + if (dataEnv.contains((Envelope) targetEnvelope)) { + // requested slice is entirely inside data bounds + // build slice based on requested bounds + rval = getSubSlice(geom, targetEnvelope, dims); + } else { + // build slice based on intersection + Envelope intersection = targetEnvelope.intersection(dataEnv); + rval = getSubSlice(geom, intersection, dims); + } + return rval; + } + + /** + * @param geom + * grid geometry for projected dataset + * @param env + * geographic bounds for slice + * @param dims + * dimensions of dataset + * @return grid slice that corresponds to env + * @throws MismatchedDimensionException + * @throws TransformException + */ + protected RequestWrapper getSubSlice(GridGeometry2D geom, Envelope env, + int[] dims) throws MismatchedDimensionException, TransformException { + RequestWrapper rval = new RequestWrapper(); + MathTransform2D crsToGrid2D = geom + .getCRSToGrid2D(PixelOrientation.UPPER_LEFT); + // find a slice that has data for entire envelope (can have extra) + int[][] minmax = transformEnv(crsToGrid2D, env, dims); + MathTransform2D gridToCrs = crsToGrid2D.inverse(); + // find an envelope that matches the slice (could be a bit larger than + // previous envelope) + rval.env = transformGrid(gridToCrs, minmax, + geom.getCoordinateReferenceSystem()); + rval.req = Request.buildSlab(minmax[0], minmax[1]); + return rval; + } + + /** + * @param gridToCrs + * @param minmax + * 2d array holding slice + * @param crs + * @return + * @throws MismatchedDimensionException + * @throws TransformException + */ + protected ReferencedEnvelope transformGrid(MathTransform2D gridToCrs, + int[][] minmax, CoordinateReferenceSystem crs) + throws MismatchedDimensionException, TransformException { + int[] min = minmax[0]; + int[] max = minmax[1]; + DirectPosition lower = new DirectPosition2D(min[0], min[1]); + DirectPosition upper = new DirectPosition2D(max[0], max[1]); + DirectPosition lowerCrs = gridToCrs.transform(lower, null); + DirectPosition upperCrs = gridToCrs.transform(upper, null); + double x0 = lowerCrs.getOrdinate(0); + double x1 = upperCrs.getOrdinate(0); + // handle y axis flip + double y0 = upperCrs.getOrdinate(1); + double y1 = lowerCrs.getOrdinate(1); + return new ReferencedEnvelope(x0, x1, y0, y1, crs); + } + + /** + * transforms crs coordinates to grid indexes using given math transform + * + * @param crsToGrid + * @param env + * @param dims + * max bounds to be limited to + * @return an array with [[minx, miny], [maxx, maxy]] + * @throws MismatchedDimensionException + * @throws TransformException + */ + protected int[][] transformEnv(MathTransform2D crsToGrid, Envelope env, + int[] dims) throws MismatchedDimensionException, TransformException { + DirectPosition lower = new DirectPosition2D(env.getMinX(), + env.getMinY()); + DirectPosition upper = new DirectPosition2D(env.getMaxX(), + env.getMaxY()); + DirectPosition lowerGrid = crsToGrid.transform(lower, null); + DirectPosition upperGrid = crsToGrid.transform(upper, null); + int x0 = (int) Math.floor(lowerGrid.getOrdinate(0)); + // we want ceiling since slices are inclusive + int x1 = (int) Math.ceil(upperGrid.getOrdinate(0)); + // handle y axis flip + int y0 = (int) Math.floor(upperGrid.getOrdinate(1)); + // we want ceiling since slices are inclusive + int y1 = (int) Math.ceil(lowerGrid.getOrdinate(1)); + // truncate requests to dataset dimensions + if (x0 < 0) { + x0 = 0; + } + if (y0 < 0) { + y0 = 0; + } + if (x1 > dims[0]) { + x1 = dims[0]; + } + if (y1 > dims[1]) { + y1 = dims[1]; + } + return new int[][] { { x0, y0 }, { x1, y1 } }; + } + + /** + * construct the dataset name based on the name of the crs. + * + * @param crs + * @return + */ + protected String buildDatasetName(CoordinateReferenceSystem crs) { + Set ids = crs.getIdentifiers(); + String code; + if (ids == null || ids.isEmpty()) { + code = crs.getName().toString(); + } else { + Iterator i = ids.iterator(); + code = i.next().toString(); + while (i.hasNext()) { + code += "-" + i.next().toString(); + } + } + return dataSetBase + code; + } + + public IDataStore getDataStore() { + return dataStore; + } + + public void setDataStore(IDataStore dataStore) { + this.dataStore = dataStore; + } + + public String getDataSetBase() { + return dataSetBase; + } + + public void setDataSetBase(String dataSetBase) { + this.dataSetBase = dataSetBase; + } + + public String getDataSet() { + return dataSet; + } + + public void setDataSet(String dataSet) { + this.dataSet = dataSet; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/FloatDataReprojector.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/FloatDataReprojector.java new file mode 100644 index 0000000000..626fdde857 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/FloatDataReprojector.java @@ -0,0 +1,246 @@ +/* + * The following software products were developed by Raytheon: + * + * ADE (AWIPS Development Environment) software + * CAVE (Common AWIPS Visualization Environment) software + * EDEX (Environmental Data Exchange) software + * uFrameâ„¢ (Universal Framework) software + * + * Copyright (c) 2010 Raytheon Co. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/epl-v10.php + * + * + * Contractor Name: Raytheon Company + * Contractor Address: + * 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Jun 13, 2011 bclement Initial creation + * + */ +package com.raytheon.uf.edex.database.spatial; + +import java.awt.Point; +import java.awt.image.DataBufferFloat; +import java.awt.image.Raster; +import java.awt.image.RenderedImage; +import java.util.Arrays; + +import org.geotools.coverage.grid.GridCoverage2D; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.raytheon.uf.common.datastorage.Request; +import com.raytheon.uf.common.datastorage.records.FloatDataRecord; +import com.raytheon.uf.common.datastorage.records.IDataRecord; + +/** + * + * @author bclement + * @version 1.0 + */ +public class FloatDataReprojector extends + AbstractDataReprojector { + + protected float fill = -999999.0f; + + protected float dataMaskValue = -0; + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getGridCoverage + * (com.raytheon.uf.common.datastorage.records.IDataRecord, + * org.opengis.referencing.crs.CoordinateReferenceSystem, + * org.opengis.geometry.Envelope) + */ + @Override + protected GridCoverage2D getGridCoverage(IDataRecord record, + ReferencedEnvelope env) throws Exception { + FloatDataRecord dataRecord = (FloatDataRecord) record; + float[] data = dataRecord.getFloatData(); + DataBufferFloat buff = new DataBufferFloat(data, data.length); + int x = (int) dataRecord.getSizes()[0]; + int y = (int) dataRecord.getSizes()[1]; + CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem(); + return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getMaskCoverage + * (com.raytheon.uf.common.datastorage.records.IDataRecord, + * org.opengis.referencing.crs.CoordinateReferenceSystem, + * org.opengis.geometry.Envelope) + */ + @Override + protected GridCoverage2D getMaskCoverage(IDataRecord record, + ReferencedEnvelope env) throws Exception { + int x = (int) record.getSizes()[0]; + int y = (int) record.getSizes()[1]; + float[] mask = new float[x * y]; + Arrays.fill(mask, dataMaskValue); + DataBufferFloat buff = new DataBufferFloat(mask, mask.length); + CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem(); + return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#extractData(org + * .geotools.coverage.grid.GridCoverage2D) + */ + @Override + protected FloatDataRecord extractData(GridCoverage2D coverage) { + RenderedImage image = coverage.getRenderedImage(); + Raster raster; + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + DataBufferFloat dataBuffer = (DataBufferFloat) raster.getDataBuffer(); + float[] data = dataBuffer.getData(); + int height = raster.getHeight(); + int width = raster.getWidth(); + return new FloatDataRecord("", "", data, 2, + new long[] { width, height }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#extractData(org + * .geotools.coverage.grid.GridCoverage2D, + * org.geotools.coverage.grid.GridCoverage2D) + */ + @Override + protected FloatDataRecord extractData(GridCoverage2D coverage, + GridCoverage2D maskCoverage) { + RenderedImage image = coverage.getRenderedImage(); + Raster raster; + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + DataBufferFloat dataBuffer = (DataBufferFloat) raster.getDataBuffer(); + float[] data = dataBuffer.getData(); + + // Extract mask + image = maskCoverage.getRenderedImage(); + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + dataBuffer = (DataBufferFloat) raster.getDataBuffer(); + float[] mask = dataBuffer.getData(); + + if (mask.length == data.length) { + for (int i = 0; i < data.length; ++i) { + if (mask[i] != dataMaskValue) { + data[i] = fill; + } + } + } + + int height = raster.getHeight(); + int width = raster.getWidth(); + return new FloatDataRecord("", "", data, 2, + new long[] { width, height }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getDataSlice(com + * .raytheon.uf.common.datastorage.records.IDataRecord, + * com.raytheon.uf.common.datastorage.Request) + */ + @Override + protected FloatDataRecord getDataSlice(IDataRecord record, Request req) { + FloatDataRecord dataRecord = (FloatDataRecord) record; + int[] max = req.getMaxIndexForSlab(); + int[] min = req.getMinIndexForSlab(); + int toWidth = max[0] - min[0]; + int toHeight = max[1] - min[1]; + float[] from = dataRecord.getFloatData(); + int fromWidth = (int) dataRecord.getSizes()[0]; + float[] to = new float[toWidth * toHeight]; + for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) { + int toRow = toY * toWidth; + int fromRow = fromY * fromWidth; + for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) { + to[toRow + toX] = from[fromRow + fromX]; + } + } + long[] sizes = { toWidth, toHeight }; + return new FloatDataRecord("", "", to, 2, sizes); + } + + /** + * @return the fill + */ + public float getFill() { + return fill; + } + + /** + * @param fill + * the fill to set + */ + public void setFill(float fill) { + this.fill = fill; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.AbstractDataReprojector#compatible + * (com.raytheon.uf.common.datastorage.records.IDataRecord) + */ + @Override + protected boolean compatible(IDataRecord dataRecord) { + return dataRecord instanceof FloatDataRecord; + } + + @Override + protected IDataRecord getDataPoints(IDataRecord record, Request req) { + FloatDataRecord dataRecord = (FloatDataRecord) record; + float[] from = dataRecord.getFloatData(); + int fromWidth = (int) dataRecord.getSizes()[0]; + Point[] points = req.getPoints(); + float[] to = new float[points.length]; + for (int i = 0; i < to.length; ++i) { + Point p = points[i]; + to[i] = from[p.y * fromWidth + p.x]; + } + return new FloatDataRecord("", "", to, 1, new long[] { to.length }); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/IntDataReprojector.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/IntDataReprojector.java new file mode 100644 index 0000000000..a2452012ec --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/IntDataReprojector.java @@ -0,0 +1,247 @@ +/* + * The following software products were developed by Raytheon: + * + * ADE (AWIPS Development Environment) software + * CAVE (Common AWIPS Visualization Environment) software + * EDEX (Environmental Data Exchange) software + * uFrameâ„¢ (Universal Framework) software + * + * Copyright (c) 2010 Raytheon Co. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/epl-v10.php + * + * + * Contractor Name: Raytheon Company + * Contractor Address: + * 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Jun 13, 2011 bclement Initial creation + * + */ +package com.raytheon.uf.edex.database.spatial; + +import java.awt.Point; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferInt; +import java.awt.image.Raster; +import java.awt.image.RenderedImage; +import java.util.Arrays; + +import org.geotools.coverage.grid.GridCoverage2D; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.raytheon.uf.common.datastorage.Request; +import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.datastorage.records.IntegerDataRecord; + +/** + * + * @author bclement + * @version 1.0 + */ +public class IntDataReprojector extends + AbstractDataReprojector { + + protected int fill = 0; + + protected int dataMaskValue = -1; + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getGridCoverage + * (com.raytheon.uf.common.datastorage.records.IDataRecord, + * org.opengis.referencing.crs.CoordinateReferenceSystem, + * org.opengis.geometry.Envelope) + */ + @Override + protected GridCoverage2D getGridCoverage(IDataRecord record, + ReferencedEnvelope env) throws Exception { + IntegerDataRecord dataRecord = (IntegerDataRecord) record; + int[] data = dataRecord.getIntData(); + DataBuffer buff = new DataBufferInt(data, data.length); + int x = (int) dataRecord.getSizes()[0]; + int y = (int) dataRecord.getSizes()[1]; + CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem(); + return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getMaskCoverage + * (com.raytheon.uf.common.datastorage.records.IDataRecord, + * org.opengis.referencing.crs.CoordinateReferenceSystem, + * org.opengis.geometry.Envelope) + */ + @Override + protected GridCoverage2D getMaskCoverage(IDataRecord record, + ReferencedEnvelope env) throws Exception { + int x = (int) record.getSizes()[0]; + int y = (int) record.getSizes()[1]; + int[] mask = new int[x * y]; + Arrays.fill(mask, dataMaskValue); + DataBufferInt buff = new DataBufferInt(mask, mask.length); + CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem(); + return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#extractData(org + * .geotools.coverage.grid.GridCoverage2D) + */ + @Override + protected IntegerDataRecord extractData(GridCoverage2D coverage) { + RenderedImage image = coverage.getRenderedImage(); + Raster raster; + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer(); + int[] data = dataBuffer.getData(); + int height = raster.getHeight(); + int width = raster.getWidth(); + return new IntegerDataRecord("", "", data, 2, new long[] { width, + height }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#extractData(org + * .geotools.coverage.grid.GridCoverage2D, + * org.geotools.coverage.grid.GridCoverage2D) + */ + @Override + protected IntegerDataRecord extractData(GridCoverage2D coverage, + GridCoverage2D maskCoverage) { + RenderedImage image = coverage.getRenderedImage(); + Raster raster; + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer(); + int[] data = dataBuffer.getData(); + + // Extract mask + image = maskCoverage.getRenderedImage(); + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + dataBuffer = (DataBufferInt) raster.getDataBuffer(); + int[] mask = dataBuffer.getData(); + + if (mask.length == data.length) { + for (int i = 0; i < data.length; ++i) { + if (mask[i] != dataMaskValue) { + data[i] = fill; + } + } + } + + int height = raster.getHeight(); + int width = raster.getWidth(); + return new IntegerDataRecord("", "", data, 2, new long[] { width, + height }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getDataSlice(com + * .raytheon.uf.common.datastorage.records.IDataRecord, + * com.raytheon.uf.common.datastorage.Request) + */ + @Override + protected IntegerDataRecord getDataSlice(IDataRecord record, Request req) { + IntegerDataRecord dataRecord = (IntegerDataRecord) record; + int[] max = req.getMaxIndexForSlab(); + int[] min = req.getMinIndexForSlab(); + int toWidth = max[0] - min[0]; + int toHeight = max[1] - min[1]; + int[] from = dataRecord.getIntData(); + int fromWidth = (int) dataRecord.getSizes()[0]; + int[] to = new int[toWidth * toHeight]; + for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) { + int toRow = toY * toWidth; + int fromRow = fromY * fromWidth; + for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) { + to[toRow + toX] = from[fromRow + fromX]; + } + } + long[] sizes = { toWidth, toHeight }; + return new IntegerDataRecord("", "", to, 2, sizes); + } + + /** + * @return the fill + */ + public int getFill() { + return fill; + } + + /** + * @param fill + * the fill to set + */ + public void setFill(int fill) { + this.fill = fill; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.AbstractDataReprojector#compatible + * (com.raytheon.uf.common.datastorage.records.IDataRecord) + */ + @Override + protected boolean compatible(IDataRecord dataRecord) { + return dataRecord instanceof IntegerDataRecord; + } + + @Override + protected IDataRecord getDataPoints(IDataRecord record, Request req) { + IntegerDataRecord dataRecord = (IntegerDataRecord) record; + int[] from = dataRecord.getIntData(); + int fromWidth = (int) dataRecord.getSizes()[0]; + Point[] points = req.getPoints(); + int[] to = new int[points.length]; + for (int i = 0; i < to.length; ++i) { + Point p = points[i]; + to[i] = from[p.y * fromWidth + p.x]; + } + return new IntegerDataRecord("", "", to, 1, new long[] { to.length }); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/KeyLocker.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/KeyLocker.java new file mode 100644 index 0000000000..bb8e378dc2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/KeyLocker.java @@ -0,0 +1,104 @@ +/* + * The following software products were developed by Raytheon: + * + * ADE (AWIPS Development Environment) software + * CAVE (Common AWIPS Visualization Environment) software + * EDEX (Environmental Data Exchange) software + * uFrameâ„¢ (Universal Framework) software + * + * Copyright (c) 2010 Raytheon Co. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/epl-v10.php + * + * + * Contractor Name: Raytheon Company + * Contractor Address: + * 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + */ +package com.raytheon.uf.edex.database.spatial; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +/** + * Class for managing a pool of concurrency locks organized by string keys. + * + * @author bclement + * @version 1.0 + */ +public class KeyLocker { + + public class KeyLock { + private final String key; + + private final Lock lock; + + private boolean released = false; + + public KeyLock(String key, Lock lock) { + this.key = key; + this.lock = lock; + } + + @Override + protected void finalize() throws Throwable { + release(); + } + + public void release() { + if (!this.released) { + releaseLock(this.key); + this.released = true; + } + } + + public void lock() { + this.lock.lock(); + } + + public void unlock() { + this.lock.unlock(); + } + + } + + private class Entry { + int count = 0; + final Lock lock = new ReentrantLock(); + } + + private final Map locks = new HashMap(); + + public KeyLock getLock(String key) { + synchronized (locks) { + Entry e = locks.get(key); + if (e == null) { + e = new Entry(); + locks.put(key, e); + } + e.count++; + return new KeyLock(key, e.lock); + } + } + + void releaseLock(String key) { + synchronized (locks) { + Entry e = locks.get(key); + if (e != null) { + e.count--; + if (e.count <= 0) { + locks.remove(key); + } + } + } + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/ReferencedDataRecord.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/ReferencedDataRecord.java new file mode 100644 index 0000000000..9644ef3943 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/ReferencedDataRecord.java @@ -0,0 +1,64 @@ +/* + * The following software products were developed by Raytheon: + * + * ADE (AWIPS Development Environment) software + * CAVE (Common AWIPS Visualization Environment) software + * EDEX (Environmental Data Exchange) software + * uFrameâ„¢ (Universal Framework) software + * + * Copyright (c) 2010 Raytheon Co. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/epl-v10.php + * + * + * Contractor Name: Raytheon Company + * Contractor Address: + * 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * May 18, 2011 bclement Initial creation + * + */ +package com.raytheon.uf.edex.database.spatial; + +import org.geotools.geometry.jts.ReferencedEnvelope; + +import com.raytheon.uf.common.datastorage.records.IDataRecord; + +public class ReferencedDataRecord{ + + protected IDataRecord record; + + protected ReferencedEnvelope envelope; + + public ReferencedDataRecord(IDataRecord record, ReferencedEnvelope envlope) { + this.record = record; + this.envelope = envlope; + } + + public IDataRecord getRecord() { + return record; + } + + public void setRecord(IDataRecord record) { + this.record = record; + } + + public ReferencedEnvelope getEnvelope() { + return envelope; + } + + public void setEnvelope(ReferencedEnvelope envelope) { + this.envelope = envelope; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/ShortDataReprojector.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/ShortDataReprojector.java new file mode 100644 index 0000000000..95274d1f09 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/spatial/ShortDataReprojector.java @@ -0,0 +1,248 @@ +/* + * The following software products were developed by Raytheon: + * + * ADE (AWIPS Development Environment) software + * CAVE (Common AWIPS Visualization Environment) software + * EDEX (Environmental Data Exchange) software + * uFrameâ„¢ (Universal Framework) software + * + * Copyright (c) 2010 Raytheon Co. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/epl-v10.php + * + * + * Contractor Name: Raytheon Company + * Contractor Address: + * 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Jun 13, 2011 bclement Initial creation + * + */ +package com.raytheon.uf.edex.database.spatial; + +import java.awt.Point; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferShort; +import java.awt.image.Raster; +import java.awt.image.RenderedImage; +import java.util.Arrays; + +import org.geotools.coverage.grid.GridCoverage2D; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.raytheon.uf.common.datastorage.Request; +import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.datastorage.records.ShortDataRecord; + +/** + * TODO Add Description + * + * @author bclement + * @version 1.0 + */ +public class ShortDataReprojector extends + AbstractDataReprojector { + + protected short fill = 0; + + protected short dataMaskValue = -1; + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getGridCoverage + * (com.raytheon.uf.common.datastorage.records.IDataRecord, + * org.opengis.referencing.crs.CoordinateReferenceSystem, + * org.opengis.geometry.Envelope) + */ + @Override + protected GridCoverage2D getGridCoverage(IDataRecord record, + ReferencedEnvelope env) throws Exception { + ShortDataRecord dataRecord = (ShortDataRecord) record; + short[] data = dataRecord.getShortData(); + DataBuffer buff = new DataBufferShort(data, data.length); + int x = (int) dataRecord.getSizes()[0]; + int y = (int) dataRecord.getSizes()[1]; + CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem(); + return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getMaskCoverage + * (com.raytheon.uf.common.datastorage.records.IDataRecord, + * org.opengis.referencing.crs.CoordinateReferenceSystem, + * org.opengis.geometry.Envelope) + */ + @Override + protected GridCoverage2D getMaskCoverage(IDataRecord record, + ReferencedEnvelope env) throws Exception { + int x = (int) record.getSizes()[0]; + int y = (int) record.getSizes()[1]; + short[] mask = new short[x * y]; + Arrays.fill(mask, dataMaskValue); + DataBufferShort buff = new DataBufferShort(mask, mask.length); + CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem(); + return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#extractData(org + * .geotools.coverage.grid.GridCoverage2D) + */ + @Override + protected ShortDataRecord extractData(GridCoverage2D coverage) { + RenderedImage image = coverage.getRenderedImage(); + Raster raster; + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + DataBufferShort dataBuffer = (DataBufferShort) raster.getDataBuffer(); + short[] data = dataBuffer.getData(); + int height = raster.getHeight(); + int width = raster.getWidth(); + return new ShortDataRecord("", "", data, 2, + new long[] { width, height }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#extractData(org + * .geotools.coverage.grid.GridCoverage2D, + * org.geotools.coverage.grid.GridCoverage2D) + */ + @Override + protected ShortDataRecord extractData(GridCoverage2D coverage, + GridCoverage2D maskCoverage) { + RenderedImage image = coverage.getRenderedImage(); + Raster raster; + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + DataBufferShort dataBuffer = (DataBufferShort) raster.getDataBuffer(); + short[] data = dataBuffer.getData(); + + // Extract mask + image = maskCoverage.getRenderedImage(); + if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) { + // we can directly access data + raster = image.getTile(0, 0); + } else { + // need to copy data out + raster = image.getData(); + } + dataBuffer = (DataBufferShort) raster.getDataBuffer(); + short[] mask = dataBuffer.getData(); + + if (mask.length == data.length) { + for (int i = 0; i < data.length; ++i) { + if (mask[i] != dataMaskValue) { + data[i] = fill; + } + } + } + + int height = raster.getHeight(); + int width = raster.getWidth(); + return new ShortDataRecord("", "", data, 2, + new long[] { width, height }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.DataReprojector#getDataSlice(com + * .raytheon.uf.common.datastorage.records.IDataRecord, + * com.raytheon.uf.common.datastorage.Request) + */ + @Override + protected ShortDataRecord getDataSlice(IDataRecord record, Request req) { + ShortDataRecord dataRecord = (ShortDataRecord) record; + int[] max = req.getMaxIndexForSlab(); + int[] min = req.getMinIndexForSlab(); + int toWidth = max[0] - min[0]; + int toHeight = max[1] - min[1]; + short[] from = dataRecord.getShortData(); + int fromWidth = (int) dataRecord.getSizes()[0]; + short[] to = new short[toWidth * toHeight]; + for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) { + int toRow = toY * toWidth; + int fromRow = fromY * fromWidth; + for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) { + to[toRow + toX] = from[fromRow + fromX]; + } + } + long[] sizes = { toWidth, toHeight }; + return new ShortDataRecord("", "", to, 2, sizes); + } + + /** + * @return the fill + */ + public short getFill() { + return fill; + } + + /** + * @param fill + * the fill to set + */ + public void setFill(short fill) { + this.fill = fill; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.database.spatial.AbstractDataReprojector#compatible + * (com.raytheon.uf.common.datastorage.records.IDataRecord) + */ + @Override + protected boolean compatible(IDataRecord dataRecord) { + return dataRecord instanceof ShortDataRecord; + } + + @Override + protected IDataRecord getDataPoints(IDataRecord record, Request req) { + ShortDataRecord dataRecord = (ShortDataRecord) record; + short[] from = dataRecord.getShortData(); + int fromWidth = (int) dataRecord.getSizes()[0]; + Point[] points = req.getPoints(); + short[] to = new short[points.length]; + for (int i = 0; i < to.length; ++i) { + Point p = points[i]; + to[i] = from[p.y * fromWidth + p.x]; + } + return new ShortDataRecord("", "", to, 1, new long[] { to.length }); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.esb.camel/META-INF/MANIFEST.MF index 8a76ef99c0..883adb4f6e 100644 --- a/edexOsgi/com.raytheon.uf.edex.esb.camel/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/META-INF/MANIFEST.MF @@ -12,6 +12,7 @@ Require-Bundle: org.apache.camel;bundle-version="1.0.0", org.apache.http;bundle-version="3.0.1", com.raytheon.uf.common.localization;bundle-version="1.11.17", com.raytheon.uf.common.status, + com.raytheon.uf.common.util, com.raytheon.uf.edex.core, org.apache.commons.logging, javax.servlet diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/Executor.java b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/Executor.java index 2214b576be..53fd45356f 100644 --- a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/Executor.java +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/Executor.java @@ -21,13 +21,9 @@ package com.raytheon.uf.edex.esb.camel; import java.io.File; import java.io.FileFilter; -import java.io.FileInputStream; import java.io.FileReader; import java.io.FilenameFilter; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.Arrays; @@ -38,6 +34,7 @@ import java.util.List; import java.util.Properties; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.regex.Pattern; import javax.management.MBeanServerConnection; import javax.management.ObjectInstance; @@ -49,9 +46,12 @@ import javax.xml.bind.Unmarshaller; import org.apache.activemq.console.util.JmxMBeansUtil; import org.springframework.context.support.ClassPathXmlApplicationContext; +import com.raytheon.uf.common.util.PropertiesUtil; +import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.core.props.PropertiesFactory; import com.raytheon.uf.edex.esb.camel.context.ContextManager; import com.raytheon.uf.edex.esb.camel.spring.DefaultEdexMode; +import com.raytheon.uf.edex.esb.camel.spring.EdexMode; import com.raytheon.uf.edex.esb.camel.spring.EdexModesContainer; /** @@ -62,9 +62,12 @@ import com.raytheon.uf.edex.esb.camel.spring.EdexModesContainer; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Nov 14, 2008 chammack Initial creation - * Jul 14, 2009 #2950 njensen Basic spring file ordering - * Apr 5, 2010 #3857 njensen Removed file ordering in favor of - * spring's depends-on attribute + * Jul 14, 2009 #2950 njensen Basic spring file ordering + * Apr 05, 2010 #3857 njensen Removed file ordering in favor of + * spring's depends-on attribute + * Jun 12, 2012 #0609 djohnson Use EDEXUtil for EDEX_HOME. + * Jul 09, 2012 #0643 djohnson Read plugin provided resources into system properties. + * Jul 17, 2012 #0740 djohnson Redo changes since the decomposed repositories lost them. * Oct 19, 2012 #1274 bgonzale Load properties from files in conf * resources directory. * @@ -78,6 +81,11 @@ public class Executor { public static final String XML = ".xml"; + private static final Pattern XML_PATTERN = Pattern.compile("\\" + XML); + + private static final Pattern RES_SPRING_PATTERN = Pattern + .compile("res/spring/"); + private static final String MODES_FILE = "modes.xml"; public static void start() throws Exception { @@ -93,7 +101,7 @@ public class Executor { List xmlFiles = new ArrayList(); List propertiesFiles = new ArrayList(); - File confDir = new File(System.getProperty("edex.home") + File confDir = new File(EDEXUtil.EDEX_HOME + File.separator + "conf"); File resourcesDir = new File(confDir, "resources"); propertiesFiles.addAll(Arrays.asList(findFiles(resourcesDir, @@ -108,42 +116,25 @@ public class Executor { // Add each file to the system properties for (File propertiesFile : propertiesFiles) { - InputStream is = null; - Reader reader = null; - try { - is = new FileInputStream(propertiesFile); - reader = new InputStreamReader(is); - Properties properties = new Properties(); - properties.load(reader); - System.getProperties().putAll(properties); - } finally { - if (reader != null) { - reader.close(); - } - if (is != null) { - is.close(); - } - } + Properties properties = PropertiesUtil.read(propertiesFile); + System.getProperties().putAll(properties); } File springDir = new File(confDir, "spring"); - File[] springFiles = springDir.listFiles(new FileFilter() { + File[] springFiles = findFiles(springDir, XML); - @Override - public boolean accept(File pathname) { - return pathname.getName().endsWith(XML); - } - }); List springList = new ArrayList(); for (File f : springFiles) { - xmlFiles.add(f.getName()); - springList.add(f.getName().replace(XML, "")); + String name = f.getName(); + + xmlFiles.add(name); + springList.add(XML_PATTERN.matcher(name).replaceAll("")); } EdexModesContainer emc = getModeFilter(confDir); String modeName = System.getProperty("edex.run.mode"); String highMem = System.getProperty("HighMem"); - boolean highMemEnabled = (highMem != null && highMem.equals("on")); + boolean highMemEnabled = "on".equals(highMem); if (modeName != null && modeName.length() > 0) { System.out.println("EDEX run configuration: " + modeName @@ -154,7 +145,16 @@ public class Executor { } System.out.println("EDEX site configuration: " + System.getProperty("aw.site.identifier")); - FilenameFilter mode = emc.getMode(modeName, highMemEnabled); + + EdexMode edexMode = emc.getMode(modeName, highMemEnabled); + + if (edexMode != null && edexMode.isTemplate()) { + throw new UnsupportedOperationException(modeName + + " is a template mode, and is not bootable."); + } + + FilenameFilter mode = edexMode; + if (mode == null) { if (modeName == null || modeName.length() == 0) { mode = new DefaultEdexMode(); @@ -231,12 +231,11 @@ public class Executor { */ private static File[] findFiles(File directory, final String extension) { File[] files = directory.listFiles(new FileFilter() { - - @Override - public boolean accept(File pathname) { - return pathname.getName().endsWith(extension); - } - }); + @Override + public boolean accept(File pathname) { + return pathname.getName().endsWith(extension); + } + }); // If no files were found return an empty array return (files == null) ? new File[0] : files; @@ -244,20 +243,17 @@ public class Executor { private static String printList(List components) { StringBuffer sb = new StringBuffer(); - boolean first = true; Collections.sort(components); Iterator iterator = components.iterator(); while (iterator.hasNext()) { - if (first) { - first = false; - } else { - sb.append(", "); - } - sb.append(iterator.next()); + sb.append(", "); } + int length = sb.length(); + sb.delete(length - 2, length); + return sb.toString(); } @@ -293,7 +289,9 @@ public class Executor { String name = e.getName(); if (filter.accept(null, name)) { files.add(name); - retVal.add(name.replace(XML, "").replace("res/spring/", "")); + retVal.add(RES_SPRING_PATTERN.matcher( + XML_PATTERN.matcher(name).replaceAll("")) + .replaceAll("")); } } @@ -304,8 +302,7 @@ public class Executor { private static EdexModesContainer getModeFilter(File confDir) throws IOException, JAXBException { - String path = confDir.getPath() + File.separator + MODES_FILE; - File file = new File(path); + File file = new File(confDir.getPath(), MODES_FILE); FileReader reader = null; Unmarshaller msh = null; @@ -318,11 +315,7 @@ public class Executor { return emc; } finally { if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - // ignore - } + PropertiesUtil.close(reader); } } } diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/FileToString.java b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/FileToString.java index e793947fe6..f3225a83b9 100644 --- a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/FileToString.java +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/FileToString.java @@ -26,6 +26,8 @@ import org.apache.camel.Processor; import org.apache.camel.component.file.GenericFile; import org.springframework.util.FileCopyUtils; +import com.raytheon.uf.edex.core.EDEXUtil; + /** * Provides a capability to transform java.io.File to Strings * @@ -36,7 +38,8 @@ import org.springframework.util.FileCopyUtils; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Dec 3, 2008 chammack Initial creation + * Dec 03, 2008 chammack Initial creation + * Jun 12, 2012 00609 djohnson Use EDEXUtil for EDEX_HOME. * * * @@ -46,7 +49,7 @@ import org.springframework.util.FileCopyUtils; public class FileToString implements Processor { - private static String DIR = System.getProperty("edex.home") + private static String DIR = EDEXUtil.EDEX_HOME + File.separator + "data" + File.separator + "processing"; @Override diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/spring/EdexMode.java b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/spring/EdexMode.java index 32caf43dfa..0cda0096d3 100644 --- a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/spring/EdexMode.java +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/spring/EdexMode.java @@ -21,6 +21,7 @@ package com.raytheon.uf.edex.esb.camel.spring; import java.io.File; import java.util.ArrayList; +import java.util.List; import java.util.regex.Pattern; import javax.xml.bind.annotation.XmlAccessType; @@ -28,6 +29,8 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlID; +import javax.xml.bind.annotation.XmlIDREF; import javax.xml.bind.annotation.XmlRootElement; /** @@ -40,6 +43,7 @@ import javax.xml.bind.annotation.XmlRootElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 22, 2010 njensen Initial creation + * Sep 19, 2012 1195 djohnson Allow 0..n other modes to be included. * * * @@ -52,31 +56,54 @@ import javax.xml.bind.annotation.XmlRootElement; public class EdexMode extends DefaultEdexMode { @XmlAttribute(name = "name") + @XmlID private String name; @XmlElements( { @XmlElement(name = "include", type = String.class) }) - private ArrayList includeList; + private final List includeList; - private ArrayList compiledIncludes; + private final List compiledIncludes; @XmlElements( { @XmlElement(name = "exclude", type = String.class) }) - private ArrayList excludeList; + private final List excludeList; - private ArrayList compiledExcludes; + private final List compiledExcludes; - private boolean inited = false; + @XmlElements({ @XmlElement(name = "includeMode") }) + @XmlIDREF + private final List includedModes; + + private boolean inited; + + @XmlAttribute + private boolean template; public EdexMode() { - includeList = new ArrayList(); - compiledIncludes = new ArrayList(); - excludeList = new ArrayList(); - compiledExcludes = new ArrayList(); + this(new ArrayList(), new ArrayList(), + new ArrayList()); + } + + // @VisibleForTesting + EdexMode(List includeList, List excludeList, + List includedModes) { + this.includeList = includeList; + compiledIncludes = new ArrayList(includeList.size()); + this.excludeList = excludeList; + compiledExcludes = new ArrayList(excludeList.size()); + this.includedModes = includedModes; } /** * Compiles the patterns */ public void init() { + + for (EdexMode includedMode : includedModes) { + if (!includedMode.isInited()) { + includedMode.init(); + } + } + for (String s : includeList) { compiledIncludes.add(Pattern.compile(s)); } @@ -84,6 +111,11 @@ public class EdexMode extends DefaultEdexMode { for (String s : excludeList) { compiledExcludes.add(Pattern.compile(s)); } + + for (EdexMode includedMode : includedModes) { + compiledIncludes.addAll(includedMode.compiledIncludes); + compiledExcludes.addAll(includedMode.compiledExcludes); + } inited = true; } @@ -100,9 +132,17 @@ public class EdexMode extends DefaultEdexMode { .substring(filename.lastIndexOf(File.separator) + 1); } + // If we explicitly exclude the pattern, just return false + for (Pattern p : compiledExcludes) { + if (p.matcher(filename).find()) { + return false; + } + } + boolean matches = false; + // default to include * if no include regexes are present - if (compiledIncludes.size() == 0) { + if (compiledIncludes.isEmpty()) { matches = true; } else { for (Pattern p : compiledIncludes) { @@ -113,15 +153,6 @@ public class EdexMode extends DefaultEdexMode { } } - if (matches) { - for (Pattern p : compiledExcludes) { - if (p.matcher(filename).find()) { - matches = false; - break; - } - } - } - return matches; } @@ -150,4 +181,24 @@ public class EdexMode extends DefaultEdexMode { this.inited = inited; } + /** + * Return whether or not the mode is a template mode. Template modes cannot + * be booted. + * + * @return the template + */ + public boolean isTemplate() { + return template; + } + + /** + * Set whether the mode is a template or not. + * + * @param template + * true to denote a template mode + */ + public void setTemplate(boolean template) { + this.template = template; + } + } diff --git a/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/dpaDecoder-spring.xml b/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/DPADecoder-spring.xml similarity index 100% rename from edexOsgi/com.raytheon.uf.edex.ohd/res/spring/dpaDecoder-spring.xml rename to edexOsgi/com.raytheon.uf.edex.ohd/res/spring/DPADecoder-spring.xml diff --git a/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/MpeRUCFreezingLevel.java b/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/MpeRUCFreezingLevel.java index 2d37448626..446538c0c2 100644 --- a/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/MpeRUCFreezingLevel.java +++ b/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/MpeRUCFreezingLevel.java @@ -93,16 +93,24 @@ public class MpeRUCFreezingLevel { public static String[] models = new String[] { "RUC236" }; public MpeRUCFreezingLevel() { - File directory = new File(stationFilePath); + try { + File directory = new File(stationFilePath); - if (directory != null) { - for (File file : directory.listFiles()) { - if (file.isFile() - && file.getName().contains("freezing_station_list")) { - this.stationFile = file; - break; + if (directory != null) { + for (File file : directory.listFiles()) { + if (file != null) { + if (file.isFile() + && file.getName().contains( + "freezing_station_list")) { + this.stationFile = file; + break; + } + } } } + } catch (Exception e) { + statusHandler + .handle(Priority.WARN, "No mpe_station_list_dir found"); } // correct env vairiable dqcPreprocessorBasetime if needed diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.acars/src/com/raytheon/uf/edex/plugin/acars/dao/ACARSDao.java b/edexOsgi/com.raytheon.uf.edex.plugin.acars/src/com/raytheon/uf/edex/plugin/acars/dao/ACARSDao.java index 4e0099d432..b6e500b3a8 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.acars/src/com/raytheon/uf/edex/plugin/acars/dao/ACARSDao.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.acars/src/com/raytheon/uf/edex/plugin/acars/dao/ACARSDao.java @@ -29,8 +29,8 @@ import org.springframework.transaction.support.TransactionCallback; import com.raytheon.edex.db.dao.DefaultPluginDao; import com.raytheon.uf.common.dataplugin.PluginException; -import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; import com.raytheon.uf.common.dataplugin.acars.ACARSRecord; +import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; import com.raytheon.uf.edex.database.DataAccessLayerException; /** @@ -42,6 +42,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 21, 2009 1939 jkorman Initial creation + * Oct 10, 2012 1261 djohnson Add some generics wildcarding. * * * @@ -51,11 +52,6 @@ import com.raytheon.uf.edex.database.DataAccessLayerException; public class ACARSDao extends DefaultPluginDao { - /** - * The cache region to store query - */ - private final String QUERY_CACHE_REGION = "Queries"; - /** * Creates a new ReccoDao * @@ -103,10 +99,11 @@ public class ACARSDao extends DefaultPluginDao { List retData = null; - List results = super.queryByExample(example); + @SuppressWarnings("unchecked") + List> results = super.queryByExample(example); if (results != null) { retData = new ArrayList(); - for (PersistableDataObject d : results) { + for (PersistableDataObject d : results) { retData.add((ACARSRecord) d); } } @@ -125,6 +122,7 @@ public class ACARSDao extends DefaultPluginDao { List result = (List) txTemplate .execute(new TransactionCallback() { + @Override public List doInTransaction(TransactionStatus status) { Query hibQuery = getSession(false) .createQuery(hqlQuery); diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grid/src/com/raytheon/uf/edex/plugin/grid/dao/GridInfoCache.java b/edexOsgi/com.raytheon.uf.edex.plugin.grid/src/com/raytheon/uf/edex/plugin/grid/dao/GridInfoCache.java index ad4e8bab16..ae17c6708c 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grid/src/com/raytheon/uf/edex/plugin/grid/dao/GridInfoCache.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.grid/src/com/raytheon/uf/edex/plugin/grid/dao/GridInfoCache.java @@ -55,7 +55,7 @@ public class GridInfoCache { return instance; } - private CoreDao dao; + private final CoreDao dao; // A weak hashmap of soft references is used as a SoftSet. private Map> cache = null; @@ -77,9 +77,10 @@ public class GridInfoCache { // secondaryId. In general these cases should be rare and small. // So we handle it by caching everything returned and then // double checking the cache. - List dbList = dao.queryByExample(record); + List> dbList = dao + .queryByExample(record); if (dbList != null && !dbList.isEmpty()) { - for (PersistableDataObject pdo : dbList) { + for (PersistableDataObject pdo : dbList) { GridInfoRecord gir = (GridInfoRecord) pdo; cache.put(gir, new SoftReference(gir)); } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/META-INF/MANIFEST.MF index efc77f8c3e..c8e3926a3c 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/META-INF/MANIFEST.MF @@ -7,7 +7,8 @@ Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: com.raytheon.uf.edex.auth;bundle-version="1.12.2", com.raytheon.uf.common.auth;bundle-version="1.12.2", - com.raytheon.uf.common.plugin.nwsauth;bundle-version="1.0.0" + com.raytheon.uf.common.plugin.nwsauth;bundle-version="1.0.0", + com.raytheon.uf.common.status;bundle-version="1.12.1174" Import-Package: com.raytheon.uf.common.localization, com.raytheon.uf.common.serialization, com.raytheon.uf.common.status, diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index c7bd175870..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,2 +0,0 @@ -com.raytheon.uf.edex.plugin.nwsauth.roles.NwsRole -com.raytheon.uf.edex.plugin.nwsauth.roles.NwsRoleData \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/res/spring/nwsauth-request.xml b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/res/spring/nwsauth-request.xml index 6ca9f69189..94734124d0 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/res/spring/nwsauth-request.xml +++ b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/res/spring/nwsauth-request.xml @@ -4,7 +4,7 @@ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> - + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/src/com/raytheon/uf/edex/plugin/nwsauth/roles/NwsRole.java b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/src/com/raytheon/uf/edex/plugin/nwsauth/roles/NwsRole.java deleted file mode 100644 index bcbc2193c2..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/src/com/raytheon/uf/edex/plugin/nwsauth/roles/NwsRole.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.raytheon.uf.edex.plugin.nwsauth.roles; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; - -import com.raytheon.uf.common.auth.user.IUser; -import com.raytheon.uf.common.plugin.nwsauth.user.UserId; -import com.raytheon.uf.edex.auth.roles.IRole; - -/** - * Implementation of IRole - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * May 25, 2010            rgeorge     Initial creation
- * 
- * 
- * - * @author rgeorge - * @version 1.0 - */ -@XmlAccessorType(XmlAccessType.NONE) -public class NwsRole implements IRole { - private static final UserId ALL = new UserId("ALL"); - - @XmlAttribute - private String roleId; - - private NwsRole parentRole; - - private Set users = new HashSet(); - - private Set subRoles = new HashSet(); - - @XmlElement(name = "user") - public void setUserIdCollection(UserId[] userIds) { - users = new HashSet(Arrays.asList(userIds)); - } - - public UserId[] getUserIdCollection() { - return users.toArray(new UserId[users.size()]); - } - - @XmlElement(name = "subRole") - public void setSubRolesCollection(String[] subRoles) { - this.subRoles = new HashSet(Arrays.asList(subRoles)); - } - - public String[] getSubRolesCollection() { - return subRoles.toArray(new String[subRoles.size()]); - } - - public String getRoleId() { - return roleId; - } - - public void setRoleId(String roleId) { - this.roleId = roleId; - } - - public void setParentRole(NwsRole parent) { - this.parentRole = parent; - } - - /** - * @param userRolesMap - */ - public void addRolesForUsers(Map userRolesMap) { - for (String subRoleId : subRoles) { - NwsRole subRole = userRolesMap.get(subRoleId.toLowerCase()); - if (subRole != null) { - subRole.setParentRole(this); - subRole.addRolesForUsers(userRolesMap); - } - } - } - - @Override - public boolean validForUser(IUser user) { - if (user != null) { - if (users.contains(ALL)) { - return true; - } - for (UserId id : users) { - if (id.equals(user.uniqueId())) { - return true; - } - } - } - - if (parentRole != null && parentRole.validForUser(user)) { - return true; - } - - return false; - } - - @Override - public String toString() { - return this.roleId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((roleId == null) ? 0 : roleId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NwsRole other = (NwsRole) obj; - if (roleId == null) { - if (other.roleId != null) - return false; - } else if (!roleId.equals(other.roleId)) - return false; - return true; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/src/com/raytheon/uf/edex/plugin/nwsauth/roles/NwsRoleData.java b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/src/com/raytheon/uf/edex/plugin/nwsauth/roles/NwsRoleData.java deleted file mode 100644 index bf3237db6a..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/src/com/raytheon/uf/edex/plugin/nwsauth/roles/NwsRoleData.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.raytheon.uf.edex.plugin.nwsauth.roles; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.raytheon.uf.common.serialization.ISerializableObject; -import com.raytheon.uf.common.serialization.SerializationUtil; -import com.raytheon.uf.edex.core.EdexException; - -@XmlRootElement -@XmlAccessorType(XmlAccessType.NONE) -public class NwsRoleData implements ISerializableObject { - - private Map userRolesMap; - - private List allRoles = new ArrayList(); - - public NwsRole lookupRole(String roleId) { - if (userRolesMap == null) { - userRolesMap = new HashMap(); - for (NwsRole role : allRoles) { - userRolesMap.put(role.getRoleId().toLowerCase(), role); - } - - for (NwsRole role : allRoles) { - role.addRolesForUsers(userRolesMap); - } - } - return userRolesMap.get(("" + roleId).toLowerCase()); - } - - public NwsRole[] getAllRolesCollection() { - return this.allRoles.toArray(new NwsRole[this.allRoles.size()]); - } - - @XmlElement(name = "role") - public void setAllRolesCollection(NwsRole[] allRolesArray) { - this.allRoles = new ArrayList(Arrays.asList(allRolesArray)); - } - - public String toXML() throws EdexException { - try { - return SerializationUtil.marshalToXml(this); - } catch (JAXBException e) { - throw new EdexException("", e); - } - } - - public static NwsRoleData loadRoleData(File file) throws EdexException { - try { - return (NwsRoleData) SerializationUtil - .jaxbUnmarshalFromXmlFile(file.getAbsolutePath()); - } catch (Exception e) { - e.printStackTrace(); - throw new EdexException("", e); - } - } - - public void storeRoleData(File file) throws EdexException { - try { - if (file != null) { - SerializationUtil.jaxbMarshalToXmlFile(this, - file.getAbsolutePath()); - } - } catch (Exception e) { - e.printStackTrace(); - throw new EdexException("", e); - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/src/com/raytheon/uf/edex/plugin/nwsauth/roles/NwsRoleStorage.java b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/src/com/raytheon/uf/edex/plugin/nwsauth/roles/NwsRoleStorage.java deleted file mode 100644 index daeb760b7e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/src/com/raytheon/uf/edex/plugin/nwsauth/roles/NwsRoleStorage.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.raytheon.uf.edex.plugin.nwsauth.roles; - -import java.io.File; -import java.util.Map; - -import com.raytheon.uf.common.localization.LocalizationContext; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.edex.auth.roles.IRole; -import com.raytheon.uf.edex.auth.roles.IRoleStorage; -import com.raytheon.uf.edex.core.EdexException; - -/** - * Implementation of IRoleStorage - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * May 25, 2010            rgeorge     Initial creation
- * 
- * 
- * - * @author rgeorge - * @version 1.0 - */ -public class NwsRoleStorage implements IRoleStorage { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(NwsRoleStorage.class); - - private static final NwsRole DEFAULT_ROLE = new NwsRole(); - - private static final LocalizationLevel BASE = LocalizationContext.LocalizationLevel.BASE; - - private static final LocalizationType EDEX_STATIC = LocalizationContext.LocalizationType.EDEX_STATIC; - - private static final String ROLES_FILE_NAME = "roles" + File.separator - + "userRoles.xml"; - - private NwsRoleData roleData = null; - - private File lastUsedFile = null; - - private long lastModificationTime = 0; - - private synchronized NwsRoleData getRoleData() { - Map fileMap = PathManagerFactory - .getPathManager().getTieredLocalizationFile( - LocalizationType.EDEX_STATIC, ROLES_FILE_NAME); - LocalizationLevel[] levels = PathManagerFactory.getPathManager() - .getAvailableLevels(); - - File file = null; - // reverse search for file to get highest level - for (int i = levels.length - 1; i >= 0; --i) { - LocalizationFile locFile = fileMap.get(levels[i]); - if (locFile != null && locFile.exists()) { - file = locFile.getFile(); - break; - } - } - - if (file == null && lastUsedFile == null) { - // No file found and lastFile wasn't set before, default - roleData = new NwsRoleData(); - } else if (lastUsedFile == null - || (file != null && (file.equals(lastUsedFile) == false || file - .lastModified() > lastModificationTime))) { - // First time we found a role file, or we have a different file to - // use or we were modified since our last check - lastUsedFile = file; - try { - roleData = NwsRoleData.loadRoleData(file); - } catch (EdexException e) { - UFStatus.getHandler().handle(Priority.PROBLEM, - "Error loading NWS Roles file", e); - roleData = new NwsRoleData(); - } - lastModificationTime = file.lastModified(); - } - - return roleData; - } - - @Override - public boolean isDefaultRole(IRole role) { - return role == DEFAULT_ROLE; - } - - @Override - public IRole lookupRole(String roleId) { - if (roleId != null && "".equals(roleId) == false) { - NwsRoleData roleData = getRoleData(); - NwsRole role = roleData.lookupRole(roleId); - if (role == null) { - return DEFAULT_ROLE; - } - return role; - } - - return DEFAULT_ROLE; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/utility/common_static/base/roles/userRoles.xml b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/utility/common_static/base/roles/userRoles.xml new file mode 100644 index 0000000000..67ab28709d --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.nwsauth/utility/common_static/base/roles/userRoles.xml @@ -0,0 +1,124 @@ + + + Localization + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + com.raytheon.localization.site/common_static/purge + com.raytheon.localization.site/cave_static/colormaps + com.raytheon.localization.site/cave_static/ffmp + com.raytheon.localization.site/cave_static/fog + com.raytheon.localization.site/common_static/fog + com.raytheon.localization.site/cave_static/safeseas + com.raytheon.localization.site/common_static/safeseas + com.raytheon.localization.site/cave_static/snow + com.raytheon.localization.site/common_static/snow + com.raytheon.localization.site/cave_static/scan + com.raytheon.localization.site/cave_static/aviation/config + com.raytheon.localization.site/cave_static/aviation/tmp + com.raytheon.localization.site/cave_static/monitorIcons + com.raytheon.localization.site/cave_static/alertViz + com.raytheon.localization.site/common_static/hydro + com.raytheon.localization.site/common_static/gfe + com.raytheon.localization.site/cave_static/gfe/comboData + com.raytheon.localization.site/cave_static/gfe + com.raytheon.localization.site/common_static/isc + com.raytheon.localization.user/common_static/gfe + com.raytheon.localization.user/cave_static/gfe + com.raytheon.localization.site/common_static/ffmp + com.raytheon.localization.site/common_static/scan + com.raytheon.localization.site/common_static/monitoring + com.raytheon.localization.site/cave_static/scan/config/trendSets/CellTrendSets.xml + com.raytheon.localization.site/cave_static/aviation/avnwatch + com.raytheon.localization.site/common_static/radar/rmr/rmrAvailableRequests.xml + com.raytheon.localization.site/common_static/shef + com.raytheon.localization.site/common_static/roles + + + diff --git a/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/PointDataQuery.java b/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/PointDataQuery.java index 2917a7451d..1646a6ed2a 100644 --- a/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/PointDataQuery.java +++ b/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/PointDataQuery.java @@ -63,75 +63,77 @@ import com.raytheon.uf.edex.pointdata.PointDataPluginDao.LevelRequest; public class PointDataQuery { - protected PointDataPluginDao dao; + protected PointDataPluginDao dao; - protected TableQuery tq; + protected TableQuery tq; - protected String[] attribs; + protected String[] attribs; - protected PointDataPluginDao.LevelRequest requestStyle = LevelRequest.NONE; + protected PointDataPluginDao.LevelRequest requestStyle = LevelRequest.NONE; - public PointDataQuery(String plugin) throws DataAccessLayerException, - PluginException { - this.tq = new TableQuery(PluginFactory.getInstance() - .getDatabase(plugin), PluginFactory.getInstance() - .getPluginRecordClass(plugin).getName()); - try { - PluginDao pd = PluginFactory.getInstance().getPluginDao(plugin); - if (!(pd instanceof PointDataPluginDao)) { - throw new PluginException(plugin - + " DAO is not a point data DAO"); - } - this.dao = (PointDataPluginDao) pd; - } catch (Exception e) { - e.printStackTrace(); - throw new DataAccessLayerException( - "Unable to instantiate data access object on database: " - + plugin, e); - } - } + public PointDataQuery(final String plugin) throws DataAccessLayerException, + PluginException { + this.tq = new TableQuery(PluginFactory.getInstance() + .getDatabase(plugin), PluginFactory.getInstance() + .getPluginRecordClass(plugin).getName()); + try { + PluginDao pd = PluginFactory.getInstance().getPluginDao(plugin); + if (!(pd instanceof PointDataPluginDao)) { + throw new PluginException(plugin + + " DAO is not a point data DAO"); + } + this.dao = (PointDataPluginDao) pd; + } catch (Exception e) { + e.printStackTrace(); + throw new DataAccessLayerException( + "Unable to instantiate data access object on database: " + + plugin, e); + } + } - public void setParameters(String params) { - String[] strs = params.split(","); - for (int i = 0; i < strs.length; i++) { - strs[i] = strs[i].trim(); - } - this.attribs = strs; - } + public void setParameters(final String params) { + String[] strs = params.split(","); + for (int i = 0; i < strs.length; i++) { + strs[i] = strs[i].trim(); + } + this.attribs = strs; + } - public void addParameter(String name, String value, String operand) { - if (operand == null) - operand = "="; + public void addParameter(final String name, final String value, + String operand) { + if (operand == null) { + operand = "="; + } - tq.addParameter(name, value, operand); + tq.addParameter(name, value, operand); - } + } - public void requestAllLevels() { - this.requestStyle = LevelRequest.ALL; - } + public void requestAllLevels() { + this.requestStyle = LevelRequest.ALL; + } - public void requestSpecificLevel(String parameter, String vals) { - String[] valList = vals.split(","); - double[] d = new double[valList.length]; - for (int i = 0; i < d.length; i++) { - d[i] = Double.parseDouble(valList[i]); - } + public void requestSpecificLevel(final String parameter, final String vals) { + String[] valList = vals.split(","); + double[] d = new double[valList.length]; + for (int i = 0; i < d.length; i++) { + d[i] = Double.parseDouble(valList[i]); + } - this.requestStyle = LevelRequest.SPECIFIC; - this.requestStyle.setLevels(parameter, d); - } + this.requestStyle = LevelRequest.SPECIFIC; + this.requestStyle.setLevels(parameter, d); + } - public ResponseMessageCatalog getAvailableParameters() throws Exception { + public ResponseMessageCatalog getAvailableParameters() throws Exception { - Set parameters = new HashSet(); + Set parameters = new HashSet(); - PointDataDbDescription dbDesc = dao.getPointDataDbDescription(); - if (dbDesc != null) { - for (DbParameterDescription parameter : dbDesc.parameters) { - parameters.add(parameter.getParameterName()); - } - } + PointDataDbDescription dbDesc = dao.getPointDataDbDescription(); + if (dbDesc != null) { + for (DbParameterDescription parameter : dbDesc.parameters) { + parameters.add(parameter.getParameterName()); + } + } boolean needsDbQuery = false; for (String key : dao.getKeysRequiredForFileName()) { if (!key.equals("dataTime.refTime")) { @@ -165,201 +167,202 @@ public class PointDataQuery { return cat; } - private List> performDbQuery(List fields, - int limit) throws Exception { + private List> performDbQuery(final List fields, + final int limit) throws Exception { - for (String field : fields) { - tq.addReturnedField(field, null); - } - tq.setCount(limit); - List queryResults = tq.execute(); + for (String field : fields) { + tq.addReturnedField(field, null); + } + tq.setCount(limit); + List queryResults = tq.execute(); - List> results = new ArrayList>(); + List> results = new ArrayList>(); - for (Object o : queryResults) { - Map workingMap = new HashMap(); - if (o instanceof Object[]) { - Object[] oArr = (Object[]) o; - for (int i = 0; i < fields.size(); i++) { - workingMap.put(fields.get(i), oArr[i]); - } - } else if (fields.size() == 1) { - workingMap.put(fields.get(0), o); - } - results.add(workingMap); - } + for (Object o : queryResults) { + Map workingMap = new HashMap(); + if (o instanceof Object[]) { + Object[] oArr = (Object[]) o; + for (int i = 0; i < fields.size(); i++) { + workingMap.put(fields.get(i), oArr[i]); + } + } else if (fields.size() == 1) { + workingMap.put(fields.get(0), o); + } + results.add(workingMap); + } - return results; + return results; - } + } - /* - * (non-Javadoc) - * - * @see com.raytheon.edex.uengine.tasks.query.TableQuery#execute() - */ - public PointDataContainer execute() throws Exception { + /* + * (non-Javadoc) + * + * @see com.raytheon.edex.uengine.tasks.query.TableQuery#execute() + */ + public PointDataContainer execute() throws Exception { - List hdf5attribList = new ArrayList(); - HashSet dbAttribSet = new HashSet(); - List dbParamDesc = new ArrayList(); + List hdf5attribList = new ArrayList(); + HashSet dbAttribSet = new HashSet(); + List dbParamDesc = new ArrayList(); - PointDataDbDescription dbDesc = dao.getPointDataDbDescription(); - if (dbDesc == null) { - hdf5attribList.addAll(Arrays.asList(attribs)); - } else { - for (String attrib : attribs) { - DbParameterDescription desc = dbDesc.getDescription(attrib); - if (desc != null) { - dbAttribSet.add(desc.getQueryName()); - dbParamDesc.add(desc); - } else { - hdf5attribList.add(attrib); - } - } - } + PointDataDbDescription dbDesc = dao.getPointDataDbDescription(); + if (dbDesc == null) { + hdf5attribList.addAll(Arrays.asList(attribs)); + } else { + for (String attrib : attribs) { + DbParameterDescription desc = dbDesc.getDescription(attrib); + if (desc != null) { + dbAttribSet.add(desc.getQueryName()); + dbParamDesc.add(desc); + } else { + hdf5attribList.add(attrib); + } + } + } - dbAttribSet.add("id"); - if (!hdf5attribList.isEmpty()) { - dbAttribSet.add("pointDataView.curIdx"); - dbAttribSet.addAll(Arrays.asList(dao.getKeysRequiredForFileName())); - } + dbAttribSet.add("id"); + if (!hdf5attribList.isEmpty()) { + dbAttribSet.add("pointDataView.curIdx"); + dbAttribSet.addAll(Arrays.asList(dao.getKeysRequiredForFileName())); + } - List> dbResults = performDbQuery( - new ArrayList(dbAttribSet), 999999); + List> dbResults = performDbQuery( + new ArrayList(dbAttribSet), 999999); - if (dbResults == null || dbResults.isEmpty()) { - return null; - } + if ((dbResults == null) || dbResults.isEmpty()) { + return null; + } - Map> dbResultMap = new HashMap>(); - PointDataContainer masterPDC = null; + Map> dbResultMap = new HashMap>(); + PointDataContainer masterPDC = null; - if (hdf5attribList.isEmpty()) { - int[] idArr = new int[dbResults.size()]; - for (int j = 0; j < dbResults.size(); j++) { - Map workingMap = dbResults.get(j); - idArr[j] = (Integer) workingMap.get("id"); - dbResultMap.put(idArr[j], workingMap); - } - masterPDC = PointDataContainer - .build(new IDataRecord[] { new IntegerDataRecord("id", "", - idArr) }); - masterPDC.setCurrentSz(masterPDC.getAllocatedSz()); - } else { - List files = new ArrayList(); - List> ids = new ArrayList>(); - List> indexes = new ArrayList>(); + if (hdf5attribList.isEmpty()) { + int[] idArr = new int[dbResults.size()]; + for (int j = 0; j < dbResults.size(); j++) { + Map workingMap = dbResults.get(j); + idArr[j] = (Integer) workingMap.get("id"); + dbResultMap.put(idArr[j], workingMap); + } + masterPDC = PointDataContainer + .build(new IDataRecord[] { new IntegerDataRecord("id", "", + idArr) }); + masterPDC.setCurrentSz(masterPDC.getAllocatedSz()); + } else { + List files = new ArrayList(); + List> ids = new ArrayList>(); + List> indexes = new ArrayList>(); - for (Map workingMap : dbResults) { - int id = (Integer) workingMap.get("id"); - int idx = (Integer) workingMap.get("pointDataView.curIdx"); - dbResultMap.put(id, workingMap); - String fileName = dao.getPointDataFileName(workingMap); - int listIndex = files.indexOf(fileName); - if (listIndex == -1) { - listIndex = files.size(); - files.add(fileName); - ids.add(new ArrayList()); - indexes.add(new ArrayList()); - hdf5attribList.retainAll(Arrays.asList(dao - .getPointDataDescription(workingMap) - .getParameterNames())); - } - ids.get(listIndex).add(id); - indexes.get(listIndex).add(idx); - } - long t0 = System.currentTimeMillis(); - for (int i = 0; i < files.size(); i++) { - File file = new File(files.get(i)); - List attribSet = new ArrayList(hdf5attribList); - int[] idxArr = new int[indexes.get(i).size()]; - int[] idArr = new int[ids.get(i).size()]; - for (int j = 0; j < idArr.length; j++) { - idxArr[j] = indexes.get(i).get(j); - idArr[j] = ids.get(i).get(j); - } - PointDataContainer pdc = dao.getPointData(file, idxArr, idArr, - attribSet.toArray(new String[0]), this.requestStyle); - if (masterPDC == null) { - masterPDC = pdc; - masterPDC.setCurrentSz(masterPDC.getAllocatedSz()); - } else { - masterPDC.combine(pdc); - masterPDC.setCurrentSz(masterPDC.getAllocatedSz()); - } - } - long t1 = System.currentTimeMillis(); - System.out - .println("Total time spent on pointdata hdf5 retrieval (all files): " - + (t1 - t0)); - } + for (Map workingMap : dbResults) { + int id = (Integer) workingMap.get("id"); + int idx = (Integer) workingMap.get("pointDataView.curIdx"); + dbResultMap.put(id, workingMap); + String fileName = dao.getPointDataFileName(workingMap); + int listIndex = files.indexOf(fileName); + if (listIndex == -1) { + listIndex = files.size(); + files.add(fileName); + ids.add(new ArrayList()); + indexes.add(new ArrayList()); + hdf5attribList.retainAll(Arrays.asList(dao + .getPointDataDescription(workingMap) + .getParameterNames())); + } + ids.get(listIndex).add(id); + indexes.get(listIndex).add(idx); + } + long t0 = System.currentTimeMillis(); + for (int i = 0; i < files.size(); i++) { + File file = new File(files.get(i)); + List attribSet = new ArrayList(hdf5attribList); + int[] idxArr = new int[indexes.get(i).size()]; + int[] idArr = new int[ids.get(i).size()]; + for (int j = 0; j < idArr.length; j++) { + idxArr[j] = indexes.get(i).get(j); + idArr[j] = ids.get(i).get(j); + } + PointDataContainer pdc = dao.getPointData(file, idxArr, idArr, + attribSet.toArray(new String[0]), this.requestStyle); + if (masterPDC == null) { + masterPDC = pdc; + masterPDC.setCurrentSz(masterPDC.getAllocatedSz()); + } else { + masterPDC.combine(pdc); + masterPDC.setCurrentSz(masterPDC.getAllocatedSz()); + } + } + long t1 = System.currentTimeMillis(); + System.out + .println("Total time spent on pointdata hdf5 retrieval (all files): " + + (t1 - t0)); + } - if (!dbParamDesc.isEmpty()) { - for (DbParameterDescription desc : dbParamDesc) { - switch (desc.getType()) { - case FLOAT: - float[] fdata = new float[masterPDC.getCurrentSz()]; - FloatDataRecord frec = new FloatDataRecord( - desc.getParameterName(), "", fdata); - if (desc.getFillValue() != null) { - frec.setFillValue(Float.parseFloat(desc.getFillValue())); - } - masterPDC.add(frec, desc.getUnit()); - break; - case INT: - int[] idata = new int[masterPDC.getCurrentSz()]; - masterPDC - .add(new IntegerDataRecord(desc.getParameterName(), - "", idata), desc.getUnit()); - break; - case LONG: - long[] ldata = new long[masterPDC.getCurrentSz()]; - masterPDC.add(new LongDataRecord(desc.getParameterName(), - "", ldata), desc.getUnit()); - break; - case STRING: - String[] sdata = new String[masterPDC.getCurrentSz()]; - masterPDC.add(new StringDataRecord(desc.getParameterName(), - "", sdata), desc.getUnit()); - break; - } - } - for (int i = 0; i < masterPDC.getAllocatedSz(); i++) { - PointDataView pdv = masterPDC.readRandom(i); - Map dbMap = dbResultMap.get(pdv.getInt("id")); - for (DbParameterDescription desc : dbParamDesc) { - Object obj = dbMap.get(desc.getQueryName()); - if (obj == null) { - obj = pdv.getContainer() - .getParameterRecord(desc.getParameterName()) - .getFillValue(); - if (obj == null) { - continue; - } - } - switch (desc.getType()) { - case FLOAT: - pdv.setFloat(desc.getParameterName(), - ((Number) obj).floatValue()); - break; - case INT: + if (!dbParamDesc.isEmpty()) { + for (DbParameterDescription desc : dbParamDesc) { + switch (desc.getType()) { + case FLOAT: + float[] fdata = new float[masterPDC.getCurrentSz()]; + FloatDataRecord frec = new FloatDataRecord( + desc.getParameterName(), "", fdata); + if (desc.getFillValue() != null) { + frec.setFillValue(Float.parseFloat(desc.getFillValue())); + } + masterPDC.add(frec, desc.getUnit()); + break; + case INT: + int[] idata = new int[masterPDC.getCurrentSz()]; + masterPDC + .add(new IntegerDataRecord(desc.getParameterName(), + "", idata), desc.getUnit()); + break; + case LONG: + long[] ldata = new long[masterPDC.getCurrentSz()]; + masterPDC.add(new LongDataRecord(desc.getParameterName(), + "", ldata), desc.getUnit()); + break; + case STRING: + String[] sdata = new String[masterPDC.getCurrentSz()]; + masterPDC.add(new StringDataRecord(desc.getParameterName(), + "", sdata), desc.getUnit()); + break; + } + } + for (int i = 0; i < masterPDC.getAllocatedSz(); i++) { + PointDataView pdv = masterPDC.readRandom(i); + Map dbMap = dbResultMap.get(pdv.getInt("id")); + for (DbParameterDescription desc : dbParamDesc) { + Object obj = dbMap.get(desc.getQueryName()); + if (obj == null) { + obj = pdv.getContainer() + .getParameterRecord(desc.getParameterName()) + .getFillValue(); + if (obj == null) { + continue; + } + } + switch (desc.getType()) { + case FLOAT: + pdv.setFloat(desc.getParameterName(), + ((Number) obj).floatValue()); + break; + case INT: - pdv.setInt(desc.getParameterName(), - ((Number) obj).intValue()); - break; - case LONG: - pdv.setLong(desc.getParameterName(), - ((Number) obj).longValue()); - break; - case STRING: - pdv.setString(desc.getParameterName(), obj.toString()); - break; - } - } - } - } + pdv.setInt(desc.getParameterName(), + ((Number) obj).intValue()); + break; + case LONG: + pdv.setLong(desc.getParameterName(), + ((Number) obj).longValue()); + break; + case STRING: + pdv.setString(desc.getParameterName(), obj.toString()); + break; + } + } + } + } - return masterPDC; - } + return masterPDC; + } } + diff --git a/edexOsgi/gov.noaa.nws.ost.edex.plugin.regionalsat/utility/edex_static/base/purge/regionalsatPurgeRules.xml b/edexOsgi/gov.noaa.nws.ost.edex.plugin.regionalsat/utility/edex_static/base/purge/regionalsatPurgeRules.xml new file mode 100644 index 0000000000..fbed4d37d9 --- /dev/null +++ b/edexOsgi/gov.noaa.nws.ost.edex.plugin.regionalsat/utility/edex_static/base/purge/regionalsatPurgeRules.xml @@ -0,0 +1,164 @@ + + + + + satellite + default + + 24 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager Channel 4-5 IR + + 48 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager 3.9 micron IR + + 48 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager 3 Channel Diff + + 48 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=MTSAT;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=MTSAT;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=MTSAT;physicalElement=Imager Channel 4-5 IR + + 48 + + + + satellite + creatingEntity=GVAR;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=GVAR;physicalElement=Imager 3.9 micron IR + + 48 + + + + satellite + creatingEntity=GVAR;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=GVAR;physicalElement=Imager 6.7-6.5 micron IR (WV) + + 48 + + + + satellite + creatingEntity=DMSP;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=DMSP;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=FY1C;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=FY1C;physicalElement=Imager Channel 4-5 IR + + 48 + + + + satellite + creatingEntity=FY1C;physicalElement=Imager 3 Channel Diff + + 48 + + + + satellite + creatingEntity=FY1C;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=FY3C;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=FY3C;physicalElement=Imager Channel 4-5 IR + + 48 + + + + satellite + creatingEntity=FY3C;physicalElement=Imager 3 Channel Diff + + 48 + + + + satellite + creatingEntity=FY3C;physicalElement=Imager Visible + + 48 + + diff --git a/edexOsgi/gov.noaa.nws.ost.edex.plugin.regionalsat/utility/edex_static/site/AFC/purge/regionalsatPurgeRules.xml b/edexOsgi/gov.noaa.nws.ost.edex.plugin.regionalsat/utility/edex_static/site/AFC/purge/regionalsatPurgeRules.xml new file mode 100644 index 0000000000..fbed4d37d9 --- /dev/null +++ b/edexOsgi/gov.noaa.nws.ost.edex.plugin.regionalsat/utility/edex_static/site/AFC/purge/regionalsatPurgeRules.xml @@ -0,0 +1,164 @@ + + + + + satellite + default + + 24 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager Channel 4-5 IR + + 48 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager 3.9 micron IR + + 48 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager 3 Channel Diff + + 48 + + + + satellite + creatingEntity=HRPT;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=MTSAT;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=MTSAT;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=MTSAT;physicalElement=Imager Channel 4-5 IR + + 48 + + + + satellite + creatingEntity=GVAR;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=GVAR;physicalElement=Imager 3.9 micron IR + + 48 + + + + satellite + creatingEntity=GVAR;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=GVAR;physicalElement=Imager 6.7-6.5 micron IR (WV) + + 48 + + + + satellite + creatingEntity=DMSP;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=DMSP;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=FY1C;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=FY1C;physicalElement=Imager Channel 4-5 IR + + 48 + + + + satellite + creatingEntity=FY1C;physicalElement=Imager 3 Channel Diff + + 48 + + + + satellite + creatingEntity=FY1C;physicalElement=Imager Visible + + 48 + + + + satellite + creatingEntity=FY3C;physicalElement=Imager 11 micron IR + + 48 + + + + satellite + creatingEntity=FY3C;physicalElement=Imager Channel 4-5 IR + + 48 + + + + satellite + creatingEntity=FY3C;physicalElement=Imager 3 Channel Diff + + 48 + + + + satellite + creatingEntity=FY3C;physicalElement=Imager Visible + + 48 + + diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.atcf/unit-test/gov/noaa/nws/ncep/edex/plugin/atcf/util/AtcfParserTest.java b/ncep/gov.noaa.nws.ncep.edex.plugin.atcf/unit-test/gov/noaa/nws/ncep/edex/plugin/atcf/util/AtcfParserTest.java index 5201e47eac..661d154428 100644 --- a/ncep/gov.noaa.nws.ncep.edex.plugin.atcf/unit-test/gov/noaa/nws/ncep/edex/plugin/atcf/util/AtcfParserTest.java +++ b/ncep/gov.noaa.nws.ncep.edex.plugin.atcf/unit-test/gov/noaa/nws/ncep/edex/plugin/atcf/util/AtcfParserTest.java @@ -1,39 +1,36 @@ package gov.noaa.nws.ncep.edex.plugin.atcf.util; -import static org.junit.Assert.*; -import gov.noaa.nws.ncep.common.dataplugin.atcf.*; +import static org.junit.Assert.assertEquals; +import gov.noaa.nws.ncep.common.dataplugin.atcf.AtcfRecord; + import java.util.Calendar; -import org.junit.BeforeClass; import org.junit.Test; public class AtcfParserTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } + private static final double ALLOWABLE_DOUBLE_DELTA = 0.00001; @Test public void testProcessLatLon() { - Float latLon; - latLon = AtcfParser.processLatLon("975W"); - assertEquals (-97.5, latLon); + float latLon = AtcfParser.processLatLon("975W"); + assertEquals(-97.5F, latLon, ALLOWABLE_DOUBLE_DELTA); latLon = AtcfParser.processLatLon("1605E"); - assertEquals (160.5, latLon); + assertEquals(160.5, latLon, ALLOWABLE_DOUBLE_DELTA); latLon = AtcfParser.processLatLon("1605W"); - assertEquals (-160.5, latLon); + assertEquals(-160.5, latLon, ALLOWABLE_DOUBLE_DELTA); latLon = AtcfParser.processLatLon("623E"); - assertEquals (62.3, latLon); + assertEquals(62.3, latLon, ALLOWABLE_DOUBLE_DELTA); latLon = AtcfParser.processLatLon("62N"); - assertEquals (6.2, latLon); + assertEquals(6.2, latLon, ALLOWABLE_DOUBLE_DELTA); latLon = AtcfParser.processLatLon("847S"); - assertEquals (-84.7, latLon); + assertEquals(-84.7, latLon, ALLOWABLE_DOUBLE_DELTA); latLon = AtcfParser.processLatLon("847G"); - assertEquals (999999., latLon); + assertEquals(999999., latLon, ALLOWABLE_DOUBLE_DELTA); latLon = AtcfParser.processLatLon(""); - assertEquals (999999., latLon); + assertEquals(999999., latLon, ALLOWABLE_DOUBLE_DELTA); latLon = AtcfParser.processLatLon(" "); - assertEquals (999999., latLon); + assertEquals(999999., latLon, ALLOWABLE_DOUBLE_DELTA); } @Test @@ -95,19 +92,19 @@ public class AtcfParserTest { assertEquals (2, record.getTechniqueNum()); assertEquals ("ZGFS", record.getTechnique()); assertEquals (0, record.getFcstHour()); - assertEquals (999999., record.getClat()); - assertEquals (-96.6, record.getClon()); - assertEquals (25., record.getWindMax()); - assertEquals (1008., record.getMslp()); + assertEquals(999999., record.getClat(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(-96.6, record.getClon(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(25., record.getWindMax(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(1008., record.getMslp(), ALLOWABLE_DOUBLE_DELTA); assertEquals ("XX", record.getIntensity()); - assertEquals (34., record.getRadWind()); + assertEquals(34., record.getRadWind(), ALLOWABLE_DOUBLE_DELTA); assertEquals ("NEQ", record.getRadWindQuad()); - assertEquals (100., record.getQuad1WindRad()); - assertEquals (85., record.getQuad2WindRad()); - assertEquals (70., record.getQuad3WindRad()); - assertEquals (85., record.getQuad4WindRad()); - assertEquals (999999., record.getClosedP()); - assertEquals (999999., record.getRadClosedP()); + assertEquals(100., record.getQuad1WindRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(85., record.getQuad2WindRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(70., record.getQuad3WindRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(85., record.getQuad4WindRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(999999., record.getClosedP(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(999999., record.getRadClosedP(), ALLOWABLE_DOUBLE_DELTA); // theBulletin = "CP, 85, 2010053012, 03, OFCL, 3, 242N, 1568W, 100, 960, HU, 34, NEQ, 130, 132, 134, 135, 0, 0, 0, 120, 20, C, 0, RMT, 25, 9, HURCNAME, , 12, NEQ, 130, 131, 132, 133\n"; record = AtcfParser.processFields(theBulletin); @@ -121,35 +118,35 @@ public class AtcfParserTest { assertEquals (3, record.getTechniqueNum()); assertEquals ("OFCL", record.getTechnique()); assertEquals (3, record.getFcstHour()); - assertEquals (24.2, record.getClat()); - assertEquals (-156.8, record.getClon()); - assertEquals (100., record.getWindMax()); - assertEquals (960., record.getMslp()); + assertEquals(24.2, record.getClat(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(-156.8, record.getClon(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(100., record.getWindMax(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(960., record.getMslp(), ALLOWABLE_DOUBLE_DELTA); assertEquals ("HU", record.getIntensity()); - assertEquals (34., record.getRadWind()); + assertEquals(34., record.getRadWind(), ALLOWABLE_DOUBLE_DELTA); assertEquals ("NEQ", record.getRadWindQuad()); - assertEquals (130., record.getQuad1WindRad()); - assertEquals (132., record.getQuad2WindRad()); - assertEquals (134., record.getQuad3WindRad()); - assertEquals (135., record.getQuad4WindRad()); - assertEquals (0., record.getClosedP()); - assertEquals (0., record.getRadClosedP()); - assertEquals (0., record.getMaxWindRad()); - assertEquals (120., record.getGust()); - assertEquals (20., record.getEyeSize()); + assertEquals(130., record.getQuad1WindRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(132., record.getQuad2WindRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(134., record.getQuad3WindRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(135., record.getQuad4WindRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(0., record.getClosedP(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(0., record.getRadClosedP(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(0., record.getMaxWindRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(120., record.getGust(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(20., record.getEyeSize(), ALLOWABLE_DOUBLE_DELTA); assertEquals ("C", record.getSubRegion()); - assertEquals (0., record.getMaxSeas()); + assertEquals(0., record.getMaxSeas(), ALLOWABLE_DOUBLE_DELTA); assertEquals ("RMT", record.getForecaster()); - assertEquals (25., record.getStormDrct()); - assertEquals (9., record.getStormSped()); + assertEquals(25., record.getStormDrct(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(9., record.getStormSped(), ALLOWABLE_DOUBLE_DELTA); assertEquals ("HURCNAME", record.getStormName()); assertEquals (" ", record.getStormDepth()); - assertEquals (12., record.getRadWave()); + assertEquals(12., record.getRadWave(), ALLOWABLE_DOUBLE_DELTA); assertEquals ("NEQ", record.getRadWaveQuad()); - assertEquals (130., record.getQuad1WaveRad()); - assertEquals (131., record.getQuad2WaveRad()); - assertEquals (132., record.getQuad3WaveRad()); - assertEquals (133., record.getQuad4WaveRad()); + assertEquals(130., record.getQuad1WaveRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(131., record.getQuad2WaveRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(132., record.getQuad3WaveRad(), ALLOWABLE_DOUBLE_DELTA); + assertEquals(133., record.getQuad4WaveRad(), ALLOWABLE_DOUBLE_DELTA); } } diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/NcgribDecoder.java b/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/NcgribDecoder.java index 5ca159b5f5..975d527495 100644 --- a/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/NcgribDecoder.java +++ b/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/NcgribDecoder.java @@ -19,8 +19,11 @@ **/ package gov.noaa.nws.ncep.edex.plugin.ncgrib; +import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord; +import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException; +import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.TableTimeStamp; + import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -33,16 +36,12 @@ import ucar.grib.grib2.Grib2Input; import ucar.grib.grib2.Grib2Record; import ucar.unidata.io.RandomAccessFile; - import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.python.decoder.PythonDecoder; -import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord; - -import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException; -import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.TableTimeStamp; /** * Generic decoder for decoding grib files @@ -55,6 +54,7 @@ import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.TableTimeStamp; * 10/13/10 276 llin Modified for NC GRIB. * 01/19/12 xguo Split large files * 05/23/12 xguo Split large file to each record file + * 06/12/12 00609 djohnson Use EDEXUtil for EDEX_HOME. * * * @author njensen @@ -193,7 +193,7 @@ public class NcgribDecoder { raf.read(transfer); try { - out = new FileOutputStream(System.getProperty("edex.home") + out = new FileOutputStream(EDEXUtil.EDEX_HOME + "/data/sbn/ncgrib/" + fileName + "_" + num); out.write(transfer); out.close(); @@ -224,7 +224,7 @@ public class NcgribDecoder { raf.read(transfer); try { - out = new FileOutputStream(System.getProperty("edex.home") + out = new FileOutputStream(EDEXUtil.EDEX_HOME + "/data/sbn/ncgrib/" + fileName + "_" + num); out.write(transfer); out.close(); @@ -245,7 +245,7 @@ public class NcgribDecoder { raf.read(transfer); try { - out = new FileOutputStream(System.getProperty("edex.home") + out = new FileOutputStream(EDEXUtil.EDEX_HOME + "/data/sbn/ncgrib/" + fileName + "_" + num); out.write(transfer); out.close(); diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.ncuair/unit-test/gov/noaa/nws/ncep/edex/plugin/ncuair/util/NcUairParserTest.java b/ncep/gov.noaa.nws.ncep.edex.plugin.ncuair/unit-test/gov/noaa/nws/ncep/edex/plugin/ncuair/util/NcUairParserTest.java index 7473710da0..95346b8f71 100644 --- a/ncep/gov.noaa.nws.ncep.edex.plugin.ncuair/unit-test/gov/noaa/nws/ncep/edex/plugin/ncuair/util/NcUairParserTest.java +++ b/ncep/gov.noaa.nws.ncep.edex.plugin.ncuair/unit-test/gov/noaa/nws/ncep/edex/plugin/ncuair/util/NcUairParserTest.java @@ -5,32 +5,16 @@ * * L. Lin 04/09 Creation * S. Gurung 09/11 Renamed H5 to Nc and h5 to nc + * D. Johnson 08/12 Upgrade to JUnit 4.10. * * */ package gov.noaa.nws.ncep.edex.plugin.ncuair.util; -import static org.junit.Assert.*; -import java.util.Calendar; -import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.junit.Before; - -import gov.noaa.nws.ncep.common.dataplugin.ncuair.NcUairLiftedIndex; -import gov.noaa.nws.ncep.common.dataplugin.ncuair.NcUairMaxWind; -import gov.noaa.nws.ncep.common.dataplugin.ncuair.NcUairObsLevels; -import gov.noaa.nws.ncep.common.dataplugin.ncuair.NcUairTropopause; -import gov.noaa.nws.ncep.common.dataplugin.ncuair.NcUairRecord; -import gov.noaa.nws.ncep.edex.plugin.ncuair.util.NcUairParser; -import gov.noaa.nws.ncep.edex.plugin.ncuair.util.NcUairWindGroup; -import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.*; - -import gov.noaa.nws.ncep.edex.tools.decoder.MndTime; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.TimeZone; +import org.junit.Test; public class NcUairParserTest { String report = "USUS41 KLWX 190000\r\r\n" + @@ -68,7 +52,7 @@ public class NcUairParserTest { @Test public void testGetUairType() { Integer uairType = NcUairParser.getUairType("TTAA"); - assertEquals( 1, uairType); + assertEquals(1, uairType.intValue()); } } diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.stormtrack/unit-test/gov/noaa/nws/ncep/edex/plugin/stormtrack/util/StormTrackParserTest.java b/ncep/gov.noaa.nws.ncep.edex.plugin.stormtrack/unit-test/gov/noaa/nws/ncep/edex/plugin/stormtrack/util/StormTrackParserTest.java index b43c857f3c..478a29240a 100644 --- a/ncep/gov.noaa.nws.ncep.edex.plugin.stormtrack/unit-test/gov/noaa/nws/ncep/edex/plugin/stormtrack/util/StormTrackParserTest.java +++ b/ncep/gov.noaa.nws.ncep.edex.plugin.stormtrack/unit-test/gov/noaa/nws/ncep/edex/plugin/stormtrack/util/StormTrackParserTest.java @@ -1,8 +1,7 @@ package gov.noaa.nws.ncep.edex.plugin.stormtrack.util; -import static org.junit.Assert.*; -import gov.noaa.nws.ncep.common.dataplugin.stormtrack.*; -import gov.noaa.nws.ncep.edex.plugin.stormtrack.util.StormTrackParser; +import static org.junit.Assert.assertEquals; +import gov.noaa.nws.ncep.common.dataplugin.stormtrack.StormTrackRecord; import java.util.Calendar; @@ -19,23 +18,23 @@ public class StormTrackParserTest { public void testProcessLatLon() { Float latLon; latLon = StormTrackParser.processLatLon("975W"); - assertEquals (-97.5, latLon); + assertEquals(-97.5, latLon.doubleValue()); latLon = StormTrackParser.processLatLon("1605E"); - assertEquals (160.5, latLon); + assertEquals(160.5, latLon.doubleValue()); latLon = StormTrackParser.processLatLon("1605W"); - assertEquals (-160.5, latLon); + assertEquals(-160.5, latLon.doubleValue()); latLon = StormTrackParser.processLatLon("623E"); - assertEquals (62.3, latLon); + assertEquals(62.3, latLon.doubleValue()); latLon = StormTrackParser.processLatLon("62N"); - assertEquals (6.2, latLon); + assertEquals(6.2, latLon.doubleValue()); latLon = StormTrackParser.processLatLon("847S"); - assertEquals (-84.7, latLon); + assertEquals(-84.7, latLon.doubleValue()); latLon = StormTrackParser.processLatLon("847G"); - assertEquals (999999., latLon); + assertEquals(999999., latLon.doubleValue()); latLon = StormTrackParser.processLatLon(""); - assertEquals (999999., latLon); + assertEquals(999999., latLon.doubleValue()); latLon = StormTrackParser.processLatLon(" "); - assertEquals (999999., latLon); + assertEquals(999999., latLon.doubleValue()); } @Test diff --git a/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/categorymap/CATMAPTest.java b/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/categorymap/CATMAPTest.java index 39233cdec7..2cf173fd26 100644 --- a/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/categorymap/CATMAPTest.java +++ b/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/categorymap/CATMAPTest.java @@ -1,30 +1,33 @@ package gov.noaa.nws.ncep.gempak.parameters.core.categorymap; -import static org.junit.Assert.*; -import gov.noaa.nws.ncep.gempak.parameters.core.categorymap.CatMap; - +import org.junit.Assert; import org.junit.Test; - -/**
-* SOFTWARE HISTORY
-* Date          Ticket#     Engineer     Description
-* ------------ ---------- ----------- --------------------------
-* 16-Nov-2009    194        Archana.S   Initial Creation
-* 20-Nov-2009    194        Archana.S   Updated per review comments:
-*                                         Added a test-case to retrieve the label
-*                                         given a value
-*                                         Updated method names per design changes in the class
-*                                         CATMAP
-*  
-* 
-* @author Archana.S -* @version 1

-{@link gov.noaa.nws.ncep.gempak.parameters.core.categorymap.CatMap}. -*/ +/** + *

+ * SOFTWARE HISTORY
+ * Date          Ticket#     Engineer     Description
+ * ------------ ---------- ----------- --------------------------
+ * 16-Nov-2009    194        Archana.S   Initial Creation
+ * 20-Nov-2009    194        Archana.S   Updated per review comments:
+ *                                         Added a test-case to retrieve the label
+ *                                         given a value
+ *                                         Updated method names per design changes in the class
+ *                                         CATMAP
+ * 25-Aug-2012    743        djohnson    Upgrade to JUnit 4.10.
+ * 
+ * 
+ * + * @author Archana.S + * @version 1 + *

+ * {@link gov.noaa.nws.ncep.gempak.parameters.core.categorymap.CatMap}. + */ public class CATMAPTest { private static int testCaseNumber; + private static final double ALLOWABLE_DOUBLE_DELTA = 0.0001; + /** *Test for valid label/value pair */ @@ -46,16 +49,25 @@ private static int testCaseNumber; } /** - *Test to retrieve matching label given a floating point value - */ + * @param val1 + * @param expected + */ + private void assertEquals(Float val1, double expected) { + Assert.assertEquals(expected, val1.doubleValue(), + ALLOWABLE_DOUBLE_DELTA); + } + + /** + * Test to retrieve matching label given a floating point value + */ @Test public void testGetLabelForValue() { CatMap catmap = new CatMap("ABC=4;acd=2;lmn=0.5;efg=2;hij=2"); - assertEquals(catmap.getMatchingLabelForValue(0.5f),"lmn"); - assertEquals(catmap.getMatchingLabelForValue(4f),"ABC"); - assertEquals(catmap.getMatchingLabelForValue(2f),"acd"); + Assert.assertEquals(catmap.getMatchingLabelForValue(0.5f), "lmn"); + Assert.assertEquals(catmap.getMatchingLabelForValue(4f), "ABC"); + Assert.assertEquals(catmap.getMatchingLabelForValue(2f), "acd"); System.out.println("=====================Test-Case "+testCaseNumber+" ========================"); System.out.println("Test for getting the matching label, given a floating point value"); @@ -75,7 +87,7 @@ private static int testCaseNumber; CatMap catmap = new CatMap("ABC=4;acd=2;lmn=0.5;efg=2;hij=2"); - assertEquals(catmap.getMatchingLabelForValue(0.00005f),null); + Assert.assertNull(catmap.getMatchingLabelForValue(0.00005f)); System.out.println("=====================Test-Case "+testCaseNumber+" ========================"); System.out.println("Test for getting the matching label, given a floating point value not in the list"); diff --git a/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/contourinterval/CINTTest.java b/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/contourinterval/CINTTest.java index fa6d889577..320fac04cc 100644 --- a/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/contourinterval/CINTTest.java +++ b/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/contourinterval/CINTTest.java @@ -1,16 +1,13 @@ package gov.noaa.nws.ncep.gempak.parameters.core.contourinterval; -import gov.noaa.nws.ncep.gempak.parameters.core.contourinterval.CINT; - +import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import org.junit.Test; -import static org.junit.Assert.*; /** *

@@ -30,6 +27,7 @@ import static org.junit.Assert.*;
 
 public class CINTTest {
 	
+    private static final double ALLOWABLE_DOUBLE_DELTA = 0.0001;
 	private static int testCaseNumber;
 	private List testList;
 	private List testList2;
@@ -47,10 +45,14 @@ public class CINTTest {
 		    testList = new ArrayList(Arrays.asList(0.5, 9.0));
 		    keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
 		    assertEquals(keySetList,testList);
-		    assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL).doubleValue(), 10);
-		    assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL).doubleValue(), 0.5);
-		    assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL).doubleValue(), 9);
-		    assertEquals(cint.getNumPaddingDigits(CINT.FIRST_ZOOM_LEVEL), 0);
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 10, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 0.5, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 9, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(
+                cint.getNumPaddingDigits(CINT.FIRST_ZOOM_LEVEL).intValue(), 0);
 		    System.out.println("=====================Test-Case "+testCaseNumber+"a ========================");
 		    System.out.println("The input string = " + cint.getUserInputString());
 			System.out.println("Is the contour data string parsed correctly? " + cint.isCINTStringParsed());
@@ -67,10 +69,14 @@ public class CINTTest {
                     20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0));
 		    keySetList = cint2.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
 		    assertEquals(testList2,keySetList);
-		    assertEquals(cint2.getContourInterval(CINT.FIRST_ZOOM_LEVEL).doubleValue(), 10);
-		    assertEquals(cint2.getMinContourValue(CINT.FIRST_ZOOM_LEVEL).doubleValue(), -57);
-		    assertEquals(cint2.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL).doubleValue(), 86);		    
-			assertEquals(cint2.getNumPaddingDigits(CINT.FIRST_ZOOM_LEVEL), 4);
+        assertEquals(cint2.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 10, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint2.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), -57, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint2.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 86, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint2.getNumPaddingDigits(CINT.FIRST_ZOOM_LEVEL)
+                .intValue(), 4);
 			System.out.println("=====================Test-Case "+testCaseNumber+"b ========================");
 			System.out.println("The input string = " + cint2.getUserInputString());
 		    System.out.println("Is the contour data string parsed correctly? " + cint2.isCINTStringParsed());
@@ -158,9 +164,12 @@ public class CINTTest {
 	/*Test for valid contour string of the form contourInterval/minContourValue/ */
 	public void testContourIntervalWithMinValueOnly(){
 		CINT cint = new CINT("-0.345/0/");
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),-0.345);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),0);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);	
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), -0.345, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 0, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
 		
 		System.out.println("=====================Test-Case "+testCaseNumber+" ========================");
 		System.out.println("The input string = " + cint.getUserInputString());
@@ -177,9 +186,12 @@ public class CINTTest {
 	/*Test for valid contour data string of the form contourInterval//maxContourValue */
 	public void testContourIntervalWithMaxValueOnly(){
 		CINT cint = new CINT("15//30");
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),15);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),30);	
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 15, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 30, ALLOWABLE_DOUBLE_DELTA);
 	
 		System.out.println("=====================Test-Case "+testCaseNumber+" ========================");
 		System.out.println("Is the contour data string parsed correctly? " + cint.isCINTStringParsed());
@@ -196,9 +208,12 @@ public class CINTTest {
 		
 		CINT cint = new CINT("-0.5/");
 		assertEquals(cint.isCINTStringParsed(),true);
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),-0.5);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), -0.5, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
 		
 	    System.out.println("=====================Test-Case "+testCaseNumber+"a ========================");
 	    System.out.println("The input string = " + cint.getUserInputString());
@@ -209,9 +224,12 @@ public class CINTTest {
 
 		CINT cint2 = new CINT("-.89//");
 		assertEquals(cint2.isCINTStringParsed(),true);
-		assertEquals(cint2.getContourInterval(CINT.FIRST_ZOOM_LEVEL),-0.89);
-		assertEquals(cint2.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
-		assertEquals(cint2.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
+        assertEquals(cint2.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), -0.89, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint2.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint2.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
 		
 	    System.out.println("=====================Test-Case "+testCaseNumber+"b ========================");
 	    System.out.println("The input string = " + cint2.getUserInputString());
@@ -229,9 +247,12 @@ public class CINTTest {
 	/*Test for valid contour data string of the form /minContourValue/maxContourValue */
 	public void testContourIntervalWithNoContourIntervalAndWithMinMaxValueOnly(){
 		CINT cint = new CINT("/10/30");
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),10);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),30);	
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 10, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 30, ALLOWABLE_DOUBLE_DELTA);
 	
 		System.out.println("=====================Test-Case "+testCaseNumber+" ========================");
 		System.out.println("The input string = " + cint.getUserInputString());
@@ -249,9 +270,12 @@ public class CINTTest {
 	/*Test for valid contour data string of the form /minContourValue/maxContourValue */
 	public void testContourIntervalWithMinValSameAsMaxValAndNoContourIntervalSpecified(){
 		CINT cint = new CINT("/10/10");
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),10);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),10);	
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 10, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 10, ALLOWABLE_DOUBLE_DELTA);
 	    testList = new ArrayList(Arrays.asList(10.0));
 	    keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
 	    assertEquals(keySetList,testList);
@@ -312,9 +336,12 @@ public class CINTTest {
 		
 		CINT cint = new CINT("20/10/70/30/40/500");
 		assertEquals(cint.isCINTStringParsed(), true);
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),20);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),10);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),70);
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 20, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 10, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 70, ALLOWABLE_DOUBLE_DELTA);
 		//
 		testList = new ArrayList(Arrays.asList(10.0, 30.0, 50.0, 60.0));
 	    keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
@@ -338,9 +365,12 @@ public class CINTTest {
 	public void testNonNumericContourIntervalString(){
 		CINT cint = new CINT("-def/abc/%^&/30/40");
 		assertEquals(cint.isCINTStringParsed(), false);
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
 		
 		System.out.println("=====================Test-Case "+testCaseNumber+"========================");	
 		System.out.println("The input string      = "+cint.getUserInputString());
@@ -359,9 +389,12 @@ public class CINTTest {
 		
 		CINT cint = new CINT("5.10.60.9");
 		assertEquals(cint.isCINTStringParsed(), false);
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),Double.NaN);		
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), Double.NaN, ALLOWABLE_DOUBLE_DELTA);
     	
 		System.out.println("=====================Test-Case "+testCaseNumber+"========================");
 		System.out.println("The input string      = "+cint.getUserInputString());
@@ -379,9 +412,12 @@ public class CINTTest {
 	public void testMinMaxValuesInterchangedContourIntervalString(){
 		CINT cint = new CINT("-5/20/5");
 		assertEquals(cint.isCINTStringParsed(), true);
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),-5);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),5);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),20);
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), -5, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 5, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 20, ALLOWABLE_DOUBLE_DELTA);
 		
 	    testList = new ArrayList(Arrays.asList(5.0, 10.0, 15.0, 20.0));
 	    keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
@@ -398,9 +434,12 @@ public class CINTTest {
 		
 		CINT cint2 = new CINT("5/20/5");
 		assertEquals(cint2.isCINTStringParsed(), true);
-		assertEquals(cint2.getContourInterval(CINT.FIRST_ZOOM_LEVEL),5);
-		assertEquals(cint2.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),5);
-		assertEquals(cint2.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),20);		
+        assertEquals(cint2.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 5, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint2.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 5, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint2.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 20, ALLOWABLE_DOUBLE_DELTA);
 	    testList = new ArrayList(Arrays.asList(5.0, 10.0, 15.0, 20.0));
 //	    assertEquals(cint2.getContourValuesList(),testList);	
 		
@@ -492,9 +531,12 @@ public class CINTTest {
 	public void testSingleLabelledContourIntervalString(){
 		CINT cint = new CINT("5=good/5/5");
 		assertEquals(cint.isCINTStringParsed(), true);
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),0);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),5);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),5);
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 0, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 5, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 5, ALLOWABLE_DOUBLE_DELTA);
 		
 	    testList = new ArrayList(Arrays.asList(5.0));
 	    keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
@@ -540,10 +582,14 @@ public class CINTTest {
 		CINT cint = new CINT("1/2/10/3 > 4/2/18");
 		
 		assertEquals(cint.isCINTStringParsed(), true);
-		assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL),1);
-		assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL),2);
-		assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL),10);
-		assertEquals(cint.getNumPaddingDigits(CINT.FIRST_ZOOM_LEVEL),3);
+        assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 1, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 2, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 10, ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(cint.getNumPaddingDigits(CINT.FIRST_ZOOM_LEVEL)
+                .doubleValue(), 3, ALLOWABLE_DOUBLE_DELTA);
 		
 	    testList = new ArrayList(Arrays.asList(2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0));
 	    keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
@@ -591,8 +637,11 @@ public class CINTTest {
 	 	testList = new ArrayList(Arrays.asList(60.0,80.0));
 	    keySetList = cint.getContourValuesListAsDouble(CINT.THIRD_ZOOM_LEVEL);
 	    assertEquals(testList,keySetList);
-	    assertEquals(0.00009999, cint.getContourInterval(CINT.FOURTH_ZOOM_LEVEL));
-	    assertEquals(0.0000001, cint.getContourInterval(CINT.FIFTH_ZOOM_LEVEL));
+        assertEquals(0.00009999, cint
+                .getContourInterval(CINT.FOURTH_ZOOM_LEVEL).doubleValue(),
+                ALLOWABLE_DOUBLE_DELTA);
+        assertEquals(0.0000001, cint.getContourInterval(CINT.FIFTH_ZOOM_LEVEL)
+                .doubleValue(), ALLOWABLE_DOUBLE_DELTA);
 //	 	testList = new ArrayList(Arrays.asList(0.00009999));
 //	    keySetList = cint.getContourValuesListAsDouble(CINT.FOURTH_ZOOM_LEVEL);
 //	    assertEquals(testList,keySetList);
diff --git a/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/marshaller/garea/MapProjectionTest.java b/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/marshaller/garea/MapProjectionTest.java
index 9fe3b10a8a..4262506624 100644
--- a/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/marshaller/garea/MapProjectionTest.java
+++ b/ncep/gov.noaa.nws.ncep.gempak.parameters.core/unit_test/gov/noaa/nws/ncep/gempak/parameters/core/marshaller/garea/MapProjectionTest.java
@@ -1,7 +1,6 @@
 package gov.noaa.nws.ncep.gempak.parameters.core.marshaller.garea;
 
-import static org.junit.Assert.*;
-import gov.noaa.nws.ncep.gempak.parameters.core.marshaller.garea.MapProjection;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 
@@ -16,14 +15,14 @@ public class MapProjectionTest {
 		MapProjection map_obj = new MapProjection("LCC");
 		assertEquals(map_obj.isProjectionStringValid(),true);
 		Integer[] margins = map_obj.getProjectionMargins();
-	    assertEquals(margins[0],0);
-	    assertEquals(margins[1],3);
-	    assertEquals(margins[2],0);
-	    assertEquals(margins[3],0);
+        assertEquals(margins[0].intValue(), 0);
+        assertEquals(margins[1].intValue(), 3);
+        assertEquals(margins[2].intValue(), 0);
+        assertEquals(margins[3].intValue(), 0);
 	    Float[] angles = map_obj.getProjectionAngles();
-	    assertEquals(angles[0],0);
-	    assertEquals(angles[1],0);
-	    assertEquals(angles[2],0);	    
+        assertEquals(angles[0].intValue(), 0);
+        assertEquals(angles[1].intValue(), 0);
+        assertEquals(angles[2].intValue(), 0);
 
 	}
 
diff --git a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/discrete/DiscreteTest.java b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/discrete/DiscreteTest.java
index bfc3e41605..88c1e0f1be 100644
--- a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/discrete/DiscreteTest.java
+++ b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/discrete/DiscreteTest.java
@@ -3,43 +3,45 @@
  */
 package gov.noaa.nws.ncep.gempak.parameters.discrete;
 
-import static org.junit.Assert.*;
-
-import gov.noaa.nws.ncep.gempak.parameters.discrete.Discrete;
+import static org.junit.Assert.assertEquals;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-
 import org.junit.Test;
-/**
-* 
-* Junit test for {@link gov.noaa.nws.ncep.gempak.parameters.discrete.Discrete}.
-* 
-* 
-* SOFTWARE HISTORY
-* Date          Ticket#     Engineer     Description
-* ------------ ---------- ----------- --------------------------
-* 10-Dec-2009    205       Archana.S   Initial Creation
-* 18-Dec-2009    205       Archana.S   Updated per review comments:
-*                                      ----------------------------
-*                                      1. Removed all references to hard-coded tolerance value
-*                                         (0.000001) and replaced it with the method
-*                                         getTolerance(). Accordingly updated Javadoc for the corresponding
-*                                         tests. 
-*                                      2. Updated all test-cases, to replace the '-' delimiter in the
-*                                         input string with '~' 
-*                                      3. Added the following test-cases: 
-*                                      a. To parse negative numbers in the Discrete string.
-*                                      b. Test for extra arguments.
-* 
-* 
-* @author Archana.S -* @version 1 -*/ + +/** + *
+ * 
+ * Junit test for {@link gov.noaa.nws.ncep.gempak.parameters.discrete.Discrete}.
+ * 
+ * 
+ * SOFTWARE HISTORY
+ * Date          Ticket#     Engineer     Description
+ * ------------ ---------- ----------- --------------------------
+ * 10-Dec-2009    205       Archana.S   Initial Creation
+ * 18-Dec-2009    205       Archana.S   Updated per review comments:
+ *                                      ----------------------------
+ *                                      1. Removed all references to hard-coded tolerance value
+ *                                         (0.000001) and replaced it with the method
+ *                                         getTolerance(). Accordingly updated Javadoc for the corresponding
+ *                                         tests. 
+ *                                      2. Updated all test-cases, to replace the '-' delimiter in the
+ *                                         input string with '~' 
+ *                                      3. Added the following test-cases: 
+ *                                      a. To parse negative numbers in the Discrete string.
+ *                                      b. Test for extra arguments.
+ * 25-Aug-2012   743        djohnson    Upgrade to JUnit 4.10.
+ * 
+ * + * @author Archana.S + * @version 1 + */ public class DiscreteTest { - private static int testCaseNumber; + private static final double ALLOWABLE_DOUBLE_DELTA = 0.1; + + private static int testCaseNumber; private List testList; /** * Test valid input string with multiple start/end/discrete value strings. @@ -64,33 +66,33 @@ public class DiscreteTest { System.out.println("Discrete value = "+discreteObj .getDiscreteDataList().get(i).getDiscreteValue()); if(i==0){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(0)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(1)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(2)); } else if(i==1){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(3)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(4)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(5)); } else if(i==2){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(6)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(7)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(8)); } } @@ -121,33 +123,33 @@ public class DiscreteTest { System.out.println("Discrete value = "+discreteObj .getDiscreteDataList().get(i).getDiscreteValue()); if(i==0){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(0)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(1)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(2)); } else if(i==1){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(3)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(4)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(5)); } else if(i==2){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(6)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(7)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(8)); } } @@ -179,33 +181,33 @@ public class DiscreteTest { System.out.println("Discrete value = "+discreteObj .getDiscreteDataList().get(i).getDiscreteValue()); if(i==0){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(0)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(1)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(2)); } else if(i==1){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(3)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(4)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(5)); } else if(i==2){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(6)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(7)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(8)); } } @@ -238,33 +240,33 @@ public class DiscreteTest { System.out.println("Discrete value = "+discreteObj .getDiscreteDataList().get(i).getDiscreteValue()); if(i==0){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(0)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(1)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(2)); } else if(i==1){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(3)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(4)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(5)); } else if(i==2){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(6)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(7)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(8)); } } @@ -297,33 +299,33 @@ public class DiscreteTest { System.out.println("Discrete value = "+discreteObj .getDiscreteDataList().get(i).getDiscreteValue()); if(i==0){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(0)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(1)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(2)); } else if(i==1){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(3)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(4)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(5)); } else if(i==2){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(6)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(7)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(8)); } } @@ -356,33 +358,33 @@ public class DiscreteTest { System.out.println("Discrete value = "+discreteObj .getDiscreteDataList().get(i).getDiscreteValue()); if(i==0){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(0)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(1)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(2)); } else if(i==1){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(3)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(4)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(5)); } else if(i==2){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(6)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(7)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(8)); } } @@ -414,33 +416,33 @@ public class DiscreteTest { System.out.println("Discrete value = "+discreteObj .getDiscreteDataList().get(i).getDiscreteValue()); if(i==0){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(0)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(1)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(2)); } else if(i==1){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(3)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(4)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(5)); } else if(i==2){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(6)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(7)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(8)); } } @@ -461,7 +463,7 @@ public class DiscreteTest { System.out.println("Test input string with invalid delimiters\n"); System.out.println("The input string is "+discreteObj.getStrDiscrete()); System.out.println("Size of discrete data list = "+discreteObj.getDiscreteDataList().size()); - assertEquals(discreteObj.getDiscreteDataList().size(), 0); + assertEquals(discreteObj.getDiscreteDataList().size(), 0); testCaseNumber++; System.out.println("=========================================="); } @@ -493,33 +495,33 @@ public class DiscreteTest { System.out.println("Discrete value = "+discreteObj .getDiscreteDataList().get(i).getDiscreteValue()); if(i==0){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(0)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(1)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(2)); } else if(i==1){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(3)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(4)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(5)); } else if(i==2){ - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getStartValue(),testList.get(6)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getEndValue(),testList.get(7)); - assertEquals(discreteObj.getDiscreteDataList() + assertFloatComparison(discreteObj.getDiscreteDataList() .get(i).getDiscreteValue(),testList.get(8)); } } @@ -556,7 +558,7 @@ public class DiscreteTest { System.out.println("Test empty string\n"); System.out.println("The input string is "+discreteObj.getStrDiscrete()); System.out.println("Size of discrete data list = "+discreteObj.getDiscreteDataList().size()); - assertEquals(discreteObj.getDiscreteDataList().size(), 0); + assertEquals(discreteObj.getDiscreteDataList().size(), 0); Discrete discreteObj2 = new Discrete(null); @@ -565,7 +567,7 @@ public class DiscreteTest { System.out.println("Test empty string\n"); System.out.println("The input string is "+discreteObj2.getStrDiscrete()); System.out.println("Size of discrete data list = "+discreteObj2.getDiscreteDataList().size()); - assertEquals(discreteObj2.getDiscreteDataList().size(), 0); + assertEquals(discreteObj2.getDiscreteDataList().size(), 0); Discrete discreteObj3 = new Discrete(" "); @@ -573,7 +575,7 @@ public class DiscreteTest { System.out.println("Test empty string\n"); System.out.println("The input string is "+discreteObj3.getStrDiscrete()); System.out.println("Size of discrete data list = "+discreteObj3.getDiscreteDataList().size()); - assertEquals(discreteObj3.getDiscreteDataList().size(), 0); + assertEquals(discreteObj3.getDiscreteDataList().size(), 0); System.out.println("=========================================="); testCaseNumber++; @@ -591,7 +593,7 @@ public class DiscreteTest { System.out.println("Test input string with non numeric inputs\n"); System.out.println("The input string is "+discreteObj.getStrDiscrete()); System.out.println("Size of discrete data list = "+discreteObj.getDiscreteDataList().size()); - assertEquals(discreteObj.getDiscreteDataList().size(), 0); + assertEquals(discreteObj.getDiscreteDataList().size(), 0); testCaseNumber++; System.out.println("=========================================="); } @@ -609,19 +611,31 @@ public class DiscreteTest { System.out.println("Discrete Value to the left of 3.6 = "+discreteObj.getPrecedingDiscreteValue(3.6f)); System.out.println("Discrete Value to the left of 0.444 = "+discreteObj.getPrecedingDiscreteValue(0.444f)); - assertEquals(discreteObj.getPrecedingDiscreteValue(3.6f), 1.105f); - assertEquals(discreteObj.getPrecedingDiscreteValue(0.444f),0.444f); + assertFloatComparison(discreteObj.getPrecedingDiscreteValue(3.6f), + 1.105f); + assertFloatComparison(discreteObj.getPrecedingDiscreteValue(0.444f), + 0.444f); testCaseNumber++; System.out.println("=========================================="); } - - /** - * Test the method getDiscreteValueClosestToTwoContourLines() when the following conditions are satisfied: - * The absolute difference between the current start value and the first parameter in the function is - * less than the tolerance value and - * The absolute difference between the current end value and the second parameter in the function is - * less than the tolerance value - */ + + /** + * @param precedingDiscreteValue + * @param f + */ + private void assertFloatComparison(Float precedingDiscreteValue, float f) { + assertEquals(precedingDiscreteValue.floatValue(), f, + ALLOWABLE_DOUBLE_DELTA); + } + + /** + * Test the method getDiscreteValueClosestToTwoContourLines() when the + * following conditions are satisfied: The absolute difference between the + * current start value and the first parameter in the function is less than + * the tolerance value and The absolute difference between the current end + * value and the second parameter in the function is less than the tolerance + * value + */ @Test public void testGetDiscreteValueClosestToTwoContourLines1(){ Discrete discreteObj = new Discrete("0.1~.5=0.444;0.6~0.9=0.75;0.99~1.15=1.105;1.25~3.5=3.6"); @@ -635,7 +649,9 @@ public class DiscreteTest { System.out.println("The input string is "+discreteObj.getStrDiscrete()); System.out.println("Discrete Value between 0.99 and 1.15 = "+discreteObj.getDiscreteValueClosestToTwoContourLines(0.99f,1.15f)); - assertEquals(discreteObj.getDiscreteValueClosestToTwoContourLines(0.99f, 1.15f),1.105f); + assertFloatComparison( + discreteObj.getDiscreteValueClosestToTwoContourLines(0.99f, + 1.15f), 1.105f); testCaseNumber++; System.out.println("=========================================="); @@ -661,7 +677,9 @@ public class DiscreteTest { System.out.println("The input string is "+discreteObj.getStrDiscrete()); System.out.println("Discrete Value between 0.990001 and 1.15 = "+discreteObj.getDiscreteValueClosestToTwoContourLines(0.990001f,1.15f)); - assertEquals(discreteObj.getDiscreteValueClosestToTwoContourLines(0.990001f, 1.15f),Float.NaN); + assertFloatComparison( + discreteObj.getDiscreteValueClosestToTwoContourLines(0.990001f, + 1.15f), Float.NaN); testCaseNumber++; System.out.println("=========================================="); @@ -687,7 +705,9 @@ public class DiscreteTest { System.out.println("The input string is "+discreteObj.getStrDiscrete()); System.out.println("Discrete Value between 0.99 and 1.150001 = "+discreteObj.getDiscreteValueClosestToTwoContourLines(0.99f,1.150001f)); - assertEquals(discreteObj.getDiscreteValueClosestToTwoContourLines(0.99f, 1.150001f),Float.NaN); + assertFloatComparison( + discreteObj.getDiscreteValueClosestToTwoContourLines(0.99f, + 1.150001f), Float.NaN); testCaseNumber++; System.out.println("=========================================="); @@ -716,7 +736,9 @@ public class DiscreteTest { System.out.println("The input string is "+discreteObj.getStrDiscrete()); System.out.println("Discrete Value between Float.MAX-VALUE and 1.15 = "+discreteObj.getDiscreteValueClosestToTwoContourLines(Float.MAX_VALUE, 0.5f)); - assertEquals(discreteObj.getDiscreteValueClosestToTwoContourLines(Float.MAX_VALUE, 0.5f),0.444f); + assertFloatComparison( + discreteObj.getDiscreteValueClosestToTwoContourLines( + Float.MAX_VALUE, 0.5f), 0.444f); testCaseNumber++; System.out.println("=========================================="); @@ -744,7 +766,9 @@ public class DiscreteTest { System.out.println("The input string is "+discreteObj.getStrDiscrete()); System.out.println("Discrete Value between 1.25 and Float.MAX-VALUE = "+discreteObj.getDiscreteValueClosestToTwoContourLines(1.25f,Float.MAX_VALUE)); - assertEquals(discreteObj.getDiscreteValueClosestToTwoContourLines(1.25f,Float.MAX_VALUE),3.6f); + assertFloatComparison( + discreteObj.getDiscreteValueClosestToTwoContourLines(1.25f, + Float.MAX_VALUE), 3.6f); testCaseNumber++; System.out.println("=========================================="); @@ -765,10 +789,13 @@ public class DiscreteTest { System.out.println("The starting value="+discreteObj.getDiscreteDataList().get(0).getStartValue()); System.out.println("The ending value="+discreteObj.getDiscreteDataList().get(0).getEndValue()); System.out.println("The discrete value="+discreteObj.getDiscreteDataList().get(0).getDiscreteValue()); - assertEquals(discreteObj.getDiscreteDataList().size(),1); - assertEquals(discreteObj.getDiscreteDataList().get(0).getStartValue(), 0.1f); - assertEquals(discreteObj.getDiscreteDataList().get(0).getEndValue(), 0.5f); - assertEquals(discreteObj.getDiscreteDataList().get(0).getDiscreteValue(), 0.444f); + assertEquals(discreteObj.getDiscreteDataList().size(), 1); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getStartValue(), 0.1f); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getEndValue(), 0.5f); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getDiscreteValue(), 0.444f); testCaseNumber++; System.out.println("=========================================="); @@ -790,10 +817,13 @@ public class DiscreteTest { System.out.println("The starting value="+discreteObj.getDiscreteDataList().get(0).getStartValue()); System.out.println("The ending value="+discreteObj.getDiscreteDataList().get(0).getEndValue()); System.out.println("The discrete value="+discreteObj.getDiscreteDataList().get(0).getDiscreteValue()); - assertEquals(discreteObj.getDiscreteDataList().size(),1); - assertEquals(discreteObj.getDiscreteDataList().get(0).getStartValue(), 0.1f); - assertEquals(discreteObj.getDiscreteDataList().get(0).getEndValue(), 0.5f); - assertEquals(discreteObj.getDiscreteDataList().get(0).getDiscreteValue(), 0.444f); + assertEquals(discreteObj.getDiscreteDataList().size(), 1); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getStartValue(), 0.1f); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getEndValue(), 0.5f); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getDiscreteValue(), 0.444f); testCaseNumber++; System.out.println("=========================================="); } @@ -813,10 +843,13 @@ public class DiscreteTest { System.out.println("The starting value="+discreteObj.getDiscreteDataList().get(0).getStartValue()); System.out.println("The ending value="+discreteObj.getDiscreteDataList().get(0).getEndValue()); System.out.println("The discrete value="+discreteObj.getDiscreteDataList().get(0).getDiscreteValue()); - assertEquals(discreteObj.getDiscreteDataList().size(),1); - assertEquals(discreteObj.getDiscreteDataList().get(0).getStartValue(), -Float.MAX_VALUE); - assertEquals(discreteObj.getDiscreteDataList().get(0).getEndValue(), 0.5f); - assertEquals(discreteObj.getDiscreteDataList().get(0).getDiscreteValue(), 0.444f); + assertEquals(discreteObj.getDiscreteDataList().size(), 1); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getStartValue(), -Float.MAX_VALUE); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getEndValue(), 0.5f); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getDiscreteValue(), 0.444f); testCaseNumber++; System.out.println("=========================================="); } @@ -837,10 +870,13 @@ public class DiscreteTest { System.out.println("The starting value="+discreteObj.getDiscreteDataList().get(0).getStartValue()); System.out.println("The ending value="+discreteObj.getDiscreteDataList().get(0).getEndValue()); System.out.println("The discrete value="+discreteObj.getDiscreteDataList().get(0).getDiscreteValue()); - assertEquals(discreteObj.getDiscreteDataList().size(),1); - assertEquals(discreteObj.getDiscreteDataList().get(0).getStartValue(),0.5f ); - assertEquals(discreteObj.getDiscreteDataList().get(0).getEndValue(), Float.MAX_VALUE); - assertEquals(discreteObj.getDiscreteDataList().get(0).getDiscreteValue(), 0.444f); + assertEquals(discreteObj.getDiscreteDataList().size(), 1); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getStartValue(), 0.5f); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getEndValue(), Float.MAX_VALUE); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getDiscreteValue(), 0.444f); testCaseNumber++; System.out.println("=========================================="); } @@ -862,10 +898,13 @@ public class DiscreteTest { System.out.println("The starting value="+discreteObj.getDiscreteDataList().get(0).getStartValue()); System.out.println("The ending value="+discreteObj.getDiscreteDataList().get(0).getEndValue()); System.out.println("The discrete value="+discreteObj.getDiscreteDataList().get(0).getDiscreteValue()); - assertEquals(discreteObj.getDiscreteDataList().size(),1); - assertEquals(discreteObj.getDiscreteDataList().get(0).getStartValue(),-Float.MAX_VALUE ); - assertEquals(discreteObj.getDiscreteDataList().get(0).getEndValue(), Float.MAX_VALUE); - assertEquals(discreteObj.getDiscreteDataList().get(0).getDiscreteValue(), 0.444f); + assertEquals(discreteObj.getDiscreteDataList().size(), 1); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getStartValue(), -Float.MAX_VALUE); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getEndValue(), Float.MAX_VALUE); + assertFloatComparison(discreteObj.getDiscreteDataList().get(0) + .getDiscreteValue(), 0.444f); testCaseNumber++; System.out.println("=========================================="); } diff --git a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/dlines/DLINESTest.java b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/dlines/DLINESTest.java index 94b4ed4e01..c01e14cc79 100644 --- a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/dlines/DLINESTest.java +++ b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/dlines/DLINESTest.java @@ -1,21 +1,23 @@ package gov.noaa.nws.ncep.gempak.parameters.dlines; -import static org.junit.Assert.*; -import gov.noaa.nws.ncep.gempak.parameters.dlines.DLines; +import static org.junit.Assert.assertEquals; import org.junit.Test; -/**
-*Junit test-case for DLINES and DLINEData
-*
-* SOFTWARE HISTORY
-* Date          Ticket#     Engineer     Description
-* ------------ ---------- ----------- --------------------------
-* 29-Dec-2009    211        Archana.S    Initial Creation
-* 
-* @author Archana.S -* @version 1 -*/ +/** + *
+ * Junit test-case for DLINES and DLINEData
+ * 
+ *  SOFTWARE HISTORY
+ *  Date          Ticket#     Engineer     Description
+ *  ------------ ---------- ----------- --------------------------
+ *  29-Dec-2009    211        Archana.S    Initial Creation
+ *  25-Aug-2012    743        djohnson     Upgrade to JUnit 4.10.
+ * 
+ * + * @author Archana.S + * @version 1 + */ public class DLINESTest { /** @@ -89,7 +91,8 @@ public class DLINESTest { .isRightOfContourLineGreater().booleanValue(),true); assertEquals("Contour values to the left of the current contour line should be greater",dlines.getDlineData() .isLeftOfContourLineGreater(),true); - assertEquals("Epsilon should be set to 0.25",dlines.getDlineData().getEpsilon(),0.25); + assertEquals("Epsilon should be set to 0.25", dlines + .getDlineData().getEpsilon(), 0.25, 0.01); break; case 1: @@ -98,7 +101,7 @@ public class DLINESTest { assertEquals("Contour values to the left of the current contour line should be greater",dlines.getDlineData() .isLeftOfContourLineGreater(),true); assertEquals("Epsilon should be undefined",dlines.getDlineData() - .getEpsilon(),Double.NaN); +.getEpsilon(), Double.NaN, 0.01); break; case 2: @@ -107,7 +110,7 @@ public class DLINESTest { assertEquals("Contour values to the left of the current contour line should be lesser",dlines.getDlineData() .isLeftOfContourLineGreater(),false); assertEquals("Epsilon should be undefined",dlines.getDlineData() - .getEpsilon(),Double.NaN); +.getEpsilon(), Double.NaN, 0.01); break; case 3: @@ -115,7 +118,8 @@ public class DLINESTest { .isRightOfContourLineGreater().booleanValue(),false); assertEquals("Contour values to the left of the current contour line should be lesser",dlines.getDlineData() .isLeftOfContourLineGreater(),false); - assertEquals("Epsilon should be set to 1.3",dlines.getDlineData().getEpsilon(),1.3); + assertEquals("Epsilon should be set to 1.3", dlines + .getDlineData().getEpsilon(), 1.3, 0.01); break; case 6: @@ -124,7 +128,7 @@ public class DLINESTest { assertEquals("Contour values to the left of the current contour line should be greater",dlines.getDlineData() .isLeftOfContourLineGreater(),true); assertEquals("Epsilon should be undefined",dlines.getDlineData() - .getEpsilon(), Double.NaN); +.getEpsilon(), Double.NaN, 0.01); break; case 7: @@ -133,7 +137,7 @@ public class DLINESTest { assertEquals("Contour values to the left of the current contour line should be lesser",dlines.getDlineData() .isLeftOfContourLineGreater(),false); assertEquals("Epsilon should be undefined",dlines.getDlineData() - .getEpsilon(), Double.NaN); +.getEpsilon(), Double.NaN, 0.01); break; case 8: @@ -142,7 +146,7 @@ public class DLINESTest { assertEquals("Contour values to the left of the current contour line should be greater",dlines.getDlineData() .isLeftOfContourLineGreater(),true); assertEquals("Epsilon should be undefined",dlines.getDlineData() - .getEpsilon(),Double.NaN); +.getEpsilon(), Double.NaN, 0.01); break; case 10: @@ -151,7 +155,7 @@ public class DLINESTest { assertEquals("Contour values to the left of the current contour line should be lesser",dlines.getDlineData() .isLeftOfContourLineGreater(),false); assertEquals("Epsilon should be undefined",dlines.getDlineData() - .getEpsilon(), Double.NaN); +.getEpsilon(), Double.NaN, 0.01); break; default: @@ -164,7 +168,7 @@ public class DLINESTest { dlines.getDlineData().isLeftOfContourLineGreater(), false); assertEquals("Epsilon should be undefined", dlines - .getDlineData().getEpsilon(), Double.NaN); + .getDlineData().getEpsilon(), Double.NaN, 0.01); }else{ assertEquals("DLINES should be null", dlines.getDlineData(), null); } diff --git a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/gridlimits/GGLIMSTest.java b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/gridlimits/GGLIMSTest.java index 3a67135f53..2d5fb7b841 100644 --- a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/gridlimits/GGLIMSTest.java +++ b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/gridlimits/GGLIMSTest.java @@ -1,8 +1,6 @@ package gov.noaa.nws.ncep.gempak.parameters.gridlimits; -import static org.junit.Assert.*; -import gov.noaa.nws.ncep.gempak.parameters.gridlimits.GGLIMS; - +import org.junit.Assert; import org.junit.Test; public class GGLIMSTest { @@ -32,9 +30,17 @@ public class GGLIMSTest { testCaseNumber++; } - /** - * Test valid GGLIMS string of the form lowerLimit;minValue|upperLimit;maxValue + * @param lowerLimit + * @param d + */ + private static void assertEquals(Float lowerLimit, double d) { + Assert.assertEquals(d, lowerLimit.doubleValue(), 0.01); + } + + /** + * Test valid GGLIMS string of the form + * lowerLimit;minValue|upperLimit;maxValue */ @Test public void testGGLIMSStringWithoutDefaultValue() { diff --git a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/infill/FINTTest.java b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/infill/FINTTest.java index 6051945f86..203d6e98ca 100644 --- a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/infill/FINTTest.java +++ b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/infill/FINTTest.java @@ -2,16 +2,18 @@ package gov.noaa.nws.ncep.gempak.parameters.infill; -import gov.noaa.nws.ncep.gempak.parameters.infill.FINT; +import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; + +import org.junit.Assert; import org.junit.Test; -import static org.junit.Assert.*; + /** - *
+ * 
  * SOFTWARE HISTORY
  * Date          Ticket#     Engineer     Description
  * ------------ ---------- ----------- --------------------------
@@ -20,7 +22,9 @@ import static org.junit.Assert.*;
  *                                                            updated code in FINT  
  * 03-Aug-2010     184       Archana.S   Updated test-cases to test
  *                                                            updated code in FINT
+ * 25-Aug-2012     743       djohnson    Upgrade to JUnit 4.10.
  * 
+ * * @author Archana.S * @version 1 */ @@ -76,7 +80,15 @@ public class FINTTest { testCaseNumber++; } - @Test + /** + * @param doubleValue + * @param i + */ + // private static void assertEquals(double doubleValue, int i) { + // Assert.assertEquals(doubleValue, i, 0.001); + // } + + @Test /* Test for valid FINT string of the form fillInterval/minFillValue/maxFillValue * with a negative contourInterval @@ -105,7 +117,7 @@ public class FINTTest { FINT fint = new FINT("66.1;0.1;5000;76;-.999;12233459390;0.00009988;1234.567890"); - assertEquals(fint.isFINTStringParsed(), true); + Assert.assertTrue(fint.isFINTStringParsed()); testList = new ArrayList(Arrays.asList(66.1, 0.1, 5000.0, 76.0, -0.999, 1.223345939E10, 9.988E-5, 1234.56789)); keySetList = fint.getFillValuesListAsDouble(FINT.FIRST_ZOOM_LEVEL); @@ -126,7 +138,7 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR FINT fint = new FINT(" 66.1 ; 0.1 ; 5000 "); - assertEquals(fint.isFINTStringParsed(), true); + Assert.assertTrue(fint.isFINTStringParsed()); testList = new ArrayList(Arrays.asList(66.1, 0.1, 5000.0)); keySetList = fint.getFillValuesListAsDouble(FINT.FIRST_ZOOM_LEVEL); assertEquals(keySetList,testList); @@ -146,9 +158,10 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR /*Test for valid FINT string of the form fillInterval/minFillValue/ */ public void testFillIntervalWithMinValueOnly(){ FINT fint = new FINT("-0.345/0/"); - assertEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL),-0.345); - assertEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),0); - assertEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); + assertDoubleEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL), -0.345); + assertDoubleEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), 0); + assertDoubleEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); System.out.println("=====================Test-Case "+testCaseNumber+" ========================"); System.out.println("The input string = " + fint.getUserInputString()); @@ -160,14 +173,23 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR testCaseNumber++; } - @Test + /** + * @param fillInterval + * @param d + */ + private void assertDoubleEquals(Double fillInterval, double d) { + Assert.assertEquals(d, fillInterval.doubleValue(), 0.01); + } + + @Test /*Test for valid FINT string of the form fillInterval//maxFillValue */ public void testFillIntervalWithMaxValueOnly(){ FINT fint = new FINT("15//30"); - assertEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL),15); - assertEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); - assertEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),30); + assertDoubleEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL), 15); + assertDoubleEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); + assertDoubleEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), 30); System.out.println("=====================Test-Case "+testCaseNumber+" ========================"); System.out.println("Is the FINT string parsed correctly? " + fint.isFINTStringParsed()); @@ -185,9 +207,11 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR FINT fint = new FINT("-0.5/"); assertEquals(fint.isFINTStringParsed(),true); - assertEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL),-0.5); - assertEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); - assertEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); + assertDoubleEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL), -0.5); + assertDoubleEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); + assertDoubleEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); System.out.println("=====================Test-Case "+testCaseNumber+"a ========================"); System.out.println("The input string = " + fint.getUserInputString()); @@ -198,9 +222,11 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR FINT fint2 = new FINT("-.89//"); assertEquals(fint2.isFINTStringParsed(),true); - assertEquals(fint2.getFillInterval(FINT.FIRST_ZOOM_LEVEL),-0.89); - assertEquals(fint2.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); - assertEquals(fint2.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); + assertDoubleEquals(fint2.getFillInterval(FINT.FIRST_ZOOM_LEVEL), -0.89); + assertDoubleEquals(fint2.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); + assertDoubleEquals(fint2.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); System.out.println("=====================Test-Case "+testCaseNumber+"b ========================"); System.out.println("The input string = " + fint2.getUserInputString()); @@ -218,9 +244,10 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR /*Test for valid FINT string of the form /minFillValue/maxFillValue */ public void testFillIntervalWithNoFillIntervalAndWithMinMaxValueOnly(){ FINT fint = new FINT("/10/30"); - assertEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL),Double.NaN); - assertEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),10); - assertEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),30); + assertDoubleEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); + assertDoubleEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), 10); + assertDoubleEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), 30); System.out.println("=====================Test-Case "+testCaseNumber+" ========================"); System.out.println("The input string = " + fint.getUserInputString()); @@ -239,9 +266,10 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR *and maxFillValue are the same*/ public void testFillIntervalWithMinValSameAsMaxValAndNoFillIntervalSpecified(){ FINT fint = new FINT("/10/10"); - assertEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL),Double.NaN); - assertEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),10); - assertEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),10); + assertDoubleEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); + assertDoubleEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), 10); + assertDoubleEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), 10); testList = new ArrayList(Arrays.asList(10.0)); keySetList = fint.getFillValuesListAsDouble(FINT.FIRST_ZOOM_LEVEL); assertEquals(keySetList,testList); @@ -292,10 +320,10 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR public void testExtraNumArgsFillIntervalString(){ FINT fint = new FINT("20/10/70/30/40/500"); - assertEquals(fint.isFINTStringParsed(), true); - assertEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL),20); - assertEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),10); - assertEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),70); + Assert.assertTrue(fint.isFINTStringParsed()); + assertDoubleEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL), 20); + assertDoubleEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), 10); + assertDoubleEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), 70); testList = new ArrayList(Arrays.asList(10.0,30.0,50.0,60.0)); keySetList = fint.getFillValuesListAsDouble(FINT.FIRST_ZOOM_LEVEL); @@ -318,9 +346,12 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR public void testNonNumericFillIntervalString(){ FINT fint = new FINT("-def/abc/%^&/30/40"); assertEquals(fint.isFINTStringParsed(), false); - assertEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL),Double.NaN); - assertEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); - assertEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); + assertDoubleEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); + assertDoubleEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); + assertDoubleEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); System.out.println("=====================Test-Case "+testCaseNumber+"========================"); System.out.println("The input string = "+fint.getUserInputString()); @@ -339,9 +370,12 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR FINT fint = new FINT("5.10.60.9"); assertEquals(fint.isFINTStringParsed(), false); - assertEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL),Double.NaN); - assertEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); - assertEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),Double.NaN); + assertDoubleEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); + assertDoubleEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); + assertDoubleEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), + Double.NaN); System.out.println("=====================Test-Case "+testCaseNumber+"========================"); System.out.println("The input string = "+fint.getUserInputString()); @@ -358,10 +392,10 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR /*Test FINT string by interchanging minFillValue and maxFillValue */ public void testMinMaxValuesInterchangedFillIntervalString(){ FINT fint = new FINT("-5/20/5"); - assertEquals(fint.isFINTStringParsed(), true); - assertEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL),-5); - assertEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),5); - assertEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),20); + Assert.assertTrue(fint.isFINTStringParsed()); + assertDoubleEquals(fint.getFillInterval(FINT.FIRST_ZOOM_LEVEL), -5); + assertDoubleEquals(fint.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), 5); + assertDoubleEquals(fint.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), 20); testList = new ArrayList(Arrays.asList(5.0, 10.0, 15.0, 20.0)); keySetList = fint.getFillValuesListAsDouble(FINT.FIRST_ZOOM_LEVEL); @@ -376,9 +410,9 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR FINT fint2 = new FINT("5/20/5"); assertEquals(fint2.isFINTStringParsed(), true); - assertEquals(fint2.getFillInterval(FINT.FIRST_ZOOM_LEVEL),5); - assertEquals(fint2.getMinFillValue(FINT.FIRST_ZOOM_LEVEL),5); - assertEquals(fint2.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL),20); + assertDoubleEquals(fint2.getFillInterval(FINT.FIRST_ZOOM_LEVEL), 5); + assertDoubleEquals(fint2.getMinFillValue(FINT.FIRST_ZOOM_LEVEL), 5); + assertDoubleEquals(fint2.getMaxFillValue(FINT.FIRST_ZOOM_LEVEL), 20); testList = new ArrayList(Arrays.asList(5.0, 10.0, 15.0, 20.0)); keySetList = fint2.getFillValuesListAsDouble(FINT.FIRST_ZOOM_LEVEL); assertEquals(testList,keySetList); @@ -471,7 +505,7 @@ System.out.println("Fill Values List = "+fint.getFillValuesListAsDouble(FINT.FIR @Test public void testFINTMultipleZoomLevels(){ FINT fint = new FINT("2/-6/6/3 > 30;50;80 > 60 ; 80 > 0.00009999 > 0.0000001;"); - assertEquals(fint.isFINTStringParsed(), true); + Assert.assertTrue(fint.isFINTStringParsed()); testList = new ArrayList(Arrays.asList(-6.0, -4.0,-2.0, 0.0, 2.0, 4.0, 6.0)); keySetList = fint.getFillValuesListAsDouble(FINT.FIRST_ZOOM_LEVEL); assertEquals(testList,keySetList); diff --git a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/inline/LineDataStringParserTest.java b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/inline/LineDataStringParserTest.java index af841b60f7..fe1cdc2dfd 100644 --- a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/inline/LineDataStringParserTest.java +++ b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/inline/LineDataStringParserTest.java @@ -1,18 +1,23 @@ package gov.noaa.nws.ncep.gempak.parameters.inline; -import gov.noaa.nws.ncep.gempak.parameters.inline.LineDataStringParser; +import static org.junit.Assert.assertEquals; +import org.junit.Assert; import org.junit.Test; -import static org.junit.Assert.*; + /** - * *
+ * *
+ * 
+ * 
  * SOFTWARE HISTORY
  * Date          Ticket#     Engineer     Description
  * ------------ ---------- ----------- --------------------------
  * 30-Oct-2009    186       Archana.S   Initial Creation 
+ * 25-Aug-2012    743       djohnson    Upgrade to JUnit 4.10.
  * 
+ * * @author Archana.S - * @version 1 + * @version 1 */ @@ -27,9 +32,12 @@ private static Integer testCaseNumber=1; System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.5); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertDoubleComparison(ldsp1.getInstanceOfLineBuilder() + .getPointsFilter().doubleValue(), 0.5); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); System.out.println("List of line patterns: " +ldsp1.getInstanceOfLineBuilder().getLinePatternsList()); @@ -43,7 +51,15 @@ private static Integer testCaseNumber=1; } - @Test + /** + * @param pointsFilter + * @param d + */ + private static void assertDoubleComparison(Double pointsFilter, double d) { + Assert.assertEquals(d, pointsFilter.doubleValue(), 0.01); + } + + @Test public void testValidLineDataStringWithOnlyLineColorInput(){ System.out.println("------------------Test-case "+ testCaseNumber +"a----------------"); @@ -52,9 +68,12 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertDoubleComparison(ldsp1.getInstanceOfLineBuilder() + .getPointsFilter().doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"a? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -72,8 +91,10 @@ private static Integer testCaseNumber=1; if(ldsp2.isLineDataParsed()){ assertEquals(ldsp2.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp2.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp2.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp2.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp2.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp2.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"b? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp2.getInstanceOfLineBuilder().getLineColorsList()); @@ -90,8 +111,10 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp3 = new LineDataStringParser("5"); if(ldsp3.isLineDataParsed()){ assertEquals(ldsp3.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp3.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp3.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp3.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp3.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp3.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"c? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp3.getInstanceOfLineBuilder().getLineColorsList()); @@ -113,9 +136,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("3;2;16/0.67654"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.67654); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.67654); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -136,9 +162,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("3/0.67654"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.67654); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.67654); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -158,9 +187,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("7/0.5/true"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.5); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.5); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -180,9 +212,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser(".7"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.7); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.7); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -202,9 +237,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("1.0/TRUE"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),1.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 1.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -226,9 +264,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("7/7"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -248,9 +289,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("8;9;10/2;4/3/2/2"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -270,9 +314,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("true"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -292,9 +339,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser(); if(!ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -314,9 +364,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser(""); if(!ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -336,9 +389,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser(" "); if(!ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -358,9 +414,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("132;240;255/4;4;4/5;5;5/3"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -380,9 +439,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("/4;10/6/1/1/0.65789/true"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); System.out.println("List of line patterns: " +ldsp1.getInstanceOfLineBuilder().getLinePatternsList()); @@ -401,9 +463,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("144;110//6/1/1/0.65789/true"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -423,9 +488,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("4;10/8;9//1/1/0.9999/true"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.9999); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.9999); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -445,9 +513,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("4;10/8;9/6;7//1/0.65789/true"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -467,9 +538,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("4;10/8;9/6;7/2//0.65789/true"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -489,9 +563,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("4;10/8;9/6;7/2/2//true"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -511,9 +588,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("4;10/8;9/6;7/2/1/0.65789/"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -533,9 +613,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("4;10//6;7///0.65789/"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -555,9 +638,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("240;234/28;36/6/1/1/0.4477"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.4477); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.4477); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -577,9 +663,12 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp1 = new LineDataStringParser("2/4/6/1/1/3.65789"); if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -602,9 +691,12 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -626,9 +718,12 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.7); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.7); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -650,9 +745,12 @@ private static Integer testCaseNumber=1; if(!ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -674,9 +772,12 @@ private static Integer testCaseNumber=1; if(!ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -698,9 +799,12 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.6); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.6); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -722,9 +826,12 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), false); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -746,9 +853,12 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.5); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isSmallContourFlagSuppressed(), true); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.5); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -771,7 +881,8 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isBreakInLineForLabel(),false); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isBreakInLineForLabel(), false); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("Is there a break in the line for the label: " +ldsp1.getInstanceOfLineBuilder().isBreakInLineForLabel()); @@ -788,7 +899,8 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isBreakInLineForLabel(),true); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isBreakInLineForLabel(), true); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"a? "+ldsp1.isLineDataParsed()); System.out.println("Is there a break in the line for the label: " +ldsp1.getInstanceOfLineBuilder().isBreakInLineForLabel()); @@ -798,7 +910,8 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ - assertEquals(ldsp1.getInstanceOfLineBuilder().isBreakInLineForLabel(),true); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .isBreakInLineForLabel(), true); System.out.println("The input string : " +ldsp2.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"b? "+ldsp1.isLineDataParsed()); System.out.println("Is there a break in the line for the label: " +ldsp2.getInstanceOfLineBuilder().isBreakInLineForLabel()); diff --git a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/line/LineDataStringParserTest.java b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/line/LineDataStringParserTest.java index 453b036aa4..0a149ba04f 100644 --- a/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/line/LineDataStringParserTest.java +++ b/ncep/gov.noaa.nws.ncep.gempak.parameters/unit_test/gov/noaa/nws/ncep/gempak/parameters/line/LineDataStringParserTest.java @@ -1,17 +1,23 @@ package gov.noaa.nws.ncep.gempak.parameters.line; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import gov.noaa.nws.ncep.viz.common.ui.color.GempakColor; + +import org.junit.Test; + /** - * *
+ * *
+ * 
+ * 
  * SOFTWARE HISTORY
  * Date          Ticket#     Engineer     Description
  * ------------ ---------- ----------- --------------------------
  * 30-Oct-2009    186       Archana.S   Initial Creation 
+ * 25-Aug-2012    743       djohnson    Upgrade to JUnit 4.10.
  * 
+ * * @author Archana.S - * @version 1 + * @version 1 */ @@ -27,8 +33,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.5); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.5); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); int firstColor = ldsp1.getInstanceOfLineBuilder().getLineColorsList().get(0); @@ -54,8 +62,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"a? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -73,8 +83,10 @@ private static Integer testCaseNumber=1; if(ldsp2.isLineDataParsed()){ assertEquals(ldsp2.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp2.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp2.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp2.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp2.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp2.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"b? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp2.getInstanceOfLineBuilder().getLineColorsList()); @@ -91,8 +103,10 @@ private static Integer testCaseNumber=1; LineDataStringParser ldsp3 = new LineDataStringParser("5"); if(ldsp3.isLineDataParsed()){ assertEquals(ldsp3.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp3.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp3.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp3.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp3.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp3.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"c? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp3.getInstanceOfLineBuilder().getLineColorsList()); @@ -115,8 +129,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.67654); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.67654); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -138,8 +154,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.67654); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.67654); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -160,8 +178,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.5); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.5); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -182,8 +202,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.7); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.7); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -204,8 +226,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),1.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 1.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -228,8 +252,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -250,8 +276,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -272,8 +300,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -294,8 +324,10 @@ private static Integer testCaseNumber=1; if(!ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -316,8 +348,10 @@ private static Integer testCaseNumber=1; if(!ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -338,8 +372,10 @@ private static Integer testCaseNumber=1; if(!ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -360,8 +396,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -382,8 +420,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); System.out.println("List of line patterns: " +ldsp1.getInstanceOfLineBuilder().getLineStyleList()); @@ -403,8 +443,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -425,8 +467,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.9999); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.9999); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -447,8 +491,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -469,8 +515,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -491,8 +539,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -513,8 +563,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -535,8 +587,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.65789); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.65789); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -557,8 +611,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.4477); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.4477); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -579,8 +635,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),1); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 1); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -604,8 +662,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -628,8 +688,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.7); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.7); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -652,8 +714,10 @@ private static Integer testCaseNumber=1; if(!ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -676,8 +740,10 @@ private static Integer testCaseNumber=1; if(!ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -700,8 +766,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.6); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),2); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.6); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 2); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -724,8 +792,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),false); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.0); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.0); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); @@ -748,8 +818,10 @@ private static Integer testCaseNumber=1; if(ldsp1.isLineDataParsed()){ assertEquals(ldsp1.getInstanceOfLineBuilder().isSmallContourFlagSuppressed(),true); - assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter(),0.5); - assertEquals(ldsp1.getInstanceOfLineBuilder().getLineSmoothingLevel(),0); + assertEquals(ldsp1.getInstanceOfLineBuilder().getPointsFilter() + .doubleValue(), 0.5); + assertEquals(ldsp1.getInstanceOfLineBuilder() + .getLineSmoothingLevel().intValue(), 0); System.out.println("The input string : " +ldsp1.getLineDataString()); System.out.println("Is line data parsed in test-case "+testCaseNumber+"? "+ldsp1.isLineDataParsed()); System.out.println("List of line colors: " +ldsp1.getInstanceOfLineBuilder().getLineColorsList()); diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/.classpath b/ncep/gov.noaa.nws.ncep.ui.nsharp/.classpath index 44f12466f5..121e527a93 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/.classpath +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/.classpath @@ -3,6 +3,5 @@ - diff --git a/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/display/SymbolSetElement.java b/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/display/SymbolSetElement.java index 8748d08528..649230371d 100644 --- a/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/display/SymbolSetElement.java +++ b/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/display/SymbolSetElement.java @@ -7,126 +7,117 @@ */ package gov.noaa.nws.ncep.ui.pgen.display; -import com.raytheon.uf.viz.core.IExtent; +import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.PixelCoverage; import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.PaintProperties; -import com.raytheon.uf.viz.core.exception.VizException; import com.vividsolutions.jts.geom.Coordinate; - +import com.raytheon.viz.core.gl.images.GLImage; /** - * Contains a raster image and information needed to readily display that image - * on a graphics target at one or more locations. + * Contains a raster image and information needed to readily display that image on a graphics target + * at one or more locations. *

- * Objects of this class are typically created from Symbol or SymbolLocationSet - * elements using the DisplayElementFactory class. - * + * Objects of this class are typically created from Symbol or SymbolLocationSet elements using the + * DisplayElementFactory class. * @author sgilbert - * + * */ public class SymbolSetElement implements IDisplayable { - /* - * The raster image to be displayed - */ - private IImage raster; + /* + * The raster image to be displayed + */ + private IImage raster; + + /* + * targets properties used for zoom and extent info + */ + private PaintProperties paintProps; + + /* + * Array of plot locations in pixel coordinates + */ + private double[][] locations; + private Coordinate ul = new Coordinate(), ur= new Coordinate(), lr= new Coordinate(), ll= new Coordinate(); + + /** + * Constructor used to set an image and its associated locations + * @param raster Rater image to display + * @param paintProps paint properties for the target + * @param locations pixel coordinate locations to display the image + */ + public SymbolSetElement(IImage raster, PaintProperties paintProps, + double[][] locations ) { + this.raster = raster; + this.paintProps = paintProps; + this.locations = locations; + } - /* - * targets properties used for zoom and extent info - */ - private PaintProperties paintProps; + /** + * disposes the resources held by the raster image + * @see gov.noaa.nws.ncep.ui.pgen.display.IDisplayable#dispose() + */ + @Override + public void dispose() { - /* - * Array of plot locations in pixel coordinates - */ - private double[][] locations; + raster.dispose(); - private Coordinate ul = new Coordinate(), ur = new Coordinate(), - lr = new Coordinate(), ll = new Coordinate(); + } - /** - * Constructor used to set an image and its associated locations - * - * @param raster - * Rater image to display - * @param paintProps - * paint properties for the target - * @param locations - * pixel coordinate locations to display the image - */ - public SymbolSetElement(IImage raster, PaintProperties paintProps, - double[][] locations) { - this.raster = raster; - this.paintProps = paintProps; - this.locations = locations; - } + /** + * Plots the image to the specified graphics target at the various locations + * @see gov.noaa.nws.ncep.ui.pgen.display.IDisplayable#draw(com.raytheon.viz.core.IGraphicsTarget) + */ + @Override + public void draw(IGraphicsTarget target) { - /** - * disposes the resources held by the raster image - * - * @see gov.noaa.nws.ncep.ui.pgen.display.IDisplayable#dispose() - */ - @Override - public void dispose() { + double[] loc = new double[3]; - raster.dispose(); + /* + * Scale image + */ + double halfWidth; + double halfHeight; + double screenToWorldRatio = paintProps.getCanvasBounds().width + / paintProps.getView().getExtent().getWidth(); + double scale = 0.5 / screenToWorldRatio ; + if ( raster instanceof GLImage ) { + halfWidth = ((GLImage)raster).getImage().getWidth() * scale; + halfHeight = ((GLImage)raster).getImage().getHeight() * scale; + } + else { + halfWidth = raster.getWidth() * scale; + halfHeight = raster.getHeight() * scale; + } - } - - /** - * Plots the image to the specified graphics target at the various locations - * - * @see gov.noaa.nws.ncep.ui.pgen.display.IDisplayable#draw(com.raytheon.viz.core.IGraphicsTarget) - */ - @Override - public void draw(IGraphicsTarget target) { - - double[] loc = new double[3]; - - /* - * Scale image - */ - double halfWidth; - double halfHeight; - - IExtent screenExtentInPixels = paintProps.getView().getExtent(); - - double screenToWorldRatio = paintProps.getCanvasBounds().width - / paintProps.getView().getExtent().getWidth(); - double scale = 0.5 / screenToWorldRatio; - halfWidth = raster.getWidth() * scale; - halfHeight = raster.getHeight() * scale; - - /* - * draw raster image at each location - */ - for (int j = 0; j < locations.length; j++) { - loc = locations[j]; - if (loc == null || !screenExtentInPixels.contains(loc)) - continue; - ul.x = loc[0] - halfWidth; - ul.y = loc[1] - halfHeight; - ur.x = loc[0] + halfWidth; - ur.y = loc[1] - halfHeight; - lr.x = loc[0] + halfWidth; - lr.y = loc[1] + halfHeight; - ll.x = loc[0] - halfWidth; - ll.y = loc[1] + halfHeight; - PixelCoverage extent = new PixelCoverage(ul, ur, lr, ll); - /* - * PixelCoverage extent = new PixelCoverage(new - * Coordinate(loc[0]-halfWidth,loc[1]-halfHeight), new - * Coordinate(loc[0]+halfWidth,loc[1]-halfHeight), new - * Coordinate(loc[0]+halfWidth,loc[1]+halfHeight), new - * Coordinate(loc[0]-halfWidth,loc[1]+halfHeight)); - */ - try { - target.drawRaster(raster, extent, paintProps); - } catch (VizException ve) { - ve.printStackTrace(); - } - } - } + /* + * draw raster image at each location + */ + for (int j=0; j < locations.length; j++) { + loc = locations[j]; + ul.x = loc[0]-halfWidth; + ul.y = loc[1]-halfHeight; + ur.x = loc[0]+halfWidth; + ur.y = loc[1]-halfHeight; + lr.x = loc[0]+halfWidth; + lr.y = loc[1]+halfHeight; + ll.x = loc[0]-halfWidth; + ll.y = loc[1]+halfHeight; + PixelCoverage extent = new PixelCoverage(ul, ur, lr, ll); + /* + PixelCoverage extent = new PixelCoverage(new Coordinate(loc[0]-halfWidth,loc[1]-halfHeight), + new Coordinate(loc[0]+halfWidth,loc[1]-halfHeight), + new Coordinate(loc[0]+halfWidth,loc[1]+halfHeight), + new Coordinate(loc[0]-halfWidth,loc[1]+halfHeight)); + */ + try { + target.drawRaster(raster, extent, paintProps); + } + catch (VizException ve) { + ve.printStackTrace(); + } + } + } } diff --git a/rpms/awips2.core/Installer.database/component.spec b/rpms/awips2.core/Installer.database/component.spec index bc733f9f17..6b2e1b461d 100644 --- a/rpms/awips2.core/Installer.database/component.spec +++ b/rpms/awips2.core/Installer.database/component.spec @@ -66,7 +66,7 @@ cp -r %{_baseline_workspace}/${EXPECTED_PATH_TO_CONFIG}/${CONFIG_FILE_TO_INCLUDE # Copy The SQL Scripts That The Database RPM Will Need To The # Temporary Directory. -DIRS_TO_COPY=('damcat' 'hmdb' 'migrated' 'setup' 'SHEF' 'vtec') +DIRS_TO_COPY=('damcat' 'hmdb' 'migrated' 'setup' 'SHEF' 'vtec' 'ebxml' 'events') for dir in ${DIRS_TO_COPY[*]}; do cp -r %{_baseline_workspace}/${PATH_TO_DDL}/${dir}/* \ @@ -166,6 +166,7 @@ IFHS=${AWIPS2_DATA_DIRECTORY}/pgdata_ihfs MAPS=${AWIPS2_DATA_DIRECTORY}/maps DAMCAT=${AWIPS2_DATA_DIRECTORY}/damcat HMDB=${AWIPS2_DATA_DIRECTORY}/hmdb +EBXML=${AWIPS2_DATA_DIRECTORY}/ebxml # Add The PostgreSQL Libraries And The PSQL Libraries To LD_LIBRARY_PATH. export LD_LIBRARY_PATH=${POSTGRESQL_INSTALL}/lib:$LD_LIBRARY_PATH @@ -271,6 +272,15 @@ function update_createDamcat() ${SQL_SHARE_DIR}/createDamcat.sql } +function update_createEbxml() +{ + echo ${AWIPS2_DATA_DIRECTORY} | sed 's/\//\\\//g' > .awips2_escape.tmp + AWIPS2_DATA_DIRECTORY_ESCAPED=`cat .awips2_escape.tmp` + rm -f .awips2_escape.tmp + perl -p -i -e "s/%{database_files_home}%/${AWIPS2_DATA_DIRECTORY_ESCAPED}/g" \ + ${SQL_SHARE_DIR}/createEbxml.sql +} + function update_createHMDB() { echo ${AWIPS2_DATA_DIRECTORY} | sed 's/\//\\\//g' > .awips2_escape.tmp @@ -334,6 +344,10 @@ echo "-------------------------------------------------------------------------- echo "\| Creating a Directory for the hmdb Tablespace..." echo "--------------------------------------------------------------------------------" create_sql_element ${HMDB} +echo "--------------------------------------------------------------------------------" +echo "\| Creating a Directory for the ebxml Tablespace..." +echo "--------------------------------------------------------------------------------" +create_sql_element ${EBXML} echo "" echo "--------------------------------------------------------------------------------" echo "\| Starting PostgreSQL..." @@ -371,6 +385,9 @@ execute_psql_sql_script ${SQL_SHARE_DIR}/bit_table.sql metadata execute_psql_sql_script ${SQL_SHARE_DIR}/collective.sql metadata execute_psql_sql_script ${SQL_SHARE_DIR}/national_category.sql metadata +# create the events schema +execute_psql_sql_script ${SQL_SHARE_DIR}/createEventsSchema.sql metadata + echo "--------------------------------------------------------------------------------" echo "\| Creating shef Tables..." echo "--------------------------------------------------------------------------------" @@ -387,6 +404,12 @@ execute_psql_sql_script ${SQL_SHARE_DIR}/populateDamcatDatabase.sql dc_ob7oax update_createHMDB su ${AWIPS_DEFAULT_USER} -c \ "${SQL_SHARE_DIR}/createHMDB.sh ${PSQL_INSTALL} ${AWIPS_DEFAULT_PORT} ${AWIPS_DEFAULT_USER} ${SQL_SHARE_DIR} ${SQL_LOG}" + +update_createEbxml +echo "--------------------------------------------------------------------------------" +echo "\| Creating ebxml Tables..." +echo "--------------------------------------------------------------------------------" +execute_psql_sql_script ${SQL_SHARE_DIR}/createEbxml.sql postgres echo "--------------------------------------------------------------------------------" echo "\| Creating VTEC Tables..." echo "--------------------------------------------------------------------------------" diff --git a/rpms/awips2.core/Installer.ldm/patch/etc/pqact.conf.template b/rpms/awips2.core/Installer.ldm/patch/etc/pqact.conf.template old mode 100644 new mode 100755 diff --git a/rpms/awips2.edex/Installer.edex-base/scripts/init.d/edex_camel b/rpms/awips2.edex/Installer.edex-base/scripts/init.d/edex_camel index 7ac4db2294..6df26fe72d 100644 --- a/rpms/awips2.edex/Installer.edex-base/scripts/init.d/edex_camel +++ b/rpms/awips2.edex/Installer.edex-base/scripts/init.d/edex_camel @@ -30,10 +30,10 @@ if [ $TOTAL_MEM -gt 4 ]; then fi # Default Services to start -SERVICES=('ingest' 'ingestGrib' 'request') +SERVICES=('ingest' 'ingestGrib' 'request' 'datadelivery') if [ $HIGH_MEM == "on" ]; then - SERVICES=('ingest' 'ingestGrib' 'ingestDat' 'request') + SERVICES=('ingest' 'ingestGrib' 'ingestDat' 'request' 'datadelivery') fi # Who to run EDEX server as, usually "awips". (NOT "root") diff --git a/rpms/awips2.edex/Installer.edex-configuration/component.spec b/rpms/awips2.edex/Installer.edex-configuration/component.spec index 614a158d47..079fc1e4b6 100644 --- a/rpms/awips2.edex/Installer.edex-configuration/component.spec +++ b/rpms/awips2.edex/Installer.edex-configuration/component.spec @@ -126,4 +126,4 @@ rm -rf ${RPM_BUILD_ROOT} %dir /awips2 %dir /awips2/edex %dir /awips2/edex/bin -%config(noreplace) /awips2/edex/bin/setup.env +%config(noreplace) /awips2/edex/bin/setup.env \ No newline at end of file diff --git a/rpms/awips2.edex/Installer.edex-datadelivery/component.spec b/rpms/awips2.edex/Installer.edex-datadelivery/component.spec new file mode 100644 index 0000000000..d1b47fe04c --- /dev/null +++ b/rpms/awips2.edex/Installer.edex-datadelivery/component.spec @@ -0,0 +1,70 @@ +# Turn off the brp-python-bytecompile script +%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') +# Turn off the java jar repack +%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-java-repack-jars[[:space:]].*$!!g') + +%define _component_name awips2-edex-datadelivery +%define _component_project_dir awips2.edex/Installer.edex-datadelivery +# +# AWIPS II Edex Datadelivery Spec File +# +Name: %{_component_name} +Summary: AWIPS II Edex Dat +Version: %{_component_version} +Release: %{_component_release} +Group: AWIPSII +BuildRoot: /tmp +Prefix: %{_component_default_prefix} +URL: N/A +License: N/A +Distribution: N/A +Vendor: Raytheon +Packager: Bryan Kowal + +AutoReq: no +provides: %{_component_name} +requires: awips2 +requires: awips2-edex-base +requires: awips2-python +requires: awips2-java +requires: awips2-psql + +%description +AWIPS II Edex Installation - Installs The AWIPS II Edex Datadelivery Plugins. + +%prep +# Verify That The User Has Specified A BuildRoot. +if [ "${RPM_BUILD_ROOT}" = "/tmp" ] +then + echo "An Actual BuildRoot Must Be Specified. Use The --buildroot Parameter." + echo "Unable To Continue ... Terminating" + exit 1 +fi + +mkdir -p ${RPM_BUILD_ROOT}/awips2/edex + +%install +DEPLOY_SCRIPT="build.edex/deploy-install.xml" + +# Deploy Edex To Our Temporary Build Directory. +/awips2/ant/bin/ant -file ${WORKSPACE_DIR}/${DEPLOY_SCRIPT} \ + -Dinstall.dir=${RPM_BUILD_ROOT}/awips2/edex \ + -Dinstaller=true -Dlocal.build=false \ + -Dcomponent.to.deploy=edex-datadelivery +if [ $? -ne 0 ]; then + exit 1 +fi + +%pre +%post +%preun +%postun + +%clean +rm -rf ${RPM_BUILD_ROOT} + +%files +%defattr(644,awips,fxalpha,755) +%dir /awips2 +%dir /awips2/edex +/awips2/edex/* \ No newline at end of file diff --git a/rpms/awips2.qpid/SOURCES/queueCreator.sh b/rpms/awips2.qpid/SOURCES/queueCreator.sh index c8ccf29261..7dda8e76a6 100644 --- a/rpms/awips2.qpid/SOURCES/queueCreator.sh +++ b/rpms/awips2.qpid/SOURCES/queueCreator.sh @@ -52,4 +52,12 @@ do qpid-config add queue $queue --durable --file-count 16 --file-size 24 done +#define 24 Meg persistence queues for HPE ingest +QUEUES=('Ingest.dhr' 'dhrProcess') +for queue in ${QUEUES[*]}; +do + echo "Creating queue $queue" + qpid-config add queue $queue --durable --file-count 16 --file-size 24 +done + diff --git a/rpms/common/yum/arch.x86/comps.xml b/rpms/common/yum/arch.x86/comps.xml index 51501f4677..168bad9fc9 100644 --- a/rpms/common/yum/arch.x86/comps.xml +++ b/rpms/common/yum/arch.x86/comps.xml @@ -35,6 +35,7 @@ awips2-edex-configuration awips2-edex-npp awips2-edex-ncep + awips2-edex-datadelivery awips2-gfesuite-server awips2-httpd-pypies @@ -186,6 +187,8 @@ awips2-cave-viz-npp awips2-cave-viz-kml-export awips2-cave-viz-collaboration + awips2-cave-viz-kml-export + awips2-cave-viz-datadelivery awips2-gfesuite-client awips2-alertviz @@ -247,6 +250,7 @@ awips2-edex-text awips2-edex-ncep awips2-edex-npp + awips2-edex-datadelivery awips2-gfesuite-server awips2-hydroapps-shared @@ -507,6 +511,8 @@ awips2-cave-viz-thinclient awips2-cave-viz-npp awips2-cave-viz-collaboration + awips2-cave-viz-kml-export + awips2-cave-viz-datadelivery awips2-localapps-environment diff --git a/rpms/common/yum/arch.x86_64/comps.xml b/rpms/common/yum/arch.x86_64/comps.xml index 3229a222d7..f6b4f6c05c 100644 --- a/rpms/common/yum/arch.x86_64/comps.xml +++ b/rpms/common/yum/arch.x86_64/comps.xml @@ -125,6 +125,7 @@ awips2-cave-viz-npp awips2-cave-viz-kml-export awips2-cave-viz-collaboration + awips2-cave-viz-datadelivery awips2-gfesuite-client awips2-alertviz