diff --git a/RadarServer/com.raytheon.rcm.feature/feature.xml b/RadarServer/com.raytheon.rcm.feature/feature.xml index da6032f0a6..8ef01d72ba 100644 --- a/RadarServer/com.raytheon.rcm.feature/feature.xml +++ b/RadarServer/com.raytheon.rcm.feature/feature.xml @@ -173,4 +173,10 @@ install-size="0" version="0.0.0"/> + + diff --git a/cave/com.raytheon.uf.viz.core.maps/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/cave/com.raytheon.uf.viz.core.maps/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index eaca841d6a..0000000000 --- a/cave/com.raytheon.uf.viz.core.maps/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -com.raytheon.uf.viz.core.maps.MapStylePreferenceStore \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/MapStylePreferenceStore.java b/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/MapStylePreferenceStore.java index 7f157c9208..49115eb1ae 100644 --- a/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/MapStylePreferenceStore.java +++ b/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/MapStylePreferenceStore.java @@ -20,10 +20,12 @@ package com.raytheon.uf.viz.core.maps; import java.io.File; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; @@ -37,12 +39,13 @@ 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.localization.exception.LocalizationException; -import com.raytheon.uf.common.serialization.ISerializableObject; -import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.serialization.JAXBManager; +import com.raytheon.uf.common.serialization.jaxb.JAXBClassLocator; 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.viz.core.reflect.SubClassLocator; +import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability; import com.raytheon.uf.viz.core.rsc.capabilities.Capabilities; /** @@ -53,10 +56,11 @@ import com.raytheon.uf.viz.core.rsc.capabilities.Capabilities; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * May 7, 2010 randerso Initial creation + * May 7, 2010 randerso Initial creation * Jan 25, 2013 DR 15649 D. Friedman Clone capabilities in get/put. * Stored preferences in a sub-directory * and observe changes. + * Nov 08, 2013 2361 njensen Use JAXBManager for XML * * * @@ -66,7 +70,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.Capabilities; @XmlRootElement() @XmlAccessorType(XmlAccessType.FIELD) -public class MapStylePreferenceStore implements ISerializableObject { +public class MapStylePreferenceStore { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(MapStylePreferenceStore.class); @@ -74,6 +78,8 @@ public class MapStylePreferenceStore implements ISerializableObject { private static final String OLD_MAPSTYLE_FILENAME = "mapstylepreferences.xml"; + private static JAXBManager jaxb; + private static class MapStylePreferenceKey { private String perspective; @@ -195,13 +201,13 @@ public class MapStylePreferenceStore implements ISerializableObject { IPathManager pathMgr = PathManagerFactory.getPathManager(); if (siteLf == null) { - siteLf = pathMgr.getLocalizationFile(pathMgr - .getContext(LocalizationType.CAVE_STATIC, - LocalizationLevel.SITE), MAPSTYLE_FILENAME); + siteLf = pathMgr.getLocalizationFile(pathMgr.getContext( + LocalizationType.CAVE_STATIC, LocalizationLevel.SITE), + MAPSTYLE_FILENAME); - userLf = pathMgr.getLocalizationFile(pathMgr - .getContext(LocalizationType.CAVE_STATIC, - LocalizationLevel.USER), MAPSTYLE_FILENAME); + userLf = pathMgr.getLocalizationFile(pathMgr.getContext( + LocalizationType.CAVE_STATIC, LocalizationLevel.USER), + MAPSTYLE_FILENAME); ILocalizationFileObserver obs = new ILocalizationFileObserver() { @Override @@ -215,22 +221,26 @@ public class MapStylePreferenceStore implements ISerializableObject { siteLf.addFileUpdatedObserver(obs); userLf.addFileUpdatedObserver(obs); - /* DR 15649 for OB 13.3.1: If the map style preferences are in the - * old location, move it to the correct place. This code can be + /* + * DR 15649 for OB 13.3.1: If the map style preferences are in the + * old location, move it to the correct place. This code can be * removed in the future. */ - if (! userLf.exists()) { - LocalizationFile oldUserLf = pathMgr.getLocalizationFile(pathMgr - .getContext(LocalizationType.CAVE_STATIC, + if (!userLf.exists()) { + LocalizationFile oldUserLf = pathMgr.getLocalizationFile( + pathMgr.getContext(LocalizationType.CAVE_STATIC, LocalizationLevel.USER), OLD_MAPSTYLE_FILENAME); if (oldUserLf.exists()) { try { userLf.write(oldUserLf.read()); oldUserLf.delete(); - statusHandler.handle(Priority.INFO, "Moved user map style preferences to new location"); + statusHandler + .handle(Priority.INFO, + "Moved user map style preferences to new location"); } catch (LocalizationException e) { - statusHandler.handle(Priority.PROBLEM, "Unable to move map style preferences", e); + statusHandler.handle(Priority.PROBLEM, + "Unable to move map style preferences", e); e.printStackTrace(); } } @@ -239,9 +249,9 @@ public class MapStylePreferenceStore implements ISerializableObject { if (siteLf.exists()) { try { - combinedPreferences = ((MapStylePreferenceStore) SerializationUtil - .jaxbUnmarshalFromXmlFile(siteLf.getFile())).preferences; - } catch (SerializationException e) { + combinedPreferences = getJaxbManager().unmarshalFromXmlFile( + MapStylePreferenceStore.class, siteLf.getFile()).preferences; + } catch (Exception e) { statusHandler .handle(Priority.PROBLEM, "Exception while loading site map style preferences", @@ -253,17 +263,16 @@ public class MapStylePreferenceStore implements ISerializableObject { if (userLf.exists()) { try { - preferences = ((MapStylePreferenceStore) SerializationUtil - .jaxbUnmarshalFromXmlFile(userLf.getFile())).preferences; + preferences = getJaxbManager().unmarshalFromXmlFile( + MapStylePreferenceStore.class, userLf.getFile()).preferences; // merge user into site for (Entry entry : preferences .entrySet()) { - combinedPreferences.put(entry.getKey(), - entry.getValue()); + combinedPreferences.put(entry.getKey(), entry.getValue()); } - } catch (SerializationException e) { + } catch (Exception e) { statusHandler .handle(Priority.PROBLEM, "Exception while loading user map style preferences", @@ -274,6 +283,18 @@ public class MapStylePreferenceStore implements ISerializableObject { } } + private static synchronized JAXBManager getJaxbManager() + throws JAXBException { + if (jaxb == null) { + SubClassLocator locator = new SubClassLocator(); + Collection> classes = JAXBClassLocator.getJAXBClasses( + locator, AbstractCapability.class, + MapStylePreferenceStore.class); + jaxb = new JAXBManager(classes.toArray(new Class[0])); + } + return jaxb; + } + private MapStylePreferenceStore() { } @@ -308,8 +329,7 @@ public class MapStylePreferenceStore implements ISerializableObject { File file = lf.getFile(); try { - SerializationUtil - .jaxbMarshalToXmlFile(this, file.getAbsolutePath()); + getJaxbManager().marshalToXmlFile(this, file.getAbsolutePath()); lf.save(); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, diff --git a/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/rsc/DbMapResource.java b/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/rsc/DbMapResource.java index 5443a4246a..64674708d7 100644 --- a/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/rsc/DbMapResource.java +++ b/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/rsc/DbMapResource.java @@ -92,6 +92,8 @@ import com.vividsolutions.jts.io.WKBReader; * Sep 18, 2012 1019 randerso improved error handling * Aug 12, 2013 1133 bsteffen Better error handling for invalid * polygons in map resource. + * Nov 06, 2013 2361 njensen Prepopulate fields in initInternal + * instead of constructor for speed * * * @@ -295,9 +297,10 @@ public class DbMapResource extends fields.add(column.toString()); } } + double[] lev = getLevels(); QueryResult mappedResult = DbMapQueryFactory.getMapQuery( resourceData.getTable(), - getGeomField(levels[levels.length - 1])) + getGeomField(lev[lev.length - 1])) .queryWithinEnvelope(req.envelope, fields, constraints); Map gidMap = new HashMap( @@ -533,7 +536,7 @@ public class DbMapResource extends protected Map colorMap; - protected double[] levels; + private double[] levels; protected double lastSimpLev; @@ -543,16 +546,11 @@ public class DbMapResource extends private MapQueryJob queryJob; - protected String geometryType; + private String geometryType; public DbMapResource(DbMapResourceData data, LoadProperties loadProperties) { super(data, loadProperties); queryJob = new MapQueryJob(); - - // Prepopulate fields - getGeometryType(); - getLabelFields(); - getLevels(); } @Override @@ -571,6 +569,13 @@ public class DbMapResource extends @Override protected void initInternal(IGraphicsTarget target) throws VizException { super.initInternal(target); + + // Prepopulate fields in initInternal since this is not on the UI + // thread + getGeometryType(); + getLabelFields(); + getLevels(); + getCapability(ShadeableCapability.class).setAvailableShadingFields( getLabelFields().toArray(new String[0])); } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/DirectDbQuery.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/DirectDbQuery.java index 8e8a75cd48..90f8be97de 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/DirectDbQuery.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/DirectDbQuery.java @@ -25,16 +25,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.xml.bind.JAXBException; - import com.raytheon.uf.common.dataquery.db.QueryResult; import com.raytheon.uf.common.dataquery.db.QueryResultRow; import com.raytheon.uf.common.dataquery.requests.QlServerRequest; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.dataquery.requests.SaveOrUpdateRequest; import com.raytheon.uf.common.message.response.AbstractResponseMessage; import com.raytheon.uf.common.message.response.ResponseMessageError; import com.raytheon.uf.common.message.response.ResponseMessageGeneric; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizServerSideException; import com.raytheon.uf.viz.core.requests.ThriftClient; @@ -49,6 +47,7 @@ import com.raytheon.uf.viz.core.requests.ThriftClient; * ------------ ---------- ----------- -------------------------- * 10/15/2008 1615 bphillip Initial Creation * 12/11/2008 1777 bphillip Added insert/update functionality + * Nov 08, 2013 2361 njensen Refactored/improved saveOrUpdateList() * * * @@ -319,44 +318,11 @@ public class DirectDbQuery { */ private int saveOrUpdateList(List objList, String database) throws VizException { + SaveOrUpdateRequest req = new SaveOrUpdateRequest(); + req.setDbName(database); + req.setObjectsToUpdate(objList); - constraints.put("database", new RequestConstraint(database)); - - for (int i = 0; i < objList.size(); i++) { - String xml = null; - try { - xml = SerializationUtil.marshalToXml(objList.get(i)); - } catch (JAXBException e) { - throw new VizException( - "Unable to marshal object. Save Failed.", e); - } - // xml = xml.replaceAll("\"", ""); - // xml = xml.replaceAll("\n", ""); - constraints.put("obj" + String.valueOf(i), new RequestConstraint( - xml)); - } - // set mode - constraints.put("mode", new RequestConstraint("saveOrUpdateObject")); - - // create and send request - QlServerRequest request = new QlServerRequest(constraints); - int retVal = 0; - AbstractResponseMessage response = (AbstractResponseMessage) ThriftClient - .sendRequest(request); - - if (constraints.containsKey("mode")) { - constraints.remove("mode"); - } - - if (response instanceof ResponseMessageGeneric) { - retVal = (Integer) ((ResponseMessageGeneric) response) - .getContents(); - } else if (response instanceof ResponseMessageError) { - ResponseMessageError rme = (ResponseMessageError) response; - VizServerSideException innerException = new VizServerSideException( - rme.toString()); - throw new VizServerSideException(rme.getErrorMsg(), innerException); - } - return retVal; + Object result = ThriftClient.sendRequest(req); + return (Integer) result; } } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/IColormappedImage.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/IColormappedImage.java index 65337306dd..afe9e1a04a 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/IColormappedImage.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/IColormappedImage.java @@ -19,8 +19,9 @@ **/ package com.raytheon.uf.viz.core.drawables; -import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; +import javax.measure.unit.Unit; +import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; /** * Describes a Colormapped Image @@ -64,4 +65,12 @@ public interface IColormappedImage extends IImage { */ public abstract double getValue(int x, int y); + /** + * Get the unit associated with the data in the image. Values returned from + * {@link #getValue(int, int)} will be in this unit + * + * @return + */ + public abstract Unit getDataUnit(); + } \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/colormap/ColormappedImage.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/colormap/ColormappedImage.java index 709fb95c68..8544c7a73e 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/colormap/ColormappedImage.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/colormap/ColormappedImage.java @@ -21,6 +21,8 @@ package com.raytheon.uf.viz.core.drawables.ext.colormap; import java.awt.image.RenderedImage; +import javax.measure.unit.Unit; + import com.raytheon.uf.common.colormap.image.ColorMapData; import com.raytheon.uf.common.colormap.image.Colormapper; import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; @@ -59,6 +61,8 @@ public class ColormappedImage implements IColormappedImage, private ColorMapParameters parameters; + private Unit dataUnit; + public ColormappedImage(IGraphicsTarget target, IColorMapDataRetrievalCallback callback, ColorMapParameters parameters) { @@ -103,9 +107,7 @@ public class ColormappedImage implements IColormappedImage, */ @Override public void dispose() { - if (image != null) { - image.dispose(); - } + image.dispose(); } /* @@ -209,11 +211,15 @@ public class ColormappedImage implements IColormappedImage, */ @Override public RenderedImage getImage() throws VizException { - if (parameters == null || parameters.getColorMap() == null) { - return null; + RenderedImage image = null; + if (parameters != null && parameters.getColorMap() != null) { + ColorMapData colorMapData = callback.getColorMapData(); + if (colorMapData != null) { + this.dataUnit = colorMapData.getDataUnit(); + image = Colormapper.colorMap(colorMapData, parameters); + } } - ColorMapData colorMapData = callback.getColorMapData(); - return Colormapper.colorMap(colorMapData, parameters); + return image; } /* @@ -237,4 +243,15 @@ public class ColormappedImage implements IColormappedImage, image.stage(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.drawables.IColormappedImage#getDataUnit() + */ + @Override + public Unit getDataUnit() { + return dataUnit == null ? getColorMapParameters().getDataUnit() + : dataUnit; + } + } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/CreateSubscriptionDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/CreateSubscriptionDlg.java index 82da0c1e43..e7a9c3efeb 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/CreateSubscriptionDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/CreateSubscriptionDlg.java @@ -142,6 +142,7 @@ import com.raytheon.viz.ui.presenter.components.ComboBoxConf; * Oct 15, 2013 2477 mpduff Fix bug in group settings. * Oct 23, 2013 2484 dhladky Unique ID for subscriptions updated. * Oct 21, 2013 2292 mpduff Close dialog on OK. + * Nov 07, 2013 2291 skorolev Used showText() method for "Unable to Create Subscription" message. * * * @@ -1206,9 +1207,11 @@ public class CreateSubscriptionDlg extends CaveSWTDialog { close(); } else { setStatus(Status.CANCEL); - displayPopup( - "Unable to Create Subscription", - status.getMessage()); + DataDeliveryUtils + .showText( + getShell(), + "Unable to Create Subscription", + status.getMessage()); } } } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionService.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionService.java index 6eeebf1374..20a5f298bf 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionService.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionService.java @@ -31,7 +31,6 @@ import java.util.TimeZone; import java.util.TreeSet; import java.util.concurrent.Callable; -import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Shell; import com.google.common.annotations.VisibleForTesting; @@ -94,6 +93,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils; * Sept 25, 2013 1797 dhladky separated time from gridded time * Oct 12, 2013 2460 dhladky restored adhoc subscriptions to registry storage. * Oct 22, 2013 2292 mpduff Removed subscriptionOverlapService. + * Nov 07, 2013 2291 skorolev Used showText() method for "Shared Subscription" message. * * * @@ -151,8 +151,8 @@ public class SubscriptionService implements ISubscriptionService { shell.getDisplay().syncExec(new Runnable() { @Override public void run() { - DataDeliveryUtils.showMessage(shell, SWT.OK, - "Shared Subscription", message); + DataDeliveryUtils.showText(shell, "Shared Subscription", + message); } }); } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtils.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtils.java index 98c3820189..f143cd1117 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtils.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtils.java @@ -81,8 +81,9 @@ import com.vividsolutions.jts.geom.Coordinate; * Jun 12, 2013 2064 mpduff Use SizeUtil to format data size output. * Jul 26, 2031 2232 mpduff Removed sendAuthorizationRequest method. * Aug 30, 2013 2288 bgonzale Added latency to details display. - * Sept 30, 2013 1797 dhladky Time GriddedTime separation + * Sep 30, 2013 1797 dhladky Time GriddedTime separation * Oct 11, 2013 2386 mpduff Refactor DD Front end. + * Nov 07, 2013 2291 skorolev Added showText() method for messages with many lines. * * * @author mpduff @@ -614,6 +615,20 @@ public class DataDeliveryUtils { "The changes were successfully applied."); } + /** + * Show message with long list of lines. + * + * @param shell + * @param messageTitle + * @param messageText + */ + public static void showText(Shell shell, String messageTitle, + String messageText) { + TextMessageDlg textMsgDlgdlg = new TextMessageDlg(shell, messageTitle, + messageText); + textMsgDlgdlg.open(); + } + /** * Provides the text for the subscription details dialog * diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/TextMessageDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/TextMessageDlg.java new file mode 100644 index 0000000000..3ba0b13cc6 --- /dev/null +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/TextMessageDlg.java @@ -0,0 +1,69 @@ +package com.raytheon.uf.viz.datadelivery.utils; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +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.Shell; + +import com.raytheon.viz.ui.dialogs.CaveSWTDialog; + +/** + * Replace a message box for messages with too big number of lines. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 7, 2013            skorolev     Initial creation
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ +public class TextMessageDlg extends CaveSWTDialog { + + private String messageText; + + protected TextMessageDlg(Shell parentShell, String messageTitle, + String messageText) { + super(parentShell, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK); + this.messageText = messageText; + this.setText(messageTitle); + } + + @Override + protected void initializeComponents(Shell shell) { + GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, false, false); + GridLayout gl = new GridLayout(1, false); + Composite mainComp = new Composite(shell, SWT.NONE); + mainComp.setLayout(gl); + mainComp.setLayoutData(gd); + + gd = new GridData(); + gd.widthHint = 350; + gd.heightHint = 350; + StyledText text = new StyledText(mainComp, SWT.MULTI | SWT.WRAP + | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + text.setLayoutData(gd); + text.setText(messageText); + + Button okBtn = new Button(mainComp, SWT.PUSH); + okBtn.setText("OK"); + okBtn.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, true)); + okBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + close(); + } + }); + } + +} diff --git a/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/graphics/ext/KmlColormappedImage.java b/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/graphics/ext/KmlColormappedImage.java index 91a1be4184..47d320c949 100644 --- a/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/graphics/ext/KmlColormappedImage.java +++ b/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/graphics/ext/KmlColormappedImage.java @@ -24,6 +24,8 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.ShortBuffer; +import javax.measure.unit.Unit; + import org.geotools.coverage.grid.GridGeometry2D; import com.raytheon.uf.common.colormap.image.ColorMapData; @@ -64,6 +66,8 @@ public class KmlColormappedImage extends KmlImage implements IColormappedImage { private ColorMapParameters colorMapParameters; + private Unit dataUnit; + public KmlColormappedImage(IColorMapDataRetrievalCallback dataCallback, ColorMapParameters colorMapParameters) { this.dataCallback = dataCallback; @@ -72,6 +76,7 @@ public class KmlColormappedImage extends KmlImage implements IColormappedImage { public DataSource getData(GridGeometry2D geometry) throws VizException { ColorMapData data = dataCallback.getColorMapData(); + this.dataUnit = data.getDataUnit(); switch (data.getDataType()) { case FLOAT: return new FloatBufferWrapper(((FloatBuffer) data.getBuffer()), @@ -122,4 +127,15 @@ public class KmlColormappedImage extends KmlImage implements IColormappedImage { return 0; } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.drawables.IColormappedImage#getDataUnit() + */ + @Override + public Unit getDataUnit() { + return dataUnit == null ? getColorMapParameters().getDataUnit() + : dataUnit; + } + } diff --git a/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/graphics/ext/KmlMosaicImage.java b/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/graphics/ext/KmlMosaicImage.java index 62e01dc168..28dd547f24 100644 --- a/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/graphics/ext/KmlMosaicImage.java +++ b/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/graphics/ext/KmlMosaicImage.java @@ -21,6 +21,8 @@ package com.raytheon.uf.viz.kml.export.graphics.ext; import java.util.Comparator; +import javax.measure.unit.Unit; + import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.viz.core.DrawableImage; import com.raytheon.uf.viz.core.IExtent; @@ -146,4 +148,14 @@ class KmlMosaicImage implements IMosaicImage { this.imageExtent = imageExtent; } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.drawables.IColormappedImage#getDataUnit() + */ + @Override + public Unit getDataUnit() { + return getColorMapParameters().getColorMapUnit(); + } + } \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.remote.graphics/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.remote.graphics/META-INF/MANIFEST.MF index 98e79b34d5..0ce0fb6dde 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.remote.graphics/META-INF/MANIFEST.MF @@ -10,12 +10,12 @@ Eclipse-BuddyPolicy: dependent Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, com.raytheon.uf.viz.core;bundle-version="1.12.1174", - org.geotools;bundle-version="2.6.4", com.raytheon.uf.common.colormap;bundle-version="1.12.1174", com.raytheon.viz.ui;bundle-version="1.12.1174", - javax.vecmath;bundle-version="1.3.1", com.raytheon.uf.common.util;bundle-version="1.12.1174", - com.raytheon.uf.common.geospatial;bundle-version="1.12.1174" + com.raytheon.uf.common.geospatial;bundle-version="1.12.1174", + javax.measure;bundle-version="1.0.0", + javax.vecmath;bundle-version="1.3.1" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.remote.graphics, diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingColormappedImage.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingColormappedImage.java index 7c1c8efbdd..94fedfccf6 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingColormappedImage.java +++ b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingColormappedImage.java @@ -19,6 +19,8 @@ **/ package com.raytheon.uf.viz.remote.graphics.objects; +import javax.measure.unit.Unit; + import com.raytheon.uf.common.colormap.IColorMap; import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.common.colormap.prefs.IColorMapParametersListener; @@ -150,4 +152,14 @@ public class DispatchingColormappedImage extends } } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.drawables.IColormappedImage#getDataUnit() + */ + @Override + public Unit getDataUnit() { + return wrappedObject.getDataUnit(); + } + } diff --git a/cave/com.raytheon.uf.viz.truecolor.gl/src/com/raytheon/uf/viz/truecolor/gl/extension/GLTrueColorImagingExtension.java b/cave/com.raytheon.uf.viz.truecolor.gl/src/com/raytheon/uf/viz/truecolor/gl/extension/GLTrueColorImagingExtension.java index a2dfb6b56f..acae687de9 100644 --- a/cave/com.raytheon.uf.viz.truecolor.gl/src/com/raytheon/uf/viz/truecolor/gl/extension/GLTrueColorImagingExtension.java +++ b/cave/com.raytheon.uf.viz.truecolor.gl/src/com/raytheon/uf/viz/truecolor/gl/extension/GLTrueColorImagingExtension.java @@ -52,7 +52,8 @@ import com.raytheon.viz.core.gl.images.AbstractGLImage; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Aug 6, 2012 mschenke Initial creation + * Aug 6, 2012 mschenke Initial creation + * Nov 4, 2013 2492 mschenke Reworked to use GLSL Data mapping * * * diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java index 8184ff688c..94e1d8fc2e 100644 --- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java +++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java @@ -225,8 +225,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * 11/05/2012 15477 zhao Trim blank lines in text in Editor when check Syntax * 01/09/2013 15528 zhao Modified saveFile() and restoreFile() * 08/09/2013 2033 mschenke Switched File.separator to IPathManager.SEPARATOR + * 09/04/2013 2322 lvenable Added CAVE style so this dialog is perspective independent * 10/24/2013 16478 zhao add syntax check for extra '=' sign - * 04Sep2013 #2322 lvenable Added CAVE style so this dialog is perspective independent * * * diff --git a/cave/com.raytheon.viz.core.gl/localization/glsl/include/mapping.glsl b/cave/com.raytheon.viz.core.gl/localization/glsl/include/mapping.glsl index 8ded421d66..4951fa1307 100644 --- a/cave/com.raytheon.viz.core.gl/localization/glsl/include/mapping.glsl +++ b/cave/com.raytheon.viz.core.gl/localization/glsl/include/mapping.glsl @@ -161,69 +161,111 @@ float getLinearIndex(float cmapValue, float cmapMin, float cmapMax) { return capIndex(index); } +/** + * Converts a colormap value to a log index + */ +float valueToLogIndex(float value, float rangeMin, float rangeMax) { + // Account for 0 min index + if (rangeMin == 0) { + rangeMin = 0.0000001; + if (rangeMax < 0) { + rangeMin = -rangeMin; + } + } + + int reverse = 0; + if ((value < rangeMin && rangeMin > 0) + || (value > rangeMin && rangeMin < 0)) { + reverse = 1; + } + + value = abs(value); + rangeMin = abs(rangeMin); + rangeMax = abs(rangeMax); + + // Check uncomputable index value, everything between this range is 0, + // rangeMin->rangeMax 0 -> 1, -rangeMin->-rangeMax 0 -> -1 + if (value <= rangeMin && value >= -rangeMin) { + return 0; + } + + double index = (log(value) - log(rangeMin)) + / (log(rangeMax) - log(rangeMin)); + if (reverse != 0) { + index = -index; + } + + return index; +} + /** * This function logarithmically finds the index for the cmapValue into * cmapMin/cmapMax (capped at 0-1). */ float getLogIndex(float cmapValue, float cmapMin, float cmapMax, int mirror) { + int inverted = 0; + float rangeMin = abs(cmapMin); + float rangeMax = abs(cmapMax); + float rangeValue = abs(cmapValue); + if (rangeMin > rangeMax) { + // Inverted colormapping range (cmapMax is closest to 0) + inverted = 1; + float tmp = rangeMin; + rangeMin = rangeMax; + rangeMax = tmp; + } + float index = 0.0; - // is this strictly negative, strictly positive or neg to pos scaling? - if (cmapMin >= 0.0 && cmapMax >= 0.0 && mirror != 1) { - if (cmapValue < cmapMin) { - index = 0.0; - } else { - // simple calculation - index = ((log(cmapValue) - log(cmapMin)) - / abs(log(cmapMax) - log(cmapMin))); + // Flag if min/max values are on opposite sides of zero + int minMaxOpposite = 0; + if ((cmapMin < 0 && cmapMax > 0) || (cmapMin > 0 && cmapMax < 0)) { + minMaxOpposite = 1; + } + + if (mirror != 0 || minMaxOpposite != 0) { + if (cmapMax < 0) { + // Invert colormapping if negative range was given + cmapValue = -cmapValue; } - } else if (cmapMin <= 0.0 && cmapMax <= 0.0 && mirror != 1) { - index = ((log(cmapValue) - log(cmapMax)) - / abs(log(cmapMin) - log(cmapMax))); - } else { - // special case, neg to pos: - float colorMapMin = cmapMin; - float colorMapMax = cmapMax; - float zeroVal = max(colorMapMax, abs(colorMapMin)) * 0.0001; - if (mirror == 1 && (colorMapMin > 0.0 || colorMapMax < 0.0)) { - if (colorMapMax < 0.0) { - colorMapMax = -cmapMax; - cmapValue = -cmapValue; - zeroVal = -colorMapMin; - } else { - zeroVal = cmapMin; - } - colorMapMin = -cmapMax; + // Log scaling is happening on both sides of zero, need to compute + // our zero index value + float zeroVal = rangeMin; + if (minMaxOpposite == 1) { + // Min/Max are on opposite sides of zero, compute a zero value + zeroVal = max(rangeMin, rangeMax) * 0.0001; } - float leftZero = 0.0; - float rightZero = 0.0; + + float negCmapMax = rangeMin; + float posCmapMax = rangeMax; + if (mirror != 0) { + negCmapMax = posCmapMax = rangeMax; + } + + // Compute log zero val and log neg/pos max vals float absLogZeroVal = abs(log(zeroVal)); - - rightZero = absLogZeroVal + log(colorMapMax); - - float cmapMax2 = abs(colorMapMin); - - leftZero = absLogZeroVal + log(cmapMax2); - - float zeroIndex = leftZero / (leftZero + rightZero); - - // figure out index for texture val - float absTextureColor = abs(cmapValue); - if (absTextureColor <= zeroVal) { - index = zeroIndex; - } else if (cmapValue > 0.0) { - // positive texture color value, find index from 0 to - // cmapMax: - float logTexColor = absLogZeroVal + log(cmapValue); - - float texIndex = logTexColor / rightZero; - index = (zeroIndex + ((1.0 - zeroIndex) * texIndex)); + float logNegCmapMax = absLogZeroVal + log(negCmapMax); + float logPosCmapMax = absLogZeroVal + log(posCmapMax); + // Calculate index which zeroVal is at based on neg max and pos max + float zeroValIndex = logNegCmapMax / (logNegCmapMax + logPosCmapMax); + if (cmapValue > 0) { + index = valueToLogIndex(rangeValue, zeroVal, posCmapMax); + index = zeroValIndex + (1 - zeroValIndex) * index; } else { - // negative texture color value, find index from 0 to - // cmapMax: - float logTexColor = absLogZeroVal + log(absTextureColor); - - float texIndex = logTexColor / leftZero; - index = (zeroIndex - (zeroIndex * texIndex)); + index = valueToLogIndex(rangeValue, zeroVal, negCmapMax); + index = zeroValIndex - zeroValIndex * index; + } + if (inverted != 0) { + index = 1.0 - index; + } + } else { + // Simple case, just use log converter to get index + index = valueToLogIndex(rangeValue, rangeMin, rangeMax); + if (inverted == 1) { + index = 1.0 - index; + } + if (cmapMin > 0 && cmapValue < rangeMin + || (cmapMin < 0 && cmapValue > -rangeMin)) { + index = -index; } } return capIndex(index); diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/imaging/GLDataMappingFactory.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/imaging/GLDataMappingFactory.java index 9fdbad5dd3..f867700f2b 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/imaging/GLDataMappingFactory.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/imaging/GLDataMappingFactory.java @@ -256,6 +256,10 @@ public class GLDataMappingFactory { float currDelta = (float) (currEndValue - dataMapping[0]); for (int i = 2; i < dataMapping.length; ++i) { double nextValue = dataMapping[i]; + // Deltas are compared in float space because it + // minimizes the precision errors and the mapping will + // occur in floats in GLSL so no need for the extra + // precision float nextDelta = (float) ((nextValue - currEndValue) / (i - currEndIndex)); if (nextDelta == currDelta) { // Remove linear entries diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/imaging/GLDefaultImagingExtension.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/imaging/GLDefaultImagingExtension.java index 5f81878958..20a502a7eb 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/imaging/GLDefaultImagingExtension.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/imaging/GLDefaultImagingExtension.java @@ -27,7 +27,8 @@ import com.raytheon.viz.core.gl.glsl.GLShaderProgram; import com.raytheon.viz.core.gl.images.AbstractGLImage; /** - * TODO Add Description + * Default GL imaging extension. Renders RGB images in GL applying alpha, + * brightness, and contrast settings. * *
  * 
diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/glsl/GLSLStructFactory.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/glsl/GLSLStructFactory.java
index e8fd320933..757e84544d 100644
--- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/glsl/GLSLStructFactory.java
+++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/glsl/GLSLStructFactory.java
@@ -23,7 +23,7 @@ import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
 import com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat;
 
 /**
- * Factory for creating GLSL struct mappings
+ * Factory for creating API defined GLSL structs in a {@link GLShaderProgram}.
  * 
  * 
  * 
diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/AbstractGLColormappedImage.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/AbstractGLColormappedImage.java
index 8f093e27f2..8ab9210a16 100644
--- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/AbstractGLColormappedImage.java
+++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/AbstractGLColormappedImage.java
@@ -39,7 +39,8 @@ import com.sun.opengl.util.texture.TextureCoords;
  * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Oct 16, 2013       2333 mschenke    Initial creation
+ * Oct 16, 2013 2333       mschenke    Initial creation
+ * Nov  4, 2013 2492       mschenke    Reworked to use GLSL Data mapping
  * 
  * 
* diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLColormappedImage.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLColormappedImage.java index 98811a23db..5c4643c67c 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLColormappedImage.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLColormappedImage.java @@ -19,6 +19,7 @@ **/ package com.raytheon.viz.core.gl.images; +import javax.measure.unit.Unit; import javax.media.opengl.GL; import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType; @@ -102,4 +103,12 @@ public class GLColormappedImage extends AbstractGLColormappedImage { super.usaAsFrameBuffer(); } + @Override + public Unit getDataUnit() { + if (data != null && data.getDataUnit() != null) { + return data.getDataUnit(); + } + return getColorMapParameters().getDataUnit(); + } + } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLOffscreenColormappedImage.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLOffscreenColormappedImage.java index 181ee5275a..c802cc94a3 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLOffscreenColormappedImage.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLOffscreenColormappedImage.java @@ -19,6 +19,8 @@ **/ package com.raytheon.viz.core.gl.images; +import javax.measure.unit.Unit; + import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension; import com.raytheon.viz.core.gl.dataformat.GLColorMapData; @@ -66,4 +68,9 @@ public class GLOffscreenColormappedImage extends AbstractGLColormappedImage { return Double.NaN; } + @Override + public Unit getDataUnit() { + return getColorMapParameters().getColorMapUnit(); + } + } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImage.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImage.java index 08adb03de7..b09ff41055 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImage.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImage.java @@ -19,6 +19,8 @@ **/ package com.raytheon.viz.core.gl.internal.ext.mosaic; +import javax.measure.unit.Unit; + import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.viz.core.DrawableImage; import com.raytheon.uf.viz.core.IExtent; @@ -172,4 +174,14 @@ public class GLMosaicImage extends GLDelegateImage this.image = wrappedImage; } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.drawables.IColormappedImage#getDataUnit() + */ + @Override + public Unit getDataUnit() { + return image.getDataUnit(); + } + } diff --git a/cave/com.raytheon.viz.gfe/localization/gfe/userPython/utilities/SmartScript.py b/cave/com.raytheon.viz.gfe/localization/gfe/userPython/utilities/SmartScript.py index 3eddd1542f..4d24e6f8d7 100644 --- a/cave/com.raytheon.viz.gfe/localization/gfe/userPython/utilities/SmartScript.py +++ b/cave/com.raytheon.viz.gfe/localization/gfe/userPython/utilities/SmartScript.py @@ -50,8 +50,10 @@ # so mask can be used with advanced indexing # (e.g. grid[mask] = value) # Oct 07, 2013 2424 randerso remove use of pytz -# Oct 29, 2013 2476 njensen Improved getting wx/discrete keys in _getGridResults +# Oct 29, 2013 2476 njensen Improved getting wx/discrete keys in _getGridResults # Oct 31, 2013 2508 randerso Change to use DiscreteGridSlice.getKeys() +# Nov 07, 2013 2476 dgilling Fix _getGridsResult() for retrieving +# Wx/Discrete in First mode. # ######################################################################## import types, string, time, sys @@ -485,7 +487,7 @@ class SmartScript(BaseTool.BaseTool): if result[0].dtype != numpy.int8: # scalar result = result[0] - else: + else: # discrete or weather keys = JUtil.javaObjToPyVal(slice.getKeyList()) result.append(keys) diff --git a/cave/com.raytheon.viz.grid/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/cave/com.raytheon.viz.grid/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 588bd6c7a3..0000000000 --- a/cave/com.raytheon.viz.grid/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,2 +0,0 @@ -com.raytheon.viz.grid.xml.ParameterList -com.raytheon.viz.grid.xml.ParameterMapping \ No newline at end of file diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/util/RadarProductCodeMapping.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/util/RadarProductCodeMapping.java index c793d6a922..d222e5a698 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/util/RadarProductCodeMapping.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/util/RadarProductCodeMapping.java @@ -29,13 +29,11 @@ import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; 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.viz.core.status.StatusConstants; -import com.raytheon.viz.grid.Activator; import com.raytheon.viz.grid.xml.ParameterList; import com.raytheon.viz.grid.xml.ParameterMapping; @@ -48,6 +46,7 @@ import com.raytheon.viz.grid.xml.ParameterMapping; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 22, 2010 #4473 rjpeter Initial creation + * Nov 07, 2361 2361 njensen Use JAXBManager for XML * *
* @@ -86,13 +85,14 @@ public class RadarProductCodeMapping { "/parameterMapping/radar/RadarProductCodes.xml"); try { - loadParameters(baseFile); + JAXBManager jaxb = new JAXBManager(ParameterList.class); + loadParameters(baseFile, jaxb); if (siteFile.exists()) { - loadParameters(siteFile); + loadParameters(siteFile, jaxb); } if (userFile.exists()) { - loadParameters(userFile); + loadParameters(userFile, jaxb); } } catch (Exception e) { statusHandler.handle( @@ -102,9 +102,10 @@ public class RadarProductCodeMapping { } } - private void loadParameters(File fileToLoad) throws SerializationException { - ParameterList parameterList = (ParameterList) SerializationUtil - .jaxbUnmarshalFromXmlFile(fileToLoad); + private void loadParameters(File fileToLoad, JAXBManager jaxb) + throws SerializationException { + ParameterList parameterList = jaxb.unmarshalFromXmlFile( + ParameterList.class, fileToLoad); for (ParameterMapping parameter : parameterList.getParameters()) { // print message for overwrite? parameterMappings.put(parameter.getAbbrev(), diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/xml/ParameterList.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/xml/ParameterList.java index f3174c8da0..3e7990a7bc 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/xml/ParameterList.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/xml/ParameterList.java @@ -26,10 +26,8 @@ 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; - /** - * TODO Add Description + * List of ParameterMappings * *
  * 
@@ -37,6 +35,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 22, 2010 #4473      rjpeter     Initial creation
+ * Nov 07, 2013  2361      njensen     Remove ISerializableObject
  * 
  * 
* @@ -45,7 +44,8 @@ import com.raytheon.uf.common.serialization.ISerializableObject; */ @XmlRootElement(name = "parameterList") @XmlAccessorType(XmlAccessType.NONE) -public class ParameterList implements ISerializableObject { +public class ParameterList { + @XmlElement(name = "parameter") private List parameters; diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/xml/ParameterMapping.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/xml/ParameterMapping.java index 1de0bb26c5..ee45b3ebba 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/xml/ParameterMapping.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/xml/ParameterMapping.java @@ -25,10 +25,8 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import com.raytheon.uf.common.serialization.ISerializableObject; - /** - * TODO Add Description + * Grid parameter name to map various radar product codes * *
  * 
@@ -36,6 +34,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 22, 2010 #4473      rjpeter     Initial creation
+ * Nov 07, 2013  2361      njensen     Remove ISerializableObject
  * 
  * 
* @@ -43,7 +42,8 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) -public class ParameterMapping implements ISerializableObject { +public class ParameterMapping { + @XmlAttribute private String abbrev; diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/stationprofile/StationProfileDlg.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/stationprofile/StationProfileDlg.java index a1f6763239..0f8748e27e 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/stationprofile/StationProfileDlg.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/stationprofile/StationProfileDlg.java @@ -328,8 +328,8 @@ public class StationProfileDlg extends CaveSWTDialog { * Calculate pixel and offset values. */ private void calculateValues() { - double totalElevInc = Math.abs(stationProfData.getElevationFtMax()) - - Math.abs(stationProfData.getElevationFtMin()); + double totalElevInc = stationProfData.getElevationFtMax() + - stationProfData.getElevationFtMin(); // Calculate the offset between the elevation points double offsetDbl = totalElevInc / 5; diff --git a/cave/com.raytheon.viz.text.feature/feature.xml b/cave/com.raytheon.viz.text.feature/feature.xml index da85a8918a..b6297ff451 100644 --- a/cave/com.raytheon.viz.text.feature/feature.xml +++ b/cave/com.raytheon.viz.text.feature/feature.xml @@ -24,6 +24,27 @@ + + + + + + - - - - * @@ -61,8 +61,13 @@ import com.raytheon.viz.ui.dialogs.colordialog.ColorUtil; public class ColorMapSliderComp extends Composite { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(ColorMapSliderComp.class); + private static final String NaN_STRING = "NO DATA"; + + private static final int SLIDER_MIN = 0; + + private static final int SLIDER_MAX = 255; + + private static final int SLIDER_INC = 1; private ColorMapParameters cmap; @@ -74,25 +79,25 @@ public class ColorMapSliderComp extends Composite { private Text maxValueText; - private String[] sliderText; + private final float cmapAbsoluteMin; - private float cmapMin; + private final float cmapAbsoluteMax; - private float cmapMax; + private final float origCmapMin; - private float cmapWidth; + private final float origCmapMax; - private float cmapIncrement; + private float currentCmapMin; - private DecimalFormat format = null; + private float currentCmapMax; - private float currentMin; + private final DecimalFormat format; - private float currentMax; + private final boolean dataInverted; - private float origCmapMin; + private UnitConverter displayToColorMap; - private float origCmapMax; + private UnitConverter colorMapToDisplay; /** * @param parent @@ -101,8 +106,46 @@ public class ColorMapSliderComp extends Composite { public ColorMapSliderComp(Composite parent, ColorMapParameters cmap) { super(parent, SWT.NONE); this.cmap = cmap; - this.origCmapMin = cmap.getColorMapMin(); - this.origCmapMax = cmap.getColorMapMax(); + this.currentCmapMin = this.origCmapMin = cmap.getColorMapMin(); + this.currentCmapMax = this.origCmapMax = cmap.getColorMapMax(); + this.displayToColorMap = cmap.getDisplayToColorMapConverter(); + this.colorMapToDisplay = cmap.getColorMapToDisplayConverter(); + if (displayToColorMap == null) { + displayToColorMap = Unit.ONE.getConverterTo(Unit.ONE); + } + if (colorMapToDisplay == null) { + colorMapToDisplay = Unit.ONE.getConverterTo(Unit.ONE); + } + float cmapAbsoluteMin, cmapAbsoluteMax; + if (cmap.getDataMapping() != null) { + cmapAbsoluteMin = cmap.getColorMapMin(); + cmapAbsoluteMax = cmap.getColorMapMax(); + } else { + UnitConverter dataToColorMap = cmap.getDataToColorMapConverter(); + cmapAbsoluteMin = cmap.getDataMin(); + cmapAbsoluteMax = cmap.getDataMax(); + if (dataToColorMap != null) { + cmapAbsoluteMin = (float) dataToColorMap.convert(cmap + .getDataMin()); + cmapAbsoluteMax = (float) dataToColorMap.convert(cmap + .getDataMax()); + } + } + + this.cmapAbsoluteMin = cmapAbsoluteMin; + this.cmapAbsoluteMax = cmapAbsoluteMax; + + boolean dataInverted = false; + if ((cmapAbsoluteMin > cmapAbsoluteMax && cmap.getDataMin() < cmap + .getDataMax()) + || (cmapAbsoluteMin < cmapAbsoluteMax && cmap.getDataMin() > cmap + .getDataMax())) { + dataInverted = true; + } + + this.dataInverted = dataInverted; + this.format = getTextFormat(); + initializeComponents(); } @@ -115,16 +158,15 @@ public class ColorMapSliderComp extends Composite { * */ private void initializeComponents() { - buildColorMapData(); setLayout(new GridLayout(3, false)); Label maxLabel = new Label(this, SWT.None); maxLabel.setText("Max:"); maxSlider = new Scale(this, SWT.HORIZONTAL); - maxSlider.setMaximum(255); - maxSlider.setMinimum(0); - maxSlider.setIncrement(1); + maxSlider.setMaximum(SLIDER_MAX); + maxSlider.setMinimum(SLIDER_MIN); + maxSlider.setIncrement(SLIDER_INC); maxSlider.setSelection(maxSlider.getMaximum()); GridData layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); layoutData.minimumWidth = 250; @@ -142,9 +184,9 @@ public class ColorMapSliderComp extends Composite { minLabel.setText("Min:"); minSlider = new Scale(this, SWT.HORIZONTAL); - minSlider.setMaximum(255); - minSlider.setMinimum(0); - minSlider.setIncrement(1); + minSlider.setMaximum(SLIDER_MAX); + minSlider.setMinimum(SLIDER_MIN); + minSlider.setIncrement(SLIDER_INC); minSlider.setSelection(minSlider.getMinimum()); layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); layoutData.minimumWidth = 250; @@ -156,286 +198,186 @@ public class ColorMapSliderComp extends Composite { minValueText.setLayoutData(labelLayoutData); maxSlider.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { - if (maxSlider.getSelection() <= minSlider.getSelection()) { - maxSlider.setSelection(minSlider.getSelection() + 1); - } - maxValueText.setText(selectionToText(maxSlider.getSelection())); - changeMax(maxSlider.getSelection()); + setColorMapMax(selectionToColorMapValue(maxSlider + .getSelection())); } - }); minSlider.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { - if (minSlider.getSelection() >= maxSlider.getSelection()) { - minSlider.setSelection(maxSlider.getSelection() - 1); - } - minValueText.setText(selectionToText(minSlider.getSelection())); - changeMin(minSlider.getSelection()); + setColorMapMin(selectionToColorMapValue(minSlider + .getSelection())); } - }); - maxValueText.addKeyListener(new KeyListener() { - + maxValueText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { - maxTextChanged(); + setColorMapMax(textToColorMapValue(maxValueText.getText() + .trim())); } } - - @Override - public void keyReleased(KeyEvent e) { - // do nothing - } - }); - minValueText.addKeyListener(new KeyListener() { - + minValueText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { - minTextChanged(); + setColorMapMin(textToColorMapValue(minValueText.getText() + .trim())); } } - - @Override - public void keyReleased(KeyEvent e) { - // do nothing - } - }); - // set initial values - currentMax = cmap.getColorMapMax(); - currentMin = cmap.getColorMapMin(); - maxSlider.setSelection(cmapToSelection(currentMax)); - minSlider.setSelection(cmapToSelection(currentMin)); - setMaxText(); - setMinText(); + setColorMapMin(currentCmapMin); + setColorMapMax(currentCmapMax); } - private void setMaxText() { - maxValueText.setText(cmapToText(currentMax)); - } - - private void setMinText() { - minValueText.setText(cmapToText(currentMin)); - } - - private void setColorMapMax(float f) { - if (currentMax != f) { - currentMax = f; - cmap.setColorMapMax(f, true); + /** + * Converts a slider selection index to a colormap value + * + * @param selection + * @return + */ + private float selectionToColorMapValue(int selection) { + double indexValue = Colormapper.getLinearIndex(selection, SLIDER_MIN, + SLIDER_MAX); + if (dataInverted) { + indexValue = 1 - indexValue; } + double colorMapValue = cmapAbsoluteMin + + (cmapAbsoluteMax - cmapAbsoluteMin) * indexValue; + return (float) colorMapValue; } - private void setColorMapMin(float f) { - if (currentMin != f) { - currentMin = f; - cmap.setColorMapMin(f, true); + /** + * Converts a colormap value to a slider selection index + * + * @param colorMapValue + * @return + */ + private int colorMapValueToSelection(float colorMapValue) { + double indexValue = Colormapper.getLinearIndex(colorMapValue, + cmapAbsoluteMin, cmapAbsoluteMax); + if (dataInverted) { + indexValue = 1 - indexValue; } + return (int) (SLIDER_MIN + (SLIDER_MAX - SLIDER_MIN) * indexValue); } - private void minTextChanged() { - String text = minValueText.getText().trim().split(" ")[0]; - try { - float f = Float.valueOf(text); - UnitConverter unitConv = cmap.getImageToDisplayConverter(); - if (unitConv != null) { - f = (float) unitConv.inverse().convert(f); - } - if (f >= currentMax) { - setMinText(); - statusHandler.handle(Priority.ERROR, - "Minimum of colormap range cannot exceed the maximum."); - } else if (cmapMin >= f) { - setColorMapMin(cmapMin); - minSlider.setSelection(0); - setMinText(); - } else { - setColorMapMin(f); - minSlider.setSelection(cmapToSelection(f)); - } - } catch (NumberFormatException ex) { - statusHandler.handle(Priority.ERROR, - "Minimum of colormap range cannot be parsed: " + text); - setMinText(); - } catch (ConversionException ex) { - statusHandler.handle(Priority.ERROR, "Unit converter error.", ex); - setMinText(); - } - } - - private void maxTextChanged() { - String text = maxValueText.getText().trim().split(" ")[0]; - try { - float f = Float.valueOf(text); - UnitConverter unitConv = cmap.getImageToDisplayConverter(); - if (unitConv != null) { - f = (float) unitConv.inverse().convert(f); - } - if (currentMin >= f) { - statusHandler - .handle(Priority.ERROR, - "Maximum of colormap range cannot be below the minimum."); - setMaxText(); - } else if (f >= cmapMax) { - setColorMapMax(cmapMax); - maxSlider.setSelection(255); - setMaxText(); - } else { - setColorMapMax(f); - maxSlider.setSelection(cmapToSelection(f)); - } - } catch (NumberFormatException ex) { - statusHandler.handle(Priority.ERROR, - "Maximum of colormap range cannot be parsed: " + text); - setMaxText(); - } catch (ConversionException ex) { - statusHandler.handle(Priority.ERROR, "Unit converter error.", ex); - setMaxText(); - } - - } - - private void changeMax(int position) { - // slider min and max is based on the color map, so position is the new - // color map max - currentMax = selectionToCmap(position); - cmap.setColorMapMax(currentMax, true); - } - - private void changeMin(int position) { - // slider min and max is based on the color map, so position is the new - // color map min - currentMin = selectionToCmap(position); - cmap.setColorMapMin(currentMin, true); - } - - private String cmapToText(double value) { - UnitConverter unitConv = cmap.getImageToDisplayConverter(); - String textStr = ""; - - if (unitConv != null) { - value = unitConv.convert(value); - - if (((Double) value).isNaN()) { - textStr = "NO DATA"; + /** + * Converts a text string to a colormap value + * + * @param text + * @return + */ + private float textToColorMapValue(String text) { + if (cmap.getDataMapping() != null && text.isEmpty() == false) { + // First check for data mapping entries + for (DataMappingEntry entry : cmap.getDataMapping().getEntries()) { + if (entry.getLabel() != null && text.equals(entry.getLabel())) { + return entry.getPixelValue().floatValue(); + } } } - - String txt; - if (textStr.length() == 0) { - txt = format.format(value); + if (NaN_STRING.equals(text)) { + // If special NaN String, try to find first NaN value + for (int i = SLIDER_MIN; i < SLIDER_MAX; i += SLIDER_INC) { + float colorMapValue = selectionToColorMapValue(i); + if (Double.isNaN(colorMapToDisplay.convert(colorMapValue))) { + return colorMapValue; + } + } } else { - txt = textStr; - } - - return txt; - } - - private String selectionToText(int selection) { - String rval = "ERR"; - - if (selection > -1 && selection < sliderText.length) { - // exact match into sliderText array - rval = sliderText[selection]; - } else { - statusHandler.handle(Priority.CRITICAL, "index " + selection - + " out of range, max " + (sliderText.length - 1)); - } - return rval; - } - - private float selectionToCmap(int selection) { - float percentOffset = selection / 255.0f; - float value = percentOffset * cmapWidth + cmapMin; - return value; - } - - private int cmapToSelection(float value) { - int selection = (int) ((value - cmapMin) * 255.0f / cmapWidth); - return selection; - } - - // modified from logic in ColorBar.java - private void buildColorMapData() { - sliderText = new String[256]; - cmapWidth = cmap.getDataMax() - cmap.getDataMin(); - cmapIncrement = cmapWidth / ColorUtil.MAX_VALUE; - cmapMin = cmap.getDataMin(); - cmapMax = cmap.getDataMax(); - float start = cmap.getDataMin(); - String units = ""; - - UnitConverter unitConv = cmap.getImageToDisplayConverter(); - - Double lastVal = Double.NaN; - - // TODO: Handle piecewise pixel converts to show ranges (for radar) - for (int i = 0; i < sliderText.length; ++i) { - double value = start; - - // handle precision errors - if (value > cmapMax) { - // if the difference is .1 the increment between steps assume - // that cmapMax is ok - if ((value - cmapMax) < (.1 * cmapIncrement)) { - value = cmapMax; - } + // Attempt to parse and convert + try { + float displayValue = Float.parseFloat(text); + return (float) displayToColorMap.convert(displayValue); + } catch (Throwable t) { + // Ignore, NaN will be returned and text will be reverted } + } + return Float.NaN; + } - String textStr = ""; - - if (cmap.isLogarithmic()) { - // TODO: Handle case where min/max go from neg to pos - if (cmap.getColorMapMax() >= 0 && cmap.getColorMapMin() >= 0) { - double index = (i) / ColorUtil.MAX_VALUE; - value = Math.pow(Math.E, - (Math.log(cmap.getColorMapMin()) + (index * (Math - .log(cmap.getColorMapMax()) - Math.log(cmap - .getColorMapMin()))))); - } - if (format == null) { - format = new DecimalFormat("0.000"); - } - } - - if (unitConv != null) { - value = unitConv.convert(value); - - /* - * Check if the last value is non a number. - */ - if (lastVal.isNaN()) { - // If value is not a number then set the text to - // "NO DATA". - if (((Double) value).isNaN()) { - textStr = "NO DATA"; - } - lastVal = value; - } else { - // If value is not a number then prepend ">" - // to the value. - if (((Double) value).isNaN()) { - textStr = "> " + lastVal; - } else { - lastVal = value; + /** + * Converts a colormap value into a text display string + * + * @param colorMapValue + * @return + */ + private String colorMapValueToText(float colorMapValue) { + String text = null; + if (cmap.getDataMapping() != null) { + text = cmap.getDataMapping().getLabelValueForDataValue( + colorMapValue); + } + if (text == null || text.trim().isEmpty()) { + float displayValue = (float) colorMapToDisplay + .convert(colorMapValue); + if (Float.isNaN(displayValue) == false) { + text = format.format(displayValue); + } else { + text = NaN_STRING; + int selection = colorMapValueToSelection(colorMapValue); + for (int i = selection; i >= SLIDER_MIN; i -= SLIDER_INC) { + displayValue = (float) colorMapToDisplay + .convert(selectionToColorMapValue(i)); + if (Float.isNaN(displayValue) == false) { + text = "> " + format.format(displayValue); + break; } } } + } + return text; + } + + /** + * Sets the colormap min value, updates the text and slider + * + * @param colorMapMin + */ + private void setColorMapMin(float colorMapMin) { + if (Float.isNaN(colorMapMin) == false) { + currentCmapMin = colorMapMin; + } + minSlider.setSelection(colorMapValueToSelection(currentCmapMin)); + minValueText.setText(colorMapValueToText(currentCmapMin)); + + cmap.setColorMapMin(currentCmapMin, true); + } + + /** + * Sets the colormap max value, updates the text and slider + * + * @param colorMapMax + */ + private void setColorMapMax(float colorMapMax) { + if (Float.isNaN(colorMapMax) == false) { + currentCmapMax = colorMapMax; + } + maxSlider.setSelection(colorMapValueToSelection(currentCmapMax)); + maxValueText.setText(colorMapValueToText(currentCmapMax)); + + cmap.setColorMapMax(currentCmapMax, true); + } + + private DecimalFormat getTextFormat() { + if (cmap.isLogarithmic() == false) { + for (int i = SLIDER_MIN; i < SLIDER_MAX; ++i) { + double cmapValue = selectionToColorMapValue(i); + double displayValue = colorMapToDisplay.convert(cmapValue); + if (Double.isNaN(displayValue)) { + continue; + } - if (format == null && new Double(value).isNaN() == false) { int zeros = 0; - String val = "" + value; + String val = "" + displayValue; char[] vals = val.substring(val.indexOf(".") + 1).toCharArray(); for (int j = 0; j < vals.length; ++j) { if (vals[j] == '0') { @@ -451,28 +393,10 @@ public class ColorMapSliderComp extends Composite { for (int j = 0; j < zeros; ++j) { f += "0"; } - format = new DecimalFormat(f); + return new DecimalFormat(f); } - - String txt; - - /* - * If textStr doesn't have any text then set txt to the value in the - * value variable. - */ - if (textStr.length() == 0) { - txt = format.format(value); - } else { - txt = textStr; - } - - if (units != null && units.length() != 0) { - txt += " " + units; - } - - sliderText[i] = txt; - start += cmapIncrement; } + return new DecimalFormat("0.000"); } } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java index bb505ff54f..3d40222b40 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java @@ -151,7 +151,7 @@ import com.vividsolutions.jts.geom.Polygon; * Sep 17, 2013 DR 16496 D. Friedman Make editable state more consistent. * Sep 24, 2013 #2401 lvenable Fixed font memory leak. * Oct 01, 2013 DR16612 m.gamazaychikov Fixed inconsistencies with track locking and updateListSelected method - * Oct 29, 2013 DR 16734 D. Friedman If redraw-from-hatched-area fails, don't allow the pollygon the be used. + * Oct 29, 2013 DR 16734 D. Friedman If redraw-from-hatched-area fails, don't allow the polygon the be used. * * * @author chammack @@ -1073,14 +1073,16 @@ public class WarngenDialog extends CaveSWTDialog implements if ((followupData != null) && (WarningAction.valueOf(followupData.getAct()) == WarningAction.NEW)) { - redrawFromWarned(); + if (! redrawFromWarned()) + return; } if (((followupData == null) || ((WarningAction.valueOf(followupData .getAct()) == WarningAction.CON) && warngenLayer .conWarnAreaChanged(followupData))) && !polygonLocked && !trackLocked) { - redrawFromWarned(); + if (!redrawFromWarned()) + return; } // Need to check again because redraw may have failed. @@ -1457,14 +1459,10 @@ public class WarngenDialog extends CaveSWTDialog implements /** * Redraw everything based on warned area */ - private void redrawFromWarned() { - try { - warngenLayer.redrawBoxFromHatched(); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error redrawing box from hatched", e); - } + private boolean redrawFromWarned() { + boolean result = warngenLayer.redrawBoxFromHatched(); warngenLayer.issueRefresh(); + return result; } /** diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java index a9f7e18629..13ccbf53d4 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java @@ -396,6 +396,8 @@ public class WarngenLayer extends AbstractStormTrackResource { private Polygon oldWarningPolygon; + private boolean haveInput; + public AreaHatcher(PolygonUtil polygonUtil) { super("Hatching Warning Area"); setSystem(true); @@ -513,6 +515,7 @@ public class WarngenLayer extends AbstractStormTrackResource { this.warningPolygon = warningPolygon; this.warningArea = warningArea; this.oldWarningPolygon = oldWarningPolygon; + this.haveInput = true; } schedule(); } @@ -520,12 +523,15 @@ public class WarngenLayer extends AbstractStormTrackResource { public synchronized Geometry[] getHatchedAreas() { Polygon hatchedArea = null; Geometry hatchedWarningArea = null; - if (getState() == Job.RUNNING) { + while (getState() != Job.NONE) { try { join(); } catch (InterruptedException e) { + break; } } + if (! this.haveInput) + return null; hatchedArea = this.hatchedArea; hatchedWarningArea = this.hatchedWarningArea; return new Geometry[] { hatchedArea, hatchedWarningArea }; @@ -2254,13 +2260,14 @@ public class WarngenLayer extends AbstractStormTrackResource { } /** - * + * @return true if the box has been redraw successfully */ - public void redrawBoxFromHatched() throws VizException { + public boolean redrawBoxFromHatched() { + boolean result = true; if (state.snappedToArea == false) { if (state.getWarningArea() == null || state.getWarningArea().isEmpty()) { - return; + return true; } try { @@ -2269,6 +2276,14 @@ public class WarngenLayer extends AbstractStormTrackResource { Geometry hatchedArea = state.getWarningArea(); if (areaHatcher != null) { Geometry[] areas = areaHatcher.getHatchedAreas(); + if (areas == null) { + // Somehow, the hatcher has not been run. Try it now. + warningAreaChanged(); + areas = areaHatcher.getHatchedAreas(); + // If still null, give up. + if (areas == null) + return false; + } hatched = (Polygon) areas[0]; hatchedArea = areas[1]; } @@ -2302,15 +2317,18 @@ public class WarngenLayer extends AbstractStormTrackResource { issueRefresh(); statusHandler.handle(Priority.PROBLEM, "Could not redraw box from warned area"); + result = false; } System.out.println("Time to createWarningPolygon: " + (System.currentTimeMillis() - t0) + "ms"); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, "Error hatching polygon", e); + result = false; } issueRefresh(); } + return result; } public void createDamThreatArea(Coordinate[] coordinates) { diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/CWASPSResource.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/CWASPSResource.java index 70c93c3987..3e8533c5b2 100644 --- a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/CWASPSResource.java +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/CWASPSResource.java @@ -56,6 +56,8 @@ import com.vividsolutions.jts.io.WKTReader; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 10, 2013 1951 rjpeter Initial history entry, updated ugcZones references + * Nov 08, 2013 16758 mgamazaychikov Added mergeWatches to simplify SPS processing + * and getEventKey to create SPS-unique key * * * @author rjpeter @@ -286,4 +288,27 @@ public class CWASPSResource extends WatchesResource { return textToPrint; } + + /** + * Groups all the ugc zones with the same 'product.act.phensig.etn' + * + * Since there are no ugc zones in SPSs return the input watch records + * without changing them. + */ + protected List mergeWatches( + List watchrecs) { + return watchrecs; + } + + /** + * Create unique enough key to be used in paint method entryMap + * + * Use wmoId and countyHeader fields + **/ + @Override + protected String getEventKey(WarningEntry entry) { + AbstractWarningRecord rec = entry.record; + return rec.getWmoid().replaceAll(" ", "_") + ':' + + rec.getInsertTime().getTimeInMillis(); + } } diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java index 6b4b755a75..1494ac5034 100644 --- a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java @@ -50,6 +50,8 @@ import com.vividsolutions.jts.geom.GeometryFactory; * May 06, 2013 1930 bsteffen Check for null in WatchesResource. * May 10, 2013 1951 rjpeter Updated ugcZones references * Sep 5, 2013 2176 jsanchez Disposed the emergency font. + * Nov 8, 2013 16758 mgamazaychikov Changed access modifier of mergeWatches to protected + * so a child class can override the implementation. * * * @author jsanchez @@ -377,7 +379,7 @@ public class WatchesResource extends AbstractWWAResource { /** * Groups all the ugc zones with the same 'product.act.phensig.etn' */ - private List mergeWatches( + protected List mergeWatches( List watchrecs) { Map watches = new HashMap(); for (AbstractWarningRecord watchrec : watchrecs) { diff --git a/cots/org.apache.camel/.classpath b/cots/org.apache.camel/.classpath index abf53adcea..a2c6e537e6 100644 --- a/cots/org.apache.camel/.classpath +++ b/cots/org.apache.camel/.classpath @@ -1,12 +1,12 @@ - - - - - - - + + + + + + + diff --git a/cots/org.apache.camel/META-INF/MANIFEST.MF b/cots/org.apache.camel/META-INF/MANIFEST.MF index d374d00f55..f0b89a45d6 100644 --- a/cots/org.apache.camel/META-INF/MANIFEST.MF +++ b/cots/org.apache.camel/META-INF/MANIFEST.MF @@ -2,16 +2,16 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Camel Plug-in Bundle-SymbolicName: org.apache.camel -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 2.11.2 Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ClassPath: ., - camel-core-2.11.0.jar, - camel-http4-2.11.0.jar, - camel-jetty-2.11.0.jar, - camel-jms-2.11.0.jar, - camel-quartz-2.11.0.jar, - camel-spring-2.11.0.jar, - camel-http-2.11.0.jar + camel-core-2.11.2.jar, + camel-http-2.11.2.jar, + camel-http4-2.11.2.jar, + camel-jetty-2.11.2.jar, + camel-jms-2.11.2.jar, + camel-quartz-2.11.2.jar, + camel-spring-2.11.2.jar Require-Bundle: org.springframework;bundle-version="3.1.4", org.apache.commons.management;bundle-version="1.0.0" Export-Package: org.apache.camel, diff --git a/cots/org.apache.camel/apache-camel-2.11.0-src.zip b/cots/org.apache.camel/apache-camel-2.11.2-src.zip similarity index 87% rename from cots/org.apache.camel/apache-camel-2.11.0-src.zip rename to cots/org.apache.camel/apache-camel-2.11.2-src.zip index e2f49b3526..f5d1a7f2e7 100644 Binary files a/cots/org.apache.camel/apache-camel-2.11.0-src.zip and b/cots/org.apache.camel/apache-camel-2.11.2-src.zip differ diff --git a/cots/org.apache.camel/build.properties b/cots/org.apache.camel/build.properties index 640e1187c9..c108e5c805 100644 --- a/cots/org.apache.camel/build.properties +++ b/cots/org.apache.camel/build.properties @@ -1,9 +1,9 @@ bin.includes = META-INF/,\ .,\ - camel-core-2.11.0.jar,\ - camel-http4-2.11.0.jar,\ - camel-jetty-2.11.0.jar,\ - camel-jms-2.11.0.jar,\ - camel-quartz-2.11.0.jar,\ - camel-spring-2.11.0.jar,\ - camel-http-2.11.0.jar + camel-core-2.11.2.jar,\ + camel-http-2.11.2.jar,\ + camel-http4-2.11.2.jar,\ + camel-jetty-2.11.2.jar,\ + camel-jms-2.11.2.jar,\ + camel-quartz-2.11.2.jar,\ + camel-spring-2.11.2.jar diff --git a/cots/org.apache.camel/camel-core-2.11.0.jar b/cots/org.apache.camel/camel-core-2.11.2.jar similarity index 59% rename from cots/org.apache.camel/camel-core-2.11.0.jar rename to cots/org.apache.camel/camel-core-2.11.2.jar index a0507714a6..cde219bb4b 100644 Binary files a/cots/org.apache.camel/camel-core-2.11.0.jar and b/cots/org.apache.camel/camel-core-2.11.2.jar differ diff --git a/cots/org.apache.camel/camel-http-2.11.0.jar b/cots/org.apache.camel/camel-http-2.11.0.jar deleted file mode 100644 index 29e2587ea1..0000000000 Binary files a/cots/org.apache.camel/camel-http-2.11.0.jar and /dev/null differ diff --git a/cots/org.apache.camel/camel-http-2.11.2.jar b/cots/org.apache.camel/camel-http-2.11.2.jar new file mode 100644 index 0000000000..dd2557ac92 Binary files /dev/null and b/cots/org.apache.camel/camel-http-2.11.2.jar differ diff --git a/cots/org.apache.camel/camel-http4-2.11.0.jar b/cots/org.apache.camel/camel-http4-2.11.0.jar deleted file mode 100644 index aff3bf4072..0000000000 Binary files a/cots/org.apache.camel/camel-http4-2.11.0.jar and /dev/null differ diff --git a/cots/org.apache.camel/camel-http4-2.11.2.jar b/cots/org.apache.camel/camel-http4-2.11.2.jar new file mode 100644 index 0000000000..b0e21ffb74 Binary files /dev/null and b/cots/org.apache.camel/camel-http4-2.11.2.jar differ diff --git a/cots/org.apache.camel/camel-jetty-2.11.0.jar b/cots/org.apache.camel/camel-jetty-2.11.0.jar deleted file mode 100644 index 57f9229dfb..0000000000 Binary files a/cots/org.apache.camel/camel-jetty-2.11.0.jar and /dev/null differ diff --git a/cots/org.apache.camel/camel-jetty-2.11.2.jar b/cots/org.apache.camel/camel-jetty-2.11.2.jar new file mode 100644 index 0000000000..b59344826a Binary files /dev/null and b/cots/org.apache.camel/camel-jetty-2.11.2.jar differ diff --git a/cots/org.apache.camel/camel-jms-2.11.0.jar b/cots/org.apache.camel/camel-jms-2.11.0.jar deleted file mode 100644 index 388f7a94e2..0000000000 Binary files a/cots/org.apache.camel/camel-jms-2.11.0.jar and /dev/null differ diff --git a/cots/org.apache.camel/camel-jms-2.11.2.jar b/cots/org.apache.camel/camel-jms-2.11.2.jar new file mode 100644 index 0000000000..e65600081a Binary files /dev/null and b/cots/org.apache.camel/camel-jms-2.11.2.jar differ diff --git a/cots/org.apache.camel/camel-quartz-2.11.0.jar b/cots/org.apache.camel/camel-quartz-2.11.0.jar deleted file mode 100644 index 574543c8fb..0000000000 Binary files a/cots/org.apache.camel/camel-quartz-2.11.0.jar and /dev/null differ diff --git a/cots/org.apache.camel/camel-quartz-2.11.2.jar b/cots/org.apache.camel/camel-quartz-2.11.2.jar new file mode 100644 index 0000000000..a78f72588c Binary files /dev/null and b/cots/org.apache.camel/camel-quartz-2.11.2.jar differ diff --git a/cots/org.apache.camel/camel-spring-2.11.0.jar b/cots/org.apache.camel/camel-spring-2.11.2.jar similarity index 59% rename from cots/org.apache.camel/camel-spring-2.11.0.jar rename to cots/org.apache.camel/camel-spring-2.11.2.jar index 564f6c1e98..eb30af5441 100644 Binary files a/cots/org.apache.camel/camel-spring-2.11.0.jar and b/cots/org.apache.camel/camel-spring-2.11.2.jar differ diff --git a/edexOsgi/build.edex/build.xml b/edexOsgi/build.edex/build.xml index 15896918ce..7d63f9c4da 100644 --- a/edexOsgi/build.edex/build.xml +++ b/edexOsgi/build.edex/build.xml @@ -50,6 +50,10 @@ + + + @@ -110,10 +114,6 @@ - - - diff --git a/edexOsgi/build.edex/esb/conf/logback-ingest.xml b/edexOsgi/build.edex/esb/conf/logback-ingest.xml index a7635516ab..f987275dae 100644 --- a/edexOsgi/build.edex/esb/conf/logback-ingest.xml +++ b/edexOsgi/build.edex/esb/conf/logback-ingest.xml @@ -166,7 +166,7 @@ - RadarLog:radarThreadPool.*;SatelliteLog:satelliteThreadPool.*;ShefLog:shefThreadPool.*;TextLog:textThreadPool.*;SmartInitLog:smartInit.* + RadarLog:radarThreadPool.*;SatelliteLog:satelliteThreadPool.*;ShefLog:shefThreadPool.*;TextLog:textThreadPool.*;SmartInitLog:smartInit.*;PurgeLog:Purge.*;ArchiveLog:Archive.* asyncConsole @@ -174,6 +174,8 @@ + + @@ -273,11 +275,6 @@ - - - - - diff --git a/edexOsgi/build.edex/esb/conf/spring/edex.xml b/edexOsgi/build.edex/esb/conf/spring/edex.xml index 8e2cef70c7..8f08ea06e1 100644 --- a/edexOsgi/build.edex/esb/conf/spring/edex.xml +++ b/edexOsgi/build.edex/esb/conf/spring/edex.xml @@ -183,25 +183,14 @@ - + + + - - - - - - - - - - - - - diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/dao/SubscriptionDAO.java b/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/dao/SubscriptionDAO.java index 261ddc8865..2250d99aea 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/dao/SubscriptionDAO.java +++ b/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/dao/SubscriptionDAO.java @@ -51,6 +51,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * 14Nov2008 1709 MW Fegan Initial creation. * 14Apr2011 5163 cjeanbap NWRWAVES Setting AFOS text triggers in AWIPS II * 04/24/13 1949 rjpeter Removed @Override on delete. + * Nov 08, 2013 2361 njensen Chaged method signature of saveOrUpdate(Object) * * * @author mfegan @@ -127,9 +128,10 @@ public class SubscriptionDAO extends CoreDao { } @Override - public void saveOrUpdate(PersistableDataObject obj) { + public void saveOrUpdate(Object obj) { super.saveOrUpdate(obj); - sendSubscriptionNotifyMessage(String.valueOf(obj.getIdentifier())); + sendSubscriptionNotifyMessage(String + .valueOf(((PersistableDataObject) obj).getIdentifier())); } @Override diff --git a/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml b/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml index 7b979f68f5..f39f236137 100644 --- a/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml +++ b/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml @@ -68,6 +68,10 @@ id="com.raytheon.uf.edex.grib.feature" version="0.0.0"/> + + @@ -132,8 +136,4 @@ id="com.raytheon.uf.edex.dataprovideragent.feature" version="0.0.0"/> - - diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/GFESiteActivation.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/GFESiteActivation.java index a1b5789adb..0f6e90ccdc 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/GFESiteActivation.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/config/GFESiteActivation.java @@ -329,8 +329,8 @@ public class GFESiteActivation implements ISiteActivationListener { e); } } else { - statusHandler.handle(Priority.EVENTA, - "ISC Enabled but will use another EDEX instance"); + statusHandler + .info("ISC Enabled but will use another EDEX instance"); } } else { @@ -340,7 +340,7 @@ public class GFESiteActivation implements ISiteActivationListener { // doesn't need to be cluster locked final IFPServerConfig configRef = config; - if (config.tableFetchTime() > 0 && isIscActivated) { + if ((config.tableFetchTime() > 0) && isIscActivated) { Runnable activateFetchAT = new Runnable() { @Override diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/isc/GfeIRT.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/isc/GfeIRT.java index 10d221f5dd..fa1d4c4eef 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/isc/GfeIRT.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/isc/GfeIRT.java @@ -65,7 +65,6 @@ import com.raytheon.uf.common.util.FileUtil; * Sep 05, 2013 2307 dgilling Use better PythonScript constructor. * Oct 16, 2013 2475 dgilling Move logic previously in IrtServer.py * into this class to avoid Jep memory leak. - * * * * @author bphillip @@ -205,6 +204,7 @@ public class GfeIRT extends Thread { @Override public void run() { + try { IPathManager pathMgr = PathManagerFactory.getPathManager(); LocalizationContext cx = pathMgr.getContext( diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/ifpnetCDF.py b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/ifpnetCDF.py index e50173bcb9..c4eb15f94b 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/ifpnetCDF.py +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/ifpnetCDF.py @@ -176,13 +176,11 @@ def encodeGridSlice(grid, gridType, clipArea, cube, idx, keyList): cube[0][idx] = clipToExtrema(vecGrids[0], clipArea) cube[1][idx] = clipToExtrema(vecGrids[1], clipArea) elif gridType == "WEATHER" or gridType == "DISCRETE": - if gridType == "DISCRETE": - keys = grid.getKeys() + keys = grid.getKeys() gridKeys = [] for theKey in keys: gridKeys.append(theKey.toString()) - keyList.append(gridKeys) cube[idx]= clipToExtrema(grid.__numpy__[0], clipArea) diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/iscMosaic.py b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/iscMosaic.py index efa1451c05..7e28103f3c 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/iscMosaic.py +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/iscMosaic.py @@ -87,7 +87,7 @@ from com.raytheon.uf.edex.database.cluster import ClusterTask # -BATCH_WRITE_COUNT = 10 +BATCH_WRITE_COUNT = 20 BATCH_DELAY = 0.0 ISC_USER="isc" @@ -113,15 +113,20 @@ class WECache(object): for i in tokill: del pyInv[i] - javaTRs = ArrayList() - for tr in pyInv: - javaTRs.add(iscUtil.toJavaTimeRange(tr)) - gridsAndHist = self._we.get(javaTRs, True) - for idx, tr in enumerate(pyInv): - pair = gridsAndHist.get(idx) - g = self.__encodeGridSlice(pair.getFirst()) - h = self.__encodeGridHistory(pair.getSecond()) - self._inv[tr] = (g, h) + lst = list(pyInv) + while len(lst): + i = lst[:BATCH_WRITE_COUNT] + javaTRs = ArrayList() + for tr in i: + javaTRs.add(iscUtil.toJavaTimeRange(tr)) + gridsAndHist = self._we.get(javaTRs, True) + for idx, tr in enumerate(i): + pair = gridsAndHist.get(idx) + g = self.__encodeGridSlice(pair.getFirst()) + h = self.__encodeGridHistory(pair.getSecond()) + self._inv[tr] = (g, h) + lst = lst[BATCH_WRITE_COUNT:] + time.sleep(BATCH_DELAY) def keys(self): if not self._invCache: diff --git a/edexOsgi/com.raytheon.edex.plugin.ldadhydro/src/com/raytheon/edex/plugin/ldadhydro/dao/HydroDecoder.java b/edexOsgi/com.raytheon.edex.plugin.ldadhydro/src/com/raytheon/edex/plugin/ldadhydro/dao/HydroDecoder.java index b8673b95d7..46865d1d68 100644 --- a/edexOsgi/com.raytheon.edex.plugin.ldadhydro/src/com/raytheon/edex/plugin/ldadhydro/dao/HydroDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.ldadhydro/src/com/raytheon/edex/plugin/ldadhydro/dao/HydroDecoder.java @@ -79,6 +79,7 @@ import com.raytheon.uf.common.time.DataTime; public class HydroDecoder extends AbstractDecoder implements IBinaryDecoder { private static final String BAD_PROPERTY_FMT = "NumberFormatException setting property %s.%s(%s %s)"; + private String traceId = null; public SimpleDateFormat sdf = new SimpleDateFormat("yy/MM/dd HH:mm:ss"); diff --git a/edexOsgi/com.raytheon.edex.plugin.modelsounding/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.modelsounding/META-INF/MANIFEST.MF index c084cfa21d..3aa57ebfff 100644 --- a/edexOsgi/com.raytheon.edex.plugin.modelsounding/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.modelsounding/META-INF/MANIFEST.MF @@ -2,16 +2,22 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Modelsounding Plug-in Bundle-SymbolicName: com.raytheon.edex.plugin.modelsounding -Bundle-Version: 1.12.1174.qualifier +Bundle-Version: 1.13.0.qualifier Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization Bundle-Vendor: RAYTHEON - com.google.guava;bundle-version="1.0.0" Export-Package: com.raytheon.edex.plugin.modelsounding, com.raytheon.edex.plugin.modelsounding.common, com.raytheon.edex.plugin.modelsounding.dao, com.raytheon.edex.plugin.modelsounding.decoder Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", + com.google.guava;bundle-version="1.0.0", + javax.measure, + com.raytheon.uf.common.comm, + com.raytheon.uf.common.dataaccess, + com.raytheon.uf.common.dataplugin.level, + com.raytheon.uf.common.dataquery, + com.raytheon.uf.common.serialization.comm, com.raytheon.uf.common.status;bundle-version="1.12.1174", com.raytheon.uf.common.serialization;bundle-version="1.12.1174", com.raytheon.uf.common.geospatial;bundle-version="1.12.1174", @@ -24,8 +30,7 @@ Require-Bundle: com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", com.raytheon.uf.edex.decodertools;bundle-version="1.12.1174", javax.persistence;bundle-version="1.0.0", org.hibernate;bundle-version="1.0.0", - org.springframework;bundle-version="3.1.4", - com.google.guava;bundle-version="1.0.0" + org.springframework;bundle-version="3.1.4" Import-Package: com.raytheon.edex.esb, com.raytheon.edex.exception, com.raytheon.edex.plugin, diff --git a/edexOsgi/com.raytheon.edex.plugin.modelsounding/res/spring/modelsounding-common-dataaccess.xml b/edexOsgi/com.raytheon.edex.plugin.modelsounding/res/spring/modelsounding-common-dataaccess.xml new file mode 100644 index 0000000000..163fd374aa --- /dev/null +++ b/edexOsgi/com.raytheon.edex.plugin.modelsounding/res/spring/modelsounding-common-dataaccess.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + pressure + temperature + specHum + omega + uComp + vComp + cldCvr + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.edex.plugin.modelsounding/src/com/raytheon/edex/plugin/modelsounding/dataaccess/PointDataAccessFactory.java b/edexOsgi/com.raytheon.edex.plugin.modelsounding/src/com/raytheon/edex/plugin/modelsounding/dataaccess/PointDataAccessFactory.java new file mode 100644 index 0000000000..b642487b9f --- /dev/null +++ b/edexOsgi/com.raytheon.edex.plugin.modelsounding/src/com/raytheon/edex/plugin/modelsounding/dataaccess/PointDataAccessFactory.java @@ -0,0 +1,484 @@ +/** + * 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.plugin.modelsounding.dataaccess; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import javax.measure.unit.Unit; +import javax.measure.unit.UnitFormat; + +import com.raytheon.uf.common.comm.CommunicationException; +import com.raytheon.uf.common.dataaccess.DataAccessLayer; +import com.raytheon.uf.common.dataaccess.IDataRequest; +import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException; +import com.raytheon.uf.common.dataaccess.exception.UnsupportedOutputTypeException; +import com.raytheon.uf.common.dataaccess.geom.IGeometryData; +import com.raytheon.uf.common.dataaccess.geom.IGeometryData.Type; +import com.raytheon.uf.common.dataaccess.grid.IGridData; +import com.raytheon.uf.common.dataaccess.impl.AbstractDataPluginFactory; +import com.raytheon.uf.common.dataaccess.impl.DefaultGeometryData; +import com.raytheon.uf.common.dataplugin.level.LevelFactory; +import com.raytheon.uf.common.dataplugin.level.MasterLevel; +import com.raytheon.uf.common.dataquery.requests.DbQueryRequest; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; +import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; +import com.raytheon.uf.common.pointdata.PointDataConstants; +import com.raytheon.uf.common.pointdata.PointDataContainer; +import com.raytheon.uf.common.pointdata.PointDataDescription; +import com.raytheon.uf.common.pointdata.PointDataServerRequest; +import com.raytheon.uf.common.pointdata.PointDataView; +import com.raytheon.uf.common.serialization.comm.RequestRouter; +import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.common.time.TimeRange; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.GeometryFactory; + +/** + * Data Access Factory for retrieving point data as a geometry. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Oct 31, 2013  2502     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public class PointDataAccessFactory extends AbstractDataPluginFactory { + + // TODO this should be in PointDataServerRequest + private static final String REQUEST_PARAMETERS_KEY = "requestedParameters"; + + // TODO this should be in PointDataServerRequest + private static final String REQUEST_MODE_KEY = "mode"; + + // TODO this should be in PointDataServerRequest + private static final String REQUEST_MODE_2D = "select2d"; + + private static class TwoDimensionalParameterGroup { + + public final String countParameter; + + public final String levelParameter; + + public final String levelType; + + public final String[] parameters; + + public TwoDimensionalParameterGroup(String countParameter, + String levelParameter, String levelType, String[] parameters) { + super(); + this.countParameter = countParameter; + this.levelParameter = levelParameter; + this.levelType = levelType; + this.parameters = parameters; + } + + } + + private String locationDatabaseKey = "location.stationId"; + + private String locationPointDataKey = PointDataConstants.DATASET_STATIONID; + + private String latitudePointDataKey = "latitude"; + + private String longitudePointDataKey = "longitude"; + + private String refTimePointDataKey = PointDataConstants.DATASET_REFTIME; + + private String fcstHrPointDataKey = PointDataConstants.DATASET_FORECASTHR; + + private Map parameters2D = new HashMap(); + + @Override + public String[] getAvailableLocationNames(IDataRequest request) { + return getAvailableLocationNames(request, locationDatabaseKey); + } + + @Override + public IGeometryData[] getGeometryData(IDataRequest request, + DataTime... times) { + /* + * Point data uses PointDataServerRequest instead of the DbQueryRequest + * that is used in AbstractDataPluginFactory. Override this method so + * the DbQueryRequest can be converted to a PointDataServerRequest + */ + validateRequest(request); + DbQueryRequest dbQueryRequest = this + .buildDbQueryRequest(request, times); + return getGeometryData(request, dbQueryRequest); + } + + @Override + public IGeometryData[] getGeometryData(IDataRequest request, + TimeRange timeRange) { + /* + * Point data uses PointDataServerRequest instead of the DbQueryRequest + * that is used in AbstractDataPluginFactory. Override this method so + * the DbQueryRequest can be converted to a PointDataServerRequest + */ + validateRequest(request); + DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request, + timeRange); + return getGeometryData(request, dbQueryRequest); + } + + @Override + protected IGeometryData[] getGeometryData(IDataRequest request, + DbQueryResponse dbQueryResponse) { + /* + * Since the public getGeometryData methods have been overriden, this is + * now unreachable code, but since it is an abstract method in the super + * class it must be implemented. + */ + throw new UnsupportedOperationException( + "This method should be unreachable"); + } + + @Override + protected IGridData[] getGridData(IDataRequest request, + DbQueryResponse dbQueryResponse) { + /* + * Point data cannot be gridded, so don't even try. + */ + throw new UnsupportedOutputTypeException(request.getDatatype(), "grid"); + } + + @Override + protected Map buildConstraintsFromRequest( + IDataRequest request) { + Map rcMap = new HashMap(); + String[] locations = request.getLocationNames(); + if (locations != null && locations.length != 0) { + RequestConstraint rc = new RequestConstraint(); + rc.setConstraintType(ConstraintType.IN); + rc.setConstraintValueList(locations); + rcMap.put(locationDatabaseKey, rc); + } + Map identifiers = request.getIdentifiers(); + if (identifiers != null) { + for (Entry entry : identifiers.entrySet()) { + rcMap.put(entry.getKey(), new RequestConstraint(entry + .getValue().toString())); + } + } + return rcMap; + } + + /** + * + * Request point data from the server and convert to {@link IGeometryData} + * + * @param request + * the original request from the {@link DataAccessLayer} + * @param dbQueryRequest + * the request generated by {@link AbstractDataPluginFactory}, + * this will be converted into a {@link PointDataServerRequest}. + * @return {@link IGeometryData} + */ + protected IGeometryData[] getGeometryData(IDataRequest request, + DbQueryRequest dbQueryRequest) { + PointDataServerRequest serverRequest = convertRequest(request, + dbQueryRequest); + + PointDataContainer pdc = null; + try { + pdc = (PointDataContainer) RequestRouter.route(serverRequest); + } catch (Exception e) { + throw new DataRetrievalException( + "Unable to complete the PointDataRequestMessage for request: " + + request, e); + } + LevelFactory lf = LevelFactory.getInstance(); + /* Convert the point data container into a list of IGeometryData */ + List result = new ArrayList( + pdc.getAllocatedSz()); + for (int i = 0; i < pdc.getCurrentSz(); i += 1) { + PointDataView pdv = pdc.readRandom(i); + DefaultGeometryData data = createNewGeometryData(pdv); + try { + data.setLevel(lf.getLevel(LevelFactory.UNKNOWN_LEVEL, 0.0)); + } catch (CommunicationException e) { + throw new DataRetrievalException( + "Unable to retrieve level data for request: " + request, + e); + } + Set parameters2D = new HashSet(); + for (String parameter : request.getParameters()) { + if (pdc.getParameters().contains(parameter)) { + int dim = pdc.getDimensions(parameter); + if (dim == 1) { + Unit unit = pdv.getUnit(parameter); + PointDataDescription.Type type = pdv.getType(parameter); + if (type == PointDataDescription.Type.STRING) { + data.addData(parameter, pdv.getString(parameter), + Type.STRING, unit); + } else { + data.addData(parameter, pdv.getNumber(parameter), + unit); + } + } else if (this.parameters2D.containsKey(parameter)) { + parameters2D.add(this.parameters2D.get(parameter)); + } else { + throw new DataRetrievalException( + "PointDataAccessFactory cannot handle " + dim + + "D parameters: " + parameter); + } + } + } + for (TwoDimensionalParameterGroup p2d : parameters2D) { + result.addAll(make2DData(request, p2d, pdv)); + } + if (!data.getParameters().isEmpty()) { + result.add(data); + } + } + return result.toArray(new IGeometryData[0]); + } + + /** + * Pull the constraints ouf of a {@link DbQueryRequest} and combine the + * information with an {@link IDataRequest} to build a + * {@link PointDataServerRequest}. This is done because + * {@link AbstractDataPluginFactory} makes really nice DbQueryRequests but + * we can't use them for point data. + * + * @param request + * @param dbQueryRequest + * @return + */ + private PointDataServerRequest convertRequest(IDataRequest request, + DbQueryRequest dbQueryRequest) { + Map constraints = dbQueryRequest + .getConstraints(); + constraints.put(REQUEST_MODE_KEY, + new RequestConstraint(REQUEST_MODE_2D)); + /* + * Figure out what parameters we actually need. + */ + Set parameters = new HashSet(); + Set parameters2D = new HashSet(); + + for (String parameter : request.getParameters()) { + /* + * Make sure that any 2D parameters also have the count parameter + * requested. + */ + TwoDimensionalParameterGroup p2d = this.parameters2D.get(parameter); + if (p2d != null) { + parameters.add(p2d.countParameter); + parameters.add(p2d.levelParameter); + parameters2D.add(p2d); + } + parameters.add(parameter); + } + /* Always request location parameters */ + parameters.add(locationPointDataKey); + parameters.add(latitudePointDataKey); + parameters.add(longitudePointDataKey); + parameters.add(refTimePointDataKey); + if (fcstHrPointDataKey != null) { + parameters.add(fcstHrPointDataKey); + } + + RequestConstraint rc = new RequestConstraint(); + rc.setConstraintType(ConstraintType.IN); + rc.setConstraintValueList(parameters.toArray(new String[0])); + constraints.put(REQUEST_PARAMETERS_KEY, rc); + + return new PointDataServerRequest(constraints); + } + + /** + * Pull out location and time data from a {@link PointDataView} to build a + * {@link DefaultGeometryData}. + * + * @param pdv + * view for a single record + * @return {@link DefaultGeometryData} with locationName, time, and geometry + * set. + */ + private DefaultGeometryData createNewGeometryData(PointDataView pdv) { + DefaultGeometryData data = new DefaultGeometryData(); + data.setLocationName(pdv.getString(locationPointDataKey)); + long refTime = pdv.getNumber(refTimePointDataKey).longValue(); + if (fcstHrPointDataKey != null) { + int fcstTime = pdv.getNumber(fcstHrPointDataKey).intValue(); + data.setDataTime(new DataTime(new Date(refTime), fcstTime)); + } else { + data.setDataTime(new DataTime(new Date(refTime))); + } + Coordinate c = new Coordinate(pdv.getFloat(longitudePointDataKey), + pdv.getFloat(latitudePointDataKey)); + data.setGeometry(new GeometryFactory().createPoint(c)); + // TODO python will break if attributes is null + data.setAttributes(new HashMap(0)); + return data; + } + + /** + * Make a {@link IGeometryData} object for each level in a 2 dimensional + * data set. + * + * @param request + * the original request + * @param p2d + * The 2d Parameter group + * @param pdv + * pdv contining data. + * @return One IGeometryData for each valid level in the 2d group. + */ + private List make2DData(IDataRequest request, + TwoDimensionalParameterGroup p2d, PointDataView pdv) { + List requestParameters = Arrays.asList(request.getParameters()); + LevelFactory lf = LevelFactory.getInstance(); + int count = pdv.getInt(p2d.countParameter); + List result = new ArrayList(count); + for (int j = 0; j < count; j += 1) { + /* Clone the data, not level or parameters though */ + DefaultGeometryData leveldata = createNewGeometryData(pdv); + double levelValue = pdv.getNumberAllLevels(p2d.levelParameter)[j] + .doubleValue(); + String levelUnit = UnitFormat.getUCUMInstance().format( + pdv.getUnit(p2d.levelParameter)); + try { + leveldata.setLevel(lf.getLevel(p2d.levelType, levelValue, + levelUnit)); + } catch (CommunicationException e) { + throw new DataRetrievalException( + "Unable to retrieve level data for request: " + request, + e); + } + for (String parameter : p2d.parameters) { + if (requestParameters.contains(parameter)) { + Unit unit = pdv.getUnit(parameter); + PointDataDescription.Type type = pdv.getType(parameter); + if (type == PointDataDescription.Type.STRING) { + leveldata.addData(parameter, + pdv.getStringAllLevels(parameter)[j], + Type.STRING, unit); + } else { + leveldata.addData(parameter, + pdv.getNumberAllLevels(parameter)[j], unit); + } + } + } + result.add(leveldata); + } + return result; + } + + /** + * Point data types with 2 dimensions need to register so the 2d parameters + * can be grouped appropriately + * + * @param countParameter + * parameter name of an integer parameter identifying the number + * of valid levels. + * @param levelParameter + * parameter which should be used to build the level object in + * IGeometryData, for example "pressure" + * @param levelType + * {@link MasterLevel} name for the levelParameter, for example + * "MB" + * @param parameters + * all the parameters that are valid on the same 2D levels. + * @return countParameter is returned so spring can have a bean. + */ + public String register2D(String countParameter, String levelParameter, + String levelType, String[] parameters) { + TwoDimensionalParameterGroup td = new TwoDimensionalParameterGroup( + countParameter, levelParameter, levelType, parameters); + for (String parameter : parameters) { + parameters2D.put(parameter, td); + } + return countParameter; + } + + /** + * @param locationDatabaseKey + * The hibernate field name of the field that is used to identify + * location names. Default values is "location.stationId" + */ + public void setLocationDatabaseKey(String locationDatabaseKey) { + this.locationDatabaseKey = locationDatabaseKey; + } + + /** + * @param locationPointDataKey + * The point data key that matches the location database key. + * Defaults to "stationId" + */ + public void setLocationPointDataKey(String locationPointDataKey) { + this.locationPointDataKey = locationPointDataKey; + } + + /** + * @param latitudePointDataKey + * The point data key of the station latitude. Default value is + * "latitude" + */ + public void setLatitudePointDataKey(String latitudePointDataKey) { + this.latitudePointDataKey = latitudePointDataKey; + } + + /** + * @param longitudePointDataKey + * The point data key of the station longitude. Default value is + * "longitude" + */ + public void setLongitudePointDataKey(String longitudePointDataKey) { + this.longitudePointDataKey = longitudePointDataKey; + } + + /** + * @param refTimePointDataKey + * The point data key of the reference time. Default value is + * "refTime" + */ + public void setRefTimePointDataKey(String refTimePointDataKey) { + this.refTimePointDataKey = refTimePointDataKey; + } + + /** + * @param fcstHrPointDataKey + * The point data key of the forecast hour. Default value is + * "forecastHr". For live data with no forecast times this can be + * set to null so that it is not retrieved. + */ + public void setFcstHrPointDataKey(String fcstHrPointDataKey) { + this.fcstHrPointDataKey = fcstHrPointDataKey; + } + +} diff --git a/edexOsgi/com.raytheon.edex.plugin.text/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.text/META-INF/MANIFEST.MF index ada536a455..7fa37b096c 100644 --- a/edexOsgi/com.raytheon.edex.plugin.text/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.text/META-INF/MANIFEST.MF @@ -12,12 +12,12 @@ Require-Bundle: com.raytheon.edex.textdb, com.raytheon.uf.common.serialization.comm, com.raytheon.uf.edex.decodertools;bundle-version="1.0.0", com.raytheon.uf.common.status;bundle-version="1.11.17", - com.raytheon.uf.common.site;bundle-version="1.12.1174" + com.raytheon.uf.common.site;bundle-version="1.12.1174", + com.raytheon.uf.edex.archive Export-Package: com.raytheon.edex.plugin.text, com.raytheon.edex.plugin.text.dao Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.raytheon.uf.common.dataplugin.text, com.raytheon.uf.common.dataplugin.text.db, com.raytheon.uf.common.dataplugin.text.request, - com.raytheon.uf.edex.maintenance.archive, org.apache.commons.logging diff --git a/edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/maintenance/archiver/TextArchiveFileNameFormatter.java b/edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/maintenance/archiver/TextArchiveFileNameFormatter.java index e5631a13d1..b795ffb25e 100644 --- a/edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/maintenance/archiver/TextArchiveFileNameFormatter.java +++ b/edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/maintenance/archiver/TextArchiveFileNameFormatter.java @@ -34,12 +34,12 @@ import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.edex.archive.IPluginArchiveFileNameFormatter; import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.plugin.PluginDao; -import com.raytheon.uf.edex.maintenance.archive.IPluginArchiveFileNameFormatter; /** - * TODO Add Description + * Properly stores StdTextProducts by time. * *
  * 
@@ -48,7 +48,7 @@ import com.raytheon.uf.edex.maintenance.archive.IPluginArchiveFileNameFormatter;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Apr 20, 2012            dgilling     Initial creation
- * 
+ * Nov 05, 2013 2499       rjpeter      Moved IPluginArchiveFileNameFormatter.
  * 
* * @author dgilling @@ -70,6 +70,7 @@ public class TextArchiveFileNameFormatter implements * com.raytheon.uf.edex.database.plugin.PluginDao, java.util.Map, * java.util.Calendar, java.util.Calendar) */ + @SuppressWarnings("rawtypes") @Override public Map> getPdosByFile( String pluginName, PluginDao dao, diff --git a/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-ingest.xml b/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-ingest.xml index bf81c253a1..5e5693c152 100644 --- a/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-ingest.xml +++ b/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-ingest.xml @@ -76,7 +76,7 @@ java.lang.Throwable - + diff --git a/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/ArchiveConfigManager.java b/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/ArchiveConfigManager.java index 7c7c470ed5..3c82b24d5e 100644 --- a/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/ArchiveConfigManager.java +++ b/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/ArchiveConfigManager.java @@ -188,7 +188,7 @@ public class ArchiveConfigManager { public Collection getArchives() { String fileName = ArchiveConstants.selectFileName(Type.Retention, null); SelectConfig selections = loadSelection(fileName); - if (selections != null && !selections.isEmpty()) { + if ((selections != null) && !selections.isEmpty()) { try { for (ArchiveSelect archiveSelect : selections.getArchiveList()) { ArchiveConfig archiveConfig = archiveMap.get(archiveSelect @@ -407,7 +407,8 @@ public class ArchiveConfigManager { private Calendar calculateExpiration(ArchiveConfig archive, CategoryConfig category) { Calendar expireCal = TimeUtil.newGmtCalendar(); - int retHours = category == null || category.getRetentionHours() == 0 ? archive + int retHours = (category == null) + || (category.getRetentionHours() == 0) ? archive .getRetentionHours() : category.getRetentionHours(); if (retHours != 0) { expireCal.add(Calendar.HOUR, (-1) * retHours); @@ -453,7 +454,7 @@ public class ArchiveConfigManager { for (LocalizationFile lFile : files) { try { ArchiveConfig archiveConfig = unmarshalArhiveConfigFromXmlFile(lFile); - if (archiveConfig != null && archiveConfig.isValid()) { + if ((archiveConfig != null) && archiveConfig.isValid()) { archiveNameToLocalizationFileMap.put( archiveConfig.getName(), lFile); archiveMap.put(archiveConfig.getName(), archiveConfig); diff --git a/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml b/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml index 2555c824b2..a7e98c7eea 100644 --- a/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml @@ -391,7 +391,7 @@ download-size="0" install-size="0" version="0.0.0"/> - + + * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Nov 7, 2013 2492 mschenke Initial creation + * + * + * + * @author mschenke + * @version 1.0 + */ + +public class LogConverter { + + private static double EFFECTIVE_ZERO = Double.MIN_VALUE; + + public static double valueToIndex(double value, double rangeMin, + double rangeMax) { + // Account for 0 min index + if (rangeMin == 0) { + rangeMin = EFFECTIVE_ZERO; + if (rangeMax < 0) { + rangeMin = -rangeMin; + } + } + + boolean reverse = false; + if ((value < rangeMin && rangeMin > 0) + || (value > rangeMin && rangeMin < 0)) { + reverse = true; + } + + value = Math.abs(value); + rangeMin = Math.abs(rangeMin); + rangeMax = Math.abs(rangeMax); + + // Check uncomputable index value, everything between this range is 0, + // rangeMin->rangeMax 0 -> 1, -rangeMin->-rangeMax 0 -> -1 + if (value <= rangeMin && value >= -rangeMin) { + return 0; + } + + double index = (Math.log(value) - Math.log(rangeMin)) + / (Math.log(rangeMax) - Math.log(rangeMin)); + if (reverse) { + index = -index; + } + + return index; + } + + public static double indexToValue(double index, double rangeMin, + double rangeMax) { + // Account for 0 min index + if (rangeMin == 0) { + rangeMin = EFFECTIVE_ZERO; + if (rangeMax < 0) { + rangeMin = -rangeMin; + } + } + + boolean reverse = index < 0; + + index = Math.abs(index); + rangeMin = Math.abs(rangeMin); + rangeMax = Math.abs(rangeMax); + + double value = Math.exp(Math.log(rangeMin) + + (index * (Math.log(rangeMax) - Math.log(rangeMin)))); + if (reverse) { + value = -value; + } + return value; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/image/Colormapper.java b/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/image/Colormapper.java index d225d7317a..d6c4251945 100644 --- a/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/image/Colormapper.java +++ b/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/image/Colormapper.java @@ -40,6 +40,7 @@ import javax.measure.unit.Unit; import com.raytheon.uf.common.colormap.Color; import com.raytheon.uf.common.colormap.IColorMap; +import com.raytheon.uf.common.colormap.LogConverter; import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType; import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; @@ -158,27 +159,6 @@ public class Colormapper { blue, alpha); } - /** - * Sets an index value into the indexArray for use in a Raster with - * IndexColorModel set - * - * @param dataArray - * @param idx - * @param idxValue - */ - public static void setIndexValue(Object dataArray, int idx, int idxValue) { - if (dataArray instanceof byte[]) { - ((byte[]) dataArray)[idx] = (byte) idxValue; - } else if (dataArray instanceof short[]) { - ((short[]) dataArray)[idx] = (short) idxValue; - } else if (dataArray instanceof int[]) { - ((int[]) dataArray)[idx] = idxValue; - } else { - throw new IllegalArgumentException("Unsupported dataArray type: " - + (dataArray != null ? dataArray.getClass() : null)); - } - } - /** * Returns the double representation of the data value for the Buffer at the * given index @@ -250,64 +230,70 @@ public class Colormapper { */ public static double getLogIndex(double cmapValue, double cmapMin, double cmapMax, boolean mirror) { + boolean inverted = false; + double rangeMin = Math.abs(cmapMin); + double rangeMax = Math.abs(cmapMax); + double rangeValue = Math.abs(cmapValue); + if (rangeMin > rangeMax) { + // Inverted colormapping range (cmapMax is closest to 0) + inverted = true; + double tmp = rangeMin; + rangeMin = rangeMax; + rangeMax = tmp; + } + double index = 0.0; - // is this strictly negative, strictly positive or neg to pos scaling? - if (cmapMin >= 0.0 && cmapMax >= 0.0 && !mirror) { - if (cmapValue < cmapMin) { - index = 0.0; - } else { - // simple calculation - index = ((Math.log(cmapValue) - Math.log(cmapMin)) / Math - .abs(Math.log(cmapMax) - Math.log(cmapMin))); + // Flag if min/max values are on opposite sides of zero + boolean minMaxOpposite = (cmapMin < 0 && cmapMax > 0) + || (cmapMin > 0 && cmapMax < 0); + + if (mirror || minMaxOpposite) { + if (cmapMax < 0) { + // Invert colormapping if negative range was given + cmapValue = -cmapValue; } - } else if (cmapMin <= 0.0 && cmapMax <= 0.0 && !mirror) { - index = ((Math.log(cmapValue) - Math.log(cmapMax)) / Math.abs(Math - .log(cmapMin) - Math.log(cmapMax))); - } else { - // special case, neg to pos: - double colorMapMin = cmapMin; - double colorMapMax = cmapMax; - double zeroVal = Math.max(colorMapMax, Math.abs(colorMapMin)) * 0.0001; - if (mirror && (colorMapMin > 0.0 || colorMapMax < 0.0)) { - if (colorMapMax < 0.0) { - colorMapMax = -cmapMax; - cmapValue = -cmapValue; - zeroVal = -colorMapMin; - } else { - zeroVal = cmapMin; - } - colorMapMin = -cmapMax; + // Log scaling is happening on both sides of zero, need to compute + // our zero index value + double zeroVal = rangeMin; + if (minMaxOpposite) { + // Min/Max are on opposite sides of zero, compute a zero value + zeroVal = Math.max(rangeMin, rangeMax) * 0.0001; } - double leftZero = 0.0; - double rightZero = 0.0; + + double negCmapMax = rangeMin; + double posCmapMax = rangeMax; + if (mirror) { + negCmapMax = posCmapMax = rangeMax; + } + + // Compute log zero val and log neg/pos max vals double absLogZeroVal = Math.abs(Math.log(zeroVal)); - - rightZero = absLogZeroVal + Math.log(colorMapMax); - - double cmapMax2 = Math.abs(colorMapMin); - - leftZero = absLogZeroVal + Math.log(cmapMax2); - - double zeroIndex = leftZero / (leftZero + rightZero); - - // figure out index for texture val - double absTextureColor = Math.abs(cmapValue); - if (absTextureColor <= zeroVal) { - index = zeroIndex; - } else if (cmapValue > 0.0) { - // positive texture color value, find index from 0 to - // cmapMax: - double logTexColor = absLogZeroVal + Math.log(cmapValue); - - double texIndex = logTexColor / rightZero; - index = (zeroIndex + ((1.0 - zeroIndex) * texIndex)); + double logNegCmapMax = absLogZeroVal + Math.log(negCmapMax); + double logPosCmapMax = absLogZeroVal + Math.log(posCmapMax); + // Calculate index which zeroVal is at based on neg max and pos max + double zeroValIndex = logNegCmapMax + / (logNegCmapMax + logPosCmapMax); + if (cmapValue > 0) { + index = LogConverter.valueToIndex(rangeValue, zeroVal, + posCmapMax); + index = zeroValIndex + (1 - zeroValIndex) * index; } else { - // negative texture color value, find index from 0 to - // cmapMax: - double logTexColor = absLogZeroVal + Math.log(absTextureColor); - - double texIndex = logTexColor / leftZero; - index = (zeroIndex - (zeroIndex * texIndex)); + index = LogConverter.valueToIndex(rangeValue, zeroVal, + negCmapMax); + index = zeroValIndex - zeroValIndex * index; + } + if (inverted) { + index = 1.0 - index; + } + } else { + // Simple case, just use log converter to get index + index = LogConverter.valueToIndex(rangeValue, rangeMin, rangeMax); + if (inverted) { + index = 1.0 - index; + } + if (cmapMin > 0 && cmapValue < rangeMin + || (cmapMin < 0 && cmapValue > -rangeMin)) { + index = -index; } } return index; diff --git a/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/prefs/ColorMapParameters.java b/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/prefs/ColorMapParameters.java index b20d9a1518..56e39d911b 100644 --- a/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/prefs/ColorMapParameters.java +++ b/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/prefs/ColorMapParameters.java @@ -133,6 +133,7 @@ public class ColorMapParameters { protected Unit colorMapUnit; /** Units of the data values to colormap */ + @Deprecated protected Unit dataUnit; /** The maximum value used to apply the colormap */ @@ -142,9 +143,11 @@ public class ColorMapParameters { protected float colorMapMin; /** The maximum (usually theoretical) value of the data */ + @Deprecated protected float dataMax; /** The minimum (usually theoretical) value of the data */ + @Deprecated protected float dataMin; /** The intervals upon which to apply labeling to the color bar */ @@ -162,15 +165,19 @@ public class ColorMapParameters { protected String colorMapName; /** The converter that converts data values to {@link #displayUnit} * */ + @Deprecated protected UnitConverter dataToDisplayConverter; /** The converter that converts display values to {@link #dataUnit} * */ + @Deprecated protected UnitConverter displayToDataConverter; /** The converter that converts data values to {@link #colorMapUnit} */ + @Deprecated protected UnitConverter dataToColorMapConverter; /** The converter that converts color map unit values to {@link #dataUnit} */ + @Deprecated protected UnitConverter colorMapToDataConverter; /** The converter that converts color map unit values to {@link #displayUnit} */ @@ -491,32 +498,40 @@ public class ColorMapParameters { } /** + * @deprecated data max is not important for general colormapping use * @return the dataMax */ + @Deprecated public float getDataMax() { return dataMax; } /** + * @deprecated data max is not important for general colormapping use * @param dataMax * the dataMax to set */ + @Deprecated public void setDataMax(float dataMax) { this.dataMax = dataMax; notifyListener(); } /** + * @deprecated data min is not important for general colormapping use * @return the dataMin */ + @Deprecated public float getDataMin() { return dataMin; } /** + * @deprecated data min is not important for general colormapping use * @param dataMin * the dataMin to set */ + @Deprecated public void setDataMin(float dataMin) { this.dataMin = dataMin; notifyListener(); @@ -563,8 +578,10 @@ public class ColorMapParameters { /** * Returns the unit data values to be colormapped are in * + * @deprecated data unit is not important for general colormapping use * @return the dataUnit */ + @Deprecated public Unit getDataUnit() { return dataUnit; } @@ -572,9 +589,11 @@ public class ColorMapParameters { /** * Sets the unit data values to be colormapped are in * + * @deprecated data unit is not important for general colormapping use * @param dataUnit * the dataUnit to set */ + @Deprecated public void setDataUnit(Unit dataUnit) { this.dataUnit = dataUnit; @@ -595,8 +614,10 @@ public class ColorMapParameters { * Returns the {@link UnitConverter} from {@link #dataUnit} to * {@link #displayUnit} * + * @deprecated data unit is not important for general colormapping use * @return the dataToDisplayConverter */ + @Deprecated public UnitConverter getDataToDisplayConverter() { if (dataToDisplayConverter == null) { dataToDisplayConverter = constructConverter(dataUnit, displayUnit); @@ -611,8 +632,10 @@ public class ColorMapParameters { * Returns the {@link UnitConverter} from {@link #displayUnit} to * {@link #dataUnit} * + * @deprecated data unit is not important for general colormapping use * @return the displayToDataConverter */ + @Deprecated public UnitConverter getDisplayToDataConverter() { if (displayToDataConverter == null) { displayToDataConverter = constructConverter(displayUnit, dataUnit); @@ -667,8 +690,10 @@ public class ColorMapParameters { * Returns a {@link UnitConverter} converting {@link #dataUnit} values to * the {@link #colorMapUnit} if compatible or null otherwise * + * @deprecated data unit is not important for general colormapping use * @return */ + @Deprecated public UnitConverter getDataToColorMapConverter() { if (dataToColorMapConverter == null) { dataToColorMapConverter = constructConverter(dataUnit, colorMapUnit); @@ -773,8 +798,10 @@ public class ColorMapParameters { * Returns a {@link UnitConverter} converting {@link #colorMapUnit} values * to the {@link #dataUnit} if compatible or null otherwise * + * @deprecated data unit is not important for general colormapping use * @return */ + @Deprecated public UnitConverter getColorMapToDataConverter() { if (colorMapToDataConverter == null) { colorMapToDataConverter = constructConverter(colorMapUnit, dataUnit); diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/IBandwidthService.java b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/IBandwidthService.java index 5b853618b6..1a8d9f73b6 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/IBandwidthService.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/IBandwidthService.java @@ -45,7 +45,7 @@ import com.raytheon.uf.common.datadelivery.registry.Time; * Dec 06, 2012 1397 djohnson Add ability to get bandwidth graph data. * Jul 11, 2013 2106 djohnson Bandwidth service now returns names of subscriptions for proposing bandwidth availability. * Jul 18, 2013 1653 mpduff Added getSubscriptionStatusSummary. - * Oct 2, 2013 1797 dhladky Generics + * Oct 2, 2013 1797 dhladky Generics * * * diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/web/IRegistryDataAccessService.java b/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/web/IRegistryDataAccessService.java index 2b7f9ef988..ffaba2126d 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/web/IRegistryDataAccessService.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/web/IRegistryDataAccessService.java @@ -41,6 +41,7 @@ import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResp * 10/8/2013 1682 bphillip Added rest functions for use with the query web interface * 10/23/2013 2385 bphillip restoreSubscriptions throws JAXBException * 10/30/2013 1538 bphillip Moved data delivery specific servics out of registry plugin + * 11/7/2013 1678 bphillip Added get custom query method * * * @author bphillip @@ -73,6 +74,15 @@ public interface IRegistryDataAccessService { @Path("getQueries") public String getValidQueries(); + /** + * Gets the list of non-canonical query types contained in the registry + * + * @return The non-canonical query definitions + */ + @GET + @Path("getCustomQueries") + public String getCustomQueries(); + /** * Gets the valid parameters for a given query definition * diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 84d6321e8f..0000000000 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,16 +0,0 @@ -com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval -com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute -com.raytheon.uf.common.datadelivery.retrieval.xml.Constant -com.raytheon.uf.common.datadelivery.retrieval.xml.DataSetConfig -com.raytheon.uf.common.datadelivery.retrieval.xml.DataSetNaming -com.raytheon.uf.common.datadelivery.retrieval.xml.DateConfig -com.raytheon.uf.common.datadelivery.retrieval.xml.LevelLookup -com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterConfig -com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterLookup -com.raytheon.uf.common.datadelivery.retrieval.xml.Pattern -com.raytheon.uf.common.datadelivery.retrieval.xml.ServiceConfig -com.raytheon.uf.common.datadelivery.retrieval.xml.UnitConfig -com.raytheon.uf.common.datadelivery.retrieval.xml.UnitLookup - - - diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/util/HarvesterServiceManager.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/util/HarvesterServiceManager.java index c0556406e3..acf7193b61 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/util/HarvesterServiceManager.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/util/HarvesterServiceManager.java @@ -14,7 +14,7 @@ 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.serialization.SerializationUtil; +import com.raytheon.uf.common.serialization.SingleTypeJAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -29,6 +29,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * ------------ ---------- ----------- -------------------------- * Oct 27, 2012 1163 dhladky Initial creation * Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects. + * Nov 07, 2013 2361 njensen Use JAXBManager for XML * * * @@ -48,6 +49,9 @@ public class HarvesterServiceManager implements ILocalizationFileObserver { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(HarvesterServiceManager.class); + private static final SingleTypeJAXBManager jaxb = SingleTypeJAXBManager + .createWithoutException(ServiceConfig.class); + /** * Get an instance of this singleton. * @@ -64,6 +68,7 @@ public class HarvesterServiceManager implements ILocalizationFileObserver { /** Singleton instance of this class */ private static final HarvesterServiceManager instance = new HarvesterServiceManager(); + /* Private Constructor */ private HarvesterServiceManager() { @@ -194,8 +199,7 @@ public class HarvesterServiceManager implements ILocalizationFileObserver { ServiceConfig service = null; if (file != null) { - service = SerializationUtil.jaxbUnmarshalFromXmlFile( - ServiceConfig.class, file); + service = jaxb.unmarshalFromXmlFile(file); } return service; diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/util/LookupManager.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/util/LookupManager.java index 6c0d3917d9..84c9aa1bdc 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/util/LookupManager.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/util/LookupManager.java @@ -27,6 +27,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.xml.bind.JAXBException; + import com.raytheon.uf.common.datadelivery.registry.Parameter; import com.raytheon.uf.common.datadelivery.retrieval.xml.LevelLookup; import com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterConfig; @@ -38,7 +40,7 @@ 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.serialization.SerializationUtil; +import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -56,7 +58,8 @@ import com.raytheon.uf.common.util.ServiceLoaderUtil; * Mar 7, 2011 357 dhladky Initial creation * Oct 27, 2012 1163 dhladky Improved, dynamically create files, Added Units * Jan 18, 2013 1513 dhladky Level lookup refit. - * Mar 21, 2013 1794 djohnson ServiceLoaderUtil now requires the requesting class. + * Mar 21, 2013 1794 djohnson ServiceLoaderUtil now requires the requesting class. + * Nov 07, 2013 2361 njensen Use JAXBManager for XML * * * @@ -65,7 +68,6 @@ import com.raytheon.uf.common.util.ServiceLoaderUtil; */ public class LookupManager { - /** * Implementation of the xml writers that writes to localization files. */ @@ -85,7 +87,7 @@ public class LookupManager { LocalizationFile lf = pm.getLocalizationFile(lc, fileName); File file = lf.getFile(); - SerializationUtil.jaxbMarshalToXmlFile(ll, file.getAbsolutePath()); + getJaxbManager().marshalToXmlFile(ll, file.getAbsolutePath()); } /** @@ -103,7 +105,7 @@ public class LookupManager { LocalizationFile lf = pm.getLocalizationFile(lc, fileName); File file = lf.getFile(); - SerializationUtil.jaxbMarshalToXmlFile(pl, file.getAbsolutePath()); + getJaxbManager().marshalToXmlFile(pl, file.getAbsolutePath()); } } @@ -147,6 +149,18 @@ public class LookupManager { .load(LookupManager.class, ParameterXmlWriter.class, new LocalizationXmlWriter()); + private static JAXBManager jaxb; + + private static JAXBManager getJaxbManager() + throws JAXBException { + if (jaxb == null) { + jaxb = new JAXBManager(LevelLookup.class, ParameterLookup.class, + UnitLookup.class); + } + + return jaxb; + } + /* Private Constructor */ private LookupManager() { @@ -519,7 +533,7 @@ public class LookupManager { LevelLookup levelXml = null; if (file != null && file.exists()) { - levelXml = SerializationUtil.jaxbUnmarshalFromXmlFile( + levelXml = getJaxbManager().unmarshalFromXmlFile( LevelLookup.class, file); } @@ -538,7 +552,7 @@ public class LookupManager { ParameterLookup paramXml = null; if (file != null && file.exists()) { - paramXml = SerializationUtil.jaxbUnmarshalFromXmlFile( + paramXml = getJaxbManager().unmarshalFromXmlFile( ParameterLookup.class, file); } @@ -557,7 +571,7 @@ public class LookupManager { UnitLookup unitXml = null; if (file != null && file.exists()) { - unitXml = SerializationUtil.jaxbUnmarshalFromXmlFile( + unitXml = getJaxbManager().unmarshalFromXmlFile( UnitLookup.class, file); } diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Constant.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Constant.java index 4ef854220d..a5f92b8228 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Constant.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Constant.java @@ -24,7 +24,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -37,6 +36,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 20 Oct, 2012 1163 dhladky Initial creation + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -46,7 +46,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class Constant implements ISerializableObject { +public class Constant { @XmlAttribute(name = "name") @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DataSetConfig.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DataSetConfig.java index ece9d7e22a..0b26451d85 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DataSetConfig.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DataSetConfig.java @@ -31,7 +31,6 @@ 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; /** @@ -43,6 +42,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 20 Oct, 2012 1163 dhladky Initial creation + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -53,7 +53,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; @XmlRootElement(name = "dataSetConfig") @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class DataSetConfig implements ISerializableObject { +public class DataSetConfig { @XmlElements({ @XmlElement(name = "pattern", type = com.raytheon.uf.common.datadelivery.retrieval.xml.Pattern.class) }) private List patterns; diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DataSetNaming.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DataSetNaming.java index b825c26937..15231c1c47 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DataSetNaming.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DataSetNaming.java @@ -29,6 +29,7 @@ package com.raytheon.uf.common.datadelivery.retrieval.xml; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 20 Oct, 2012 1163 dhladky Initial creation + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -40,13 +41,12 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class DataSetNaming implements ISerializableObject { +public class DataSetNaming { @XmlAttribute(name = "name") @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DateConfig.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DateConfig.java index 47cc108c33..051d6afa16 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DateConfig.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/DateConfig.java @@ -6,7 +6,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; 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; @@ -18,7 +17,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * 12 Sept, 2012 1038 dhladky Initial creation + * 12 Sept, 2012 1038 dhladky Initial creation + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -28,7 +28,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class DateConfig implements ISerializableObject { +public class DateConfig { @XmlElement(name = "format", type = String.class) @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/LevelLookup.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/LevelLookup.java index 58dbb18bd9..7b5cce81e4 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/LevelLookup.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/LevelLookup.java @@ -26,7 +26,6 @@ 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.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -39,7 +38,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 1, 2012 jpiatt Initial creation. + * Mar 1, 2012 jpiatt Initial creation. + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -50,7 +50,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlRootElement(name = "LevelLookup") @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class LevelLookup implements ISerializableObject { +public class LevelLookup { @XmlElement(name = "Level", type = Double.class) @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ParameterConfig.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ParameterConfig.java index aa4e005575..d4500d7663 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ParameterConfig.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ParameterConfig.java @@ -24,7 +24,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -37,7 +36,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 1, 2012 jpiatt Initial creation. + * Mar 1, 2012 jpiatt Initial creation. + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -47,7 +47,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class ParameterConfig implements ISerializableObject { +public class ParameterConfig { @XmlAttribute(name = "GrADs") @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ParameterLookup.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ParameterLookup.java index 732320d5c6..d962f9edc0 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ParameterLookup.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ParameterLookup.java @@ -30,7 +30,6 @@ 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; @@ -43,8 +42,9 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 1, 2012 jpiatt Initial creation. - * Oct 20, 2012 1163 dhladky speed it up + * Mar 1, 2012 jpiatt Initial creation. + * Oct 20, 2012 1163 dhladky speed it up + * Nov 07, 2013 2361 njensen Remove ISerializableObject * * * @@ -55,7 +55,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlRootElement(name = "ParameterLookup") @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class ParameterLookup implements ISerializableObject { +public class ParameterLookup { @XmlElements({ @XmlElement(name = "parameterConfig", type = ParameterConfig.class) }) @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Pattern.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Pattern.java index 6c4fc276d8..39a4dafaba 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Pattern.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Pattern.java @@ -27,7 +27,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -40,6 +39,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 20 Oct, 2012 1163 dhladky Initial creation + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -49,7 +49,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class Pattern implements ISerializableObject { +public class Pattern { private static final String SEPARATOR = ","; diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Retrieval.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Retrieval.java index 9c47bf08aa..ff119e02e4 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Retrieval.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/Retrieval.java @@ -36,7 +36,6 @@ import com.raytheon.uf.common.datadelivery.registry.Connection; import com.raytheon.uf.common.datadelivery.registry.DataType; import com.raytheon.uf.common.datadelivery.registry.Network; import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -48,9 +47,10 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jan 07, 2011 191 dhladky Initial creation - * Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects. - * Feb 07, 2013 1543 djohnson Never have null attributes. + * Jan 07, 2011 191 dhladky Initial creation + * Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects. + * Feb 07, 2013 1543 djohnson Never have null attributes. + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -61,7 +61,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class Retrieval implements ISerializableObject, Serializable { +public class Retrieval implements Serializable { private static final long serialVersionUID = -1294387473701456892L; diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/RetrievalAttribute.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/RetrievalAttribute.java index 026db1ca0e..beb4cd92c9 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/RetrievalAttribute.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/RetrievalAttribute.java @@ -32,7 +32,6 @@ import com.raytheon.uf.common.datadelivery.registry.Coverage; import com.raytheon.uf.common.datadelivery.registry.Ensemble; import com.raytheon.uf.common.datadelivery.registry.Parameter; import com.raytheon.uf.common.datadelivery.registry.Time; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -44,9 +43,10 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jan 17, 2011 191 dhladky Initial creation - * Feb 15, 2013 1543 djohnson Allow any type of Coverage instance without a JAXB adapter. - * Oct 1, 2013 1797 dhladky Generics + * Jan 17, 2011 191 dhladky Initial creation + * Feb 15, 2013 1543 djohnson Allow any type of Coverage instance without a JAXB adapter. + * Oct 01, 2013 1797 dhladky Generics + * Nov 07, 2013 2361 njensen Remove ISerializableObject * * * @@ -56,7 +56,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class RetrievalAttribute implements ISerializableObject, Serializable { +public class RetrievalAttribute implements + Serializable { /** * diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ServiceConfig.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ServiceConfig.java index a0756303c7..91ef1f5bb4 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ServiceConfig.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/ServiceConfig.java @@ -31,7 +31,6 @@ 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; @@ -43,7 +42,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * 20 Oct, 2012 1163 dhladky Initial creation + * 20 Oct, 2012 1163 dhladky Initial creation + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -54,7 +54,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlRootElement(name = "serviceConfig") @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class ServiceConfig implements ISerializableObject { +public class ServiceConfig { private static final String ALTERNATE_NAMING_SCHEMA = "ALTERNATE_NAMING_SCHEMA"; diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/UnitConfig.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/UnitConfig.java index 449deb36c3..9c24c52174 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/UnitConfig.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/UnitConfig.java @@ -25,7 +25,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; 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; @@ -38,6 +37,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 20 Oct, 2012 1163 dhladky Initial creation + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -48,7 +48,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlRootElement(name = "unitConfig") @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class UnitConfig implements ISerializableObject { +public class UnitConfig { @XmlAttribute(name = "name") @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/UnitLookup.java b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/UnitLookup.java index 92c8cb59dc..e7f1677826 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/UnitLookup.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.retrieval/src/com/raytheon/uf/common/datadelivery/retrieval/xml/UnitLookup.java @@ -10,7 +10,6 @@ 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; @@ -23,6 +22,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 20 Oct, 2012 1163 dhladky Initial creation + * 07 Nov, 2013 2361 njensen Remove ISerializableObject * * * @@ -33,7 +33,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @XmlRootElement(name = "unitLookup") @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class UnitLookup implements ISerializableObject { +public class UnitLookup { @XmlElements({ @XmlElement(name = "unitConfig", type = UnitConfig.class) }) @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject new file mode 100644 index 0000000000..04aaf6ed76 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -0,0 +1,2 @@ +com.raytheon.uf.common.dataplugin.bufrua.UAObs +com.raytheon.uf.common.dataplugin.bufrua.UAObsLevel diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/src/com/raytheon/uf/common/dataplugin/bufrua/UAObs.java b/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/src/com/raytheon/uf/common/dataplugin/bufrua/UAObs.java index fbabe31461..b91ba86f7e 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/src/com/raytheon/uf/common/dataplugin/bufrua/UAObs.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/src/com/raytheon/uf/common/dataplugin/bufrua/UAObs.java @@ -20,10 +20,21 @@ package com.raytheon.uf.common.dataplugin.bufrua; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.measure.quantity.Angle; +import javax.measure.quantity.Length; +import javax.measure.quantity.Temperature; +import javax.measure.quantity.Velocity; +import javax.measure.unit.NonSI; +import javax.measure.unit.SI; +import javax.measure.unit.Unit; import javax.persistence.Access; import javax.persistence.AccessType; import javax.persistence.Column; @@ -33,9 +44,15 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Transient; import javax.persistence.UniqueConstraint; +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.XmlRootElement; import org.hibernate.annotations.Index; +import com.raytheon.uf.common.dataplugin.IDecoderGettable; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.annotations.DataURI; import com.raytheon.uf.common.dataplugin.persist.IPersistable; @@ -46,6 +63,7 @@ import com.raytheon.uf.common.pointdata.PointDataView; import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.edex.decodertools.core.IDecoderConstants; import com.vividsolutions.jts.geom.Geometry; /** @@ -77,7 +95,6 @@ import com.vividsolutions.jts.geom.Geometry; * Jul 19, 2013 1992 bsteffen Remove redundant time columns from * bufrua. * Aug 30, 2013 2298 rjpeter Make getPluginName abstract - * Oct 22, 2013 2361 njensen Remove XML annotations and IDecoderGettable * * * @@ -93,9 +110,11 @@ import com.vividsolutions.jts.geom.Geometry; */ @org.hibernate.annotations.Table(appliesTo = UAObs.PLUGIN_NAME, indexes = { @Index(name = "bufrua_refTimeIndex", columnNames = { "refTime", "forecastTime" }) }) +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize public class UAObs extends PersistablePluginDataObject implements - ISpatialEnabled, IPointData, IPersistable { + ISpatialEnabled, IDecoderGettable, IPointData, IPersistable { private static final long serialVersionUID = 1L; @@ -120,6 +139,33 @@ public class UAObs extends PersistablePluginDataObject implements public static final String PLUGIN_NAME = "bufrua"; + public static final Unit DISTANCE_UNIT = SI.METER; + + public static final Unit TEMPERATURE_UNIT = SI.KELVIN; + + public static final Unit WIND_SPEED_UNIT = SI.METERS_PER_SECOND; + + public static final Unit WIND_DIR_UNIT = NonSI.DEGREE_ANGLE; + + public static final Unit LOCATION_UNIT = NonSI.DEGREE_ANGLE; + + private static final HashMap PARM_MAP = new HashMap(); + static { + PARM_MAP.put("GH", UA_GEOHGT); + PARM_MAP.put("Px", UA_PRESSURE); + + PARM_MAP.put("T", SFC_TEMP); + PARM_MAP.put("DpT", SFC_DWPT); + + PARM_MAP.put("WS", SFC_WNDSPD); + PARM_MAP.put("WD", SFC_WNDDIR); + + PARM_MAP.put("NLAT", STA_LAT); + PARM_MAP.put("NLON", STA_LON); + } + + public static final String UA_PARAM_PTRN = ".*:PRESS=\\d{2,4}"; + // Non persisted value. Hold the last requested parameter name. @Transient private String parameterName = null; @@ -131,17 +177,20 @@ public class UAObs extends PersistablePluginDataObject implements // The observation report type. @DataURI(position = 1) @Column + @XmlAttribute @DynamicSerializeElement private Integer reportType; @Embedded @DataURI(position = 4, embedded = true) + @XmlElement @DynamicSerializeElement private SurfaceObsLocation location; // Correction indicator from wmo header @DataURI(position = 2) @Column + @XmlAttribute @DynamicSerializeElement private String corIndicator; @@ -152,40 +201,48 @@ public class UAObs extends PersistablePluginDataObject implements // Text of the WMO header @DataURI(position = 3) @Column + @XmlAttribute @DynamicSerializeElement private String wmoHeader; // Station pressure in Pascals. @Column + @XmlAttribute @DynamicSerializeElement private Integer pressure_station; // The total cloud cover in 1/8s coverage. @Column + @XmlAttribute @DynamicSerializeElement private Integer totalCloudCover; // The platform directio in angular degrees. @Column + @XmlAttribute @DynamicSerializeElement private Integer platformDirection; // The platform movement in meters per second. @Column + @XmlAttribute @DynamicSerializeElement private Double platformMovement; // ICAO of station if known. @Column + @XmlAttribute @DynamicSerializeElement private String stationName; // The level data for this observation. @Transient + @XmlElement @DynamicSerializeElement private List levels; @Column(insertable = false, updatable = false) + @XmlAttribute @DynamicSerializeElement private Integer idx; @@ -488,6 +545,15 @@ public class UAObs extends PersistablePluginDataObject implements } /** + * Get the IDecoderGettable reference for this record. + * + * @return The IDecoderGettable reference for this record. + */ + @Override + public IDecoderGettable getDecoderGettable() { + return this; + } + /** * */ @@ -504,6 +570,203 @@ public class UAObs extends PersistablePluginDataObject implements this.pointDataView = pointDataView; } + /** + * Get the value of a parameter that is represented as a String. + * + * @param paramName + * The name of the parameter value to retrieve. + * @return The String value of the parameter. If the parameter is unknown, a + * null reference is returned. + */ + @Override + public String getString(String paramName) { + if ("STA".matches(paramName)) { + return this.getStationId(); + } + return null; + } + + /** + * Get the value and units of a named parameter within this observation. The + * parameter name may include level information for these observation data. + * The format for parameter is: + * + *
+     *    "parameterName" may be one of 
+     *        "GH"  geopotential height
+     *        "Px"  pressure
+     *        "T"   temperature
+     *        "DpT" dewpoint
+     *        "WS"  wind speed
+     *        "WD"  wind direction
+     *    followed by a level specification ":PRESS=xxxx" where xxxx is a level
+     *    in hPa (millibars). To retrieve the temperature from the 850hPa level
+     *    use the following getValue("T:PRESS=850");
+     *    
+     *    Some data is specific to the observation, latitude/longitude for
+     *    example. These data may be retrieved using the parameter minus any level
+     *    information as follows
+     *    "NLAT"  station latitude
+     *    "NLON"  station longitude
+     * 
+ * + * If the sounding data defines a surface level, and a request for a level + * below surface is requested, a null value is returned. + * + * @param paramName + * The name of the parameter value to retrieve. + * @return An Amount with value and units. If the parameter is unknown, a + * null reference is returned. + */ + @Override + public Amount getValue(String paramName) { + Amount a = null; + + if (parseParameter(paramName)) { + String pName = PARM_MAP.get(parameterName); + if ((pName != null) && (levels != null) && (levels.size() > 0)) { + + UAObsLevel obsLevel = getLevel(levelId); + if (obsLevel != null) { + Integer iValue = null; + Double dValue = null; + if (UA_GEOHGT.equals(pName)) { + iValue = obsLevel.getGeoHeight(); + if (iValue != null) { + a = new Amount(iValue, DISTANCE_UNIT); + } + } else if (SFC_TEMP.equals(pName)) { + dValue = obsLevel.getTemp(); + if (dValue != null) { + a = new Amount(dValue, TEMPERATURE_UNIT); + } + } else if (SFC_DWPT.equals(pName)) { + dValue = obsLevel.getDwpt(); + if (dValue != null) { + a = new Amount(dValue, TEMPERATURE_UNIT); + } + } else if (SFC_WNDSPD.equals(pName)) { + dValue = obsLevel.getWindSpeed(); + if (dValue != null) { + a = new Amount(dValue, WIND_SPEED_UNIT); + } + } else if (SFC_WNDDIR.equals(pName)) { + iValue = obsLevel.getWindDirection(); + if (iValue != null) { + a = new Amount(iValue, WIND_DIR_UNIT); + } + } + } + } + } else { + // Assume we are trying to get an observation attribute. + String pName = PARM_MAP.get(paramName); + if (STA_LAT.equals(pName)) { + a = new Amount(this.getLatitude(), LOCATION_UNIT); + } else if (STA_LON.equals(pName)) { + a = new Amount(this.getLongitude(), LOCATION_UNIT); + } + } + return a; + } + + /** + * Get the value of a parameter that is represented as a String. + * + * @param paramName + * The name of the parameter value to retrieve. + * @return The String value of the parameter. If the parameter is unknown, a + * null reference is returned. + */ + @Override + public Collection getValues(String paramName) { + return null; + } + + /** + * Determine if the parameter is a level request, and parse out the pressure + * level and parameter name if so. + * + * @param parameter + * The parameter string to parse. + * @return This is a level parameter. + */ + private boolean parseParameter(String parameter) { + boolean goodParse = false; + Pattern p = Pattern.compile(UA_PARAM_PTRN); + Matcher m = p.matcher(parameter); + if (m.find()) { + int start = parameter.indexOf(":PRESS="); + if (start > 0) { + parameterName = parameter.substring(0, start); + start += ":PRESS=".length(); + levelId = Integer.parseInt(parameter.substring(start)); + } + goodParse = true; + } + return goodParse; + } + + /** + * Get a specified pressure level data if it exists. If the specified level + * is below the declared surface pressure a null reference is returned. + * + * @param level + * A pressure level to get. + * @return The requested level, if found, null reference if not. + */ + private UAObsLevel getLevel(Integer level) { + UAObsLevel retValue = null; + if (level != null) { + level = level * 100; + for (UAObsLevel l : levels) { + if (IDecoderConstants.MANPRE_LEVEL.equals(l.getVertSig()) + || IDecoderConstants.SIGPRE_LEVEL + .equals(l.getVertSig())) { + + if (level.equals(l.getPressure())) { + retValue = l; + break; + } + } + } + } + if (retValue != null) { + UAObsLevel sfc = getSurfaceLevel(); + if (sfc != null) { + if (LayerTools.isLowerThan(sfc, retValue)) { + retValue = null; + } + } + } + return retValue; + } + + /** + * Get the defined surface level. If a surface level cannot be found, then + * return null. + * + * @return The surface level found, or null. + */ + private UAObsLevel getSurfaceLevel() { + UAObsLevel retValue = null; + if (levels != null) { + for (UAObsLevel level : levels) { + if (IDecoderConstants.SFC_LEVEL.equals(level.getVertSig())) { + retValue = level; + break; + } + } + } + return retValue; + } + + @Override + public String[] getStrings(String paramName) { + // TODO Auto-generated method stub + return null; + } + @Override public SurfaceObsLocation getSpatialObject() { return location; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/src/com/raytheon/uf/common/dataplugin/bufrua/UAObsLevel.java b/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/src/com/raytheon/uf/common/dataplugin/bufrua/UAObsLevel.java index 533e285222..2c2fbf5945 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/src/com/raytheon/uf/common/dataplugin/bufrua/UAObsLevel.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.bufrua/src/com/raytheon/uf/common/dataplugin/bufrua/UAObsLevel.java @@ -21,6 +21,11 @@ package com.raytheon.uf.common.dataplugin.bufrua; import java.io.Serializable; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; + +import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -37,14 +42,14 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * ------------ ---------- ----------- -------------------------- * 20071127 382 jkorman Initial Coding. * 20080630 1215 jkorman Implemented Serializable. - * 20131022 2361 njensen Remove XML annotations * * * @author jkorman * @version 1.0 */ +@XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class UAObsLevel implements Serializable { +public class UAObsLevel implements Serializable, ISerializableObject { private static final long serialVersionUID = 1L; @@ -58,41 +63,50 @@ public class UAObsLevel implements Serializable { // 5 Significant level, temperature and/or relative humidity // 6 Significant level, wind // All 7 Missing value + @XmlAttribute @DynamicSerializeElement private Integer vertSig = null; // Observation pressure in Pascals + @XmlAttribute @DynamicSerializeElement private Integer pressure = null; // Observation geopotential height in meters. + @XmlAttribute @DynamicSerializeElement private Integer geoHeight = null; // Observation dry air temperature in degrees Kelvin. + @XmlAttribute @DynamicSerializeElement private Double temp = null; // Observation dewpoint temperature in degrees Kelvin. + @XmlAttribute @DynamicSerializeElement private Double dwpt = null; // Observation wind direction in angular degrees. Integer + @XmlAttribute @DynamicSerializeElement private Integer windDirection = null; // Observation wind speed in meters per second. // Decimal(5,2) + @XmlAttribute @DynamicSerializeElement private Double windSpeed = null; // Observation 1 KM below level wind shear in meters per second. // Decimal(5,2) + @XmlAttribute @DynamicSerializeElement private Double loShear = null; // Observation 1 KM above level wind shear in meters per second. // Decimal(5,2) + @XmlAttribute @DynamicSerializeElement private Double hiShear = null; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.fssobs/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.dataplugin.fssobs/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject new file mode 100644 index 0000000000..fe04b603fc --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.fssobs/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -0,0 +1 @@ +com.raytheon.uf.common.dataplugin.fssobs.FSSObsRecord diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.fssobs/src/com/raytheon/uf/common/dataplugin/fssobs/FSSObsRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.fssobs/src/com/raytheon/uf/common/dataplugin/fssobs/FSSObsRecord.java index 9157348555..1726596ce6 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.fssobs/src/com/raytheon/uf/common/dataplugin/fssobs/FSSObsRecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.fssobs/src/com/raytheon/uf/common/dataplugin/fssobs/FSSObsRecord.java @@ -1,7 +1,18 @@ package com.raytheon.uf.common.dataplugin.fssobs; import java.util.Calendar; +import java.util.Collection; +import java.util.HashMap; +import javax.measure.quantity.Angle; +import javax.measure.quantity.DataAmount; +import javax.measure.quantity.Length; +import javax.measure.quantity.Pressure; +import javax.measure.quantity.Temperature; +import javax.measure.quantity.Velocity; +import javax.measure.unit.NonSI; +import javax.measure.unit.SI; +import javax.measure.unit.Unit; import javax.persistence.Access; import javax.persistence.AccessType; import javax.persistence.Column; @@ -11,9 +22,14 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Transient; import javax.persistence.UniqueConstraint; +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 org.hibernate.annotations.Index; +import com.raytheon.uf.common.dataplugin.IDecoderGettable; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.annotations.DataURI; import com.raytheon.uf.common.dataplugin.persist.IPersistable; @@ -26,24 +42,6 @@ import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; -/** - * Fog, Safeseas, Snow Observation record - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Dec 13, 2010            skorolev    Initial creation
- * Oct 14, 2013 2361       njensen     Removed XML annotations and IDecoderGettable
- * 
- * 
- * - * @author njensen - * @version 1.0 - */ - @Entity @SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "fssobsseq") @Table(name = FSSObsRecord.PLUGIN_NAME, uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) }) @@ -53,23 +51,69 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; */ @org.hibernate.annotations.Table(appliesTo = FSSObsRecord.PLUGIN_NAME, indexes = { @Index(name = "fssobs_refTimeIndex", columnNames = { "refTime", "forecastTime" }) }) +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize public class FSSObsRecord extends PersistablePluginDataObject implements - ISpatialEnabled, IPersistable, IPointData { + ISpatialEnabled, IDecoderGettable, IPersistable, IPointData { private static final long serialVersionUID = 1L; public static final String PLUGIN_NAME = "fssobs"; + private static final int MISSING = -9999; + + // UNITS + + public static final Unit TEMPERATURE_UNIT = SI.CELSIUS; + + public static final Unit WIND_SPEED_UNIT = NonSI.KNOT; + + public static final Unit HEIGHT_UNIT = SI.METER; + + public static final Unit WIND_DIR_UNIT = NonSI.DEGREE_ANGLE; + + public static final Unit LOCATION_UNIT = NonSI.DEGREE_ANGLE; + + public static final Unit PRESSURE_UNIT = SI.HECTO(SI.PASCAL); + + public static final Unit PRECIP_UNIT = NonSI.INCH; + + public static final Unit WAVE_UNIT = SI.METER; + + public static final Unit VISIBILITY_UNIT = NonSI.MILE; + + public static final Unit CLOUD_COVER = NonSI.OCTET; + + /** Metar specific parameter keys */ + public static final class ParameterKey { + public static final String SFC_ALTIMETER = "SFC.PRESS.ALTIMETER"; + + public static final String PRESSURE_CHANGE = "PCHNG"; + + public static final String VISIBILITY = "VIS"; + + public static final String PRECIPITATION_1HR = "PR1HR"; + } + + private static final HashMap PARM_MAP = new HashMap(); + static { + PARM_MAP.put("NLAT", STA_LAT); + PARM_MAP.put("NLON", STA_LON); + PARM_MAP.put("rawMessage", "rawMessage"); + } + /** is feature new **/ @Transient @DynamicSerializeElement + @XmlElement public boolean isNew = true; // Current CWA (WFO) @Column @DataURI(position = 2) @DynamicSerializeElement + @XmlElement(nillable = false) private String cwa; // Monitor which should use this station record @@ -79,15 +123,18 @@ public class FSSObsRecord extends PersistablePluginDataObject implements @Column @DataURI(position = 4) @DynamicSerializeElement + @XmlElement private String monitorUse = ""; // Station name @Column @DynamicSerializeElement + @XmlElement private String stnName; /* From ============ObReport================= */ + @XmlElement @DynamicSerializeElement @Column @DataURI(position = 1) @@ -95,25 +142,30 @@ public class FSSObsRecord extends PersistablePluginDataObject implements @Embedded @DataURI(position = 3, embedded = true) + @XmlElement @DynamicSerializeElement private SurfaceObsLocation location; // Observing platform identifier (same as stationID) @Transient + @XmlElement @DynamicSerializeElement private String platformId; // Indicator of whether observing platform is stationary @Transient @DynamicSerializeElement + @XmlElement private boolean isStationary; // Actual time of the observation @Transient @DynamicSerializeElement + @XmlElement private Calendar timeObs; // Time of the observation to the nearest hour. + @XmlElement @DynamicSerializeElement @Column private Calendar refHour; @@ -121,178 +173,214 @@ public class FSSObsRecord extends PersistablePluginDataObject implements // Raw message @Transient @DynamicSerializeElement + @XmlElement private String rawMessage; // Observed wind speed in knots @Transient @DynamicSerializeElement + @XmlElement private float windSpeed = -9999;; // Wind gust in knots @Transient @DynamicSerializeElement + @XmlElement private float windGust = -9999;; // Observed maximum wind speed in knots @Transient @DynamicSerializeElement + @XmlElement private float maxWindSpeed = -9999; // Observed wind direction in azimuth degrees @Transient @DynamicSerializeElement + @XmlElement private float windDir; // Observed wind chill in Fahrenheit @Transient @DynamicSerializeElement + @XmlElement private float windChill = -9999; // Observed high resolution wave height in @Transient @DynamicSerializeElement + @XmlElement private float highResWaveHeight = -9999; // Observed wave steepness in seconds ??? None @Transient @DynamicSerializeElement + @XmlElement private float waveSteepness = -9999; // Observed visibility in Statute miles @Transient @DynamicSerializeElement + @XmlElement private float visibility = -9999; // Observed visibility in meters for Maritime obs. @Transient @DynamicSerializeElement + @XmlElement private float horzVisibility = -9999; // Observed temperature in degrees in Farenheit @Transient @DynamicSerializeElement + @XmlElement private float temperature = -9999; // in feet @Transient + @XmlElement @DynamicSerializeElement private Double waveHeight = -9999.0; // in seconds @Transient + @XmlElement @DynamicSerializeElement private Integer wavePeriod = -9999; // in Azimuth degrees @Transient + @XmlElement @DynamicSerializeElement private Double primarySwellWaveDir = -9999.0; // in seconds @Transient + @XmlElement @DynamicSerializeElement private Integer primarySwellWavePeriod = -9999; // in feet @Transient + @XmlElement @DynamicSerializeElement private Double primarySwellWaveHeight = -9999.0; // in Azimuth degrees @Transient + @XmlElement @DynamicSerializeElement private Double secondarySwellWaveDir = -9999.0; // in seconds @Transient + @XmlElement @DynamicSerializeElement private Integer secondarySwellWavePeriod = -9999; // in feet @Transient + @XmlElement @DynamicSerializeElement private Double secondarySwellWaveHeight = -9999.0; // Three-hour pressure change in thousandths of an inch of mercury ???? @Transient @DynamicSerializeElement + @XmlElement private float pressChange3Hour = -9999f; // Pressure change character for metar plot model /** A string denoting the pressure tendency(rising or falling) */ @Transient @DynamicSerializeElement + @XmlElement private String pressChangeChar; // Observed dewpoint in degrees Farenheit @Transient @DynamicSerializeElement + @XmlElement private float dewpoint = -9999f; // Observed sea surface temperature in degrees in Farenheit @Transient @DynamicSerializeElement + @XmlElement private float seaSurfaceTemp = -9999f; // the sea level pressure in hPa + @XmlElement @DynamicSerializeElement @Transient private float seaLevelPress = -9999f; // Altimeter setting in mm Hg. @Transient + @XmlElement @DynamicSerializeElement private float pressureAltimeter = -9999f; // Observed hourly precipitation in inches @Transient @DynamicSerializeElement + @XmlElement private float hourlyPrecip = -9999f; // Observed snow depth in inch @Transient @DynamicSerializeElement + @XmlElement private float snowDepth = -9999f; // Observed snow increasing rapidly, hourly total in inches @Transient @DynamicSerializeElement + @XmlElement private float snincrHourly = -9999f; // Observed snow increasing rapidly, total in inches @Transient @DynamicSerializeElement + @XmlElement private float snincrTotal = -9999f; // Observed frostbite time in minutes @Transient @DynamicSerializeElement + @XmlElement private float frostbiteTime; // present weather conditions for metar plot model @Transient @DynamicSerializeElement + @XmlElement private String[] presWeather; // Observed relative humidity in percent @Transient @DynamicSerializeElement + @XmlElement private float relativeHumidity = -9999f; // Observed ceiling in feet above ground level @Transient @DynamicSerializeElement + @XmlElement private float ceiling = -9999f; // Observed dewpoint depression in Farenheit @Transient @DynamicSerializeElement + @XmlElement private float dewpointDepr = -9999f; + @XmlElement @DynamicSerializeElement @Transient private String[] skyCover; + @XmlElement @DynamicSerializeElement @Transient private int totCloudAmount = -9999; @@ -309,6 +397,58 @@ public class FSSObsRecord extends PersistablePluginDataObject implements super(uri); } + @Override + public IDecoderGettable getDecoderGettable() { + return null; + } + + @Override + public Amount getValue(String paramName) { + Amount a = null; + + String pName = PARM_MAP.get(paramName); + + if (SFC_TEMP.equals(pName) && (temperature != -9999f)) { + a = new Amount(temperature, TEMPERATURE_UNIT); + } else if (SFC_DWPT.equals(pName) && (dewpoint != -9999f)) { + a = new Amount(dewpoint, TEMPERATURE_UNIT); + } else if (SFC_WNDSPD.equals(pName) && (windSpeed != -9999f)) { + a = new Amount(windSpeed, WIND_SPEED_UNIT); + } else if (SFC_WNDDIR.equals(pName) && (windDir != -9999f)) { + a = new Amount(windDir, WIND_DIR_UNIT); + } else if (SFC_WNDGST.equals(pName) && (windGust != -9999f)) { + a = new Amount(windGust, WIND_SPEED_UNIT); + } else if (PRES_SLP.equals(pName) && (seaLevelPress != -9999f)) { + a = new Amount(seaLevelPress, PRESSURE_UNIT); + // } else if (PRES_ALTSG.equals(pName) && (pressureAltimeter != + // -9999f)) { + // a = new Amount(pressureAltimeter, PRESSURE_UNIT); + } else if (STA_LAT.equals(pName)) { + a = new Amount(this.getLatitude(), LOCATION_UNIT); + } else if (STA_LON.equals(pName)) { + a = new Amount(this.getLongitude(), LOCATION_UNIT); + } else if ("WT".equals(pName) && (this.seaSurfaceTemp != -9999f)) { + a = new Amount(this.seaSurfaceTemp, TEMPERATURE_UNIT); + } else if ("WH".equals(pName)) { + a = new Amount(waveHeight, WAVE_UNIT); + } else if ("SWP".equals(pName)) { + a = new Amount(primarySwellWavePeriod, WAVE_UNIT); + } else if ("SWH".equals(pName)) { + a = new Amount(primarySwellWaveHeight, WAVE_UNIT); + // } else if ("PCHNG".equals(pName) && pressChange3Hour != MISSING) + // { + // a = new Amount(pressChange3Hour, PRESSURE_UNIT); + } else if ("PKWND".equals(paramName) && (maxWindSpeed != MISSING)) { + a = new Amount(maxWindSpeed, WIND_SPEED_UNIT); + } else if ("SWS".equals(paramName) || "SWGS".equals(paramName)) { + a = new Amount(1, WIND_SPEED_UNIT); + } else if ("SWD".equals(paramName) && (primarySwellWaveDir != MISSING)) { + a = new Amount(primarySwellWaveDir, WIND_DIR_UNIT); + } + + return a; + } + /** * @return the isNew */ @@ -1032,6 +1172,21 @@ public class FSSObsRecord extends PersistablePluginDataObject implements return totCloudAmount; } + @Override + public Collection getValues(String paramName) { + return null; + } + + @Override + public String getString(String paramName) { + return null; + } + + @Override + public String[] getStrings(String paramName) { + return null; + } + @Override public ISpatialObject getSpatialObject() { return location; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/gridImageryStyleRules.xml b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/gridImageryStyleRules.xml index a6c7fd54ac..befbc92e4f 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/gridImageryStyleRules.xml +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/gridImageryStyleRules.xml @@ -1227,6 +1227,9 @@ TP48hr TPrun TP120hr + TP6hr_std + TP6hr_avg + TP24hr_avg diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject new file mode 100644 index 0000000000..4c1ba1c6d2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -0,0 +1,2 @@ +com.raytheon.uf.common.dataplugin.profiler.ProfilerObs +com.raytheon.uf.common.dataplugin.profiler.ProfilerLevel \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/src/com/raytheon/uf/common/dataplugin/profiler/ProfilerLevel.java b/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/src/com/raytheon/uf/common/dataplugin/profiler/ProfilerLevel.java index 3991f64ae6..8eaaa8413d 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/src/com/raytheon/uf/common/dataplugin/profiler/ProfilerLevel.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/src/com/raytheon/uf/common/dataplugin/profiler/ProfilerLevel.java @@ -21,6 +21,11 @@ package com.raytheon.uf.common.dataplugin.profiler; import java.io.Serializable; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; + +import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -32,7 +37,6 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 20080303 969 jkorman Initial implementation. - * Oct 15, 2013 2361 njensen Remove XML annotations * * * @@ -40,41 +44,53 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * @version 1.0 */ @DynamicSerialize -public class ProfilerLevel implements Serializable, Comparable { +@XmlAccessorType(XmlAccessType.NONE) +public class ProfilerLevel implements Serializable, ISerializableObject, Comparable { private static final long serialVersionUID = 1L; @DynamicSerializeElement + @XmlAttribute private Integer modeInfo; @DynamicSerializeElement + @XmlAttribute private Integer levelQualCode; @DynamicSerializeElement + @XmlAttribute private Double peakPower; @DynamicSerializeElement + @XmlAttribute private Integer levelHeight; @DynamicSerializeElement + @XmlAttribute private Double ucWind; @DynamicSerializeElement + @XmlAttribute private Double vcWind; @DynamicSerializeElement + @XmlAttribute private Double horzStdDev; @DynamicSerializeElement + @XmlAttribute private Integer horzConsensus; @DynamicSerializeElement + @XmlAttribute private Double wcWind; @DynamicSerializeElement + @XmlAttribute private Double vertStdDev; @DynamicSerializeElement + @XmlAttribute private Integer vertConsensus; /** @@ -323,5 +339,5 @@ public class ProfilerLevel implements Serializable, Comparable { } return result; } - + } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/src/com/raytheon/uf/common/dataplugin/profiler/ProfilerObs.java b/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/src/com/raytheon/uf/common/dataplugin/profiler/ProfilerObs.java index e2c48d4e93..3c8720bf16 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/src/com/raytheon/uf/common/dataplugin/profiler/ProfilerObs.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.profiler/src/com/raytheon/uf/common/dataplugin/profiler/ProfilerObs.java @@ -21,6 +21,7 @@ package com.raytheon.uf.common.dataplugin.profiler; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.regex.Matcher; @@ -40,9 +41,15 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Transient; import javax.persistence.UniqueConstraint; +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.XmlRootElement; import org.hibernate.annotations.Index; +import com.raytheon.uf.common.dataplugin.IDecoderGettable; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.annotations.DataURI; import com.raytheon.uf.common.dataplugin.persist.IPersistable; @@ -74,7 +81,6 @@ import com.vividsolutions.jts.geom.Geometry; * May 07, 2013 1869 bsteffen Remove dataURI column from * PluginDataObject. * Aug 30, 2013 2298 rjpeter Make getPluginName abstract - * Oct 14, 2013 2361 njensen Removed XML annotations and IDecoderGettable * * * @@ -90,9 +96,12 @@ import com.vividsolutions.jts.geom.Geometry; */ @org.hibernate.annotations.Table(appliesTo = ProfilerObs.PLUGIN_NAME, indexes = { @Index(name = "profiler_refTimeIndex", columnNames = { "refTime", "forecastTime" }) }) +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize public class ProfilerObs extends PersistablePluginDataObject implements - ISpatialEnabled, IPointData, IPersistable, Comparable { + ISpatialEnabled, IDecoderGettable, IPointData, IPersistable, + Comparable { private static final long serialVersionUID = 1L; @@ -118,6 +127,18 @@ public class ProfilerObs extends PersistablePluginDataObject implements public static final Unit WIND_DIR_UNIT = NonSI.DEGREE_ANGLE; + private static final HashMap PARM_MAP = new HashMap(); + + private static final String PROF_ID = "profid"; + + static { + PARM_MAP.put("NLAT", STA_LAT); + PARM_MAP.put("NLON", STA_LON); + PARM_MAP.put("WS", SFC_WNDSPD); + PARM_MAP.put("WD", SFC_WNDDIR); + PARM_MAP.put("PROF_ID", PROF_ID); + } + private static final String PRESS = "PRESS"; private static final String AGL = "AGL"; @@ -145,20 +166,24 @@ public class ProfilerObs extends PersistablePluginDataObject implements private Integer levelId; @DataURI(position = 1) + @XmlAttribute @DynamicSerializeElement private Integer reportType; // The profiler observation time. @Column + @XmlAttribute @DynamicSerializeElement private Calendar timeObs; @Embedded @DataURI(position = 2, embedded = true) + @XmlElement @DynamicSerializeElement private SurfaceObsLocation location; @Column + @XmlAttribute @DynamicSerializeElement private String profilerId; @@ -167,23 +192,28 @@ public class ProfilerObs extends PersistablePluginDataObject implements private PointDataView pointDataView; // Text of the WMO header + @XmlAttribute @DynamicSerializeElement private String wmoHeader; // the level data + @XmlElement @DynamicSerializeElement @Transient private String profilerName; // the level data + @XmlElement @DynamicSerializeElement @Transient private List levels; + @XmlAttribute @DynamicSerializeElement @Transient private Double sfcWindSpeed; + @XmlAttribute @DynamicSerializeElement @Transient private Double sfcWindDir; @@ -353,6 +383,75 @@ public class ProfilerObs extends PersistablePluginDataObject implements return wmoHeader; } + @Override + public String getString(String paramName) { + String value = null; + String pName = PARM_MAP.get(paramName); + if (PROF_ID.equals(pName)) { + value = profilerId; + } + return value; + } + + @Override + public String[] getStrings(String paramName) { + return null; + } + + @Override + public Amount getValue(String paramName) { + Amount a = null; + + if (parseParameter(paramName)) { + String pName = PARM_MAP.get(parameterName); + if (unit.equals(AGL) && (levelId == 0)) { + Double dValue = null; + if (SFC_WNDSPD.equals(pName)) { + dValue = getSfcWindSpeed(); + if (dValue != null) { + a = new Amount(dValue, WIND_SPEED_UNIT); + } + } else if (SFC_WNDDIR.equals(pName)) { + dValue = getSfcWindDir(); + if (dValue != null) { + a = new Amount(dValue, WIND_DIR_UNIT); + } + } + } else { + if ((pName != null) && (levels != null) && (levels.size() > 0)) { + profLevel = getLevel(levelId); + if (profLevel != null) { + Double dValue = null; + if (SFC_WNDSPD.equals(pName)) { + dValue = getWindSpeed(); + if (dValue != null) { + a = new Amount(dValue, WIND_SPEED_UNIT); + } + } else if (SFC_WNDDIR.equals(pName)) { + dValue = getWindDirection(); + if (dValue != null) { + a = new Amount(dValue, WIND_DIR_UNIT); + } + } + } + } + } + } else { + String pName = PARM_MAP.get(paramName); + if (STA_LAT.equals(pName)) { + a = new Amount(getLatitude(), LOCATION_UNIT); + } else if (STA_LON.equals(pName)) { + a = new Amount(getLongitude(), LOCATION_UNIT); + } + } + return a; + } + + @Override + public Collection getValues(String paramName) { + return null; + } + /** * Get the WMOHeader of the file that contained this data. * @@ -409,6 +508,17 @@ public class ProfilerObs extends PersistablePluginDataObject implements this.levels = levels; } + /** + * Get the IDecoderGettable interface implementation. This class does not + * currently support this interface. + * + * @return Returns null. + */ + @Override + public IDecoderGettable getDecoderGettable() { + return this; + } + @Override public SurfaceObsLocation getSpatialObject() { return location; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/StdTextProduct.java b/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/StdTextProduct.java index a87c33c165..581bc4e7ca 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/StdTextProduct.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/StdTextProduct.java @@ -58,6 +58,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * 04/06/2010 4734 mhuang Moved from edex server * 17May2010 2187 cjeanbap Change class to be Abstract * 27 May 2012 #647 dgilling Implement getIdentifier/setIdentifier. + * Nov 05, 2013 2499 rjpeter Fix generics. * * * @author jkorman @@ -67,8 +68,8 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public abstract class StdTextProduct extends PersistableDataObject implements - ISerializableObject { +public abstract class StdTextProduct extends + PersistableDataObject implements ISerializableObject { private static final long serialVersionUID = 1L; @@ -185,10 +186,8 @@ public abstract class StdTextProduct extends PersistableDataObject implements * (java.lang.Object) */ @Override - public void setIdentifier(Object identifier) { - if (identifier instanceof StdTextProductId) { - setProdId((StdTextProductId) identifier); - } + public void setIdentifier(StdTextProductId identifier) { + setProdId(identifier); } public String getBbbid() { @@ -227,7 +226,7 @@ public abstract class StdTextProduct extends PersistableDataObject implements Matcher m = ControlCharacterPattern.matcher(this.product); String result = this.product; - for (int i = 0; m.find(); ++i) { + for (; m.find();) { String nonAscii = m.group(); char[] charArr = nonAscii.toCharArray(); if (charArr.length == 1) { @@ -342,10 +341,12 @@ public abstract class StdTextProduct extends PersistableDataObject implements public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((bbbid == null) ? 0 : bbbid.hashCode()); - result = prime * result + ((refTime == null) ? 0 : refTime.hashCode()); - result = prime * result + ((prodId == null) ? 0 : prodId.hashCode()); - result = prime * result + ((product == null) ? 0 : product.hashCode()); + result = (prime * result) + ((bbbid == null) ? 0 : bbbid.hashCode()); + result = (prime * result) + + ((refTime == null) ? 0 : refTime.hashCode()); + result = (prime * result) + ((prodId == null) ? 0 : prodId.hashCode()); + result = (prime * result) + + ((product == null) ? 0 : product.hashCode()); return result; } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.dataplugin/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 806d5fe864..0000000000 --- a/edexOsgi/com.raytheon.uf.common.dataplugin/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,2 +0,0 @@ -com.raytheon.uf.common.dataplugin.persist.PersistencePathKey -com.raytheon.uf.common.dataplugin.persist.PersistencePathKeySet \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/DefaultPathProvider.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/DefaultPathProvider.java index e3fd7777a0..b398f33232 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/DefaultPathProvider.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/DefaultPathProvider.java @@ -37,7 +37,7 @@ import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.serialization.SingleTypeJAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -57,15 +57,20 @@ import com.raytheon.uf.common.time.util.TimeUtil; * 04/08/13 1293 bkowal Removed references to hdffileid. * 04/30/13 1861 bkowal Added constant for hdf5 file suffix. * 10/04/13 2081 mschenke Removed unused annotation logic + * 11/08/13 2361 njensen Use JAXBManager for XML * * * @author bphillip * @version 1.0 */ public class DefaultPathProvider implements IHDFFilePathProvider { + private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(DefaultPathProvider.class); + private static final SingleTypeJAXBManager jaxb = SingleTypeJAXBManager + .createWithoutException(PersistencePathKeySet.class); + public static final String HDF5_SUFFIX = ".h5"; public static final ThreadLocal fileNameFormat = new ThreadLocal() { @@ -204,11 +209,9 @@ public class DefaultPathProvider implements IHDFFilePathProvider { PersistencePathKeySet pathKeySet = null; if (sitePathFile.exists()) { - pathKeySet = (PersistencePathKeySet) SerializationUtil - .jaxbUnmarshalFromXmlFile(sitePathFile); + pathKeySet = jaxb.unmarshalFromXmlFile(sitePathFile); } else if (basePathFile.exists()) { - pathKeySet = (PersistencePathKeySet) SerializationUtil - .jaxbUnmarshalFromXmlFile(basePathFile); + pathKeySet = jaxb.unmarshalFromXmlFile(basePathFile); } List keyNames = null; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistencePathKey.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistencePathKey.java index d4bafab0b8..1709011828 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistencePathKey.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistencePathKey.java @@ -1,3 +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. + **/ package com.raytheon.uf.common.dataplugin.persist; import javax.xml.bind.annotation.XmlAccessType; @@ -5,11 +24,23 @@ 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; - +/** + * PluginDataObject key to use in IDataStore's directory path. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * --/--/----                          Initial creation
+ * Nov 08, 2013 2361       njensen     Remove ISerializableObject
+ * 
+ * 
+ * + */ @XmlRootElement(name = "pathKey") @XmlAccessorType(XmlAccessType.NONE) -public class PersistencePathKey implements Comparable,ISerializableObject { +public class PersistencePathKey implements Comparable { @XmlElement private String key; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistencePathKeySet.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistencePathKeySet.java index e3d900e7f0..9e8e8b5be0 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistencePathKeySet.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/persist/PersistencePathKeySet.java @@ -1,3 +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. + **/ package com.raytheon.uf.common.dataplugin.persist; import java.util.List; @@ -8,11 +27,23 @@ 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; - +/** + * Set of PersistencePathKeys + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * --/--/----                          Initial creation
+ * Nov 08, 2013 2361       njensen     Remove ISerializableObject
+ * 
+ * 
+ * + */ @XmlRootElement(name = "pathKeySet") @XmlAccessorType(XmlAccessType.NONE) -public class PersistencePathKeySet implements ISerializableObject{ +public class PersistencePathKeySet { @XmlElements({ @XmlElement(name = "pathKey", type = PersistencePathKey.class) }) private List pathKeys; diff --git a/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/requests/SaveOrUpdateRequest.java b/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/requests/SaveOrUpdateRequest.java new file mode 100644 index 0000000000..11845e2270 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/requests/SaveOrUpdateRequest.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.dataquery.requests; + +import java.util.List; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.common.serialization.comm.IServerRequest; + +/** + * Request for saving or updating objects in the database. Assumes that all the + * objects in the list belong to the same database, and that the DAO for that + * database knows how to handle those objects. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 8, 2013  2361       njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +@DynamicSerialize +public class SaveOrUpdateRequest implements IServerRequest { + + @DynamicSerializeElement + protected String dbName; + + @DynamicSerializeElement + protected List objectsToUpdate; + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public List getObjectsToUpdate() { + return objectsToUpdate; + } + + public void setObjectsToUpdate(List objectsToUpdate) { + this.objectsToUpdate = objectsToUpdate; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/Event.java b/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/Event.java index 4e3aa07e16..d7251046e7 100644 --- a/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/Event.java +++ b/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/Event.java @@ -17,7 +17,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Nov 5, 2012 #1305 bgonzale Added LogLevel enum and transient attribute. + * Nov 05, 2012 1305 bgonzale Added LogLevel enum and transient attribute. + * Nov 08, 2013 2506 bgonzale Added constructor. * * * @@ -47,6 +48,14 @@ public abstract class Event implements Serializable, ISerializableObject { this(LogLevel.DEBUG); } + /** + * @param id + */ + public Event(String id) { + this(); + this.id = id; + } + public Event(LogLevel logLevel) { date = Calendar.getInstance(); this.logLevel = logLevel; diff --git a/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/LocalizationUtil.py b/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/LocalizationUtil.py index 2374c3b2a4..aaed389ccd 100644 --- a/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/LocalizationUtil.py +++ b/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/LocalizationUtil.py @@ -30,12 +30,16 @@ # Date Ticket# Engineer Description # ------------ ---------- ----------- -------------------------- # 03/12/13 mnash Initial Creation. +# 11/06/13 2086 bkowal Add the containing directory to the +# PYTHONPATH long enough to import +# the module. # # # import os import imp +import sys from com.raytheon.uf.common.localization import LocalizationContext_LocalizationType as JavaLocalizationType, LocalizationContext_LocalizationLevel as JavaLocalizationLevel @@ -80,7 +84,19 @@ def loadModule(filename): @summary: This function takes a filename and find the module, loads it and returns that module ''' + addedToPath = False + path = os.path.splitext(filename)[0] + directory = os.path.dirname(filename) + # ensure the module containing directory is on the python path. + if sys.path.count(directory) == 0: + sys.path.append(directory) + addedToPath = True filename = os.path.split(path)[1] fp, pathname, description = imp.find_module(filename) - return imp.load_module(filename, fp, pathname, description) \ No newline at end of file + module = imp.load_module(filename, fp, pathname, description) + + if addedToPath: + sys.path.remove(directory) + + return module \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/PathManager.py b/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/PathManager.py index c837793394..b14e774763 100644 --- a/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/PathManager.py +++ b/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/PathManager.py @@ -28,6 +28,7 @@ # Date Ticket# Engineer Description # ------------ ---------- ----------- -------------------------- # 03/18/13 mnash Initial Creation. +# 11/08/13 2086 bkowal Declare lists using [] instead of list() # # # @@ -110,7 +111,7 @@ class PathManager(IPathManager.IPathManager): else : jfiles = self.jpathManager.listStaticFiles(name, extArr, recursive, filesOnly) if jfiles is not None : - files = list() + files = [] for file in jfiles : files.append(LocalizationFile(file)) return files @@ -121,7 +122,7 @@ class PathManager(IPathManager.IPathManager): @summary: This method returns the list of available levels. ''' jLevels = self.jpathManager.getAvailableLevels() - levels = list() + levels = [] for level in jLevels : levels.append(level.name()) return levels diff --git a/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/PythonOverrider.py b/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/PythonOverrider.py index d000e0a75b..003d5e5c00 100644 --- a/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/PythonOverrider.py +++ b/edexOsgi/com.raytheon.uf.common.localization.python/utility/common_static/base/python/PythonOverrider.py @@ -28,17 +28,19 @@ # Date Ticket# Engineer Description # ------------ ---------- ----------- -------------------------- # 03/12/13 mnash Initial Creation. +# 11/04/13 2086 bkowal Updated to merge classes - both legacy and non-legacy. +# Minimum to Maximum level of retrieval can now be specified. # # # import os import imp -import inspect +import types from PathManager import PathManager import LocalizationUtil -def override(name, loctype): +def importModule(name, loctype='COMMON_STATIC', level=None): """ Takes a name (filename and localization path) and the localization type and finds the file and overrides it, and returns the module @@ -46,20 +48,37 @@ def override(name, loctype): Args: name : the name and path of the file in localization loctype : a string representation of the localization type + level : a string representation of the localization level (BASE, SITE, etc.) Returns: a module that has all the correct methods after being overridden """ pathManager = PathManager() tieredFiles = pathManager.getTieredLocalizationFile(loctype, name) - levels = pathManager.getAvailableLevels() - lfiles = list() - for level in levels : - if tieredFiles.has_key(level) : - lfiles.append(tieredFiles[level].getPath()) + availableLevels = pathManager.getAvailableLevels() + if level == None: + levels = availableLevels + else: + # ensure that the specified level is actually a legitimate level + if level not in availableLevels: + raise LookupError('An invalid level has been specified!') + + levels = [] + try: + levelIdx = availableLevels.index(level) + levels = availableLevels[:levelIdx + 1] + except ValueError: + # ignore; the exception should never be thrown, we verify that the specified level + # is valid in the previous if statement + pass + + lfiles = [] + for _level in levels : + if _level in tieredFiles: + lfiles.append(tieredFiles[_level].getPath()) themodule = _internalOverride(lfiles) return themodule - + def _internalOverride(files): """ Takes the files and overrides them @@ -69,50 +88,102 @@ def _internalOverride(files): Returns: a new module that contains all the necessary elements - """ + """ themodule = imp.new_module('tmpmodule') # modules = list of all the modules for module in files : # load each module, temporarily tmpmodule = LocalizationUtil.loadModule(module) - the_module = _combineMembers(tmpmodule, themodule) + themodule = _combineMembers(tmpmodule, themodule) return themodule -def _combineMembers(tocombine, finalmodule): - """ - Loops over the necessary parts of each module and decides how to combine them - - Args: - tocombine : the module to combine in - finalmodule : the module that is being combined into - - Returns: - a new python module that was created above - """ - # get the functions - members = inspect.getmembers(tocombine, inspect.isfunction) - for member in members : - finalmodule.__setattr__(member[0], member[1]) - - # get the classes - classes = inspect.getmembers(tocombine, inspect.isclass) - for clazz in classes: - finalmodule.__setattr__(clazz[0], clazz[1]) - +def _combineMembers(tocombine, combinationresult): for attr in dir(tocombine): - if attr.startswith('__') == False or attr.startswith('_') == False: - if hasattr(finalmodule, attr): - if isinstance(attr, dict): - # simply update dicts with the new keys - getattr(finalmodule, attr).update(getattr(tocombine, attr)) - if isinstance(attr, list): - listattr = getattr(tocombine, attr) - for i in listattr: - # override each element in the list if it exists - getattr(finalmodule, attr)[i] = listattr[i] - else : - finalmodule.__setattr__(attr, getattr(tocombine, attr)) - else : - if inspect.ismethod(attr) == False and inspect.isbuiltin(attr) == False and inspect.isclass(attr) == False: - finalmodule.__setattr__(attr, getattr(tocombine, attr)) - return finalmodule + if attr.startswith('__') or attr.startswith('_') or isType(attr, types.BuiltinFunctionType): + # skip + continue + + # is the element a class? + if isType(getattr(tocombine, attr), types.ClassType): + combinationresult = _mergeClasses(tocombine, combinationresult, attr) + else: + # absolute override + combinationresult = _mergeAttributes(tocombine, combinationresult, attr) + + return combinationresult + +def _mergeClasses(source, target, className): + sourceClass = getattr(source, className) + targetClass = getattr(target, className, None) + + if (targetClass == None): + return _mergeAttributes(source, target, className) + + legacyMode = (hasattr(sourceClass, '__class__') == False) + + # verify that both classes are either legacy for current style. + if ((hasattr(targetClass, '__class__') == False) != legacyMode): + raise Exception("A legacy python class cannot be merged with a non-legacy python class!") + + # ensure that the classes are not exactly the same (breaks the legacy merge). + if compareClasses(sourceClass, targetClass): + # nothing to merge + return target + + for attr in dir(sourceClass): + # include private attributes because this is a class? + # methods cannot just be merged into a class, so skip them. + if isType(attr, types.BuiltinFunctionType) or isType(attr, types.MethodType) or \ + attr.startswith('__') or attr.startswith('_'): + continue + + # do we need to worry about nested classes? + if isType(getattr(sourceClass, attr), types.ClassType): + target = _mergeClasses(source, target, attr) + + attributeName = className + '.' + attr + target = _mergeAttributes(source, target, attributeName) + + # complete the merge / override of methods. + exec(_buildMergeDirective(className, legacyMode)) + return _mergeAttributes(source, target, className) + +def _buildMergeDirective(className, legacyMode): + if (legacyMode): + return 'source.' + className + '.__bases__ = (target.' + className + ',)' + else: + return 'source.' + className + ' = type("' + className + \ + '", (target.' + className + ',), dict(source.' + className + '.__dict__))' + +def isType(object, type): + return type(object) == type + +def compareClasses(clazz1, clazz2): + clazz1Attr = dir(clazz1) + clazz2Attr = dir(clazz2) + + if (len(clazz1Attr) != len(clazz2Attr)): + return False + + i = 0 + while i < len(clazz1Attr): + # compare the names + if (clazz1Attr[i] != clazz2Attr[i]): + return False + + # compare the attributes directly + attr1 = getattr(clazz1, clazz1Attr[i]) + attr2 = getattr(clazz2, clazz2Attr[i]) + if (attr1 != attr2): + return False + + i += 1 + + return True + +def _mergeAttributes(source, target, attributeName): + + mergeDirective = 'target.' + attributeName + ' = source.' + attributeName + exec(mergeDirective) + + return target \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.pointdata/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject index 02051a688a..9dad017dfe 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ b/edexOsgi/com.raytheon.uf.common.pointdata/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -1,3 +1,11 @@ +com.raytheon.uf.common.pointdata.PointDataContainer +com.raytheon.uf.common.pointdata.PointDataSerializable +com.raytheon.uf.common.pointdata.ParameterDescription +com.raytheon.uf.common.pointdata.Dimension +com.raytheon.uf.common.pointdata.elements.FloatPointDataObject +com.raytheon.uf.common.pointdata.elements.IntPointDataObject +com.raytheon.uf.common.pointdata.elements.LongPointDataObject +com.raytheon.uf.common.pointdata.elements.StringPointDataObject com.raytheon.uf.common.pointdata.spatial.ObStation com.raytheon.uf.common.pointdata.spatial.AircraftObsLocation com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/Dimension.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/Dimension.java index 88d69cfa41..a30246b22d 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/Dimension.java +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/Dimension.java @@ -23,6 +23,8 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; +import com.raytheon.uf.common.serialization.ISerializableObject; + /** * Provides metadata (primarily the size) of a named dimension * @@ -39,7 +41,7 @@ import javax.xml.bind.annotation.XmlAttribute; * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) -public class Dimension { +public class Dimension implements ISerializableObject { @XmlAttribute(name = "name") private String dimensionName; diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/ParameterDescription.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/ParameterDescription.java index 431ef1ef32..6be79c020f 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/ParameterDescription.java +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/ParameterDescription.java @@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import com.raytheon.uf.common.pointdata.PointDataDescription.Type; +import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -50,7 +51,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; */ @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public class ParameterDescription { +public class ParameterDescription implements ISerializableObject { @XmlAttribute(name = "name", required = true) @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/PointDataContainer.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/PointDataContainer.java index e32a5deb0f..179b0aa393 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/PointDataContainer.java +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/PointDataContainer.java @@ -23,8 +23,17 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map.Entry; 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 javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.raytheon.uf.common.datastorage.records.FloatDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.IntegerDataRecord; @@ -37,6 +46,7 @@ import com.raytheon.uf.common.pointdata.elements.FloatPointDataObject; import com.raytheon.uf.common.pointdata.elements.IntPointDataObject; import com.raytheon.uf.common.pointdata.elements.LongPointDataObject; import com.raytheon.uf.common.pointdata.elements.StringPointDataObject; +import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -49,8 +59,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 8, 2009 chammack Initial creation - * Oct 9, 2013 2361 njensen Removed XML annotations + * Apr 8, 2009 chammack Initial creation * * * @@ -58,17 +67,23 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * @version 1.0 */ @DynamicSerialize -public class PointDataContainer { +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class PointDataContainer implements ISerializableObject { protected static final int DEFAULT_SZ = 2048; @DynamicSerializeElement + @XmlAttribute protected int currentSz; @DynamicSerializeElement + @XmlAttribute protected int allocatedSz; @DynamicSerializeElement + @XmlElement + @XmlJavaTypeAdapter(value = PointDataMarshaller.class) protected HashMap> pointDataTypes; public PointDataContainer() { @@ -411,6 +426,55 @@ public class PointDataContainer { this.currentSz = currentSz; } + public static class PointDataMarshaller + extends + XmlAdapter>> { + + /* + * (non-Javadoc) + * + * @see + * javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object + * ) + */ + @Override + public PointDataSerializable marshal( + HashMap> v) throws Exception { + PointDataSerializable serializable = new PointDataSerializable(); + PointDataSerializable.PointDataItemSerializable[] items = new PointDataSerializable.PointDataItemSerializable[v + .size()]; + int i = 0; + for (Entry> entry : v.entrySet()) { + items[i] = new PointDataSerializable.PointDataItemSerializable(); + items[i].key = entry.getKey(); + items[i].value = entry.getValue(); + i++; + } + serializable.items = items; + return serializable; + } + + /* + * (non-Javadoc) + * + * @see + * javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang + * .Object) + */ + @Override + public HashMap> unmarshal( + PointDataSerializable v) throws Exception { + HashMap> map = new HashMap>( + v.items.length); + for (PointDataSerializable.PointDataItemSerializable item : v.items) { + map.put(item.key, item.value); + } + + return map; + } + + } + protected AbstractPointDataObject getParamSafe(String parameter) { AbstractPointDataObject p = pointDataTypes.get(parameter); if (p == null) { diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/PointDataSerializable.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/PointDataSerializable.java new file mode 100644 index 0000000000..f5bfebc698 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/PointDataSerializable.java @@ -0,0 +1,60 @@ +/** + * 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.pointdata; + +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.pointdata.elements.AbstractPointDataObject; +import com.raytheon.uf.common.serialization.ISerializableObject; + +/** + * A serialization helper class for serializing pointdata maps + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 16, 2009            chammack     Initial creation
+ * 
+ * 
+ * + * @author chammack + * @version 1.0 + */ +@XmlAccessorType(XmlAccessType.NONE) +public class PointDataSerializable implements ISerializableObject { + + @XmlElement(name = "item") + public PointDataItemSerializable[] items; + + public static class PointDataItemSerializable implements + ISerializableObject { + + @XmlAttribute + public String key; + + @XmlElement + public AbstractPointDataObject value; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/AbstractPointDataObject.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/AbstractPointDataObject.java index 8809021aa6..a7bc160516 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/AbstractPointDataObject.java +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/AbstractPointDataObject.java @@ -22,9 +22,13 @@ package com.raytheon.uf.common.pointdata.elements; import java.util.HashMap; import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; + import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.pointdata.ParameterDescription; import com.raytheon.uf.common.pointdata.PointDataContainer; +import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -36,17 +40,16 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 8, 2009 chammack Initial creation - * Oct 9, 2013 2361 njensen Removed XML annotations + * Apr 8, 2009 chammack Initial creation * * * * @author chammack * @version 1.0 */ - +@XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public abstract class AbstractPointDataObject { +public abstract class AbstractPointDataObject implements ISerializableObject { static final int STORAGE_CHUNK_SIZE = 1024; diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/FloatPointDataObject.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/FloatPointDataObject.java index bffec6ea88..02f8742dfb 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/FloatPointDataObject.java +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/FloatPointDataObject.java @@ -19,6 +19,10 @@ **/ package com.raytheon.uf.common.pointdata.elements; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + import com.raytheon.uf.common.datastorage.records.FloatDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.pointdata.ParameterDescription; @@ -34,8 +38,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 8, 2009 chammack Initial creation - * Oct 9, 2013 2361 njensen Removed XML annotations + * Apr 8, 2009 chammack Initial creation * * * @@ -43,9 +46,11 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * @version 1.0 */ @DynamicSerialize +@XmlAccessorType(XmlAccessType.NONE) public class FloatPointDataObject extends AbstractPointDataObject { @DynamicSerializeElement + @XmlElement protected float[] floatData; public FloatPointDataObject() { diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/IntPointDataObject.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/IntPointDataObject.java index 28c933b923..a41601df68 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/IntPointDataObject.java +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/IntPointDataObject.java @@ -19,6 +19,10 @@ **/ package com.raytheon.uf.common.pointdata.elements; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.IntegerDataRecord; import com.raytheon.uf.common.pointdata.ParameterDescription; @@ -34,8 +38,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 8, 2009 chammack Initial creation - * Oct 9, 2013 2361 njensen Removed XML annotations + * Apr 8, 2009 chammack Initial creation * * * @@ -43,9 +46,10 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * @version 1.0 */ @DynamicSerialize +@XmlAccessorType(XmlAccessType.NONE) public class IntPointDataObject extends AbstractPointDataObject { - @DynamicSerializeElement + @XmlElement protected int[] intData; public IntPointDataObject() { diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/LongPointDataObject.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/LongPointDataObject.java index 12d3871bc7..7f95c05964 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/LongPointDataObject.java +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/LongPointDataObject.java @@ -19,6 +19,10 @@ **/ package com.raytheon.uf.common.pointdata.elements; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.LongDataRecord; import com.raytheon.uf.common.pointdata.ParameterDescription; @@ -34,8 +38,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 8, 2009 chammack Initial creation - * Oct 9, 2013 2361 njensen Removed XML annotations + * Apr 8, 2009 chammack Initial creation * * * @@ -43,9 +46,10 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * @version 1.0 */ @DynamicSerialize +@XmlAccessorType(XmlAccessType.NONE) public class LongPointDataObject extends AbstractPointDataObject { - @DynamicSerializeElement + @XmlElement protected long[] longData; public LongPointDataObject() { diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/StringPointDataObject.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/StringPointDataObject.java index 8d504c97a3..a57cbdc427 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/StringPointDataObject.java +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/elements/StringPointDataObject.java @@ -19,6 +19,10 @@ **/ package com.raytheon.uf.common.pointdata.elements; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.StringDataRecord; import com.raytheon.uf.common.pointdata.ParameterDescription; @@ -34,8 +38,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 8, 2009 chammack Initial creation - * Oct 9, 2013 2361 njensen Removed XML annotations + * Apr 8, 2009 chammack Initial creation * * * @@ -43,9 +46,10 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * @version 1.0 */ @DynamicSerialize +@XmlAccessorType(XmlAccessType.NONE) public class StringPointDataObject extends AbstractPointDataObject { - @DynamicSerializeElement + @XmlElement protected String[] stringData; public StringPointDataObject() { diff --git a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/constants/CanonicalQueryTypes.java b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/constants/CanonicalQueryTypes.java index 8a91645569..a2f9158e97 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/constants/CanonicalQueryTypes.java +++ b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/constants/CanonicalQueryTypes.java @@ -19,6 +19,9 @@ **/ package com.raytheon.uf.common.registry.constants; +import java.util.Arrays; +import java.util.List; + /** * * Registry canonical query types @@ -31,6 +34,7 @@ package com.raytheon.uf.common.registry.constants; * ------------ ---------- ----------- -------------------------- * 4/9/2013 1802 bphillip Initial implementation * 9/18/2013 1705 bphillip Added GetReferencedObject canonical query + * 11/7/2013 1678 bphillip Added list of all canonical query types * * * @author bphillip @@ -50,20 +54,14 @@ public class CanonicalQueryTypes { public static final String GET_CLASSIFICATION_SCHEMES_BY_ID = "urn:oasis:names:tc:ebxml-regrep:query:GetClassificationSchemesById"; - public static final String EXPORT_OBJECT = "urn:oasis:names:tc:ebxml-regrep:query:ExportObject"; - public static final String GET_CHILDREN_BY_PARENT_ID = "urn:oasis:names:tc:ebxml-regrep:query:GetChildrenByParentId"; public static final String GET_REGISTRY_PACKAGES_BY_MEMBER_ID = "urn:oasis:names:tc:ebxml-regrep:query:GetRegistryPackagesByMemberId"; - public static final String FIND_ALL_MY_OBJECTS = "urn:oasis:names:tc:ebxml-regrep:query:FindAllMyObjects"; - public static final String GARBAGE_COLLECTOR = "urn:oasis:names:tc:ebxml-regrep:query:GarbageCollector"; public static final String BASIC_QUERY = "urn:oasis:names:tc:ebxml-regrep:query:BasicQuery"; - public static final String EXTRINSIC_OBJECT_QUERY = "urn:oasis:names:tc:ebxml-regrep:query:ExtrinsicObjectQuery"; - public static final String FIND_ASSOCIATIONS = "urn:oasis:names:tc:ebxml-regrep:query:FindAssociations"; public static final String FIND_ASSOCIATED_OBJECTS = "urn:oasis:names:tc:ebxml-regrep:query:FindAssociatedObjects"; @@ -80,4 +78,15 @@ public class CanonicalQueryTypes { public static final String GET_REFERENCED_OBJECT = "urn:oasis:names:tc:ebxml-regrep:query:GetReferencedObject"; + public static final List CANONICAL_QUERY_TYPES = Arrays + .asList(new String[] { GET_OBJECT_BY_ID, GET_OBJECTS_BY_LID, + GET_AUDIT_TRAIL_BY_LID, GET_AUDIT_TRAIL_BY_TIME_INTERVAL, + GET_AUDIT_TRAIL_BY_ID, GET_CLASSIFICATION_SCHEMES_BY_ID, + GET_CHILDREN_BY_PARENT_ID, + GET_REGISTRY_PACKAGES_BY_MEMBER_ID, GARBAGE_COLLECTOR, + BASIC_QUERY, FIND_ASSOCIATIONS, FIND_ASSOCIATED_OBJECTS, + ADHOC_QUERY, KEYWORD_SEARCH, REGISTRY_PACKAGE_SELECTOR, + CLASSIFICATION_SCHEME_SELECTOR, GET_NOTIFICATION, + GET_REFERENCED_OBJECT }); + } diff --git a/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/InsertRegistryEvent.java b/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/InsertRegistryEvent.java index 0601e3bd3f..57c388b6e6 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/InsertRegistryEvent.java +++ b/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/InsertRegistryEvent.java @@ -33,6 +33,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 16, 2012 jsanchez Initial creation + * Nov 08, 2013 2506 bgonzale Added constructors. * * * @@ -48,10 +49,7 @@ public class InsertRegistryEvent extends RegistryEvent { } public InsertRegistryEvent(String id, String lid, String objectType) { - this.id = id; - setLid(lid); - setObjectType(objectType); - setAction(Action.INSERT); + super(id, lid, objectType, Action.INSERT); } @Override diff --git a/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/RegistryEvent.java b/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/RegistryEvent.java index c13e1a43f5..f2df6aa846 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/RegistryEvent.java +++ b/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/RegistryEvent.java @@ -35,6 +35,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 16, 2012 jsanchez Initial creation + * Nov 08, 2013 2506 bgonzale Added constructors. * * * @@ -50,6 +51,27 @@ public abstract class RegistryEvent extends Event { UPDATE, DELETE, INSERT } + /** + * Default Constructor. + */ + public RegistryEvent() { + } + + /** + * Initialization Constructor. + * + * @param id + * @param lid + * @param objectType + * @param action + */ + public RegistryEvent(String id, String lid, String objectType, Action action) { + super(id); + this.lid = lid; + this.objectType = objectType; + this.action = action; + } + @DynamicSerializeElement private String lid; diff --git a/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/RemoveRegistryEvent.java b/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/RemoveRegistryEvent.java index c56cd7cb21..5d68c86a72 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/RemoveRegistryEvent.java +++ b/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/RemoveRegistryEvent.java @@ -33,6 +33,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 16, 2012 jsanchez Initial creation + * Nov 08, 2013 2506 bgonzale Added constructors. * * * @@ -51,11 +52,8 @@ public class RemoveRegistryEvent extends RegistryEvent { } public RemoveRegistryEvent(String username, String id) { - this.id = id; + super(id, null, null, Action.DELETE); this.username = username; - setLid(null); - setObjectType(null); - setAction(Action.DELETE); } public String getUsername() { diff --git a/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/UpdateRegistryEvent.java b/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/UpdateRegistryEvent.java index 42388847d7..bf52c47ad6 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/UpdateRegistryEvent.java +++ b/edexOsgi/com.raytheon.uf.common.registry.event/src/com/raytheon/uf/common/registry/event/UpdateRegistryEvent.java @@ -33,6 +33,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 16, 2012 jsanchez Initial creation + * Nov 08, 2013 2506 bgonzale Added constructors. * * * @@ -48,9 +49,6 @@ public class UpdateRegistryEvent extends RegistryEvent { } public UpdateRegistryEvent(String id, String lid, String objectType) { - this.id = id; - setLid(lid); - setObjectType(objectType); - setAction(Action.UPDATE); + super(id, lid, objectType, Action.UPDATE); } } diff --git a/edexOsgi/com.raytheon.uf.common.sounding/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.sounding/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 62c91c7bb2..0000000000 --- a/edexOsgi/com.raytheon.uf.common.sounding/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -com.raytheon.uf.common.sounding.util.SoundingPrefs \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/util/SoundingPrefs.java b/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/util/SoundingPrefs.java index c2709c408d..1efc10de08 100644 --- a/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/util/SoundingPrefs.java +++ b/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/util/SoundingPrefs.java @@ -21,6 +21,7 @@ package com.raytheon.uf.common.sounding.util; import java.io.File; +import javax.xml.bind.JAXB; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -31,8 +32,6 @@ 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.PathManagerFactory; -import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -50,6 +49,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * ------------ ---------- ----------- -------------------------- * Jun 15, 2011 bsteffen Initial creation * Aug 21, 2013 2259 bsteffen Add javadoc + * Nov 08, 2013 2361 njensen Use JAXB instead of SerializationUtil * * * @@ -60,11 +60,12 @@ import com.raytheon.uf.common.status.UFStatus.Priority; @XmlAccessorType(XmlAccessType.NONE) @XmlRootElement public class SoundingPrefs { + private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(SoundingPrefs.class); - + .getHandler(SoundingPrefs.class); + private static final String SOUNDING_PREFS_FILE = "sounding/soundingPrefs.xml"; - + @XmlElement private double temperatureOffset = 0.0; @@ -75,29 +76,30 @@ public class SoundingPrefs { public void setTemperatureOffset(double temperatureOffset) { this.temperatureOffset = temperatureOffset; } - + private static SoundingPrefs soundingPrefs; - + public static SoundingPrefs getSoundingPrefs() { - if(soundingPrefs == null) { + if (soundingPrefs == null) { IPathManager pathMgr = PathManagerFactory.getPathManager(); LocalizationContext lc = pathMgr.getContext( LocalizationType.COMMON_STATIC, LocalizationLevel.SITE); File file = pathMgr.getFile(lc, SOUNDING_PREFS_FILE); - if(file == null || !file.exists()) { - lc = pathMgr.getContext( - LocalizationType.COMMON_STATIC, LocalizationLevel.BASE); - file = pathMgr.getFile(lc, SOUNDING_PREFS_FILE); + if (file == null || !file.exists()) { + lc = pathMgr.getContext(LocalizationType.COMMON_STATIC, + LocalizationLevel.BASE); + file = pathMgr.getFile(lc, SOUNDING_PREFS_FILE); } try { - soundingPrefs = (SoundingPrefs) SerializationUtil.jaxbUnmarshalFromXmlFile(file); - } catch (SerializationException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); + soundingPrefs = JAXB.unmarshal(file, SoundingPrefs.class); + } catch (Exception e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), + e); soundingPrefs = new SoundingPrefs(); } } return soundingPrefs; - + } - + } diff --git a/edexOsgi/com.raytheon.uf.common.spatial/.classpath b/edexOsgi/com.raytheon.uf.common.spatial/.classpath deleted file mode 100644 index 1fa3e6803d..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.common.spatial/.project b/edexOsgi/com.raytheon.uf.common.spatial/.project deleted file mode 100644 index f8fdc72bc1..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.uf.common.spatial - - - - - - 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/edexOsgi/com.raytheon.uf.common.spatial/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.common.spatial/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 295d77f55d..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Thu Dec 02 10:55:26 CST 2010 -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/edexOsgi/com.raytheon.uf.common.spatial/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.spatial/META-INF/MANIFEST.MF deleted file mode 100644 index d284863490..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/META-INF/MANIFEST.MF +++ /dev/null @@ -1,16 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: com.raytheon.uf.common.spatial -Bundle-SymbolicName: com.raytheon.uf.common.spatial -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: RAYTHEON -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Export-Package: com.raytheon.uf.common.spatial.reprojection -Require-Bundle: org.apache.commons.lang;bundle-version="2.3.0", - org.geotools;bundle-version="2.6.4", - com.raytheon.uf.common.geospatial;bundle-version="1.12.1174", - com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", - com.raytheon.uf.common.datastorage;bundle-version="1.12.1174", - com.raytheon.uf.common.serialization;bundle-version="1.12.1174" -Import-Package: org.apache.commons.logging - diff --git a/edexOsgi/com.raytheon.uf.common.spatial/build.properties b/edexOsgi/com.raytheon.uf.common.spatial/build.properties deleted file mode 100644 index 34d2e4d2da..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/edexOsgi/com.raytheon.uf.common.spatial/com.raytheon.uf.common.spatial.ecl b/edexOsgi/com.raytheon.uf.common.spatial/com.raytheon.uf.common.spatial.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/AbstractDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/AbstractDataReprojector.java deleted file mode 100644 index 6d371973d6..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/AbstractDataReprojector.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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.common.spatial.reprojection; - -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.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ByteDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ByteDataReprojector.java deleted file mode 100644 index bb0f55e88c..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ByteDataReprojector.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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.common.spatial.reprojection; - -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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/DataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/DataReprojector.java deleted file mode 100644 index 1186cb2239..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/DataReprojector.java +++ /dev/null @@ -1,632 +0,0 @@ -/* - * 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.common.spatial.reprojection; - -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.geotools.referencing.CRS; -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.common.spatial.reprojection.AbstractDataReprojector.RequestWrapper; -import com.raytheon.uf.common.spatial.reprojection.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; - if (CRS.equalsIgnoreMetadata(crs, spatial.getCrs())) { - // original dataset, no reproject - reprojectedDataset = dataSet; - } - // 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 - */ - public static 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 static 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 static 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 static 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.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/FloatDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/FloatDataReprojector.java deleted file mode 100644 index 4d1da89252..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/FloatDataReprojector.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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.common.spatial.reprojection; - -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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/IntDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/IntDataReprojector.java deleted file mode 100644 index 384c15466c..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/IntDataReprojector.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * 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.common.spatial.reprojection; - -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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/KeyLocker.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/KeyLocker.java deleted file mode 100644 index b47c48408f..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/KeyLocker.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.spatial.reprojection; - -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.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ReferencedDataRecord.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ReferencedDataRecord.java deleted file mode 100644 index fd38a68b2d..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ReferencedDataRecord.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.common.spatial.reprojection; - -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.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ShortDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ShortDataReprojector.java deleted file mode 100644 index 4c40a28930..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ShortDataReprojector.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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.common.spatial.reprojection; - -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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.common.spatial.reprojection.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.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 34355bbd41..9c55491b7f 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 @@ -53,6 +53,7 @@ import com.raytheon.uf.common.time.domain.api.ITimePoint; * Apr 24, 2013 1628 mschenke Added GMT TimeZone Object constant * Jun 05, 2013 DR 16279 D. Friedman Add timeOfDayToAbsoluteTime * Oct 30, 2013 2448 dhladky Added current year addition to calendar object. + * Nov 05, 2013 2499 rjpeter Added prettyDuration. * * * @author njensen @@ -166,6 +167,13 @@ public final class TimeUtil { static final ITimer NULL_CLOCK = new NullClock(); + private static final long[] DURATION_INTERVALS = { MILLIS_PER_YEAR, + MILLIS_PER_WEEK, MILLIS_PER_DAY, MILLIS_PER_HOUR, + MILLIS_PER_MINUTE, MILLIS_PER_SECOND }; + + private static final String[] DURATION_QUALIFIERS = { "y", "w", "d", "h", + "m", "s" }; + /** * The strategy to retrieve the "current time" value from. */ @@ -427,20 +435,24 @@ public final class TimeUtil { } } - /** Converts a time-of-day (in seconds) to an absolute time given an - * absolute reference time. The resulting time is within a day of the - * reference time. - * @param timeOfDaySeconds The time of day in seconds past midnight - * @param referenceTime The reference time (should have GMT time zone) + /** + * Converts a time-of-day (in seconds) to an absolute time given an absolute + * reference time. The resulting time is within a day of the reference time. + * + * @param timeOfDaySeconds + * The time of day in seconds past midnight + * @param referenceTime + * The reference time (should have GMT time zone) * @return */ - public static Calendar timeOfDayToAbsoluteTime(int timeOfDaySeconds, Calendar referenceTime) { + public static Calendar timeOfDayToAbsoluteTime(int timeOfDaySeconds, + Calendar referenceTime) { Calendar targetDay = (Calendar) referenceTime.clone(); - int refTimeTodSeconds = referenceTime.get(Calendar.HOUR_OF_DAY) * SECONDS_PER_HOUR - + referenceTime.get(Calendar.MINUTE) * SECONDS_PER_MINUTE + int refTimeTodSeconds = (referenceTime.get(Calendar.HOUR_OF_DAY) * SECONDS_PER_HOUR) + + (referenceTime.get(Calendar.MINUTE) * SECONDS_PER_MINUTE) + referenceTime.get(Calendar.SECOND); int absTodDiff = Math.abs(refTimeTodSeconds - timeOfDaySeconds); - if (absTodDiff < SECONDS_PER_DAY - absTodDiff) { + if (absTodDiff < (SECONDS_PER_DAY - absTodDiff)) { // nothing; use current targetDay } else if (refTimeTodSeconds < timeOfDaySeconds) { targetDay.add(Calendar.DAY_OF_MONTH, -1); @@ -454,6 +466,43 @@ public final class TimeUtil { return targetDay; } + /** + * Formats millis keeping the two most significant digits. + * + * 1y16w 2d15h 3m5s + * + * @param durationInMillis + * @return + */ + public static String prettyDuration(long durationInMillis) { + StringBuilder timeString = new StringBuilder(); + // handle s/ms separately + for (int i = 0; i < (DURATION_INTERVALS.length - 1); i++) { + long interval = DURATION_INTERVALS[i]; + if (durationInMillis > interval) { + timeString.append(durationInMillis / interval).append( + DURATION_QUALIFIERS[i]); + durationInMillis %= interval; + timeString.append(durationInMillis / DURATION_INTERVALS[i + 1]) + .append(DURATION_QUALIFIERS[i + 1]); + + return timeString.toString(); + } + } + + // seconds/ms + if (durationInMillis > MILLIS_PER_SECOND) { + timeString.append(durationInMillis / MILLIS_PER_SECOND).append('.'); + durationInMillis %= MILLIS_PER_SECOND; + int tenth = (int) (durationInMillis / 100); + timeString.append(tenth).append('s'); + } else { + timeString.append(durationInMillis).append("ms"); + } + + return timeString.toString(); + } + /** * Disabled constructor. */ 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 1351e8ae08..03544cc32a 100644 --- a/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF @@ -12,6 +12,7 @@ Require-Bundle: org.apache.commons.beanutils;bundle-version="1.8.3", Export-Package: com.raytheon.uf.common.util, com.raytheon.uf.common.util.algorithm, com.raytheon.uf.common.util.cache, + com.raytheon.uf.common.util.concurrent, com.raytheon.uf.common.util.file, com.raytheon.uf.common.util.header, com.raytheon.uf.common.util.mapping, diff --git a/edexOsgi/com.raytheon.uf.common.util/build.properties b/edexOsgi/com.raytheon.uf.common.util/build.properties index 2b7d65d0b4..34d2e4d2da 100644 --- a/edexOsgi/com.raytheon.uf.common.util/build.properties +++ b/edexOsgi/com.raytheon.uf.common.util/build.properties @@ -2,4 +2,3 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ . -src.excludes = test/src/ 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 d1209b9df7..8ed0f2651f 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 @@ -60,6 +60,8 @@ import org.apache.commons.io.IOUtils; * Mar 11, 2013 1645 djohnson Added file modification watcher. * Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List. * May 16, 2013 1966 rferrel Add sizeOfDirectory and listDirFiles method. + * Oct 9, 2013 2467 randerso Change coypFile to use apache instead of FileChannel + * to improve memory utilization * Oct 18, 2013 2267 bgonzale Add listPaths method. * to improve memory utilization * diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/concurrent/KeyLock.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/concurrent/KeyLock.java new file mode 100644 index 0000000000..0c59420592 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/concurrent/KeyLock.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.common.util.concurrent; + +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * Lock assigned to a key + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 8, 2013            bclement     moved from KeyLocker internal class
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ + +public class KeyLock { + + private final K key; + + private final ReentrantReadWriteLock lock; + + public KeyLock(K key, ReentrantReadWriteLock lock) { + this.key = key; + this.lock = lock; + } + + /** + * Acquire write lock + */ + public void lock() { + this.lock.writeLock().lock(); + } + + /** + * Let go of write lock + */ + public void unlock() { + this.lock.writeLock().unlock(); + } + + /** + * Acquire read lock + */ + public void readLock() { + this.lock.readLock().lock(); + } + + /** + * Let go of read lock + */ + public void readUnlock() { + this.lock.readLock().unlock(); + } + + /** + * + * @return the key + */ + public K getKey() { + return key; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/concurrent/KeyLocker.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/concurrent/KeyLocker.java new file mode 100644 index 0000000000..cecbaa69eb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/concurrent/KeyLocker.java @@ -0,0 +1,130 @@ +/* + * 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.util.concurrent; + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * Manages a pool of locks assigned to keys. Allows for synchronizing expensive + * tasks on a per-key basis. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 18, 2011            bclement     Initial creation
+ * Nov 8, 2013  1314       bclement     moved to common.util
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class KeyLocker { + + private final boolean fair; + + public KeyLocker() { + this(false); + } + + /** + * @param fair + * true if created locks should use a fair ordering policy + */ + public KeyLocker(boolean fair) { + this.fair = fair; + } + + /** + * Weak reference to lock that keeps track of the key used to clean the lock + * map + * + * @author bclement + * @version 1.0 + */ + private class WeakKeyLock extends WeakReference { + + public final K key; + + public WeakKeyLock(K key, ReentrantReadWriteLock referent, + ReferenceQueue q) { + super(referent, q); + this.key = key; + } + + } + + private final Map locks = new HashMap(); + + private final ReferenceQueue refQueue = new ReferenceQueue(); + + /** + * Get lock associated with key. + * + * @param key + * @return + */ + public KeyLock getLock(K key) { + synchronized (locks) { + cleanUp(); + WeakReference weakLock = locks.get(key); + ReentrantReadWriteLock lock = null; + if (weakLock != null) { + lock = weakLock.get(); + } + if (lock == null) { + lock = new ReentrantReadWriteLock(fair); + locks.put(key, new WeakKeyLock(key, lock, refQueue)); + } + + return new KeyLock(key, lock); + } + } + + /** + * Poll weak reference and remove from locks map. Must be externally + * synchronized. + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + private void cleanUp() { + Reference unused = refQueue.poll(); + + while (unused != null) { + if (unused instanceof KeyLocker.WeakKeyLock) { + WeakKeyLock wkl = (KeyLocker.WeakKeyLock) unused; + locks.remove(wkl.key); + } + unused = refQueue.poll(); + } + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.archive/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.archive/META-INF/MANIFEST.MF index dd531b7090..038586a1a9 100644 --- a/edexOsgi/com.raytheon.uf.edex.archive/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.archive/META-INF/MANIFEST.MF @@ -5,13 +5,19 @@ Bundle-SymbolicName: com.raytheon.uf.edex.archive Bundle-Version: 1.0.0.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Export-Package: com.raytheon.uf.edex.archive.purge +Export-Package: com.raytheon.uf.edex.archive, + com.raytheon.uf.edex.archive.purge Import-Package: com.raytheon.uf.common.archive.config, com.raytheon.uf.common.archive.request Require-Bundle: com.raytheon.uf.common.auth;bundle-version="1.12.1174", - com.raytheon.uf.edex.auth;bundle-version="1.12.1174", + com.raytheon.uf.edex.database, + com.raytheon.uf.common.dataplugin, + com.raytheon.uf.common.datastorage, + com.raytheon.uf.common.localization;bundle-version="1.12.1174", com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", com.raytheon.uf.common.status;bundle-version="1.12.1174", com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.uf.common.time, com.raytheon.uf.common.util;bundle-version="1.12.1174", - com.raytheon.uf.common.localization;bundle-version="1.12.1174" + com.raytheon.uf.edex.auth;bundle-version="1.12.1174", + com.raytheon.uf.edex.core diff --git a/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archive-spring.xml b/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archive-spring.xml new file mode 100644 index 0000000000..aa18209389 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archive-spring.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + java.lang.Throwable + + + + + + + + + + + java.lang.Throwable + + + + + + + + + + + + + + + + + java.lang.Throwable + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archivepurger-spring.xml b/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archivepurger-spring.xml deleted file mode 100644 index 8dd6192d7d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archivepurger-spring.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - java.lang.Throwable - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.archive/resources/com.raytheon.uf.edex.archive.cron.properties b/edexOsgi/com.raytheon.uf.edex.archive/resources/com.raytheon.uf.edex.archive.cron.properties index 9b9705e607..5cdaa2a6c6 100644 --- a/edexOsgi/com.raytheon.uf.edex.archive/resources/com.raytheon.uf.edex.archive.cron.properties +++ b/edexOsgi/com.raytheon.uf.edex.archive/resources/com.raytheon.uf.edex.archive.cron.properties @@ -1,6 +1,11 @@ +# enable archive +archive.enable=true # runs database and hdf5 archive for archive server to pull data from archive.cron=0+40+*+*+*+? -# purge archives -archive.purge.cron=0+5+*+*+*+? # enable archive purge -archive.purge.enable=false +archive.purge.enable=true +# purge archives +archive.purge.cron=0+5+0/3+*+*+? + +# to disable a specific archive, use property archive.disable=pluginName,pluginName... +#archive.disable=grid,text,acars \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DataArchiver.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DataArchiver.java new file mode 100644 index 0000000000..73449c929f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DataArchiver.java @@ -0,0 +1,138 @@ +/** + * 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.archive; + +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.edex.core.dataplugin.PluginRegistry; + +/** + * Handles archiving of data. Has two interfaces for registering data archive. + * Data archived based on archiving for each plugin and general data archive + * programs. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 16, 2011            rjpeter     Initial creation
+ * Nov 05, 2013 2499       rjpeter     Repackaged, updated to use System properties.
+ * 
+ * + * @author rjpeter + * @version 1.0 + */ +public class DataArchiver { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(DataArchiver.class); + + // enables/disables archiving as a whole + private final static String ENABLE_PROPERTY = "archive.enable"; + + // allows for disabling of specific plugins if desired + private final static String DISABLE_PROPERTY = "archive.disable"; + + private final boolean ARCHIVING_ENABLED; + + private final Set DISABLED_PLUGINS; + + private final List pluginArchivers = new LinkedList(); + + private final List dataArchivers = new LinkedList(); + + private String archivePath = null; + + public DataArchiver(String archivePath) { + this.archivePath = archivePath; + ARCHIVING_ENABLED = Boolean.getBoolean(ENABLE_PROPERTY); + String disabledPluginList = System.getProperty(DISABLE_PROPERTY); + if (disabledPluginList != null) { + String[] plugins = disabledPluginList.split(","); + DISABLED_PLUGINS = new HashSet(plugins.length); + for (String plugin : plugins) { + DISABLED_PLUGINS.add(plugin.trim()); + } + } else { + DISABLED_PLUGINS = Collections.emptySet(); + } + } + + public void archivePlugins() { + Thread.currentThread().setName("Archiver"); + if (ARCHIVING_ENABLED) { + ITimer timer = TimeUtil.getTimer(); + timer.start(); + statusHandler.info("Archival of plugin data started"); + + // get list of plugins, ordered by plugin + Set availablePlugins = new TreeSet(PluginRegistry + .getInstance().getRegisteredObjects()); + + for (String pluginName : availablePlugins) { + if (DISABLED_PLUGINS.contains(pluginName)) { + statusHandler.info(pluginName + ": Archiving disabled"); + } else { + for (IPluginArchiver pluginArchiver : pluginArchivers) { + pluginArchiver.archivePlugin(pluginName, archivePath); + } + } + } + + timer.stop(); + statusHandler + .info("Archival of plugin data completed. Time to run: " + + TimeUtil.prettyDuration(timer.getElapsedTime())); + } else { + statusHandler.info("Archival of plugin data disabled, exiting"); + } + } + + public Object registerPluginArchiver(IPluginArchiver archiver) { + if (!pluginArchivers.contains(archiver)) { + pluginArchivers.add(archiver); + } else { + statusHandler.warn("Plugin archiver already registered: " + + archiver); + } + + return this; + } + + public Object registerDataArchiver(IDataArchiver archiver) { + if (!dataArchivers.contains(archiver)) { + dataArchivers.add(archiver); + } else { + statusHandler.warn("Data archiver already registered: " + archiver); + } + + return this; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DatabaseArchiver.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DatabaseArchiver.java similarity index 74% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DatabaseArchiver.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DatabaseArchiver.java index 1bf81c34c9..056bc09950 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DatabaseArchiver.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DatabaseArchiver.java @@ -17,16 +17,17 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.maintenance.archive; +package com.raytheon.uf.edex.archive; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; +import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.Writer; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -55,6 +56,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil; 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.time.util.TimeUtil; import com.raytheon.uf.common.util.FileUtil; import com.raytheon.uf.edex.core.dataplugin.PluginRegistry; import com.raytheon.uf.edex.database.DataAccessLayerException; @@ -64,10 +66,9 @@ import com.raytheon.uf.edex.database.cluster.ClusterTask; import com.raytheon.uf.edex.database.cluster.handler.CurrentTimeClusterLockHandler; import com.raytheon.uf.edex.database.plugin.PluginDao; import com.raytheon.uf.edex.database.plugin.PluginFactory; -import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; /** - * TODO Add Description + * This class handles moving processed data to the archiver directory. * *
  * 
@@ -77,7 +78,9 @@ import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig;
  * ------------ ---------- ----------- --------------------------
  * Nov 17, 2011            rjpeter     Initial creation
  * Jan 18, 2013 1469       bkowal      Removed the hdf5 data directory.
- * 
+ * Oct 23, 2013 2478       rferrel     Make date format thread safe.
+ *                                     Add debug information.
+ * Nov 05, 2013 2499       rjpeter     Repackaged, removed config files, always compresses.
  * 
* * @author rjpeter @@ -87,32 +90,48 @@ public class DatabaseArchiver implements IPluginArchiver { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(DatabaseArchiver.class); - private final SimpleDateFormat DATE_FORMAT; + /** Thread safe date format. */ + private static final ThreadLocal TL_DATE_FORMAT = new ThreadLocal() { - // Minimum time increment to archive, note based off of insertTime + @Override + protected SimpleDateFormat initialValue() { + SimpleDateFormat df = new SimpleDateFormat( + "yyyy-MM-dd HH:mm:ss.SSS"); + df.setTimeZone(TimeZone.getTimeZone("GMT")); + return df; + } + }; + + /** Minimum time increment to archive, note based off of insertTime. */ private static final int MIN_DURATION_MILLIS = 1000 * 60 * 30; - // Maximum time increment to archive, note based off of insertTime + /** Maximum time increment to archive, note based off of insertTime. */ private static final int MAX_DURATION_MILLIS = 1000 * 60 * 60; + /** Job's name. */ private static final String TASK_NAME = "DB Archiver"; + /** Cluster time out on lock. */ private static final int CLUSTER_LOCK_TIMEOUT = 60000; + /** Mapping for plug-in formatters. */ private final Map pluginArchiveFormatters; - public DatabaseArchiver() { - DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); + /** When true dump the pdos. */ + private final boolean debugArchiver; + /** + * The constructor. + */ + public DatabaseArchiver() { pluginArchiveFormatters = new HashMap(); pluginArchiveFormatters.put("default", new DefaultPluginArchiveFileNameFormatter()); + debugArchiver = Boolean.getBoolean("archive.debug.enable"); } @Override - public void archivePlugin(String pluginName, String archivePath, - DataArchiveConfig conf) { + public void archivePlugin(String pluginName, String archivePath) { PluginProperties props = PluginRegistry.getInstance() .getRegisteredObject(pluginName); if ((props != null) && (props.getRecord() != null) @@ -121,7 +140,7 @@ public class DatabaseArchiver implements IPluginArchiver { if (recordClass != null) { try { recordClass.asSubclass(PluginDataObject.class); - archivePluginData(pluginName, archivePath, conf); + archivePluginData(pluginName, archivePath); } catch (ClassCastException e) { // not an error, using asSubClass to filter non // PluginDataObjects @@ -131,8 +150,8 @@ public class DatabaseArchiver implements IPluginArchiver { } @SuppressWarnings("rawtypes") - public boolean archivePluginData(String pluginName, String archivePath, - DataArchiveConfig conf) { + public boolean archivePluginData(String pluginName, String archivePath) { + SimpleDateFormat dateFormat = TL_DATE_FORMAT.get(); // set archive time Calendar runTime = Calendar.getInstance(); runTime.setTimeZone(TimeZone.getTimeZone("GMT")); @@ -140,7 +159,7 @@ public class DatabaseArchiver implements IPluginArchiver { // cluster lock, grabbing time of last successful archive CurrentTimeClusterLockHandler lockHandler = new CurrentTimeClusterLockHandler( - CLUSTER_LOCK_TIMEOUT, DATE_FORMAT.format(runTime.getTime()), + CLUSTER_LOCK_TIMEOUT, dateFormat.format(runTime.getTime()), false); ClusterTask ct = ClusterLockUtils.lock(TASK_NAME, pluginName, lockHandler, false); @@ -169,7 +188,7 @@ public class DatabaseArchiver implements IPluginArchiver { Set datastoreFilesToArchive = new HashSet(); startTime = determineStartTime(pluginName, ct.getExtraInfo(), - runTime, dao, conf); + runTime, dao); Calendar endTime = determineEndTime(startTime, runTime); Map> pdoMap = new HashMap>(); @@ -186,7 +205,7 @@ public class DatabaseArchiver implements IPluginArchiver { if ((pdosToSave != null) && !pdosToSave.isEmpty()) { recordCount += savePdoMap(pluginName, archivePath, - pdosToSave, conf.getCompressionEnabled()); + pdosToSave); for (Map.Entry> entry : pdosToSave .entrySet()) { List pdoList = entry.getValue(); @@ -202,8 +221,7 @@ public class DatabaseArchiver implements IPluginArchiver { } if ((pdoMap != null) && !pdoMap.isEmpty()) { - recordCount += savePdoMap(pluginName, archivePath, pdoMap, - conf.getCompressionEnabled()); + recordCount += savePdoMap(pluginName, archivePath, pdoMap); // don't forget to archive the HDF5 for the records that weren't // saved off by the prior while block for (Map.Entry> entry : pdoMap @@ -242,15 +260,11 @@ public class DatabaseArchiver implements IPluginArchiver { try { // data must be older than 30 minutes, and no older than - // hours - // to keep hours need to lookup plugin and see if - // compression - // matches, or embed in configuration the compression - // level on - // archive, but would still need to lookup plugin - ds.copy(outputDir, compRequired, "lastArchived", - 1800000, - conf.getHoursToKeep() * 60000 + 1800000); + // hours to keep hours need to lookup plugin and see if + // compression matches, or embed in configuration the + // compression level on archive, but would still need to + // lookup plugin + ds.copy(outputDir, compRequired, "lastArchived", 0, 0); } catch (StorageException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage()); @@ -261,14 +275,16 @@ public class DatabaseArchiver implements IPluginArchiver { // set last archive time to startTime if (startTime != null) { lockHandler - .setExtraInfo(DATE_FORMAT.format(startTime.getTime())); + .setExtraInfo(dateFormat.format(startTime.getTime())); } if (recordCount > 0) { - statusHandler.info(pluginName + ": successfully archived " - + recordCount + " records in " - + (System.currentTimeMillis() - timimgStartMillis) - + " ms"); + statusHandler.info(pluginName + + ": successfully archived " + + recordCount + + " records in " + + TimeUtil.prettyDuration(System.currentTimeMillis() + - timimgStartMillis)); } else { statusHandler .info(pluginName + ": Found no records to archive"); @@ -277,7 +293,7 @@ public class DatabaseArchiver implements IPluginArchiver { // previous run time needs to be reset if (startTime != null) { lockHandler - .setExtraInfo(DATE_FORMAT.format(startTime.getTime())); + .setExtraInfo(dateFormat.format(startTime.getTime())); } statusHandler.error(pluginName + ": Error occurred archiving data", @@ -294,24 +310,24 @@ public class DatabaseArchiver implements IPluginArchiver { @SuppressWarnings("rawtypes") protected int savePdoMap(String pluginName, String archivePath, - Map> pdoMap, - boolean compressMetadata) throws SerializationException, - IOException { + Map> pdoMap) + throws SerializationException, IOException { int recordsSaved = 0; + StringBuilder path = new StringBuilder(); for (Map.Entry> entry : pdoMap .entrySet()) { - String path = archivePath + File.separator + pluginName - + File.separator + entry.getKey(); - + path.setLength(0); + path.append(archivePath).append(File.separator).append(pluginName) + .append(File.separator).append(entry.getKey()); // remove .h5 - if (path.endsWith(".h5")) { - path = path.substring(0, path.length() - 3); + if (path.lastIndexOf(".h5") == (path.length() - 3)) { + path.setLength(path.length() - 3); } + int pathDebugLength = path.length(); + path.append(".bin.gz"); - path += (compressMetadata ? ".bin.gz" : ".bin"); - - File file = new File(path); + File file = new File(path.toString()); List pdosToSerialize = entry.getValue(); recordsSaved += pdosToSerialize.size(); @@ -322,10 +338,7 @@ public class DatabaseArchiver implements IPluginArchiver { try { // created gzip'd stream - is = (compressMetadata ? new GZIPInputStream( - new FileInputStream(file), 8192) - : new BufferedInputStream( - new FileInputStream(file), 8192)); + is = new GZIPInputStream(new FileInputStream(file), 8192); // transform back for list append @SuppressWarnings("unchecked") @@ -381,11 +394,13 @@ public class DatabaseArchiver implements IPluginArchiver { file.getParentFile().mkdirs(); } + if (debugArchiver) { + String debugRootName = path.substring(0, pathDebugLength); + dumpPdos(pluginName, pdosToSerialize, debugRootName); + } + // created gzip'd stream - os = (compressMetadata ? new GZIPOutputStream( - new FileOutputStream(file), 8192) - : new BufferedOutputStream(new FileOutputStream(file), - 8192)); + os = new GZIPOutputStream(new FileOutputStream(file), 8192); // Thrift serialize pdo list SerializationUtil.transformToThriftUsingStream(pdosToSerialize, @@ -405,15 +420,72 @@ public class DatabaseArchiver implements IPluginArchiver { return recordsSaved; } + /** + * Dump the record information being archived to a file. + */ + @SuppressWarnings("rawtypes") + private void dumpPdos(String pluginName, + List pdosToSerialize, String debugRootName) { + StringBuilder sb = new StringBuilder(debugRootName); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + sb.append("_").append(sdf.format(Calendar.getInstance().getTime())) + .append(".txt"); + File file = new File(sb.toString()); + Writer writer = null; + try { + PersistableDataObject[] pdoArray = pdosToSerialize + .toArray(new PersistableDataObject[0]); + writer = new BufferedWriter(new FileWriter(file)); + statusHandler.info(String.format("Dumping %s records to: %s", + pdoArray.length, file.getAbsolutePath())); + for (int i = 0; i < pdosToSerialize.size(); ++i) { + if (pdoArray[i] instanceof PluginDataObject) { + PluginDataObject pdo = (PluginDataObject) pdoArray[i]; + if (pdo.getId() != 0) { + // otherwise was read from file + writer.write("" + pdo.getId() + ":"); + writer.write(pdo.getDataURI()); + writer.write("\n"); + } + } else { + writer.write(pdoArray[i].toString()); + writer.write("\n"); + } + } + } catch (Exception e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); + } finally { + if (writer != null) { + try { + writer.close(); + } catch (Exception e) { + // Ignore + } + writer = null; + } + } + } + + /** + * Get the plug-in's start time for a query. + * + * @param pluginName + * @param extraInfo + * @param runTime + * @param dao + * @return startTime + * @throws DataAccessLayerException + */ protected Calendar determineStartTime(String pluginName, String extraInfo, - Calendar runTime, PluginDao dao, DataArchiveConfig conf) - throws DataAccessLayerException { + Calendar runTime, PluginDao dao) throws DataAccessLayerException { Calendar startTime = null; + SimpleDateFormat dateFormat = TL_DATE_FORMAT.get(); // get previous run time if ((extraInfo != null) && !extraInfo.isEmpty()) { try { - Date prevDate = DATE_FORMAT.parse(extraInfo); + Date prevDate = dateFormat.parse(extraInfo); // cloning runTime as it already has the correct time zone startTime = (Calendar) runTime.clone(); @@ -447,14 +519,7 @@ public class DatabaseArchiver implements IPluginArchiver { } } - // earliest time based on default retention - Calendar earliestTime = Calendar.getInstance(TimeZone - .getTimeZone("GMT")); - earliestTime - .add(Calendar.HOUR, (-1 * conf.getHoursToKeep().intValue())); - - return (startTime.compareTo(earliestTime) < 0) ? earliestTime - : startTime; + return startTime; } /** @@ -484,6 +549,14 @@ public class DatabaseArchiver implements IPluginArchiver { return endTime; } + /** + * Register archive formatter for a plug-in; and issue a warning if plug-in + * is already registered. + * + * @param pluginName + * @param archiveFormatter + * @return databaseArchiver + */ public Object registerPluginArchiveFormatter(String pluginName, IPluginArchiveFileNameFormatter archiveFormatter) { if (!pluginArchiveFormatters.containsKey(pluginName)) { diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DefaultPluginArchiveFileNameFormatter.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DefaultPluginArchiveFileNameFormatter.java similarity index 98% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DefaultPluginArchiveFileNameFormatter.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DefaultPluginArchiveFileNameFormatter.java index 2cdec811dc..1246c23c10 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DefaultPluginArchiveFileNameFormatter.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DefaultPluginArchiveFileNameFormatter.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.maintenance.archive; +package com.raytheon.uf.edex.archive; import java.io.File; import java.util.Calendar; @@ -51,7 +51,7 @@ import com.raytheon.uf.edex.database.plugin.PluginDao; * Mar 12, 2013 1783 rferrel Replace ArrayList with LinkedList to * remove excess capacity and reduce * time to resize a growing list. - * + * Nov 05, 2013 2499 rjpeter Repackaged * * * @author dgilling diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IDataArchiver.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IDataArchiver.java similarity index 90% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IDataArchiver.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IDataArchiver.java index a922e0d4ee..59a035ffae 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IDataArchiver.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IDataArchiver.java @@ -17,10 +17,10 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.maintenance.archive; +package com.raytheon.uf.edex.archive; /** - * TODO Add Description + * Data Archiver interface * *
  * 
@@ -29,7 +29,7 @@ package com.raytheon.uf.edex.maintenance.archive;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Dec 16, 2011            rjpeter     Initial creation
- * 
+ * Nov 05, 2013 2499       rjpeter     Repackaged
  * 
* * @author rjpeter diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiveFileNameFormatter.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiveFileNameFormatter.java similarity index 93% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiveFileNameFormatter.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiveFileNameFormatter.java index 92d2d47b83..b0e106df98 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiveFileNameFormatter.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiveFileNameFormatter.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.maintenance.archive; +package com.raytheon.uf.edex.archive; import java.util.Calendar; import java.util.List; @@ -28,7 +28,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.plugin.PluginDao; /** - * TODO Add Description + * Interface for archive file name formatters. * *
  * 
@@ -37,7 +37,7 @@ import com.raytheon.uf.edex.database.plugin.PluginDao;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Apr 20, 2012            dgilling     Initial creation
- * 
+ * Nov 05, 2013 2499       rjpeter     Repackaged
  * 
* * @author dgilling @@ -64,6 +64,7 @@ public interface IPluginArchiveFileNameFormatter { * If the DAO is unable to retrieve the records from the * database. */ + @SuppressWarnings("rawtypes") public abstract Map> getPdosByFile( String pluginName, PluginDao dao, Map> pdoMap, diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiver.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiver.java similarity index 87% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiver.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiver.java index 1abd3d7f62..879818b5a6 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiver.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiver.java @@ -17,9 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.maintenance.archive; - -import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; +package com.raytheon.uf.edex.archive; /** * Interface for archiving data based on plugins. @@ -31,7 +29,7 @@ import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 16, 2011 rjpeter Initial creation - * + * Nov 05, 2013 2499 rjpeter Repackaged * * * @author rjpeter @@ -39,6 +37,5 @@ import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; */ public interface IPluginArchiver { - public void archivePlugin(String pluginName, String archivePath, - DataArchiveConfig config); + public void archivePlugin(String pluginName, String archivePath); } diff --git a/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/purge/ArchivePurger.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/purge/ArchivePurger.java index 3802050faa..6af9a95018 100644 --- a/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/purge/ArchivePurger.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/purge/ArchivePurger.java @@ -26,6 +26,8 @@ import com.raytheon.uf.common.archive.config.ArchiveConfigManager; 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.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; /** * Purge task to purge archived data based on configured expiration. @@ -41,7 +43,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * Aug 28, 2013 2299 rferrel manager.purgeExpiredFromArchive now returns * number of files purged. * Sep 03, 2013 2224 rferrel Add check to enable/disable purger. - * + * Nov 05, 2013 2499 rjpeter Repackaged * * * @author bgonzale @@ -58,12 +60,17 @@ public class ArchivePurger { * Purge expired elements from the archives. */ public static void purge() { + Thread.currentThread().setName("Purge-Archive"); String enableString = System.getProperty(ENABLE_PROPERTY, "false"); if (Boolean.parseBoolean(enableString)) { - statusHandler.info("::Archive Purged started."); + ITimer timer = TimeUtil.getTimer(); + timer.start(); + statusHandler.info("Archive Purge started."); ArchiveConfigManager manager = ArchiveConfigManager.getInstance(); Collection archives = manager.getArchives(); for (ArchiveConfig archive : archives) { + ITimer archiveTimer = TimeUtil.getTimer(); + archiveTimer.start(); int purgeCount = manager.purgeExpiredFromArchive(archive); if (statusHandler.isPriorityEnabled(Priority.INFO)) { StringBuilder sb = new StringBuilder(archive.getName()); @@ -73,11 +80,17 @@ public class ArchivePurger { if (purgeCount != 1) { sb.append("s"); } - sb.append("."); + sb.append(" in ") + .append(TimeUtil.prettyDuration(archiveTimer + .getElapsedTime())).append("."); statusHandler.info(sb.toString()); } } - statusHandler.info("::Archive Purged finished."); + statusHandler.info("Archive Purge finished. Time to run: " + + TimeUtil.prettyDuration(timer.getElapsedTime())); + } else { + statusHandler.info("Archive Purge disabled, exiting"); } + } } diff --git a/edexOsgi/com.raytheon.uf.edex.archive/utility/common_static/base/archiver/purger/PROCESSED_DATA.xml b/edexOsgi/com.raytheon.uf.edex.archive/utility/common_static/base/archiver/purger/PROCESSED_DATA.xml index 7b50503a88..a584710db1 100644 --- a/edexOsgi/com.raytheon.uf.edex.archive/utility/common_static/base/archiver/purger/PROCESSED_DATA.xml +++ b/edexOsgi/com.raytheon.uf.edex.archive/utility/common_static/base/archiver/purger/PROCESSED_DATA.xml @@ -25,7 +25,8 @@ * ============ ========== =========== ========================== * Jun 20, 2013 1966 rferrel Initial creation * Aug 05, 2013 2224 rferrel Changes to add dataSet tags. - * Oct 01, 2013 2147 rfrrel Date time stamp no longer requires an hour field. + * Oct 01, 2013 2147 rferrel Date time stamp no longer requires an hour field. + * Nov 05, 2013 2497 rferrel Change root directory. * * @author rferrel * @version 1.0 @@ -129,7 +130,7 @@ --> Processed - /awips2/edex/data/archive/ + /archive/ 24 Decision Assistance diff --git a/edexOsgi/com.raytheon.uf.edex.archive/utility/common_static/base/archiver/purger/RAW_DATA.xml b/edexOsgi/com.raytheon.uf.edex.archive/utility/common_static/base/archiver/purger/RAW_DATA.xml index 5b7eb5cd63..8d24cbb9f2 100644 --- a/edexOsgi/com.raytheon.uf.edex.archive/utility/common_static/base/archiver/purger/RAW_DATA.xml +++ b/edexOsgi/com.raytheon.uf.edex.archive/utility/common_static/base/archiver/purger/RAW_DATA.xml @@ -25,7 +25,7 @@ * ============ ========== =========== ========================== * Jun 20, 2013 1966 rferrel Initial creation * Aug 05, 2013 2224 rferrel Changes to add dataSet tags. - * Oct 01, 2013 2147 rfrrel Date time stamp no longer requires an hour field. + * Oct 01, 2013 2147 rferrel Date time stamp no longer requires an hour field. * * @author rferrel * @version 1.0 diff --git a/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml index 966774685b..6862aaabed 100644 --- a/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml @@ -183,10 +183,4 @@ install-size="0" version="0.0.0"/> - - diff --git a/edexOsgi/com.raytheon.uf.edex.database/res/spring/database-common.xml b/edexOsgi/com.raytheon.uf.edex.database/res/spring/database-common.xml index b1b63a337b..1e235cb53f 100644 --- a/edexOsgi/com.raytheon.uf.edex.database/res/spring/database-common.xml +++ b/edexOsgi/com.raytheon.uf.edex.database/res/spring/database-common.xml @@ -43,6 +43,12 @@ + + + + + + * @@ -126,15 +126,6 @@ public class QlServerRequestHandler implements IRequestHandler } else if (mode.equals("hqlstatement")) { HqlStatementTask task = new HqlStatementTask(query, dbName); result = task.execute(); - } else if (mode.equals("saveOrUpdateObject")) { - SaveOrUpdateTask task = new SaveOrUpdateTask(dbName); - for (String key : map.keySet()) { - String value = map.get(key).getConstraintValue(); - if (key.startsWith("obj")) { - task.addObject(value); - } - } - result = task.execute(); } // instead of placing a single value in an arraylist, just return the 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 e7b6865c95..94db3a77a6 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 @@ -94,6 +94,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * 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}. * Apr 15, 2013 1868 bsteffen Rewrite mergeAll in PluginDao. + * Nov 08, 2013 2361 njensen Changed method signature of saveOrUpdate to take Objects, not PersistableDataObjects * * * @@ -182,7 +183,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 Object obj) { txTemplate.execute(new TransactionCallbackWithoutResult() { @Override public void doInTransactionWithoutResult(TransactionStatus status) { diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/handlers/SaveOrUpdateHandler.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/handlers/SaveOrUpdateHandler.java new file mode 100644 index 0000000000..c5793e3a50 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/handlers/SaveOrUpdateHandler.java @@ -0,0 +1,76 @@ +/** + * 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.handlers; + +import java.util.List; + +import com.raytheon.uf.common.dataquery.requests.SaveOrUpdateRequest; +import com.raytheon.uf.common.serialization.comm.IRequestHandler; +import com.raytheon.uf.edex.database.dao.CoreDao; +import com.raytheon.uf.edex.database.dao.DaoConfig; + +/** + * Handler for a SaveOrUpdateRequest that saves the objects to the specified + * database. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 8, 2013  2361       njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class SaveOrUpdateHandler implements + IRequestHandler { + + @Override + public Object handleRequest(SaveOrUpdateRequest request) throws Exception { + String dbName = request.getDbName(); + if (dbName == null) { + throw new IllegalArgumentException("Database name cannot be null"); + } + + CoreDao dao = new CoreDao(DaoConfig.forDatabase(dbName)); + List objs = request.getObjectsToUpdate(); + + // This was originally written to replace the saveOrUpdate part of + // QlServerRequestHandler. To match that behavior, we're not putting + // try/catch around each call to saveOrUpdate, and we're only returning + // a count of the objects saved/updated. + // TODO contemplate better behavior + int count = 0; + if (objs != null) { + for (Object obj : objs) { + dao.saveOrUpdate(obj); + count++; + } + } + + return count; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/tasks/SaveOrUpdateTask.java b/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/tasks/SaveOrUpdateTask.java deleted file mode 100644 index a58021c27d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.database/src/com/raytheon/uf/edex/database/tasks/SaveOrUpdateTask.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ - -package com.raytheon.uf.edex.database.tasks; - -import java.util.ArrayList; -import java.util.List; - -import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; -import com.raytheon.uf.common.serialization.SerializationUtil; -import com.raytheon.uf.edex.database.dao.CoreDao; -import com.raytheon.uf.edex.database.dao.DaoConfig; - -/** - * Task to execute an insert or update to the database - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 12/11/2008   1777       bphillip    Initial Creation
- * 
- * 
- * - * @author bphillip - * @version 1.0 - */ -public class SaveOrUpdateTask { - - /** The database name to insert into */ - private String dbName; - - /** The marshalled objects * */ - private List marshalledObjects; - - /** - * Creates a new SaveOrUpdateTask object - * - * @param dbName - * The database name - */ - public SaveOrUpdateTask(String dbName) { - this.dbName = dbName; - marshalledObjects = new ArrayList(); - } - - /** - * Adds a marshalled object to the list - * - * @param marshalledObject - * The marshalled object xml - */ - public void addObject(String marshalledObject) { - marshalledObjects.add(marshalledObject); - } - - public Object execute() throws Exception { - - CoreDao dao = new CoreDao(DaoConfig.forDatabase(dbName)); - PersistableDataObject currentObject = null; - for (String xml : marshalledObjects) { - xml = xml.replaceAll("", "\""); - currentObject = (PersistableDataObject) SerializationUtil - .unmarshalFromXml(xml); - dao.saveOrUpdate(currentObject); - } - return marshalledObjects.size(); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/res/spring/bandwidth-datadelivery-edex-impl.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/res/spring/bandwidth-datadelivery-edex-impl.xml index 0d9490c928..acb87b149e 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/res/spring/bandwidth-datadelivery-edex-impl.xml +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/res/spring/bandwidth-datadelivery-edex-impl.xml @@ -28,6 +28,17 @@ + + + + + + + + + @@ -40,18 +51,7 @@ class="com.raytheon.uf.edex.datadelivery.bandwidth.InMemoryBandwidthBucketDao" /> - - - - - - - - - - + diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java index 37cafa8fa2..f298d2cfda 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java @@ -121,9 +121,10 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; * Sep 17, 2013 2383 bgonzale Reverted back to how BandwidthManager. handles * case for no matching dataset metadata for an * adhoc subscription. - * Sept 25, 2013 1797 dhladky separated time from gridded time - * 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc - * Oct 30, 2013 2448 dhladky Moved methods to TimeUtil. + * Sep 25, 2013 1797 dhladky separated time from gridded time + * Oct 23, 2013 2385 bphillip Change schedule method to scheduleAdhoc + * Oct 30, 2013 2448 dhladky Moved methods to TimeUtil. + * Nov 04, 2013 2506 bgonzale Added removeBandwidthSubscriptions method. * * * @author dhladky @@ -647,6 +648,26 @@ public abstract class BandwidthManager return unscheduled; } + /** + * Remove bandwidth subscriptions for the given id. + * + * @param subscriptionId + * the bandwidth subscriptions to remove + */ + protected void removeBandwidthSubscriptions(String subscriptionId) { + statusHandler + .info("Received Subscription removal notification for Subscription [" + + subscriptionId + + "], removing BandwidthSubscriptions."); + // Need to locate and remove all BandwidthReservations for the + // given subscription.. + List l = bandwidthDao + .getBandwidthSubscriptionByRegistryId(subscriptionId); + if (!l.isEmpty()) { + remove(l); + } + } + /** * {@inheritDoc} */ diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java index 767ed19da0..3b506f651d 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java @@ -97,6 +97,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil; * Oct 1 2013 1797 dhladky Time and GriddedTime separation * Oct 10, 2013 1797 bgonzale Refactored registry Time objects. * 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc + * Nov 04, 2013 2506 bgonzale Added removeBandwidthSubscriptions method. * * * @@ -315,13 +316,7 @@ public abstract class EdexBandwidthManager statusHandler .info("Received Subscription removal notification for Subscription [" + event.getId() + "]"); - // Need to locate and remove all BandwidthReservations for the - // given subscription.. - List l = bandwidthDao - .getBandwidthSubscriptionByRegistryId(event.getId()); - if (!l.isEmpty()) { - remove(l); - } + removeBandwidthSubscriptions(event.getId()); } } } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/WfoBandwidthManagerCreator.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/WfoBandwidthManagerCreator.java index 5fa3b32720..02419ac82e 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/WfoBandwidthManagerCreator.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/WfoBandwidthManagerCreator.java @@ -52,6 +52,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil; * May 15, 2013 2000 djohnson Include daos. * Jul 10, 2013 2106 djohnson Dependency inject registry handlers. * Oct 2, 2013 1797 dhladky Generics + * Oct 28, 2013 2506 bgonzale SBN (Shared) Scheduled at the central registry. * * * @@ -110,10 +111,9 @@ public class WfoBandwidthManagerCreator impl .proposeSchedule(subscriptions); // If the NCF bandwidth manager says they fit without - // unscheduling anything, then schedule them at the WFO level to - // track retrievals/graphing + // unscheduling anything, then schedule them at the NCF level if (proposeResponse.getUnscheduledSubscriptions().isEmpty()) { - scheduleSubscriptions(subscriptions); + ncfBandwidthService.schedule(subscriptions); } return proposeResponse; @@ -126,12 +126,9 @@ public class WfoBandwidthManagerCreator impl protected Set scheduleSbnSubscriptions( List> subscriptions) throws SerializationException { - final Set ncfResponse = ncfBandwidthService - .schedule(subscriptions); - scheduleSubscriptions(subscriptions); - - return ncfResponse; + return ncfBandwidthService.schedule(subscriptions); } + } /** diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializer.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializer.java index c10a8e15a5..e1a5a03b53 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializer.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializer.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Set; import com.raytheon.edex.site.SiteUtil; +import com.raytheon.uf.common.datadelivery.registry.SharedSubscription; import com.raytheon.uf.common.datadelivery.registry.Subscription; import com.raytheon.uf.common.registry.ebxml.RegistryUtil; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -34,6 +35,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager; * Sep 05, 2013 2330 bgonzale On WFO registry init, only subscribe to local site subscriptions. * Sep 06, 2013 2344 bgonzale Removed attempt to add to immutable empty set. * Oct 16, 2013 2267 bgonzale executeAfterRegistryInit subscribes to all local. Removed is shared checks. + * Nov 04, 2013 2506 bgonzale added site field. facilitates testing. * * * @@ -47,6 +49,8 @@ public class HibernateBandwidthInitializer implements BandwidthInitializer { private final IFindSubscriptionsForScheduling findSubscriptionsStrategy; + private final String site; + private IBandwidthManager instance; /** @@ -54,7 +58,18 @@ public class HibernateBandwidthInitializer implements BandwidthInitializer { */ public HibernateBandwidthInitializer( IFindSubscriptionsForScheduling findSubscriptionsStrategy) { + this(findSubscriptionsStrategy, SiteUtil.getSite()); + } + + /** + * @param string + * @param strategy + */ + HibernateBandwidthInitializer( + IFindSubscriptionsForScheduling findSubscriptionsStrategy, + String site) { this.findSubscriptionsStrategy = findSubscriptionsStrategy; + this.site = site; } @Override @@ -87,20 +102,24 @@ public class HibernateBandwidthInitializer implements BandwidthInitializer { Set activeSubscriptions = new HashSet(); try { final String localOffice = SiteUtil.getSite(); + final boolean isRegistry = System.getProperty("edex.run.mode") + .equals("registry"); + final boolean isCentralRegistry = System.getProperty( + "edex.run.mode").equals("centralRegistry"); // Load active subscriptions for (Subscription sub : findSubscriptionsStrategy .findSubscriptionsToSchedule()) { + boolean isShared = (sub instanceof SharedSubscription); boolean isLocalOffice = sub.getOfficeIDs() .contains(localOffice); - if (isLocalOffice) { + if ((isCentralRegistry && isShared) + || (isRegistry && isLocalOffice && !isShared)) { activeSubscriptions.add(sub); statusHandler.info("Scheduling Subscription: " + sub); } else { - statusHandler - .info("Not Scheduling Non-local Subscription: " - + sub); + statusHandler.info("Not Scheduling Subscription: " + sub); } } } catch (Exception e) { diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.core.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.core.feature/feature.xml index ca1e5bb24a..a1946d64c8 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.core.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.core.feature/feature.xml @@ -53,13 +53,6 @@ version="0.0.0" unpack="false"/> - - - + + + + + @@ -42,6 +46,7 @@ + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.registry/src/com/raytheon/uf/edex/datadelivery/registry/web/RegistryDataAccessService.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.registry/src/com/raytheon/uf/edex/datadelivery/registry/web/RegistryDataAccessService.java index facfc8c8ca..ff1c5e77a9 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.registry/src/com/raytheon/uf/edex/datadelivery/registry/web/RegistryDataAccessService.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.registry/src/com/raytheon/uf/edex/datadelivery/registry/web/RegistryDataAccessService.java @@ -50,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional; import com.raytheon.uf.common.datadelivery.registry.web.IRegistryDataAccessService; import com.raytheon.uf.common.registry.RegistryException; +import com.raytheon.uf.common.registry.constants.CanonicalQueryTypes; import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse; import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -60,6 +61,7 @@ import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.registry.ebxml.dao.QueryDefinitionDao; import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao; +import com.raytheon.uf.edex.registry.ebxml.services.query.RegistryQueryUtil; /** * @@ -75,6 +77,7 @@ import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao; * 9/20/2013 2385 bphillip Added subscription backup functions * 10/2/2013 2385 bphillip Fixed subscription backup queries * 10/8/2013 1682 bphillip Added query queries + * 11/7/2013 1678 bphillip Added getCustomQueries method * * * @author bphillip @@ -147,6 +150,15 @@ public class RegistryDataAccessService implements IRegistryDataAccessService { return builder.toString(); } + @Override + @GET + @Path("getCustomQueries") + public String getCustomQueries() { + List ids = queryDefinitionDao.getQueryIds(); + ids.removeAll(CanonicalQueryTypes.CANONICAL_QUERY_TYPES); + return RegistryQueryUtil.formatArrayString(ids.toArray()); + } + @Override @GET @Path("getParametersForQuery/{queryId}") diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.registry/src/com/raytheon/uf/edex/datadelivery/registry/web/RegistryQueryDefinitionService.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.registry/src/com/raytheon/uf/edex/datadelivery/registry/web/RegistryQueryDefinitionService.java new file mode 100644 index 0000000000..58180a4510 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.registry/src/com/raytheon/uf/edex/datadelivery/registry/web/RegistryQueryDefinitionService.java @@ -0,0 +1,201 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.datadelivery.registry.web; + +import java.math.BigInteger; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.InternationalStringType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ParameterType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryDefinitionType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringQueryExpressionType; + +import org.springframework.transaction.annotation.Transactional; + +import com.raytheon.uf.common.registry.constants.CanonicalQueryTypes; +import com.raytheon.uf.common.registry.constants.RegistryObjectTypes; +import com.raytheon.uf.common.registry.constants.StatusTypes; +import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao; +import com.raytheon.uf.edex.registry.ebxml.services.query.RegistryQueryUtil; +import com.raytheon.uf.edex.registry.ebxml.services.query.RegistryQueryUtil.PARAMETER_DATA_TYPE; + +/** + * + * REST Services used to manage registry query definitions + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * 11/7/2013     1678       bphillip    Initial Creation
+ * 
+ * + * @author bphillip + * @version 1 + **/ +@Path(RegistryQueryDefinitionService.REGISTRY_DEFINE_QUERY_PATH) +@Transactional +public class RegistryQueryDefinitionService { + + /** The path to this set of services */ + protected static final String REGISTRY_DEFINE_QUERY_PATH = "/defineQuery/"; + + /** Data access object for registry objects */ + private RegistryObjectDao registryObjectDao; + + /** + * Gets the valid data types for query parameters + * + * @return The valid parameter data types + */ + @GET + @Path("getParameterDataTypes") + public String getParameterDataTypes() { + return RegistryQueryUtil + .formatArrayString(PARAMETER_DATA_TYPE.values()); + } + + /** + * Gets the valid query languages + * + * @return The valid query languages + */ + @GET + @Path("getQueryLanguages") + public String getQueryLanguages() { + return RegistryQueryUtil + .formatArrayString(registryObjectDao + .executeHQLQuery( + "SELECT obj.code FROM ClassificationNodeType obj where id like 'urn:oasis:names:tc:ebxml-regrep:QueryLanguage:%'") + .toArray()); + } + + /** + * Stores the query definition to the registry + * + * @param params + * The query definition tokens + * @return The status message + */ + @GET + @Path("storeQuery/{params}") + public String storeQuery(@PathParam("params") String params) { + StringBuilder response = new StringBuilder(); + QueryDefinitionType queryDef = new QueryDefinitionType(); + String[] tokens = params.split(",", -1); + if (tokens.length < 4) { + throw new IllegalArgumentException( + "Argument to storeQuery must contain at least 4 comma delimited tokens!"); + } + for (int i = 0; i < tokens.length; i++) { + tokens[i] = tokens[i].trim(); + } + String queryName = tokens[0]; + String queryDescription = tokens[1]; + String queryLangCode = tokens[2]; + String queryExpression = tokens[3]; + queryDef.setId(queryName); + queryDef.setLid(queryName); + queryDef.setName(new InternationalStringType(queryName)); + queryDef.setDescription(new InternationalStringType(queryDescription)); + queryDef.setObjectType(RegistryObjectTypes.QUERY_DEFINITION); + queryDef.setStatus(StatusTypes.APPROVED); + if (!queryExpression.isEmpty()) { + StringQueryExpressionType expr = new StringQueryExpressionType(); + String queryLanguage = (String) registryObjectDao + .executeHQLQuery( + "SELECT id FROM ClassificationNodeType obj where obj.code=:code", + "code", queryLangCode).get(0); + expr.setQueryLanguage(queryLanguage); + expr.setValue(queryExpression); + queryDef.setQueryExpression(expr); + } + for (int i = 4; i < tokens.length && !tokens[4].isEmpty(); i += 6) { + if ((i + 5) >= tokens.length) { + throw new IllegalArgumentException( + "Incomplete parameter submitted to storeQuery!"); + } + ParameterType param = new ParameterType(); + param.setParameterName(tokens[i]); + param.setName(new InternationalStringType(tokens[i])); + if (!tokens[i + 1].isEmpty()) { + param.setDescription(new InternationalStringType(tokens[i + 1])); + } + if (!tokens[i + 2].isEmpty()) { + param.setDataType(tokens[i + 2]); + } + if (!tokens[i + 3].isEmpty()) { + param.setDefaultValue(tokens[i + 3]); + } + if (!tokens[i + 4].isEmpty()) { + param.setMinOccurs(new BigInteger(tokens[i + 4])); + } + if (!tokens[i + 5].isEmpty()) { + param.setMaxOccurs(new BigInteger(tokens[i + 5])); + } + queryDef.getParameter().add(param); + } + registryObjectDao.createOrUpdate(queryDef); + + response.append("Successfully created Query Definition: ").append( + queryDef.getId()); + return response.toString(); + } + + /** + * Deletes the selected query from the registry + * + * @param queryId + * The ID of the query to delete from the registry + * @return Status message whether the query was deleted + */ + @GET + @Path("deleteQuery/{queryId}") + public String deleteQuery(@PathParam("queryId") String queryId) { + + if (queryId == null || queryId.isEmpty()) { + return "A query id must be specified"; + } + + // Check to make sure we're not trying to delete a canonical query + if (CanonicalQueryTypes.CANONICAL_QUERY_TYPES.contains(queryId)) { + return "Cannot delete canonical query!"; + } + RegistryObjectType queryObj = registryObjectDao.getById(queryId); + if (queryObj == null) { + return "Query Definition [" + queryId + + "] not present in registry!"; + } + + registryObjectDao.delete(queryObj); + return "Successfully deleted query: " + queryId; + } + + public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) { + this.registryObjectDao = registryObjectDao; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/res/spring/retrieval-datadelivery-ncf.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/res/spring/retrieval-datadelivery-ncf.xml index 941a078a81..13bf3fbd9a 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/res/spring/retrieval-datadelivery-ncf.xml +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/res/spring/retrieval-datadelivery-ncf.xml @@ -30,13 +30,16 @@ + - - + + + + + - - @@ -54,13 +53,9 @@ - - - - + - * @@ -62,6 +67,7 @@ public class DeserializeRetrievedDataFromIngest implements IRetrievalsFinder { this.retrievalQueue = retrievalQueue; try { this.jaxbManager = new JAXBManager(RetrievalResponseXml.class, + SbnRetrievalResponseXml.class, OpenDapRetrievalResponse.class, WfsRetrievalResponse.class, Coverage.class); } catch (JAXBException e) { @@ -80,9 +86,9 @@ public class DeserializeRetrievedDataFromIngest implements IRetrievalsFinder { if (xml == null) { return null; } else { - WMOMessage message = new WMOMessage(xml, new Headers()); - return (RetrievalResponseXml) jaxbManager - .unmarshalFromXml(new String(message.getMessageBody())); + WMOMessage message = new XmlWMOMessage(xml, new Headers()); + return (RetrievalResponseXml) jaxbManager.unmarshalFromXml(message + .getBodyText()); } } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/IRetrievalPluginDataObjectsProcessor.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/IRetrievalPluginDataObjectsProcessor.java index babc4e0bcd..e8ad302a24 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/IRetrievalPluginDataObjectsProcessor.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/IRetrievalPluginDataObjectsProcessor.java @@ -34,7 +34,8 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord; * ------------ ---------- ----------- -------------------------- * Feb 01, 2013 1543 djohnson Initial creation * Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects. - * Oct 01, 2013 2267 bgonzale Pass request parameter instead of components of request. + * Oct 01, 2013 2267 bgonzale Removed request parameter. Return associated + * RetrievalRequestRecord. * * * @@ -48,15 +49,15 @@ public interface IRetrievalPluginDataObjectsProcessor { * Process plugin data objects that were created as a result of a data * delivery retrieval request. * - * @param request - * the request * @param retrievalPluginDataObjects * the retrieval plugin data objects + * @return the RetrievalRequestRecord associated with the processed + * retrievals * @throws SerializationException * on error with serialization * @throws TranslationException */ - void processRetrievedPluginDataObjects(RetrievalRequestRecord request, + RetrievalRequestRecord processRetrievedPluginDataObjects( RetrievalResponseXml retrievalPluginDataObjects) throws SerializationException, TranslationException; } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalResponseXml.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalResponseXml.java index 937a9c4bf5..ce03167d31 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalResponseXml.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalResponseXml.java @@ -42,6 +42,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecordPK; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Feb 01, 2013 1543 djohnson Initial creation + * Nov 04, 2013 2506 bgonzale Added constructor. * * * @@ -71,6 +72,15 @@ public class RetrievalResponseXml { public RetrievalResponseXml() { } + /** + * Constructor. + */ + public RetrievalResponseXml(RetrievalResponseXml other) { + this.requestRecord = other.requestRecord; + this.retrievalAttributePluginDataObjects = other.retrievalAttributePluginDataObjects; + this.success = other.success; + } + /** * Constructor. * diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTask.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTask.java index e2271ab5e8..b576bf98d4 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTask.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTask.java @@ -23,7 +23,6 @@ import com.raytheon.uf.common.datadelivery.registry.Network; 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.datadelivery.retrieval.db.IRetrievalDao; import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord; /** @@ -43,7 +42,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord; * Feb 15, 2013 1543 djohnson Using xml for retrievals now. * Mar 05, 2013 1647 djohnson Change no retrievals found message to debug. * Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects. - * Oct 01, 2013 2267 bgonzale Pass request parameter instead of components of request. + * Oct 01, 2013 2267 bgonzale Removed request parameter and IRetrievalDao field. * * * @@ -63,18 +62,15 @@ public class RetrievalTask implements Runnable { private final IRetrievalsFinder retrievalDataFinder; - private final IRetrievalDao retrievalDao; public RetrievalTask(Network network, IRetrievalsFinder retrievalDataFinder, IRetrievalPluginDataObjectsProcessor retrievedDataProcessor, - IRetrievalResponseCompleter retrievalCompleter, - IRetrievalDao retrievalDao) { + IRetrievalResponseCompleter retrievalCompleter) { this.network = network; this.retrievalDataFinder = retrievalDataFinder; this.retrievedDataProcessor = retrievedDataProcessor; this.retrievalCompleter = retrievalCompleter; - this.retrievalDao = retrievalDao; } @Override @@ -99,11 +95,9 @@ public class RetrievalTask implements Runnable { return; } - request = retrievalDao.getById(retrievalPluginDataObject - .getRequestRecord()); success = retrievalPluginDataObject.isSuccess(); - retrievedDataProcessor.processRetrievedPluginDataObjects( - request, retrievalPluginDataObject); + request = retrievedDataProcessor + .processRetrievedPluginDataObjects(retrievalPluginDataObject); } catch (Exception e) { statusHandler.error( network + " retrieval processing error", e); diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SbnRetrievalResponseXml.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SbnRetrievalResponseXml.java new file mode 100644 index 0000000000..7fe3a479ca --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SbnRetrievalResponseXml.java @@ -0,0 +1,106 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.datadelivery.retrieval.handlers; + +import java.util.List; + +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.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord; +import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecordPK; + +/** + * Associates plugin data objects with their retrieval request. Specifically for + * SBN retrievals passed to clients from the central registry. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 28, 2013 2506       bgonzale     Initial creation
+ * 
+ * 
+ * + * @author bgonzale + * @version 1.0 + */ +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +@DynamicSerialize +public class SbnRetrievalResponseXml extends RetrievalResponseXml { + + @XmlElement + @DynamicSerializeElement + private RetrievalRequestRecord retrievalRequestRecord; + + /** + * Constructor. + */ + public SbnRetrievalResponseXml() { + } + + /** + * Constructor. + * + * @param requestRecord + * @param retrievalAttributePluginDataObjects + */ + public SbnRetrievalResponseXml(RetrievalRequestRecordPK requestRecord, + List retrievalAttributePluginDataObjects, + RetrievalRequestRecord retrievalRequestRecord) { + super(requestRecord, retrievalAttributePluginDataObjects); + this.retrievalRequestRecord = retrievalRequestRecord; + } + + /** + * Constructor + * + * @param request + * @param retrievalPluginDataObjects + */ + SbnRetrievalResponseXml(RetrievalRequestRecord request, + RetrievalResponseXml retrievalPluginDataObjects) { + super(retrievalPluginDataObjects); + this.retrievalRequestRecord = request; + } + + /** + * @return the retrievalRequestRecord + */ + public RetrievalRequestRecord getRetrievalRequestRecord() { + return retrievalRequestRecord; + } + + /** + * @param retrievalRequestRecord + * the retrievalRequestRecord to set + */ + public void setRetrieval(RetrievalRequestRecord retrievalRequestRecord) { + this.retrievalRequestRecord = retrievalRequestRecord; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SerializeRetrievedDataToDirectory.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SerializeRetrievedDataToDirectory.java index c6912ea3c1..cc1fb6868f 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SerializeRetrievedDataToDirectory.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SerializeRetrievedDataToDirectory.java @@ -30,6 +30,7 @@ import com.raytheon.uf.common.datadelivery.registry.Coverage; import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.util.FileUtil; +import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao; import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord; import com.raytheon.uf.edex.datadelivery.retrieval.opendap.OpenDapRetrievalResponse; import com.raytheon.uf.edex.datadelivery.retrieval.wfs.WfsRetrievalResponse; @@ -48,7 +49,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.wfs.WfsRetrievalResponse; * Mar 05, 2013 1647 djohnson Apply WMO header. * Mar 07, 2013 1647 djohnson Write out as hidden file, then rename. * Aug 09, 2013 1822 bgonzale Added parameters to IWmoHeaderApplier.applyWmoHeader(). - * Oct 01, 2013 2267 bgonzale Pass request parameter instead of components of request. + * Oct 28, 2013 2506 bgonzale Removed request parameters. Constructor inject IRetrievalDao. * * * @@ -64,15 +65,19 @@ public class SerializeRetrievedDataToDirectory implements private final IWmoHeaderApplier wmoHeaderWrapper; + private final IRetrievalDao retrievalDao; + /** * @param directory */ public SerializeRetrievedDataToDirectory(File directory, - IWmoHeaderApplier wmoHeaderWrapper) { + IWmoHeaderApplier wmoHeaderWrapper, IRetrievalDao retrievalDao) { this.targetDirectory = directory; this.wmoHeaderWrapper = wmoHeaderWrapper; + this.retrievalDao = retrievalDao; try { this.jaxbManager = new JAXBManager(RetrievalResponseXml.class, + SbnRetrievalResponseXml.class, OpenDapRetrievalResponse.class, WfsRetrievalResponse.class, Coverage.class); } catch (JAXBException e) { @@ -82,10 +87,12 @@ public class SerializeRetrievedDataToDirectory implements /** * {@inheritDoc} + * + * @return the RetrievalRequestRecord associated with the response + * processing. */ @Override - public void processRetrievedPluginDataObjects( - RetrievalRequestRecord request, + public RetrievalRequestRecord processRetrievedPluginDataObjects( RetrievalResponseXml retrievalPluginDataObjects) throws SerializationException { retrievalPluginDataObjects.prepareForSerialization(); @@ -96,8 +103,11 @@ public class SerializeRetrievedDataToDirectory implements final File tempHiddenFile = new File(finalFile.getParentFile(), "." + finalFile.getName()); + final RetrievalRequestRecord request = retrievalDao + .getById(retrievalPluginDataObjects.getRequestRecord()); final String xml = jaxbManager - .marshalToXml(retrievalPluginDataObjects); + .marshalToXml(new SbnRetrievalResponseXml(request, + retrievalPluginDataObjects)); final Date date = request.getInsertTime(); final String textForFile = wmoHeaderWrapper .applyWmoHeader(request.getProvider(), request.getPlugin(), @@ -113,6 +123,7 @@ public class SerializeRetrievedDataToDirectory implements + tempHiddenFile.getAbsolutePath() + "] to [" + finalFile.getAbsolutePath() + "]"); } + return request; } catch (Exception e) { throw new SerializationException(e); } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/StoreRetrievedData.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/StoreRetrievedData.java index d21f25ecac..6da12f309f 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/StoreRetrievedData.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/handlers/StoreRetrievedData.java @@ -62,7 +62,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.util.RetrievalPersistUtil; * Feb 15, 2013 1543 djohnson Retrieve the retrieval attributes from the database. * Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects. * Aug 06, 2013 1654 bgonzale Added AdhocDataRetrievalEvent. - * Oct 01, 2013 2267 bgonzale Pass request parameter instead of components of request. + * Oct 01, 2013 2267 bgonzale Removed request parameter. Return RetrievalRequestRecord. * * * @@ -95,19 +95,25 @@ public class StoreRetrievedData implements IRetrievalPluginDataObjectsProcessor * {@inheritDoc} */ @Override - public void processRetrievedPluginDataObjects( - RetrievalRequestRecord request, + public RetrievalRequestRecord processRetrievedPluginDataObjects( RetrievalResponseXml retrievalPluginDataObjects) throws SerializationException, TranslationException { Map pluginDataObjects = Maps.newHashMap(); final RetrievalRequestRecordPK id = retrievalPluginDataObjects .getRequestRecord(); - final RetrievalRequestRecord requestRecord = retrievalDao.getById(id); + RetrievalRequestRecord requestRecord = null; + + if (retrievalPluginDataObjects instanceof SbnRetrievalResponseXml) { + requestRecord = ((SbnRetrievalResponseXml) retrievalPluginDataObjects) + .getRetrievalRequestRecord(); + } else { + requestRecord = retrievalDao.getById(id); + } if (requestRecord == null) { - statusHandler.warn("Unable to find retrieval by id [" + id - + "]! Retrieval will not be processed..."); - return; + throw new SerializationException( + "Invalid or missing retrieval found for Response id [" + id + + " ] XML from Central Registry"); } final List retrievalAttributePluginDataObjects = retrievalPluginDataObjects @@ -180,17 +186,17 @@ public class StoreRetrievedData implements IRetrievalPluginDataObjectsProcessor EventBus.publish(event); - sendToDestinationForStorage(requestRecord, records); + sendToDestinationForStorage(records); } } + return requestRecord; } /** * Sends the plugin data objects to their configured destination for storage * to the database. */ - public void sendToDestinationForStorage( - RetrievalRequestRecord requestRecord, PluginDataObject[] pdos) { + private void sendToDestinationForStorage(PluginDataObject[] pdos) { String pluginName = pdos[0].getPluginName(); if (pluginName != null) { diff --git a/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/wmo/message/WMOMessage.java b/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/wmo/message/WMOMessage.java index 42018bc804..751f31b06f 100644 --- a/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/wmo/message/WMOMessage.java +++ b/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/wmo/message/WMOMessage.java @@ -33,6 +33,7 @@ import com.raytheon.edex.esb.Headers; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 14, 2009 jkorman Initial creation + * Nov 08, 2013 2506 bgonzale Setting messageBody is done only through setter method. * * * @@ -67,9 +68,6 @@ public class WMOMessage implements Serializable { */ public WMOMessage(String wmoMessage, Headers headers) { this(wmoMessage.getBytes(), headers); - if (messageBody != null) { - bodyText = new String(messageBody); - } } /** @@ -84,9 +82,10 @@ public class WMOMessage implements Serializable { wmoHeader = header; int bodyLen = wmoMessage.length - header.getMessageDataStart(); - messageBody = new byte[bodyLen]; + byte[] messageBodyData = new byte[bodyLen]; System.arraycopy(wmoMessage, header.getMessageDataStart(), - messageBody, 0, bodyLen); + messageBodyData, 0, bodyLen); + setMessageBody(messageBodyData); } } } @@ -267,7 +266,7 @@ public class WMOMessage implements Serializable { } /** - * The the binary data that comprises the body of this message. + * Get the binary data that comprises the body of this message. * * @return The binary data. */ @@ -276,7 +275,7 @@ public class WMOMessage implements Serializable { } /** - * The the binary data that comprises the body of this message. + * Set the binary data that comprises the body of this message. * * @return The binary data. */ diff --git a/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/wmo/message/XmlWMOMessage.java b/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/wmo/message/XmlWMOMessage.java new file mode 100644 index 0000000000..9a26c656cb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.decodertools/src/com/raytheon/uf/edex/wmo/message/XmlWMOMessage.java @@ -0,0 +1,91 @@ +/** + * 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.wmo.message; + +import java.util.Arrays; + +import com.raytheon.edex.esb.Headers; + +/** + * WMOMessage that handles XML. Specifically, removes data trailing the ending + * XML tag. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 8, 2013  2506       bgonzale     Initial creation
+ * 
+ * 
+ * + * @author bgonzale + * @version 1.0 + */ + +public class XmlWMOMessage extends WMOMessage { + + /** + * Default Constructor. + */ + public XmlWMOMessage() { + } + + /** + * @param wmoMessage + * @param headers + */ + public XmlWMOMessage(String wmoMessage, Headers headers) { + super(wmoMessage, headers); + } + + /** + * @param wmoMessage + * @param headers + */ + public XmlWMOMessage(byte[] wmoMessage, Headers headers) { + super(wmoMessage, headers); + } + + /** + * Set the binary data that comprises the body of this message. + * + * @return The binary data. + */ + public void setMessageBody(byte[] binaryData) { + super.setMessageBody(getMessageBodyXML(binaryData)); + } + + private byte[] getMessageBodyXML(byte[] messageBody) { + // assumes last '>' is a part of the last xml tag + final char LAST_XML_CHARACTER = '>'; + int lastIndex = messageBody.length; + + for (int i = messageBody.length - 1; i > -1; --i) { + if (messageBody[i] == LAST_XML_CHARACTER) { + lastIndex = i + 1; + break; + } + } + return Arrays.copyOf(messageBody, lastIndex); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-request.xml b/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-request.xml index 4c6ca44914..76d83f239f 100644 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-request.xml +++ b/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-request.xml @@ -43,7 +43,7 @@ java.lang.Throwable + uri="log:manual?level=ERROR&showBody=true" /> diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/MANIFEST.MF index 7be9583144..cb074f7ac8 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/MANIFEST.MF @@ -5,22 +5,11 @@ Bundle-SymbolicName: com.raytheon.uf.edex.maintenance Bundle-Version: 1.0.0.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Import-Package: com.raytheon.uf.common.dataplugin, - com.raytheon.uf.common.dataplugin.persist, - com.raytheon.uf.common.dataquery.db, +Require-Bundle: com.raytheon.uf.common.dataplugin, com.raytheon.uf.common.datastorage, - com.raytheon.uf.common.localization, com.raytheon.uf.common.serialization, com.raytheon.uf.common.status, - com.raytheon.uf.common.time, com.raytheon.uf.common.util, - com.raytheon.uf.common.util.registry, - com.raytheon.uf.edex.core.dataplugin, - com.raytheon.uf.edex.core.props, - com.raytheon.uf.edex.database, - com.raytheon.uf.edex.database.cluster, - com.raytheon.uf.edex.database.cluster.handler, - com.raytheon.uf.edex.database.plugin, - com.raytheon.uf.edex.pointdata, - org.springframework.orm.hibernate3.support -Export-Package: com.raytheon.uf.edex.maintenance.archive + com.raytheon.uf.edex.core, + com.raytheon.uf.edex.pointdata + diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 708c60ff8c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/res/spring/maintenance-ingest.xml b/edexOsgi/com.raytheon.uf.edex.maintenance/res/spring/maintenance-ingest.xml index 65ed950ef8..a4e1376efa 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/res/spring/maintenance-ingest.xml +++ b/edexOsgi/com.raytheon.uf.edex.maintenance/res/spring/maintenance-ingest.xml @@ -8,32 +8,10 @@ - - - - - + - - - - - - - - - - - - - - - + @@ -47,23 +25,5 @@ - - - - - - - - java.lang.Throwable - - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataArchiver.java b/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataArchiver.java deleted file mode 100644 index 991d6a98e2..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataArchiver.java +++ /dev/null @@ -1,232 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.maintenance.archive; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; -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.serialization.SerializationUtil; -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.dataplugin.PluginRegistry; -import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; - -/** - * Handles archiving of data. Has two interfaces for registering data archive. - * Data archived based on archiving for each plugin and general data archive - * programs. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Dec 16, 2011            rjpeter     Initial creation
- * 
- * 
- * - * @author rjpeter - * @version 1.0 - */ -public class DataArchiver { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(DataArchiver.class); - - private List pluginArchivers = new ArrayList(); - - private List dataArchivers = new ArrayList(); - - private String archivePath = null; - - private String defaultPlugin = "default"; - - private String configDir = "archiver"; - - public DataArchiver(String archivePath) { - this.archivePath = archivePath; - } - - public void archivePlugins() { - statusHandler.info("Archival of plugin data starting"); - - // get list of plugins, ordered by plugin - Set availablePlugins = new TreeSet(PluginRegistry - .getInstance().getRegisteredObjects()); - - Map configs = getDataArchiveConfigs(); - DataArchiveConfig defaultConf = configs.get(defaultPlugin); - File baseArchive = new File(archivePath); - - for (String pluginName : availablePlugins) { - DataArchiveConfig conf = configs.get(pluginName); - if (conf == null) { - conf = defaultConf; - } - - if (Boolean.TRUE.equals(conf.getArchivingEnabled())) { - for (IPluginArchiver pluginArchiver : pluginArchivers) { - pluginArchiver.archivePlugin(pluginName, archivePath, conf); - } - } - } - - statusHandler.info("Archival of plugin data complete"); - } - - public Object registerPluginArchiver(IPluginArchiver archiver) { - if (!pluginArchivers.contains(archiver)) { - pluginArchivers.add(archiver); - } else { - statusHandler.warn("Plugin archiver already registered: " - + archiver); - } - - return this; - } - - public Object registerDataArchiver(IDataArchiver archiver) { - if (!dataArchivers.contains(archiver)) { - dataArchivers.add(archiver); - } else { - statusHandler.warn("Data archiver already registered: " + archiver); - } - - return this; - } - - private Map getDataArchiveConfigs() { - Map configs = new HashMap(); - IPathManager pathMgr = PathManagerFactory.getPathManager(); - // process in reverse order so BASE is processed before CONFIGURED - // before SITE - List contexts = Arrays.asList(pathMgr - .getLocalSearchHierarchy(LocalizationType.COMMON_STATIC)); - Collections.reverse(contexts); - String[] extensions = new String[] { "xml" }; - for (LocalizationContext ctx : contexts) { - statusHandler.info("Loading context: " + ctx); - LocalizationFile[] lfs = pathMgr.listFiles(ctx, configDir, - extensions, false, true); - if (lfs != null && lfs.length > 0) { - for (LocalizationFile lf : lfs) { - String fileName = lf.getName(); - try { - File f = lf.getFile(true); - fileName = f.getAbsolutePath(); - Object obj = SerializationUtil - .jaxbUnmarshalFromXmlFile(f); - if (obj instanceof DataArchiveConfig) { - DataArchiveConfig conf = (DataArchiveConfig) obj; - String plugin = conf.getPluginName(); - if (plugin != null) { - plugin = plugin.trim(); - if (!plugin.isEmpty()) { - configs.put(plugin, conf); - } else { - throw new Exception( - "Configuration file does not specify pluginName"); - } - } else { - throw new Exception( - "Configuration file does not specify pluginName"); - } - } else { - throw new Exception( - "File in wrong format, expected " - + DataArchiveConfig.class - + ", found " + obj.getClass()); - } - } catch (Throwable e) { - statusHandler.error( - "Failed to load archive configuration file: " - + fileName, e); - } - } - } - } - - DataArchiveConfig defaultConf = configs.get(defaultPlugin); - if (defaultConf == null) { - // default plugin didn't load from disk, force a default config - statusHandler - .warn("Failed to find default configuration, using internal defaults"); - defaultConf = new DataArchiveConfig(); - defaultConf.setPluginName(defaultPlugin); - configs.put(defaultPlugin, defaultConf); - } - - if (!defaultConf.isArchivingEnabledSet()) { - defaultConf.setArchivingEnabled(Boolean.TRUE); - } - - if (!defaultConf.isCompressionEnabledSet()) { - defaultConf.setCompressionEnabled(Boolean.TRUE); - } - - if (!defaultConf.isHoursToKeepSet()) { - defaultConf.setHoursToKeep(6); - } - - // override unset fields with default - for (DataArchiveConfig pluginConf : configs.values()) { - if (pluginConf.getPluginName().equals(defaultPlugin)) { - // skip default conf - continue; - } - - if (!pluginConf.isArchivingEnabledSet()) { - pluginConf.setArchivingEnabled(defaultConf - .getArchivingEnabled()); - } - - if (!pluginConf.isCompressionEnabledSet()) { - pluginConf.setCompressionEnabled(defaultConf - .getArchivingEnabled()); - } - - if (!pluginConf.isHoursToKeepSet()) { - pluginConf.setHoursToKeep(defaultConf.getHoursToKeep()); - } - } - - try { - statusHandler.info("DefaultConfiguration:\n" - + SerializationUtil.marshalToXml(defaultConf)); - } catch (Exception e) { - statusHandler.handle(Priority.WARN, "Failed to deserialize config", - e); - } - return configs; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataStoreArchiver.java b/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataStoreArchiver.java deleted file mode 100644 index ba7ea799da..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataStoreArchiver.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.maintenance.archive; - -import java.io.File; - -import com.raytheon.uf.common.datastorage.DataStoreFactory; -import com.raytheon.uf.common.datastorage.IDataStore; -import com.raytheon.uf.common.datastorage.StorageException; -import com.raytheon.uf.common.datastorage.StorageProperties.Compression; -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.maintenance.archive.config.DataArchiveConfig; - -/** - * Uses the repack feature of IDataStore to archive data by repacking it to a - * specified compression at the hdf5 dataset level and moving the resulting file - * to the archive dir. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Dec 8, 2011            njensen     Initial creation
- * Jan 14, 2013 1469      bkowal      Removed the hdf5 data directory.
- * Jul 23, 2013 2216      rferrel     Removed the time stamp filter in hdf5 copy.
- * 
- * 
- * - * @author njensen - * @version 1.0 - */ - -public class DataStoreArchiver { - - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(DataStoreArchiver.class); - - private Compression compression = Compression.NONE; - - public DataStoreArchiver(String compression) { - this.compression = Compression.valueOf(compression); - } - - public void archiveFiles(String[] hdf5Files, String archiveDir, - DataArchiveConfig conf) { - for (String hdf5File : hdf5Files) { - IDataStore ds = DataStoreFactory.getDataStore(new File(hdf5File)); - String outputDir = archiveDir; // + dirs of hdf5 file - - try { - // Do not perform time stamp check. - ds.copy(outputDir, compression, null, 0, 0); - } catch (StorageException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage()); - } - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/config/DataArchiveConfig.java b/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/config/DataArchiveConfig.java deleted file mode 100644 index 406e9536a6..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/config/DataArchiveConfig.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.maintenance.archive.config; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Data archive configuration. Configuration should be pulled from common_static - * localization. Configuration with a pluginName of default will all to all - * plugins. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jan 14, 2012            rjpeter     Initial creation
- * 
- * 
- * - * @author rjpeter - * @version 1.0 - */ -@XmlRootElement -@XmlAccessorType(XmlAccessType.NONE) -public class DataArchiveConfig { - @XmlElement - private String pluginName; - - @XmlElement - private Integer hoursToKeep; - - @XmlElement - private Boolean archivingEnabled; - - @XmlElement - private Boolean compressionEnabled; - - /** - * @return the pluginName - */ - public String getPluginName() { - return pluginName; - } - - /** - * @param pluginName - * the pluginName to set - */ - public void setPluginName(String pluginName) { - this.pluginName = pluginName; - } - - /** - * @return the hoursToKeep - */ - public Integer getHoursToKeep() { - return hoursToKeep; - } - - /** - * @param hoursToKeep - * the hoursToKeep to set - */ - public void setHoursToKeep(Integer hoursToKeep) { - this.hoursToKeep = hoursToKeep; - } - - /** - * @return the archivingEnabled - */ - public Boolean getArchivingEnabled() { - return archivingEnabled; - } - - /** - * @param archivingEnabled - * the archivingEnabled to set - */ - public void setArchivingEnabled(Boolean archivingEnabled) { - this.archivingEnabled = archivingEnabled; - } - - /** - * @param compressionEnabled - * the compressionEnabled to set - */ - public void setCompressionEnabled(Boolean compressionEnabled) { - this.compressionEnabled = compressionEnabled; - } - - /** - * @return the compressionEnabled - */ - public Boolean getCompressionEnabled() { - return compressionEnabled; - } - - public boolean isArchivingEnabledSet() { - return archivingEnabled != null; - } - - public boolean isHoursToKeepSet() { - return hoursToKeep != null; - } - - public boolean isCompressionEnabledSet() { - return (compressionEnabled != null); - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/utility/common_static/base/archiver/defaultArchiveConfig.xml b/edexOsgi/com.raytheon.uf.edex.maintenance/utility/common_static/base/archiver/defaultArchiveConfig.xml deleted file mode 100644 index 5f69229316..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/utility/common_static/base/archiver/defaultArchiveConfig.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - default - 6 - false - true - diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.ogc.common/META-INF/MANIFEST.MF index 7e64db705b..7563474b8c 100644 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.ogc.common/META-INF/MANIFEST.MF @@ -17,7 +17,6 @@ Require-Bundle: net.opengis;bundle-version="1.0.2", com.raytheon.uf.common.json;bundle-version="1.0.0", com.sun.xml.bind;bundle-version="1.0.0", com.raytheon.uf.common.status;bundle-version="1.12.1174", - com.raytheon.uf.common.spatial;bundle-version="1.0.0", com.raytheon.uf.common.pointdata;bundle-version="1.12.1174", ogc.tools.gml;bundle-version="1.0.2", org.apache.commons.cxf, diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/AbstractFSQueryStore.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/AbstractFSQueryStore.java index 71a654a570..2aff823953 100644 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/AbstractFSQueryStore.java +++ b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/AbstractFSQueryStore.java @@ -24,8 +24,8 @@ import java.util.Map; import org.apache.commons.collections.map.LRUMap; -import com.raytheon.uf.common.spatial.reprojection.KeyLocker; -import com.raytheon.uf.common.spatial.reprojection.KeyLocker.KeyLock; +import com.raytheon.uf.common.util.concurrent.KeyLock; +import com.raytheon.uf.common.util.concurrent.KeyLocker; import com.raytheon.uf.edex.ogc.common.OgcException.Code; /** @@ -39,6 +39,7 @@ import com.raytheon.uf.edex.ogc.common.OgcException.Code; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Feb 15, 2013 bclement Initial creation + * Nov 8, 2013 1314 bclement updated lock to use read/write * * * @@ -62,7 +63,7 @@ public abstract class AbstractFSQueryStore extends AbstractFsStore { private final Map strCache = Collections .synchronizedMap(new LRUMap(2)); - private final KeyLocker locker = new KeyLocker(); + private final KeyLocker locker = new KeyLocker(); /** * @param id @@ -70,13 +71,12 @@ public abstract class AbstractFSQueryStore extends AbstractFsStore { * @throws Exception */ public void store(String id, T query) throws OgcException { - KeyLock lock = locker.getLock(id); + KeyLock lock = locker.getLock(id); lock.lock(); try { storeObject(id, query); } finally { lock.unlock(); - lock.release(); } } @@ -130,13 +130,12 @@ public abstract class AbstractFSQueryStore extends AbstractFsStore { */ public T retrieve(String id) throws OgcException { T rval; - KeyLock lock = locker.getLock(id); - lock.lock(); + KeyLock lock = locker.getLock(id); + lock.readLock(); try { rval = retrieveObject(id); } finally { - lock.unlock(); - lock.release(); + lock.readUnlock(); } return rval; } @@ -199,13 +198,12 @@ public abstract class AbstractFSQueryStore extends AbstractFsStore { * @throws Exception */ protected String retrieveString(String id) throws OgcException { - KeyLock lock = locker.getLock(id); - lock.lock(); + KeyLock lock = locker.getLock(id); + lock.readLock(); try { return retrieveStringInternal(id); } finally { - lock.unlock(); - lock.release(); + lock.readUnlock(); } } @@ -216,7 +214,7 @@ public abstract class AbstractFSQueryStore extends AbstractFsStore { * com.raytheon.uf.edex.wfs.querystore.QueryStore#remove(java.lang.String) */ public void remove(String id) { - KeyLock lock = locker.getLock(id); + KeyLock lock = locker.getLock(id); lock.lock(); try { objCache.remove(id); @@ -227,7 +225,6 @@ public abstract class AbstractFSQueryStore extends AbstractFsStore { } } finally { lock.unlock(); - lock.release(); } } diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/spatial/RecordUtil.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/spatial/RecordUtil.java deleted file mode 100644 index 7e597f9e7c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/spatial/RecordUtil.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.ogc.common.spatial; - -import org.geotools.coverage.grid.GridCoverage2D; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.raytheon.uf.common.dataplugin.PluginDataObject; -import com.raytheon.uf.common.dataplugin.persist.IPersistable; -import com.raytheon.uf.common.datastorage.IDataStore; -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.spatial.reprojection.DataReprojector; -import com.raytheon.uf.common.spatial.reprojection.ReferencedDataRecord; -import com.raytheon.uf.edex.database.plugin.PluginDao; -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.Envelope; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.Polygon; - -/** - * Utility methods for reprojecting data records. Removing code only used by ogc - * services from {@link PluginDao} to here - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 26, 2013 1638       mschenke    Code moved from PluginDao to clean up dependencies
- * 
- * 
- * - * @author unknown - * @version 1.0 - */ - -public class RecordUtil { - - /** - * @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 static ReferencedDataRecord getProjected(PluginDao dao, - PluginDataObject record, CoordinateReferenceSystem crs, - Envelope envelope) throws Exception { - ReferencedEnvelope targetEnv = new ReferencedEnvelope( - envelope.getMinX(), envelope.getMaxX(), envelope.getMinY(), - envelope.getMaxY(), crs); - return getProjected(dao, record, targetEnv); - } - - public static double getHDF5Value(PluginDao dao, PluginDataObject pdo, - CoordinateReferenceSystem crs, Coordinate coord, - double defaultReturn) throws Exception { - // TODO a cache would probably be good here - double rval = defaultReturn; - if (pdo instanceof ISpatialEnabled) { - IDataStore store = dao.getDataStore((IPersistable) pdo); - 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 static GridCoverage2D getProjectedCoverage(PluginDao dao, - PluginDataObject record, CoordinateReferenceSystem crs, - Envelope envelope) throws Exception { - ReferencedEnvelope targetEnv = new ReferencedEnvelope( - envelope.getMinX(), envelope.getMaxX(), envelope.getMinY(), - envelope.getMaxY(), crs); - return getProjectedCoverage(dao, record, targetEnv); - } - - /** - * @param record - * @param targetEnvelope - * bounding box in target crs - * @return null if envelope is disjoint with data bounds - * @throws Exception - */ - public static ReferencedDataRecord getProjected(PluginDao dao, - PluginDataObject record, ReferencedEnvelope targetEnvelope) - throws Exception { - IDataStore store = dao.getDataStore((IPersistable) record); - ISpatialObject spatial = getSpatialObject(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 static GridCoverage2D getProjectedCoverage(PluginDao dao, - PluginDataObject record, ReferencedEnvelope envelope) - throws Exception { - IDataStore store = dao.getDataStore((IPersistable) record); - ISpatialObject spatial = getSpatialObject(record); - DataReprojector reprojector = getDataReprojector(store); - ReferencedEnvelope nativeEnvelope = getNativeEnvelope(spatial); - return reprojector.getReprojectedCoverage(record.getDataURI(), spatial, - nativeEnvelope, envelope); - } - - public static DataReprojector getDataReprojector(IDataStore dataStore) { - return new DataReprojector(dataStore); - } - - public static ReferencedEnvelope getNativeEnvelope(ISpatialObject spatial) - throws FactoryException { - CoordinateReferenceSystem crs = spatial.getCrs(); - Geometry geom = spatial.getGeometry(); - return MapUtil.getBoundingEnvelope(crs, (Polygon) geom); - } - - public static 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; - } - - public static ISpatialObject getSpatialObject(PluginDataObject record) - throws Exception { - if (record instanceof ISpatialEnabled) { - return ((ISpatialEnabled) record).getSpatialObject(); - } else { - throw new Exception(record.getClass() + " is not spatially enabled"); - } - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.manualIngest/res/spring/manualIngest-request.xml b/edexOsgi/com.raytheon.uf.edex.plugin.manualIngest/res/spring/manualIngest-request.xml index eab8b24d84..411d4428a0 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.manualIngest/res/spring/manualIngest-request.xml +++ b/edexOsgi/com.raytheon.uf.edex.plugin.manualIngest/res/spring/manualIngest-request.xml @@ -15,7 +15,7 @@ java.lang.Throwable - + diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/resources/com.raytheon.uf.edex.registry.ebxml.properties b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/resources/com.raytheon.uf.edex.registry.ebxml.properties index bac6c8310d..f122663cd7 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/resources/com.raytheon.uf.edex.registry.ebxml.properties +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/resources/com.raytheon.uf.edex.registry.ebxml.properties @@ -14,4 +14,4 @@ ebxml-email.enabled=false ebxml-notification-batch-size=50 # Configuration of thread pool used to handle web service requests ebxml-webserver-min-threads=2 -ebxml-webserver-max-threads=10 \ No newline at end of file +ebxml-webserver-max-threads=5 \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/query/RegistryQueryUtil.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/query/RegistryQueryUtil.java index e4f2bfa498..c31ede2abd 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/query/RegistryQueryUtil.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/query/RegistryQueryUtil.java @@ -21,7 +21,9 @@ package com.raytheon.uf.edex.registry.ebxml.services.query; import java.math.BigInteger; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.xml.datatype.DatatypeConfigurationException; @@ -51,6 +53,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlExceptionUtil; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 10/8/2013 1682 bphillip Initial implementation + * 11/7/2013 1678 bphillip Added formatArrayString * * * @author bphillip @@ -70,6 +73,12 @@ public class RegistryQueryUtil { private static final Pattern REPLACE_LIKE_CHARS_PATTERN = Pattern .compile("\\?"); + /** + * Pattern used to format the string representation of arrays + */ + private static final Pattern ARRAY_STRING_PATTERN = Pattern + .compile("(\\[)(.*)(\\])"); + /** * Replaces the registry character wilcard (?) with the database wildcard * (_) @@ -224,4 +233,20 @@ public class RegistryQueryUtil { } } + + /** + * Formats the string representation of an array as a comma separated list + * + * @param arrayString + * The array string to format + * @return The formatted string + */ + public static String formatArrayString(Object[] arr) { + String arrayString = Arrays.toString(arr); + Matcher matcher = ARRAY_STRING_PATTERN.matcher(arrayString); + if (matcher.find()) { + return matcher.group(2); + } + return arrayString; + } } diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/federation/status.html b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/federation/status.html index f061c21e30..7f1252ae1e 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/federation/status.html +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/federation/status.html @@ -1,3 +1,37 @@ + + + @@ -68,7 +102,7 @@
My Registry is Subscribed To: - +Retrieving Registry List...

@@ -76,7 +110,7 @@ Registries Subscribing to My Registry: - +Retrieving Registry List...

@@ -87,7 +121,7 @@
Object Types Currently Replicated: - +Retrieving Object List...

diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/navigation.html b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/navigation.html index b6c188b673..701d08abe5 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/navigation.html +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/navigation.html @@ -56,6 +56,8 @@ Date Ticket# Engineer Description Query Interface
+ Define Query +
Subscription Backup
Federation Status diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/registryUtil.js b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/registryUtil.js index d18e21c681..41ec5d9945 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/registryUtil.js +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/registryUtil.js @@ -1,4 +1,34 @@ - +/* +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. + +Navigation pane containing links + +SOFTWARE HISTORY + +Date Ticket# Engineer Description +------------ ---------- ----------- -------------------------- +10/15/2013 1682 bphillip Initial implementation + + +@author bphillip +@version 1 +*/ function callRestService(url,arg){ var url = "http://"+window.location.host+"/"+url diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/services/query/DefineQuery.html b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/services/query/DefineQuery.html new file mode 100644 index 0000000000..be98a2cfc8 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/registry/services/query/DefineQuery.html @@ -0,0 +1,215 @@ + + + + + + + + + + + + Registry Query Definition Manager + + + + +

Remove Custom Query Definition

+ + + + + +
Query Name
+
+ +

+
+

Define New Query Definition

+Query Definition +
+ + + + + + + + + + + + + + + + + +
Query Name
Query Description
Query Language
Query Expression
+

+Query Parameter Definition + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name
Description
Data Type
Default Value
Min Occurrences
Max Occurrences
+

+Defined Parameters +
+None +

+ + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.text.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.text.feature/feature.xml index 49bff7ab36..10df591fb1 100644 --- a/edexOsgi/com.raytheon.uf.edex.text.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.text.feature/feature.xml @@ -19,6 +19,7 @@ + 0) { + if ((svalues != null) && (svalues.size() > 0)) { genContour(); - if (!isCntrsCreated) + if (!isCntrsCreated) { return; + } } else { logger.debug("Re-load contour line values took: " + (t2 - t1)); } @@ -461,8 +463,9 @@ public class ContourSupport { Envelope imageEnv = ref.transform( imageGridGeometry.getCoordinateReferenceSystem(), true); - if (imageEnv == null) + if (imageEnv == null) { return null; + } // transform image envelope to image grid cells double[] image = new double[] { imageEnv.getMinX(), @@ -497,7 +500,8 @@ public class ContourSupport { int actualLength = 0; for (double[] dl : valsArr) { - if (dl[0] > minx && dl[0] < maxx && dl[1] > miny && dl[1] < maxy) { + if ((dl[0] > minx) && (dl[0] < maxx) && (dl[1] > miny) + && (dl[1] < maxy)) { visiblePts[actualLength][0] = dl[0]; visiblePts[actualLength][1] = dl[1]; actualLength++; @@ -524,8 +528,9 @@ public class ContourSupport { // remove points on longitude 360 degree. to avoid long cross lines if (isWorld180) { for (Coordinate pt : coords) { - if (pt.x == maxGridX) + if (pt.x == maxGridX) { size--; + } } } @@ -533,7 +538,7 @@ public class ContourSupport { long nx = records.getSizes()[0] - 1; for (int i = 0, jj = 0; i < coords.length; i++, jj++) { - if (isWorld180 && coords[i].x == maxGridX) { + if (isWorld180 && (coords[i].x == maxGridX)) { jj--; continue; } @@ -552,9 +557,10 @@ public class ContourSupport { } if (worldWrap) { - if (tmp[0] > (nx - 1) && out[jj][0] < 0) { + if ((tmp[0] > (nx - 1)) && (out[jj][0] < 0)) { out[jj][0] = mapScreenWidth; - } else if (tmp[0] < 1 && out[jj][0] > mapScreenWidth * 0.9) { + } else if ((tmp[0] < 1) + && (out[jj][0] > (mapScreenWidth * 0.9))) { out[jj][0] = 0; } } @@ -585,8 +591,8 @@ public class ContourSupport { return null; } - if (out[i][0] < zeroLonOnScreen - || (tmp[0] == maxGridX && out[i][0] == zeroLonOnScreen)) { + if ((out[i][0] < zeroLonOnScreen) + || ((tmp[0] == maxGridX) && (out[i][0] == zeroLonOnScreen))) { out[i][0] += mapScreenWidth; } @@ -617,8 +623,8 @@ public class ContourSupport { return null; } - if (tmpout[0] < zeroLonOnScreen - || (tmp[0] == maxGridX && tmpout[0] == zeroLonOnScreen)) { + if ((tmpout[0] < zeroLonOnScreen) + || ((tmp[0] == maxGridX) && (tmpout[0] == zeroLonOnScreen))) { tmpout[0] += mapScreenWidth; } @@ -653,8 +659,8 @@ public class ContourSupport { // System.out.println("WWWWWWW " + tmp[0]+" " + tmpout[0] + // " " + out[i][0]); - if (out[i][0] > zeroLonOnScreen - || (tmp[0] == 0 && out[i][0] == zeroLonOnScreen)) { + if ((out[i][0] > zeroLonOnScreen) + || ((tmp[0] == 0) && (out[i][0] == zeroLonOnScreen))) { // System.out.println("Shift " + tmp[0]+" " + out[i][0]); out[i][0] -= mapScreenWidth; } @@ -686,8 +692,8 @@ public class ContourSupport { return null; } - if (tmpout[0] > zeroLonOnScreen - || (tmp[0] == 0 && tmpout[0] == zeroLonOnScreen)) { + if ((tmpout[0] > zeroLonOnScreen) + || ((tmp[0] == 0) && (tmpout[0] == zeroLonOnScreen))) { tmpout[0] -= mapScreenWidth; } @@ -712,8 +718,9 @@ public class ContourSupport { // remove points on 360. to avoid long cross lines if (isWorld180) { for (Coordinate pt : coords) { - if (pt.x == maxGridX) + if (pt.x == maxGridX) { size--; + } } } @@ -721,7 +728,7 @@ public class ContourSupport { double[] tmpout = new double[3]; for (int i = 0, jj = 0; i < coords.length; i++, jj++) { - if (isWorld180 && coords[i].x == maxGridX) { + if (isWorld180 && (coords[i].x == maxGridX)) { jj--; continue; } @@ -739,9 +746,10 @@ public class ContourSupport { return null; } if (worldWrap) { - if (tmp[0] > (nx - 1) && tmpout[0] < 0) { + if ((tmp[0] > (nx - 1)) && (tmpout[0] < 0)) { tmpout[0] = extent.getMaxX(); - } else if (tmp[0] < 1 && tmpout[0] > extent.getMaxX() * 0.9) { + } else if ((tmp[0] < 1) + && (tmpout[0] > (extent.getMaxX() * 0.9))) { tmpout[0] = 0; } } @@ -759,8 +767,9 @@ public class ContourSupport { private static Geometry polyToLine(Polygon poly) { GeometryFactory gf = new GeometryFactory(); - if (poly.getNumInteriorRing() == 0) + if (poly.getNumInteriorRing() == 0) { return poly; + } poly.normalize(); LineString outerPoly = poly.getExteriorRing(); @@ -826,7 +835,7 @@ public class ContourSupport { // Geometry testGeom; Coordinate[] coords = outerPoly.getCoordinates(); - for (int i = 0; i < coords.length - 1; i++) { + for (int i = 0; i < (coords.length - 1); i++) { Coordinate intx = null; if (((y <= coords[i].y) && (y >= coords[i + 1].y)) || ((y >= coords[i].y) && (y <= coords[i + 1].y))) { @@ -840,8 +849,9 @@ public class ContourSupport { // } if (intx != null) { - if (max.compareTo(intx) == -1) + if (max.compareTo(intx) == -1) { max = intx; + } } // testGeom = seg.intersection(temp); @@ -865,8 +875,9 @@ public class ContourSupport { double centralMeridian = group.parameter( AbstractProvider.CENTRAL_MERIDIAN.getName().getCode()) .doubleValue(); - if (centralMeridian > 180) + if (centralMeridian > 180) { centralMeridian -= 360; + } return centralMeridian; } return -999; @@ -914,17 +925,18 @@ public class ContourSupport { contourGroup.grid = null; if (contourGp != null) { - if (contourGp.cvalues != null && contourGp.cvalues.size() > 0) { + if ((contourGp.cvalues != null) && (contourGp.cvalues.size() > 0)) { contourGroup.cvalues.addAll(contourGp.cvalues); } - if (contourGp.fvalues != null && contourGp.fvalues.size() > 0) { + if ((contourGp.fvalues != null) && (contourGp.fvalues.size() > 0)) { contourGroup.fvalues.addAll(contourGp.fvalues); } - if (contourGp.data != null && contourGp.data.size() > 0) { + if ((contourGp.data != null) && (contourGp.data.size() > 0)) { contourGroup.data.putAll(contourGp.data); } - if (contourGp.grid != null) + if (contourGp.grid != null) { contourGroup.grid = contourGp.grid; + } } contourGroup.lastUsedPixelExtent = (PixelExtent) extent.clone(); @@ -975,14 +987,17 @@ public class ContourSupport { private void initZoomIndex() { zoomLevelIndex = level + 1;// (int)(zoom / 2) + 1; // To be adjusted - if (zoomLevelIndex < 1) + if (zoomLevelIndex < 1) { zoomLevelIndex = 1; + } int maxZoomLevel = 5; String cint = attr.getCint(); - if (cint != null) + if (cint != null) { maxZoomLevel = cint.trim().split(">").length; - if (zoomLevelIndex > maxZoomLevel) + } + if (zoomLevelIndex > maxZoomLevel) { zoomLevelIndex = maxZoomLevel; + } } private List calcCintValue() { @@ -997,7 +1012,7 @@ public class ContourSupport { // System.out.println ("******cgen.getMinValue():" + cgen.getMinValue() // + " cgen.getMaxValue():"+cgen.getMaxValue()); // } - if (contourGroup.cvalues.size() == 0 && cvalues != null) { + if ((contourGroup.cvalues.size() == 0) && (cvalues != null)) { contourGroup.cvalues.addAll(cvalues); } else if (contourGroup.cvalues.size() > 0) { if (cvalues != null) { @@ -1022,7 +1037,7 @@ public class ContourSupport { fvalues = contourGroup.cvalues; } } - if (contourGroup.fvalues.size() == 0 && fvalues != null) { + if ((contourGroup.fvalues.size() == 0) && (fvalues != null)) { contourGroup.fvalues.addAll(fvalues); } else if (contourGroup.fvalues.size() > 0) { if (fvalues != null) { @@ -1038,13 +1053,15 @@ public class ContourSupport { } private void combineCintAndFillValues() { - if (cvalues != null && cvalues.size() > 0) + if ((cvalues != null) && (cvalues.size() > 0)) { svalues = new HashSet(cvalues); - if (fvalues != null && fvalues.size() > 0) { - if (svalues == null) + } + if ((fvalues != null) && (fvalues.size() > 0)) { + if (svalues == null) { svalues = new HashSet(fvalues); - else + } else { svalues.addAll(fvalues); + } } } @@ -1053,7 +1070,7 @@ public class ContourSupport { long total_labeling_time = 0; long t2 = System.currentTimeMillis(); if (type.trim().toUpperCase().contains("C") - && contourGroup.cvalues.size() > 0) { + && (contourGroup.cvalues.size() > 0)) { int labelFreq = 1; String[] tempLineStrs = attr.getLine().split("/"); List labelValues = null; @@ -1087,15 +1104,17 @@ public class ContourSupport { } } } else { - if (labelFreq == 0) + if (labelFreq == 0) { toLabel = false; - else - toLabel = (n % labelFreq == 0) ? true : false; + } else { + toLabel = ((n % labelFreq) == 0) ? true : false; + } } Geometry g = contourGroup.data.get(cval.toString()); - if (g == null) + if (g == null) { continue; + } for (int i = 0; i < g.getNumGeometries(); i++) { Geometry gn = g.getGeometryN(i); @@ -1108,18 +1127,21 @@ public class ContourSupport { screen = toScreenRightOfZero(gn.getCoordinates(), rastPosToWorldGrid, minX, minY); - if (screen != null) + if (screen != null) { contourGroup.negValueShape.addLineSegment(screen); + } screenx = toScreenLeftOfZero(gn.getCoordinates(), rastPosToWorldGrid, minX, minY); - if (screenx != null) + if (screenx != null) { contourGroup.negValueShape.addLineSegment(screenx); + } } else { screen = toScreen(gn.getCoordinates(), rastPosToWorldGrid, minX, minY); - if (screen != null) + if (screen != null) { contourGroup.negValueShape.addLineSegment(screen); + } } /* @@ -1133,9 +1155,10 @@ public class ContourSupport { long tl0 = System.currentTimeMillis(); // prepareLabel(contourGroup, zoom, fval, // labelPoints, screen); - if (screen != null) + if (screen != null) { createContourLabel(extent, contourGroup, fval, screen); + } if (screenx != null) { createContourLabel(extent, contourGroup, fval, screenx); @@ -1151,11 +1174,13 @@ public class ContourSupport { long t3 = System.currentTimeMillis(); logger.debug("===Creating label wireframes for (" + name + ") took: " + total_labeling_time); - if (ncgribLogger.enableCntrLogs()) + if (ncgribLogger.enableCntrLogs()) { logger.info("===Creating contour line wireframes for (" + name + ")took: " + (t3 - t2)); - // System.out.println("Creating contour line wireframes took: " + (t3 - - // t2 - total_labeling_time)); + // System.out.println("Creating contour line wireframes took: " + + // (t3 - + // t2 - total_labeling_time)); + } } private void createColorFills() { @@ -1164,7 +1189,7 @@ public class ContourSupport { // Prepare the colorbar if (type.trim().toUpperCase().contains("F") - && (attr.getClrbar() != null || !"0".equals(attr.getClrbar()))) { + && ((attr.getClrbar() != null) || !"0".equals(attr.getClrbar()))) { ColorBar tempColorBar = generateColorBarInfo(); if (tempColorBar != null) { contourGroup.colorBarForGriddedFill = new ColorBar(tempColorBar); @@ -1174,18 +1199,19 @@ public class ContourSupport { } if (type.trim().toUpperCase().contains("F") - && contourGroup.fvalues.size() > 0) { + && (contourGroup.fvalues.size() > 0)) { try { // Prepare colors for color fills List fillColorsIndex = new ArrayList(); - if (fline == null || fline.trim().length() < 1) { - for (int i = 0; i < contourGroup.fvalues.size() + 2; i++) { - if (i <= 30) + if ((fline == null) || (fline.trim().length() < 1)) { + for (int i = 0; i < (contourGroup.fvalues.size() + 2); i++) { + if (i <= 30) { fillColorsIndex.add(i + 1); - else + } else { fillColorsIndex.add(30); + } } } else { FLine flineInfo = new FLine(fline.trim()); @@ -1194,11 +1220,11 @@ public class ContourSupport { /* * Apply last color if not enough input color. */ - if (contourGroup.fvalues != null - && fillColorsIndex.size() < (contourGroup.fvalues - .size() + 1)) { - for (int i = fillColorsIndex.size(); i < contourGroup.fvalues - .size() + 2; i++) { + if ((contourGroup.fvalues != null) + && (fillColorsIndex.size() < (contourGroup.fvalues + .size() + 1))) { + for (int i = fillColorsIndex.size(); i < (contourGroup.fvalues + .size() + 2); i++) { fillColorsIndex.add(i); } } @@ -1212,17 +1238,19 @@ public class ContourSupport { for (Double cval : contourGroup.fvalues) { float fval = (float) (cval * 1.0f); Geometry g = contourGroup.data.get(cval.toString()); - if (g == null) + if (g == null) { continue; + } fgen.addContours(fval, g); } t11 = System.currentTimeMillis(); logger.debug(" add Contour took:" + (t11 - t12)); // Add color fill to contourGroup for (int n = 0; n <= contourGroup.fvalues.size(); n++) { - if (fillColorsIndex.get(n) <= 0 - || fillColorsIndex.get(n) >= 32) + if ((fillColorsIndex.get(n) <= 0) + || (fillColorsIndex.get(n) >= 32)) { continue; + } RGB color = GempakColor .convertToRGB(fillColorsIndex.get(n)); @@ -1244,33 +1272,37 @@ public class ContourSupport { } for (int j = 0; j < fillPolys.getNumGeometries(); j++) { Geometry g = fillPolys.getGeometryN(j); - if (g instanceof Polygon) + if (g instanceof Polygon) { g = polyToLine((Polygon) g); + } if (worldWrap) { LineString ls = toScreenLSRightOfZero( g.getCoordinates(), rastPosToWorldGrid, minX, minY); - if (ls != null) + if (ls != null) { contourGroup.fillShapes .addPolygonPixelSpace( new LineString[] { ls }, color); + } ls = toScreenLSLeftOfZero(g.getCoordinates(), rastPosToWorldGrid, minX, minY); - if (ls != null) + if (ls != null) { contourGroup.fillShapes .addPolygonPixelSpace( new LineString[] { ls }, color); + } } else { LineString ls = toScreenLS(g.getCoordinates(), rastPosToWorldGrid, minX, minY); - if (ls != null) + if (ls != null) { contourGroup.fillShapes .addPolygonPixelSpace( new LineString[] { ls }, color); + } } // if ( isWorld0 ) { @@ -1297,9 +1329,10 @@ public class ContourSupport { } } long t4 = System.currentTimeMillis(); - if (ncgribLogger.enableCntrLogs()) + if (ncgribLogger.enableCntrLogs()) { logger.info("===Creating color fills for (" + name + ") took : " + (t4 - t3)); + } } private void createStreamLines() { @@ -1337,7 +1370,7 @@ public class ContourSupport { if (globalData) { for (int j = 0; j < szY; j++) { - for (int i = 0; i < szX + 1; i++) { + for (int i = 0; i < (szX + 1); i++) { if ((i + minX) == 360) { continue; } @@ -1368,7 +1401,7 @@ public class ContourSupport { // Use ported legacy code to determine contour interval // contourGroup.lastDensity = currentDensity; - double spadiv = 1 * contourGroup.lastDensity * 500 / 25; + double spadiv = (1 * contourGroup.lastDensity * 500) / 25; double minSpacing = 1.0 / spadiv; double maxSpacing = 3.0 / spadiv; @@ -1393,8 +1426,9 @@ public class ContourSupport { * Fix arrow size by M. Li */ float arrowSize = (float) (0.4f / Math.sqrt(zoom)); - if (arrowSize > 0.4) + if (arrowSize > 0.4) { arrowSize = 0.4f; + } StrmPakConfig config = new StrmPakConfig(arrowSize, minspc, maxspc, -1000000f, -999998f); @@ -1423,11 +1457,12 @@ public class ContourSupport { } else { - f = maxX + 1 - point.getX(); + f = (maxX + 1) - point.getX(); } - if (f > 180) + if (f > 180) { f = f - 360; + } rastPosToWorldGrid.transform( new double[] { f, point.getY() + minY }, 0, @@ -1450,14 +1485,16 @@ public class ContourSupport { screen = toScreenRightOfZero( pts.toArray(new Coordinate[pts.size()]), rastPosToWorldGrid, minX, minY); - if (screen != null) + if (screen != null) { contourGroup.posValueShape.addLineSegment(screen); + } screenx = toScreenLeftOfZero( pts.toArray(new Coordinate[pts.size()]), rastPosToWorldGrid, minX, minY); - if (screenx != null) + if (screenx != null) { contourGroup.posValueShape.addLineSegment(screenx); + } } else { double[][] valsArr = vals.toArray(new double[vals .size()][2]); @@ -1482,14 +1519,16 @@ public class ContourSupport { screen = toScreenRightOfZero( pts.toArray(new Coordinate[pts.size()]), rastPosToWorldGrid, minX, minY); - if (screen != null) + if (screen != null) { contourGroup.posValueShape.addLineSegment(screen); + } screenx = toScreenLeftOfZero( pts.toArray(new Coordinate[pts.size()]), rastPosToWorldGrid, minX, minY); - if (screenx != null) + if (screenx != null) { contourGroup.posValueShape.addLineSegment(screenx); + } } vals.clear(); } @@ -1503,7 +1542,7 @@ public class ContourSupport { private ColorBar generateColorBarInfo() { - if (attr.getClrbar() != null && !attr.getClrbar().isEmpty()) { + if ((attr.getClrbar() != null) && !attr.getClrbar().isEmpty()) { contourGroup.clrbar = new CLRBAR(attr.getClrbar()); ColorBarAttributesBuilder cBarAttrBuilder = contourGroup.clrbar .getcBarAttributesBuilder(); @@ -1517,8 +1556,9 @@ public class ContourSupport { FINT theFillIntervals = new FINT(fint.trim()); FLine fillColorString = new FLine(fline.trim()); if (!theFillIntervals.isFINTStringParsed() - || !fillColorString.isFLineStringParsed()) + || !fillColorString.isFLineStringParsed()) { return null; + } List fillIntvls = theFillIntervals .getUniqueSortedFillValuesFromAllZoomLevels(); List fillColors = fillColorString.getFillColorList(); @@ -1527,14 +1567,14 @@ public class ContourSupport { int numFillIntervals = fillIntvls.size(); fillIntvls.add(numFillIntervals, Double.POSITIVE_INFINITY); int numDecimals = 0; - for (int index = 0; index <= numFillIntervals - 1; index++) { + for (int index = 0; index <= (numFillIntervals - 1); index++) { colorBar.addColorBarInterval(fillIntvls.get(index) .floatValue(), fillIntvls.get(index + 1) .floatValue(), GempakColor.convertToRGB(fillColors .get(index))); String tmp[] = fillIntvls.get(index).toString() .split("\\."); - if (tmp.length > 1 && tmp[1].length() > numDecimals + if ((tmp.length > 1) && (tmp[1].length() > numDecimals) && !"0".equals(tmp[1])) { numDecimals = tmp[1].length(); } @@ -1577,9 +1617,10 @@ public class ContourSupport { } long t2 = System.currentTimeMillis(); - if (ncgribLogger.enableCntrLogs()) + if (ncgribLogger.enableCntrLogs()) { logger.info("===ContourGenerator.generateContours() for (" + name + ") took: " + (t2 - t1a)); + } // System.out.println("Contour Computation took: " + (t2-t1c)); @@ -1606,8 +1647,9 @@ public class ContourSupport { } public ContourGroup getContours() { - if (!isCntrsCreated) + if (!isCntrsCreated) { return null; + } return contourGroup; } @@ -1645,11 +1687,13 @@ public class ContourSupport { double minLon = (out0[0] >= 0) ? out0[0] : out0[0] + 360; double maxLon = (out1[0] >= 0) ? out1[0] : out1[0] + 360; - if (minLon == 0 && maxLon == 360) + if ((minLon == 0) && (maxLon == 360)) { globalData = true; + } - if (maxLon >= 360) + if (maxLon >= 360) { maxLon = 359; + } double right = centralMeridian + 180; if (maxLon > minLon) { diff --git a/rpms/awips2.core/Installer.httpd-pypies/SOURCES/httpd-pypies.logrotate b/rpms/awips2.core/Installer.httpd-pypies/SOURCES/httpd-pypies.logrotate deleted file mode 100644 index ab3f28b269..0000000000 --- a/rpms/awips2.core/Installer.httpd-pypies/SOURCES/httpd-pypies.logrotate +++ /dev/null @@ -1,8 +0,0 @@ -/awips2/httpd_pypies/var/log/httpd/*log { - missingok - notifempty - sharedscripts - postrotate - /sbin/service httpd-pypies reload > /dev/null 2>/dev/null || true - endscript -} diff --git a/rpms/build/i386/build.sh_old b/rpms/build/i386/build.sh_old deleted file mode 100644 index 37dbb8eaa6..0000000000 --- a/rpms/build/i386/build.sh_old +++ /dev/null @@ -1,423 +0,0 @@ -#!/bin/bash - -function buildRPM() -{ - # Arguments: - # ${1} == the name of the rpm. - lookupRPM "${1}" - if [ $? -ne 0 ]; then - echo "ERROR: '${1}' is not a recognized AWIPS II RPM." - exit 1 - fi - - /usr/bin/rpmbuild -ba \ - --define '_topdir %(echo ${AWIPSII_TOP_DIR})' \ - --define '_baseline_workspace %(echo ${WORKSPACE})' \ - --define '_uframe_eclipse %(echo ${UFRAME_ECLIPSE})' \ - --define '_awipscm_share %(echo ${AWIPSCM_SHARE})' \ - --define '_build_root %(echo ${AWIPSII_BUILD_ROOT})' \ - --define '_component_version %(echo ${AWIPSII_VERSION})' \ - --define '_component_release %(echo ${AWIPSII_RELEASE})' \ - --define '_component_build_date %(echo ${COMPONENT_BUILD_DATE})' \ - --define '_component_build_time %(echo ${COMPONENT_BUILD_TIME})' \ - --define '_component_build_system %(echo ${COMPONENT_BUILD_SYSTEM})' \ - --buildroot ${AWIPSII_BUILD_ROOT} \ - ${RPM_SPECIFICATION}/component.spec - if [ $? -ne 0 ]; then - echo "ERROR: Failed to build RPM ${1}." - exit 1 - fi - - return 0 -} - -# This script will build all of the 32-bit rpms. -# Ensure that we are on a machine with the correct architecture. - -architecture=`uname -i` -if [ ! "${architecture}" = "i386" ]; then - echo "ERROR: This build can only be performed on a 32-bit Operating System." - exit 1 -fi - -# Determine which directory we are running from. -path_to_script=`readlink -f $0` -dir=$(dirname $path_to_script) - -common_dir=`cd ${dir}/../common; pwd;` -if [ $? -ne 0 ]; then - echo "ERROR: Unable to find the common functions directory." - exit 1 -fi -# source the common functions. -source ${common_dir}/lookupRPM.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to source the common functions." - exit 1 -fi -source ${common_dir}/usage.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to source the common functions." - exit 1 -fi -source ${common_dir}/rpms.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to source the common functions." - exit 1 -fi -source ${common_dir}/systemInfo.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to retrieve the system information." - exit 1 -fi - -# prepare the build environment. -source ${dir}/buildEnvironment.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to prepare the build environment." - exit 1 -fi - -export LIGHTNING=true -# Determine if the optional '-nobinlightning' argument has been specified. -if [ "${2}" = "-nobinlightning" ]; then - LIGHTNING=false -fi - -if [ "${1}" = "-python-qpid" ]; then - buildRPM "awips2" - buildRPM "awips2-python-qpid" - buildRPM "awips2-python" - buildRPM "awips2-python-cherrypy" - buildRPM "awips2-python-dynamicserialize" - buildRPM "awips2-python-nose" - buildRPM "awips2-python-numpy" - buildRPM "awips2-python-h5py" - buildRPM "awips2-python-jimporter" - buildRPM "awips2-python-matplotlib" - buildRPM "awips2-python-pil" - buildRPM "awips2-python-pmw" - buildRPM "awips2-python-pupynere" - buildRPM "awips2-python-scientific" - buildRPM "awips2-python-scipy" - buildRPM "awips2-python-tables" - buildRPM "awips2-python-thrift" - buildRPM "awips2-python-tpg" - buildRPM "awips2-python-ufpy" - buildRPM "awips2-python-werkzeug" - buildRPM "awips2-python-pygtk" - buildRPM "awips2-python-pycairo" - if [ $? -ne 0 ]; then - exit 1 - fi - - buildQPID - if [ $? -ne 0 ]; then - exit 1 - fi - - #buildRPM "awips2-ant" - #unpackHttpdPypies - if [ $? -ne 0 ]; then - exit 1 - fi - #buildRPM "awips2-httpd-pypies" - #buildRPM "awips2-java" - #buildRPM "awips2-ldm" - #buildRPM "awips2-tools" - buildRPM "awips2-python-shapely" - - exit 0 -fi - -if [ "${1}" = "-postgres" ]; then - buildRPM "awips2-postgres" - buildRPM "awips2-database-server-configuration" - buildRPM "awips2-database-standalone-configuration" - buildRPM "awips2-database" - buildRPM "awips2-maps-database" - buildRPM "awips2-pgadmin3" - - exit 0 -fi - -if [ "${1}" = "-delta" ]; then - buildCAVE - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-alertviz" - buildEDEX - if [ $? -ne 0 ]; then - exit 1 - fi - - buildRPM "awips2" - buildRPM "Installer.ncep-database" - buildRPM "awips2-gfesuite-client" - buildRPM "awips2-gfesuite-server" - buildRPM "awips2-python" - buildRPM "awips2-python-dynamicserialize" - buildRPM "awips2-python-ufpy" - buildRPM "awips2-python-qpid" - - buildRPM "awips2-adapt-native" - buildRPM "awips2-aviation-shared" - buildRPM "awips2-cli" - buildRPM "awips2-database" - buildRPM "awips2-database-server-configuration" - buildRPM "awips2-database-standalone-configuration" - buildRPM "awips2-data.hdf5-gfe.climo" - buildRPM "awips2-hydroapps-shared" - buildRPM "awips2-localapps-environment" - buildRPM "awips2-maps-database" - buildRPM "awips2-notification" - buildRPM "awips2-pypies" - buildRPM "awips2-data.hdf5-topo" - buildRPM "awips2-data.gfe" - buildRPM "awips2-rcm" - buildRPM "awips2-edex-environment" - buildLocalizationRPMs - if [ $? -ne 0 ]; then - exit 1 - fi - - exit 0 -fi - -if [ "${1}" = "-full" ]; then - buildCAVE - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "Installer.ncep-database" - buildRPM "awips2-alertviz" - buildEDEX - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-python" - buildRPM "awips2-python-cherrypy" - buildRPM "awips2-python-dynamicserialize" - buildRPM "awips2-python-h5py" - buildRPM "awips2-python-jimporter" - buildRPM "awips2-python-matplotlib" - buildRPM "awips2-python-nose" - buildRPM "awips2-python-numpy" - buildRPM "awips2-python-pil" - buildRPM "awips2-python-pmw" - buildRPM "awips2-python-pupynere" - buildRPM "awips2-python-qpid" - buildRPM "awips2-python-scientific" - buildRPM "awips2-python-scipy" - buildRPM "awips2-python-tables" - buildRPM "awips2-python-thrift" - buildRPM "awips2-python-tpg" - buildRPM "awips2-python-ufpy" - buildRPM "awips2-python-werkzeug" - buildRPM "awips2-python-pygtk" - buildRPM "awips2-python-pycairo" - - buildRPM "awips2" - buildRPM "awips2-adapt-native" - buildRPM "awips2-aviation-shared" - buildRPM "awips2-cli" - buildRPM "awips2-database" - buildRPM "awips2-database-server-configuration" - buildRPM "awips2-database-standalone-configuration" - buildRPM "awips2-data.hdf5-gfe.climo" - buildRPM "awips2-data.gfe" - buildRPM "awips2-gfesuite-client" - buildRPM "awips2-gfesuite-server" - buildRPM "awips2-hydroapps-shared" - buildRPM "awips2-localapps-environment" - buildRPM "awips2-maps-database" - buildRPM "awips2-notification" - buildRPM "awips2-pypies" - buildRPM "awips2-data.hdf5-topo" - buildRPM "awips2-rcm" - buildLocalizationRPMs - if [ $? -ne 0 ]; then - exit 1 - fi - - buildQPID - if [ $? -ne 0 ]; then - exit 1 - fi - - buildRPM "awips2-ant" - unpackHttpdPypies - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-httpd-pypies" - buildRPM "awips2-java" - #buildRPM "awips2-ldm" - buildRPM "awips2-postgres" - buildRPM "awips2-pgadmin3" - buildRPM "awips2-tools" - buildRPM "awips2-edex-environment" - buildRPM "awips2-openfire" - buildRPM "awips2-httpd-collaboration" - buildRPM "awips2-python-shapely" - - exit 0 -fi - -if [ "${1}" = "-ade" ]; then - buildRPM "awips2-eclipse" - buildRPM "awips2-java" - buildRPM "awips2-ant" - buildRPM "awips2-python" - buildRPM "awips2-python-cherrypy" - buildRPM "awips2-python-dynamicserialize" - buildRPM "awips2-python-h5py" - buildRPM "awips2-python-jimporter" - buildRPM "awips2-python-matplotlib" - buildRPM "awips2-python-nose" - buildRPM "awips2-python-numpy" - buildRPM "awips2-python-pil" - buildRPM "awips2-python-pmw" - buildRPM "awips2-python-pupynere" - buildRPM "awips2-python-qpid" - buildRPM "awips2-python-scientific" - buildRPM "awips2-python-scipy" - buildRPM "awips2-python-tables" - buildRPM "awips2-python-thrift" - buildRPM "awips2-python-tpg" - buildRPM "awips2-python-ufpy" - buildRPM "awips2-python-werkzeug" - buildRPM "awips2-python-pygtk" - buildRPM "awips2-python-pycairo" - buildRPM "awips2-python-shapely" - buildQPID -ade - if [ $? -ne 0 ]; then - exit 1 - fi - - # Package the ade. - # Create the containing directory. - ade_directory="awips2-ade-${AWIPSII_VERSION}-${AWIPSII_RELEASE}" - if [ -d ${WORKSPACE}/${ade_directory} ]; then - rm -rf ${WORKSPACE}/${ade_directory} - if [ $? -ne 0 ]; then - exit 1 - fi - fi - mkdir -p ${WORKSPACE}/${ade_directory} - if [ $? -ne 0 ]; then - exit 1 - fi - - # Copy the rpms to the directory. - cp -v ${AWIPSII_TOP_DIR}/RPMS/i386/* \ - ${AWIPSII_TOP_DIR}/RPMS/noarch/* \ - ${WORKSPACE}/${ade_directory} - if [ $? -ne 0 ]; then - exit 1 - fi - - awips2_ade_directory="${WORKSPACE}/rpms/awips2.ade" - # Copy the install and uninstall script to the directory. - cp -v ${awips2_ade_directory}/tar.ade/scripts/*.sh \ - ${WORKSPACE}/${ade_directory} - if [ $? -ne 0 ]; then - exit 1 - fi - - # Tar the directory. - pushd . > /dev/null 2>&1 - cd ${WORKSPACE} - tar -cvf ${ade_directory}.tar ${ade_directory} - popd > /dev/null 2>&1 - RC=$? - if [ ${RC} -ne 0 ]; then - exit 1 - fi - - exit 0 -fi - -if [ "${1}" = "-viz" ]; then - buildRPM "awips2" - buildRPM "awips2-rcm" - buildCAVE - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-alertviz" - - exit 0 -fi - -if [ "${1}" = "-edex" ]; then - buildRPM "awips2" - buildRPM "awips2-cli" - buildRPM "awips2-gfesuite-client" - buildRPM "awips2-gfesuite-server" - buildRPM "Installer.ncep-database" - buildEDEX - if [ $? -ne 0 ]; then - exit 1 - fi - - exit 0 -fi - -if [ "${1}" = "-qpid" ]; then - buildQPID - if [ $? -ne 0 ]; then - exit 1 - fi - - exit 0 -fi - -if [ "${1}" = "-ldm" ]; then - buildRPM "awips2-ldm" - - exit 0 -fi - -if [ "${1}" = "-package" ]; then - repository_directory="awips2-repository-${AWIPSII_VERSION}-${AWIPSII_RELEASE}" - if [ -d ${WORKSPACE}/${repository_directory} ]; then - rm -rf ${WORKSPACE}/${repository_directory} - if [ $? -ne 0 ]; then - exit 1 - fi - fi - mkdir -p ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE} - if [ $? -ne 0 ]; then - exit 1 - fi - - cp -r ${AWIPSII_TOP_DIR}/RPMS/* \ - ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE} - if [ $? -ne 0 ]; then - exit 1 - fi - - rpms_directory="${WORKSPACE}/rpms" - comps_xml="${rpms_directory}/common/yum/arch.x86/comps.xml" - cp -v ${comps_xml} ${WORKSPACE}/${repository_directory} - if [ $? -ne 0 ]; then - exit 1 - fi - - pushd . > /dev/null - cd ${WORKSPACE} - tar -cvf ${repository_directory}.tar ${repository_directory} - RC=$? - popd > /dev/null - if [ ${RC} -ne 0 ]; then - exit 1 - fi - - exit 0 -fi - - -usage -exit 0 diff --git a/rpms/build/x86_64/build.sh.orig b/rpms/build/x86_64/build.sh.orig deleted file mode 100644 index a2ee31d613..0000000000 --- a/rpms/build/x86_64/build.sh.orig +++ /dev/null @@ -1,406 +0,0 @@ -#!/bin/bash - -function buildRPM() -{ - # Arguments: - # ${1} == the name of the rpm. - lookupRPM "${1}" - if [ $? -ne 0 ]; then - echo "ERROR: '${1}' is not a recognized AWIPS II RPM." - exit 1 - fi - - /usr/bin/rpmbuild -ba \ - --define '_topdir %(echo ${AWIPSII_TOP_DIR})' \ - --define '_baseline_workspace %(echo ${WORKSPACE})' \ - --define '_uframe_eclipse %(echo ${UFRAME_ECLIPSE})' \ - --define '_awipscm_share %(echo ${AWIPSCM_SHARE})' \ - --define '_build_root %(echo ${AWIPSII_BUILD_ROOT})' \ - --define '_component_version %(echo ${AWIPSII_VERSION})' \ - --define '_component_release %(echo ${AWIPSII_RELEASE})' \ - --define '_component_build_date %(echo ${COMPONENT_BUILD_DATE})' \ - --define '_component_build_time %(echo ${COMPONENT_BUILD_TIME})' \ - --define '_component_build_system %(echo ${COMPONENT_BUILD_SYSTEM})' \ - --buildroot ${AWIPSII_BUILD_ROOT} \ - ${RPM_SPECIFICATION}/component.spec - if [ $? -ne 0 ]; then - echo "ERROR: Failed to build RPM ${1}." - exit 1 - fi - - return 0 -} - -# This script will build all of the 64-bit rpms. -# Ensure that we are on a machine with the correct architecture. - -architecture=`uname -i` -if [ ! "${architecture}" = "x86_64" ]; then - echo "ERROR: This build can only be performed on a 64-bit Operating System." - exit 1 -fi - -# Determine which directory we are running from. -path_to_script=`readlink -f $0` -dir=$(dirname $path_to_script) - -common_dir=`cd ${dir}/../common; pwd;` -if [ $? -ne 0 ]; then - echo "ERROR: Unable to find the common functions directory." - exit 1 -fi -# source the common functions. -source ${common_dir}/lookupRPM.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to source the common functions." - exit 1 -fi -source ${common_dir}/usage.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to source the common functions." - exit 1 -fi -source ${common_dir}/rpms.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to source the common functions." - exit 1 -fi -source ${common_dir}/systemInfo.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to retrieve the system information." - exit 1 -fi - -# prepare the build environment. -source ${dir}/buildEnvironment.sh -if [ $? -ne 0 ]; then - echo "ERROR: Unable to prepare the build environment." - exit 1 -fi - -export LIGHTNING=true -# Determine if the optional '-nobinlightning' argument has been specified. -if [ "${2}" = "-nobinlightning" ]; then - LIGHTNING=false -fi - -if [ "${1}" = "-64bit" ]; then - buildCAVE - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-alertviz" - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-python" - buildRPM "awips2-python-cherrypy" - buildRPM "awips2-python-dynamicserialize" - buildRPM "awips2-python-h5py" - buildRPM "awips2-python-jimporter" - buildRPM "awips2-python-matplotlib" - buildRPM "awips2-python-nose" - buildRPM "awips2-python-numpy" - buildRPM "awips2-python-pil" - buildRPM "awips2-python-pmw" - buildRPM "awips2-python-pupynere" - buildRPM "awips2-python-qpid" - buildRPM "awips2-python-scientific" - buildRPM "awips2-python-scipy" - buildRPM "awips2-python-tables" - buildRPM "awips2-python-thrift" - buildRPM "awips2-python-tpg" - buildRPM "awips2-python-ufpy" - buildRPM "awips2-python-werkzeug" - buildRPM "awips2-python-pygtk" - buildRPM "awips2-python-pycairo" - buildJava - buildRPM "awips2" - buildRPM "awips2-python-shapely" - buildRPM "awips2-notification" - - exit 0 -fi - -if [ "${1}" = "-rh6" ]; then - buildRPM "awips2-notification" - buildRPM "awips2-common-base" - buildEDEX - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-hydroapps-shared" - buildJava - buildRPM "awips2-python" - buildRPM "awips2-python-cherrypy" - buildRPM "awips2-python-nose" - buildRPM "awips2-python-pil" - buildRPM "awips2-python-jimporter" - buildRPM "awips2-python-qpid" - buildRPM "awips2-python-thrift" - buildRPM "awips2-python-werkzeug" - buildRPM "awips2-python-numpy" - buildRPM "awips2-python-pupynere" - buildRPM "awips2-python-h5py" - buildRPM "awips2-python-matplotlib" - buildRPM "awips2-python-scientific" - buildRPM "awips2-python-scipy" - buildRPM "awips2-python-tables" - buildRPM "awips2-python-pmw" - buildRPM "awips2-python-tpg" - buildRPM "awips2-python-ufpy" - buildRPM "awips2-python-dynamicserialize" - buildRPM "awips2-python-pycairo" - buildRPM "awips2-python-pygtk" - buildRPM "awips2-python-shapely" - buildRPM "awips2-ant" - buildRPM "awips2-tools" - buildRPM "awips2-postgres" - buildRPM "awips2-pgadmin3" - unpackHttpdPypies - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-httpd-pypies" - buildRPM "awips2-httpd-collaboration" - buildQPID - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-ldm" - buildCAVE - if [ $? -ne 0 ]; then - exit 0 - fi - buildRPM "awips2-alertviz" - buildRPM "awips2-database-server-configuration" - buildRPM "awips2-database-standalone-configuration" - buildRPM "awips2-database" - buildRPM "awips2-maps-database" - buildRPM "awips2-ncep-database" - buildRPM "awips2-adapt-native" - buildRPM "awips2-aviation-shared" - buildRPM "awips2-cli" - buildRPM "awips2-edex-environment" - buildRPM "awips2-data.gfe" - buildRPM "awips2-data.hdf5-gfe.climo" - buildRPM "awips2-gfesuite-client" - buildRPM "awips2-gfesuite-server" - buildRPM "awips2-groovy" - buildRPM "awips2-localapps-environment" - buildLocalizationRPMs - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-pypies" - buildRPM "awips2-rcm" - buildRPM "awips2-data.hdf5-topo" - buildRPM "awips2" - buildOpenfire - - exit 0 -fi - -if [ "${1}" = "-postgres" ]; then - buildRPM "awips2-postgres" - buildRPM "awips2-database-server-configuration" - buildRPM "awips2-database-standalone-configuration" - buildRPM "awips2-database" - buildRPM "awips2-maps-database" - buildRPM "awips2-ncep-database" - buildRPM "awips2-pgadmin3" - - exit 0 -fi - -if [ "${1}" = "-delta" ]; then - buildRPM "awips2-common-base" - buildCAVE - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-alertviz" - buildEDEX - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-python-dynamicserialize" - buildRPM "awips2-python-ufpy" - buildRPM "awips2-cli" - buildRPM "awips2-data.hdf5-gfe.climo" - buildRPM "awips2-gfesuite-client" - buildRPM "awips2-gfesuite-server" - buildRPM "awips2-localapps-environment" - buildRPM "awips2-data.hdf5-topo" - buildRPM "awips2-data.gfe" - buildRPM "awips2" - buildLocalizationRPMs - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-edex-environment" - buildRPM "awips2-notification" - - exit 0 -fi - -if [ "${1}" = "-full" ]; then - # buildRPM "awips2-common-base" - buildCAVE - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-alertviz" - buildEDEX - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-python" - buildRPM "awips2-python-cherrypy" - buildRPM "awips2-python-dynamicserialize" - buildRPM "awips2-python-h5py" - buildRPM "awips2-python-jimporter" - buildRPM "awips2-python-matplotlib" - buildRPM "awips2-python-nose" - buildRPM "awips2-python-numpy" - buildRPM "awips2-python-pil" - buildRPM "awips2-python-pmw" - buildRPM "awips2-python-pupynere" - # buildRPM "awips2-python-qpid" - buildRPM "awips2-python-scientific" - buildRPM "awips2-python-scipy" - buildRPM "awips2-python-tables" - buildRPM "awips2-python-thrift" - buildRPM "awips2-python-tpg" - buildRPM "awips2-python-ufpy" - buildRPM "awips2-python-werkzeug" - buildRPM "awips2-python-pygtk" - buildRPM "awips2-python-pycairo" - buildRPM "awips2-cli" - buildRPM "awips2-data.hdf5-gfe.climo" - buildRPM "awips2-gfesuite-client" - buildRPM "awips2-gfesuite-server" - buildRPM "awips2-localapps-environment" - buildRPM "awips2-data.hdf5-topo" - buildRPM "awips2-data.gfe" - buildRPM "awips2" - unpackHttpdPypies - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-httpd-pypies" - buildJava - buildRPM "awips2-groovy" - buildLocalizationRPMs - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-edex-environment" - buildRPM "awips2-notification" - buildRPM "awips2-python-shapely" - buildRPM "awips2-postgres" - buildRPM "awips2-database" - buildRPM "awips2-maps-database" - buildRPM "awips2-ncep-database" - buildRPM "awips2-pgadmin3" - buildRPM "awips2-ldm" - exit 0 -fi - -if [ "${1}" = "-ade" ]; then - echo "INFO: AWIPS II currently does not support a 64-bit version of the ADE." - exit 0 - buildRPM "awips2-eclipse" - - exit 0 -fi - -if [ "${1}" = "-viz" ]; then - buildRPM "awips2" - buildRPM "awips2-common-base" - buildRPM "awips2-tools" - buildRPM "awips2-cli" - buildCAVE - if [ $? -ne 0 ]; then - exit 1 - fi - buildRPM "awips2-alertviz" - - exit 0 -fi - -if [ "${1}" = "-edex" ]; then - buildRPM "awips2-common-base" - buildEDEX - if [ $? -ne 0 ]; then - exit 1 - fi - - exit 0 -fi - -if [ "${1}" = "-custom" ]; then - buildQPID - if [ $? -ne 0 ]; then - exit 1 - fi - - exit 0 -fi - -if [ "${1}" = "-qpid" ]; then - buildRPM "awips2-python-qpid" - buildQPID - if [ $? -ne 0 ]; then - exit 1 - fi - - exit 0 -fi - -if [ "${1}" = "-ldm" ]; then - buildRPM "awips2-ldm" - - exit 0 -fi - -if [ "${1}" = "-package" ]; then - repository_directory="awips2-repository-${AWIPSII_VERSION}-${AWIPSII_RELEASE}" - if [ -d ${WORKSPACE}/${repository_directory} ]; then - rm -rf ${WORKSPACE}/${repository_directory} - if [ $? -ne 0 ]; then - exit 1 - fi - fi - mkdir -p ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE} - if [ $? -ne 0 ]; then - exit 1 - fi - - cp -r ${AWIPSII_TOP_DIR}/RPMS/* \ - ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE} - if [ $? -ne 0 ]; then - exit 1 - fi - - rpms_directory="${WORKSPACE}/rpms" - comps_xml="${rpms_directory}/common/yum/arch.x86_64/comps.xml" - cp -v ${comps_xml} ${WORKSPACE}/${repository_directory} - if [ $? -ne 0 ]; then - exit 1 - fi - - pushd . > /dev/null - cd ${WORKSPACE} - tar -cvf ${repository_directory}.tar ${repository_directory} - RC=$? - popd > /dev/null - if [ ${RC} -ne 0 ]; then - exit 1 - fi - - exit 0 -fi - -usage -exit 0 diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializerTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializerTest.java index 8aeb5f9537..1564665401 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializerTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializerTest.java @@ -23,14 +23,12 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.junit.Before; import org.junit.Test; import com.google.common.collect.Sets; import com.raytheon.uf.common.datadelivery.registry.DataType; import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture; import com.raytheon.uf.common.datadelivery.registry.Subscription; -import com.raytheon.uf.edex.core.props.EnvAttributePropertyInjector; import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager; import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit; import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager; @@ -48,7 +46,9 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager; * Apr 18, 2013 1914 djohnson Fix broken test. * Jun 25, 2013 2106 djohnson init() now takes a {@link RetrievalManager}. * Sep 06, 2013 2344 bgonzale Added property injection of valid test value. - * Oct 21, 2013 2292 mpduff Implement multiple data types. + * Oct 21, 2013 2292 mpduff Implement multiple data types. + * Nov 04, 2013 2506 bgonzale Added site parameter to HibernateBandwidthInitializer + * constructor. * * * @@ -57,13 +57,6 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager; */ public class HibernateBandwidthInitializerTest { - @Before - public void setup() { - System.setProperty("edex.home", "../edexOsgi/build.edex/esb/"); - EnvAttributePropertyInjector.injectAttributeProperty("SITENAME", - "sitename", "OAX"); - } - @Test public void testSchedulesAllSubscriptionReturnedFromIFindSubscriptions() throws Exception { @@ -79,7 +72,7 @@ public class HibernateBandwidthInitializerTest { IBandwidthDbInit dbInit = mock(IBandwidthDbInit.class); final HibernateBandwidthInitializer initializer = new HibernateBandwidthInitializer( - strategy); + strategy, "OAX"); initializer .init(bandwidthManager, dbInit, mock(RetrievalManager.class)); initializer.executeAfterRegistryInit(); diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/DeserializeRetrievedDataFromIngestTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/DeserializeRetrievedDataFromIngestTest.java index af406879ea..5921978180 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/DeserializeRetrievedDataFromIngestTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/DeserializeRetrievedDataFromIngestTest.java @@ -24,22 +24,29 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import java.io.File; import java.io.IOException; import java.util.Date; import java.util.List; +import java.util.Random; import java.util.concurrent.ConcurrentLinkedQueue; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.mockito.Matchers; import com.raytheon.uf.common.localization.PathManagerFactoryTest; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.util.FileUtil; import com.raytheon.uf.common.util.TestUtil; import com.raytheon.uf.common.util.file.FilenameFilters; +import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao; import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord; +import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecordPK; /** * Test {@link DeserializeRetrievedDataFromIngest}. @@ -57,6 +64,9 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord; * Mar 19, 2013 1794 djohnson Read from a queue rather than the file system. * Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects. * Oct 01, 2013 2267 bgonzale Pass request parameter instead of components of request. + * Nov 04, 2013 2506 bgonzale Fixed IRetreivalDao mock initialization. + * Test deserialization of data with leading and trailing + * content on the xml. * * * @@ -72,11 +82,21 @@ public class DeserializeRetrievedDataFromIngestTest { private final DeserializeRetrievedDataFromIngest service = new DeserializeRetrievedDataFromIngest( retrievalQueue); + private final IRetrievalDao mockDao = mock(IRetrievalDao.class); + @BeforeClass public static void classSetUp() { PathManagerFactoryTest.initLocalization(); } + @Before + public void setup() { + when(mockDao.getById((RetrievalRequestRecordPK) Matchers.anyObject())) + .thenReturn( + RetrievalRequestRecordFixture.INSTANCE.getInstance(0, + new Random(0))); + } + @Test public void deserializesRetrievedDataFromTheQueue() throws Exception { @@ -110,6 +130,19 @@ public class DeserializeRetrievedDataFromIngestTest { assertNull(restored); } + @Test + public void attemptIngestWhenDataHasLeadingAndTrailingContent() + throws Exception { + + addSimulatedSBNRetrievalToQueue(); + + final RetrievalResponseXml restored = service.findRetrievals(); + + // check for the payload + assertThat(restored.getRetrievalAttributePluginDataObjects().get(0) + .getRetrievalResponse(), is(notNullValue())); + } + private void addRetrievalToQueue() throws SerializationException, IOException { RetrievalResponseXml retrievalPluginDataObjects = RetrievalPluginDataObjectsFixture.INSTANCE @@ -120,12 +153,51 @@ public class DeserializeRetrievedDataFromIngestTest { request.setInsertTime(new Date()); new SerializeRetrievedDataToDirectory(directory, - new AlwaysSameWmoHeader("SMYG10 LYBM 280000")) - .processRetrievedPluginDataObjects(request, - retrievalPluginDataObjects); + new AlwaysSameWmoHeader("SMYG10 LYBM 280000"), mockDao) + .processRetrievedPluginDataObjects(retrievalPluginDataObjects); final List files = FileUtil.listFiles(directory, FilenameFilters.ACCEPT_FILES, false); retrievalQueue.add(FileUtil.file2String(files.get(0))); } + + private void addSimulatedSBNRetrievalToQueue() + throws SerializationException, + IOException { + RetrievalResponseXml retrievalPluginDataObjects = RetrievalPluginDataObjectsFixture.INSTANCE + .get(); + RetrievalRequestRecord request = new RetrievalRequestRecord(); + request.setProvider(""); + request.setPlugin(""); + request.setInsertTime(new Date()); + + new SerializeRetrievedDataToDirectory(directory, + new WmoHeaderWithLeadingAndTrailingContent("SMYG10 LYBM 280000"), + mockDao) + .processRetrievedPluginDataObjects(retrievalPluginDataObjects); + + final List files = FileUtil.listFiles(directory, + FilenameFilters.ACCEPT_FILES, false); + retrievalQueue.add(FileUtil.file2String(files.get(0))); + } + + private static class WmoHeaderWithLeadingAndTrailingContent extends + AlwaysSameWmoHeader { + + public WmoHeaderWithLeadingAndTrailingContent(String wmoHeader) { + super(wmoHeader); + } + + @Override + public String applyWmoHeader(String dataProvider, String dataFormat, + String sourceType, Date date, String data) { + String SBN_noise_prefix = "001\r\r\n747\r\r\n"; + String SBN_noise_suffix = "\n\r\r\n 003"; + String output = super.applyWmoHeader(dataProvider, dataFormat, + sourceType, + date, data); + return SBN_noise_prefix + output + SBN_noise_suffix; + } + + } } diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTaskTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTaskTest.java index 9477f9ce16..c7b72d1bdc 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTaskTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTaskTest.java @@ -88,6 +88,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse * Apr 29, 2013 1910 djohnson Unregister from EventBus after each test. * Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects. * Oct 01, 2013 2267 bgonzale Pass request parameter instead of components of request. + * Nov 04, 2013 2506 bgonzale removed IRetrievalDao parameter. * * * @@ -108,10 +109,11 @@ public class RetrievalTaskTest { /** * {@inheritDoc} + * + * @return RetrievalRequestRecord */ @Override - public void processRetrievedPluginDataObjects( - RetrievalRequestRecord request, + public RetrievalRequestRecord processRetrievedPluginDataObjects( RetrievalResponseXml retrievalPluginDataObjects) throws SerializationException, TranslationException { final List retrievalAttributePluginDataObjects = retrievalPluginDataObjects @@ -143,6 +145,7 @@ public class RetrievalTaskTest { pluginDataObjects.addAll(Arrays.asList(pdos)); } } + return requestRecord; } } @@ -242,15 +245,16 @@ public class RetrievalTaskTest { final File testDirectory = TestUtil .setupTestClassDir(RetrievalTaskTest.class); IRetrievalPluginDataObjectsProcessor serializeToDirectory = new SerializeRetrievedDataToDirectory( - testDirectory, new AlwaysSameWmoHeader("SMYG10 LYBM 280000")); + testDirectory, new AlwaysSameWmoHeader("SMYG10 LYBM 280000"), + dao); RetrievalTask downloadTask = new RetrievalTask(Network.OPSNET, retrievalDataFinder, serializeToDirectory, - mock(IRetrievalResponseCompleter.class), dao); + mock(IRetrievalResponseCompleter.class)); RetrievalTask readDownloadsTask = new RetrievalTask(Network.OPSNET, new DeserializeRetrievedDataFromIngest(retrievalQueue), retrievedDataProcessor, new RetrievalResponseCompleter( - mock(SubscriptionNotifyTask.class), dao), dao); + mock(SubscriptionNotifyTask.class), dao)); downloadTask.run(); @@ -298,7 +302,7 @@ public class RetrievalTaskTest { mock(SubscriptionNotifyTask.class), dao); new RetrievalTask(Network.OPSNET, retrievalDataFinder, - retrievedDataProcessor, retrievalCompleter, dao).run(); + retrievedDataProcessor, retrievalCompleter).run(); } /** diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SerializeRetrievedDataToDirectoryTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SerializeRetrievedDataToDirectoryTest.java index a594ca4a98..9282f3615e 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SerializeRetrievedDataToDirectoryTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/SerializeRetrievedDataToDirectoryTest.java @@ -21,17 +21,24 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers; import static com.raytheon.uf.common.util.Matchers.hasNumberOfFiles; import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import java.io.File; import java.util.Date; +import java.util.Random; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.mockito.Matchers; import com.raytheon.uf.common.localization.PathManagerFactoryTest; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.util.TestUtil; +import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao; import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord; +import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecordPK; /** * Test {@link SerializeRetrievedDataToDirectory}. @@ -48,6 +55,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord; * Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects. * Oct 01, 2013 2267 bgonzale Pass request parameter instead of components of request. * Add test for wfs retrieval. + * Nov 04, 2013 2506 bgonzale removed IRetrievalDao and request parameters. * * * @@ -59,14 +67,24 @@ public class SerializeRetrievedDataToDirectoryTest { private final File directory = TestUtil .setupTestClassDir(SerializeRetrievedDataToDirectoryTest.class); + private final IRetrievalDao mockDao = mock(IRetrievalDao.class); + private final SerializeRetrievedDataToDirectory service = new SerializeRetrievedDataToDirectory( - directory, new AlwaysSameWmoHeader("SMYG10 LYBM 280000")); + directory, new AlwaysSameWmoHeader("SMYG10 LYBM 280000"), mockDao); @BeforeClass public static void classSetUp() { PathManagerFactoryTest.initLocalization(); } + @Before + public void setup() { + when(mockDao.getById((RetrievalRequestRecordPK) Matchers.anyObject())) + .thenReturn( + RetrievalRequestRecordFixture.INSTANCE.getInstance(0, + new Random(0))); + } + @Test public void serializesRetrievedDataToAFileInTheTargetDirectory() throws SerializationException { @@ -79,8 +97,7 @@ public class SerializeRetrievedDataToDirectoryTest { // "Model" request.setInsertTime(new Date()); - service.processRetrievedPluginDataObjects(request, - retrievalPluginDataObjects); + service.processRetrievedPluginDataObjects(retrievalPluginDataObjects); assertThat(directory, hasNumberOfFiles(1)); } @@ -97,8 +114,7 @@ public class SerializeRetrievedDataToDirectoryTest { // "Model" request.setInsertTime(new Date()); - service.processRetrievedPluginDataObjects(request, - retrievalPluginDataObjects); + service.processRetrievedPluginDataObjects(retrievalPluginDataObjects); assertThat(directory, hasNumberOfFiles(1)); }