From 6f1720aae03bde2ea2c2563938d043950d9f982f Mon Sep 17 00:00:00 2001 From: David Gillingham Date: Tue, 2 Oct 2012 12:32:13 -0500 Subject: [PATCH] Issue #1236: Merge tropical automated testing changes from old git repo to common baseline. Change-Id: I820b4e09482b52ecd42252bec7eb95c1db741c95 Former-commit-id: f17309d5f74b67b9574848363fca3a63edf08175 [formerly e27be9180b5735ee3e21cb92a1613c5ffa941d9a [formerly b64085fb436bb8347c3bff529f1c421c665c6438]] Former-commit-id: e27be9180b5735ee3e21cb92a1613c5ffa941d9a Former-commit-id: 65057b8cedcc6f3435bcc5c80d6fb9cde5e67ba9 --- .../awips/AbstractCAVEComponent.java | 55 ++++++-- .../res/spring/grib-request.xml | 6 +- .../edex/plugin/grib/dao/GribDao.java | 133 ++++++++++-------- .../handler/DeleteAllModelDataHandler.java | 59 ++++++++ .../request/DeleteAllModelDataRequest.java | 78 ++++++++++ .../impl/purgeAllModelData | 51 +++++++ .../purgeallmodeldata/purgeAllModelData.py | 77 ++++++++++ .../raytheon/uf/common/dataplugin/__init__.py | 3 +- .../gfe/request/AbstractGfeRequest.py | 44 ++++++ .../request/ClearPracticeVTECTableRequest.py | 45 ++++++ .../common/dataplugin/gfe/request/__init__.py | 4 + .../gfe/server/message/ServerResponse.py | 5 +- .../uf/common/dataplugin/grib/__init__.py | 27 ++++ .../grib/request/DeleteAllModelDataRequest.py | 33 +++++ .../dataplugin/grib/request/__init__.py | 28 ++++ 15 files changed, 575 insertions(+), 73 deletions(-) create mode 100644 edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/handler/DeleteAllModelDataHandler.java create mode 100644 edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/request/DeleteAllModelDataRequest.java create mode 100644 edexOsgi/com.raytheon.uf.tools.cli/impl/purgeAllModelData create mode 100644 edexOsgi/com.raytheon.uf.tools.cli/impl/src/purgeallmodeldata/purgeAllModelData.py create mode 100644 pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py create mode 100644 pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/ClearPracticeVTECTableRequest.py create mode 100644 pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/__init__.py create mode 100644 pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/request/DeleteAllModelDataRequest.py create mode 100644 pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/request/__init__.py diff --git a/cave/com.raytheon.viz.ui.personalities.awips/src/com/raytheon/viz/ui/personalities/awips/AbstractCAVEComponent.java b/cave/com.raytheon.viz.ui.personalities.awips/src/com/raytheon/viz/ui/personalities/awips/AbstractCAVEComponent.java index 4999d82d18..05ca7443e3 100644 --- a/cave/com.raytheon.viz.ui.personalities.awips/src/com/raytheon/viz/ui/personalities/awips/AbstractCAVEComponent.java +++ b/cave/com.raytheon.viz.ui.personalities.awips/src/com/raytheon/viz/ui/personalities/awips/AbstractCAVEComponent.java @@ -20,7 +20,11 @@ package com.raytheon.viz.ui.personalities.awips; import java.io.IOException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; +import java.util.TimeZone; import javax.xml.bind.JAXBException; @@ -49,6 +53,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.viz.alertviz.SystemStatusHandler; import com.raytheon.uf.viz.alertviz.ui.dialogs.AlertVisualization; +import com.raytheon.uf.viz.application.ProgramArguments; import com.raytheon.uf.viz.application.component.IStandaloneComponent; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.localization.CAVELocalizationNotificationObserver; @@ -77,6 +82,11 @@ import com.raytheon.viz.core.units.UnitRegistrar; * and CAVE immediately exits * if connection cannot be made to * localization server. + * May 31, 2012 #674 dgilling Allow SimulatedTime to be set from + * the command line. + * Oct 02, 2012 #1236 dgilling Allow SimulatedTime to be set from + * the command line even if practice + * mode is off. * * * @@ -105,10 +115,6 @@ public abstract class AbstractCAVEComponent implements IStandaloneComponent { @SuppressWarnings("restriction") @Override public final Object startComponent(String componentName) throws Exception { - UnitRegistrar.registerUnits(); - CAVEMode.performStartupDuties(); - - long t0 = System.currentTimeMillis(); // This is a workaround to receive status messages because without the // PlatformUI initialized Eclipse throws out the status // messages. Once PlatformUI has started, the status handler @@ -127,6 +133,11 @@ public abstract class AbstractCAVEComponent implements IStandaloneComponent { }); + UnitRegistrar.registerUnits(); + CAVEMode.performStartupDuties(); + + long t0 = System.currentTimeMillis(); + Display display = null; int modes = getRuntimeModes(); boolean alertviz = (modes & ALERT_VIZ) != 0; @@ -192,9 +203,7 @@ public abstract class AbstractCAVEComponent implements IStandaloneComponent { System.out.println("Localization time: " + (t1 - t0) + "ms"); try { - if (CAVEMode.getMode() == CAVEMode.PRACTICE) { - restoreUserTime(); - } + initializeSimulatedTime(); if (cave) { workbenchAdvisor = getWorkbenchAdvisor(); @@ -274,14 +283,34 @@ public abstract class AbstractCAVEComponent implements IStandaloneComponent { /** * Restore the prior state of SimulatedTime */ - private void restoreUserTime() { - // Get the last saved time from the localization settings - - // If CorePlugin.getDefault() == null, assume running from a unit test + private void initializeSimulatedTime() { long timeValue = 0; boolean isFrozen = false; - if (CAVEMode.getMode() == CAVEMode.PRACTICE - && CorePlugin.getDefault() != null) { + + // If CorePlugin.getDefault() == null, assume running from a unit test + if (CorePlugin.getDefault() != null) { + String dateString = ProgramArguments.getInstance().getString( + "-time"); + if (dateString != null && !dateString.isEmpty()) { + try { + DateFormat dateParser = new SimpleDateFormat( + "yyyyMMdd_HHmm"); + dateParser.setTimeZone(TimeZone.getTimeZone("GMT")); + Date newSimTime = dateParser.parse(dateString); + timeValue = newSimTime.getTime(); + } catch (ParseException e) { + statusHandler + .handle(Priority.WARN, + "Invalid argument specified for command-line parameter '-time'.", + e); + } + } + } + + // if we're in practice mode and the user did not specify a DRT value on + // the CLI, restore their previous time setting + if ((CAVEMode.getMode() == CAVEMode.PRACTICE) && (timeValue == 0)) { + // Get the last saved time from the localization settings timeValue = CorePlugin.getDefault().getPreferenceStore() .getLong(PreferenceConstants.P_LAST_USER_TIME); diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-request.xml b/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-request.xml index 4bbbb1e9cc..566c947ccd 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-request.xml +++ b/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-request.xml @@ -23,5 +23,9 @@ - + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/dao/GribDao.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/dao/GribDao.java index 78a6813581..a828854996 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/dao/GribDao.java +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/dao/GribDao.java @@ -57,11 +57,15 @@ 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.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.core.dataplugin.PluginRegistry; import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.plugin.PluginDao; +import com.raytheon.uf.edex.database.query.DatabaseQuery; /** * Data access object for accessing Grib records from the database @@ -73,6 +77,8 @@ import com.raytheon.uf.edex.database.plugin.PluginDao; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 4/7/09 1994 bphillip Initial Creation + * 5/31/12 #674 dgilling Re-factor so all purge methods + * call updateCaches(). * * * @@ -81,6 +87,9 @@ import com.raytheon.uf.edex.database.plugin.PluginDao; */ public class GribDao extends PluginDao { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(GribDao.class); + private static final String LOCAL_SECTION = "localSection"; private static final String HYBRID_LEVELS = "hybridLevels"; @@ -91,8 +100,6 @@ public class GribDao extends PluginDao { private static final String PURGE_MODEL_CACHE_TOPIC = "jms-generic:topic:purgeGribModelCache"; - private static final String ORPHAN_MODEL_QUERY = "select id from awips.grib_models where id not in(select distinct(modelinfo_id) from awips.grib)"; - /** * Creates a new GribPyDao object * @@ -109,62 +116,64 @@ public class GribDao extends PluginDao { this("grib"); } + @Override public void purgeExpiredData() throws PluginException { super.purgeExpiredData(); - try { - List orphanedIds = purgeGribModelOrphans(); - EDEXUtil.getMessageProducer().sendAsyncUri(PURGE_MODEL_CACHE_TOPIC, - orphanedIds); - } catch (DataAccessLayerException e1) { - statusHandler - .error("Error purging orphaned grib model entries", e1); - } catch (EdexException e) { - statusHandler.error( - "Error sending message to purge grib model topic", e); - } - try { - EDEXUtil.getMessageProducer().sendAsyncUri(REBUILD_CACHE_TOPIC, - null); - } catch (EdexException e) { - statusHandler.error( - "Error sending message to rebuild D2D Cache topic", e); - } + updateCaches(); } private List purgeGribModelOrphans() throws DataAccessLayerException { - QueryResult result = (QueryResult) this - .executeNativeSql(ORPHAN_MODEL_QUERY); + QueryResult result = (QueryResult) executeNativeSql("select id from awips.grib_models where id not in(select distinct(modelinfo_id) from awips.grib)"); List orphanedIds = new ArrayList(); for (int i = 0; i < result.getResultCount(); i++) { - orphanedIds.add((Integer) result.getRowColumnValue(0, 0)); + orphanedIds.add((Integer) result.getRowColumnValue(i, 0)); } + if (!orphanedIds.isEmpty()) { - this.executeNativeSql(ORPHAN_MODEL_QUERY.replace("select id", - "delete")); + DatabaseQuery deleteQuery = new DatabaseQuery(GribModel.class); + deleteQuery.addQueryParam("id", orphanedIds, "in"); + deleteByCriteria(deleteQuery); } return orphanedIds; } + @Override public void purgeAllData() throws PluginException { super.purgeAllData(); + updateCaches(); + } + + /** + * @throws PluginException + */ + private void updateCaches() throws PluginException { + Exception rethrow = null; + try { List orphanedIds = purgeGribModelOrphans(); EDEXUtil.getMessageProducer().sendAsyncUri(PURGE_MODEL_CACHE_TOPIC, orphanedIds); - } catch (DataAccessLayerException e1) { - statusHandler - .error("Error purging orphaned grib model entries", e1); - } catch (EdexException e) { + } catch (DataAccessLayerException e) { + statusHandler.error("Error purging orphaned grib model entries", e); + rethrow = e; + } catch (EdexException e1) { statusHandler.error( - "Error sending message to purge grib model topic", e); + "Error sending message to purge grib model topic", e1); + rethrow = e1; } try { EDEXUtil.getMessageProducer().sendAsyncUri(REBUILD_CACHE_TOPIC, null); } catch (EdexException e) { - throw new PluginException( + statusHandler.error( "Error sending message to rebuild D2D Cache topic", e); + rethrow = e; + } + + if (rethrow != null) { + throw new PluginException( + "Error updating GribModelCache or D2DParmIDCache", rethrow); } } @@ -192,12 +201,13 @@ public class GribDao extends PluginDao { storageRecord = new FloatDataRecord("Data", gribRec.getDataURI(), (float[]) gribRec.getMessageData(), 2, sizes); - } else + } else { throw new Exception( "Cannot create data record, spatialData = " + gribRec.getSpatialObject() + " and messageData = " + gribRec.getMessageData()); + } } else if (gribRec.getMessageData() instanceof byte[]) { storageRecord = new ByteDataRecord("Data", gribRec.getDataURI(), (byte[]) gribRec.getMessageData()); @@ -411,16 +421,13 @@ public class GribDao extends PluginDao { public List replaceRecord(GribRecord pdo) throws PluginException { List exceptions = new ArrayList(); - IPersistable persistable = (IPersistable) pdo; + IPersistable persistable = pdo; persistable.setHdfFileId(EDEXUtil.getServerId()); // get the directory - String directory = HDF5_DIR + String directory = HDF5_DIR + File.separator + pdo.getPluginName() + File.separator - + pdo.getPluginName() - + File.separator - + pathProvider.getHDFPath(pdo.getPluginName(), - (IPersistable) pdo); + + pathProvider.getHDFPath(pdo.getPluginName(), pdo); File dataStoreFile = new File(directory + File.separator + pathProvider.getHDFFileName(pdo.getPluginName(), persistable)); @@ -445,26 +452,38 @@ public class GribDao extends PluginDao { } public int purgeModelData(final String modelName) { - return (Integer) txTemplate.execute(new TransactionCallback() { - @Override - public Object doInTransaction(TransactionStatus status) { - int rval = 0; - HibernateTemplate ht = getHibernateTemplate(); - Session sess = ht.getSessionFactory().getCurrentSession(); - Query modelIdQuery = sess - .createQuery("SELECT distinct id from GribModel where modelName = :modelName"); - modelIdQuery.setString("modelName", modelName); - List mIds = (List) modelIdQuery.list(); - for (Integer mId : mIds) { - Query query = sess - .createQuery("DELETE from GribRecord where modelInfo.id = :mId"); - query.setInteger("mId", mId); - rval += query.executeUpdate(); - } + Integer recordsDeleted = (Integer) txTemplate + .execute(new TransactionCallback() { + @SuppressWarnings("unchecked") + @Override + public Object doInTransaction(TransactionStatus status) { + int rval = 0; + HibernateTemplate ht = getHibernateTemplate(); + Session sess = ht.getSessionFactory() + .getCurrentSession(); + Query modelIdQuery = sess + .createQuery("SELECT distinct id from GribModel where modelName = :modelName"); + modelIdQuery.setString("modelName", modelName); + List mIds = modelIdQuery.list(); + for (Integer mId : mIds) { + Query query = sess + .createQuery("DELETE from GribRecord where modelInfo.id = :mId"); + query.setInteger("mId", mId); + rval += query.executeUpdate(); + } - return rval; - } - }); + return rval; + } + }); + + try { + updateCaches(); + } catch (PluginException e) { + statusHandler.handle(Priority.PROBLEM, + "Could not update grib cache.", e); + } + + return recordsDeleted; } public void purgeHdf5ModelData(final String modelName) diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/handler/DeleteAllModelDataHandler.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/handler/DeleteAllModelDataHandler.java new file mode 100644 index 0000000000..46af8ca494 --- /dev/null +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/handler/DeleteAllModelDataHandler.java @@ -0,0 +1,59 @@ +/** + * 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.grib.handler; + +import com.raytheon.edex.plugin.grib.dao.GribModelDao; +import com.raytheon.uf.common.dataplugin.grib.request.DeleteAllModelDataRequest; +import com.raytheon.uf.common.serialization.comm.IRequestHandler; + +/** + * Request handler for DeleteAllModelDataRequest. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 25, 2012            dgilling     Initial creation
+ * 
+ * 
+ * + * @author dgilling + * @version 1.0 + */ + +public class DeleteAllModelDataHandler implements + IRequestHandler { + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest + * (com.raytheon.uf.common.serialization.comm.IServerRequest) + */ + @Override + public Integer handleRequest(DeleteAllModelDataRequest request) + throws Exception { + return new GribModelDao().deleteModelAndAssociatedData(request + .getModelName()); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/request/DeleteAllModelDataRequest.java b/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/request/DeleteAllModelDataRequest.java new file mode 100644 index 0000000000..1054cab501 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.grib/src/com/raytheon/uf/common/dataplugin/grib/request/DeleteAllModelDataRequest.java @@ -0,0 +1,78 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.dataplugin.grib.request; + +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 object used to delete all stored data for the specified model name. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 25, 2012            dgilling     Initial creation
+ * 
+ * 
+ * + * @author dgilling + * @version 1.0 + */ + +@DynamicSerialize +public class DeleteAllModelDataRequest implements IServerRequest { + + @DynamicSerializeElement + private String modelName; + + public DeleteAllModelDataRequest() { + this(null); + } + + public DeleteAllModelDataRequest(String modelName) { + this.modelName = modelName; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DeleteAllModelDataRequest [modelName="); + builder.append(modelName); + builder.append("]"); + return builder.toString(); + } +} diff --git a/edexOsgi/com.raytheon.uf.tools.cli/impl/purgeAllModelData b/edexOsgi/com.raytheon.uf.tools.cli/impl/purgeAllModelData new file mode 100644 index 0000000000..3c62942dcb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.tools.cli/impl/purgeAllModelData @@ -0,0 +1,51 @@ +#!/bin/bash +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +############################################################################## +# This script allows you to purge all ingested data for a specified +# model. +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/08/12 #674 dgilling Initial Creation. +############################################################################## + +# this allows you to run this script from outside of ./bin +path_to_script=`readlink -f $0` +RUN_FROM_DIR=`dirname $path_to_script` + +BASE_AWIPS_DIR=`dirname $RUN_FROM_DIR` + +# get the base environment +source ${RUN_FROM_DIR}/setup.env + +# setup the environment needed to run the the Python +export LD_LIBRARY_PATH=${BASE_AWIPS_DIR}/src/lib:${PYTHON_INSTALL}/lib +export PYTHONPATH=${RUN_FROM_DIR}/src:$PYTHONPATH + +# execute the ifpInit Python module +_PYTHON="${PYTHON_INSTALL}/bin/python" +_MODULE="${RUN_FROM_DIR}/src/purgeallmodeldata/purgeAllModelData.py" + +# quoting of '$@' is used to prevent command line interpretation +$_PYTHON $_MODULE -h ${DEFAULT_HOST} -p ${DEFAULT_PORT} "$@" + diff --git a/edexOsgi/com.raytheon.uf.tools.cli/impl/src/purgeallmodeldata/purgeAllModelData.py b/edexOsgi/com.raytheon.uf.tools.cli/impl/src/purgeallmodeldata/purgeAllModelData.py new file mode 100644 index 0000000000..5d89d35b26 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.tools.cli/impl/src/purgeallmodeldata/purgeAllModelData.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +## +# 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. +## + +import logging + +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.grib.request import DeleteAllModelDataRequest +from ufpy import ThriftClient +from ufpy import UsageArgumentParser + +logger = None +def __initLogger(): + global logger + logger = logging.getLogger("purgeAllModelData") + logger.setLevel(logging.DEBUG) + ch = logging.StreamHandler() + ch.setLevel(logging.INFO) + # Uncomment line below to enable debug-level logging + # ch.setLevel(logging.DEBUG) + formatter = logging.Formatter("%(asctime)s %(name)s %(levelname)s: %(message)s", "%H:%M:%S") + ch.setFormatter(formatter) + logger.addHandler(ch) + +def __parseCommandLine(): + parser = UsageArgumentParser.UsageArgumentParser(conflict_handler="resolve", prog='purgeAllModelData') + parser.add_argument("-h", action="store", dest="host", + help="Host upon which the EDEX server is running", + required=True, metavar="hostname") + parser.add_argument("-p", action="store", type=int, dest="port", + help="Port on which the EDEX server is listening", + required=True, metavar="portNumber") + parser.add_argument("-m", action="append", dest="models", + help="Name of the model to purge. Use multiple -m arguments to delete more than 1 model, but duplicate model names will be ignored.", + required=True, metavar="modelName") + options = parser.parse_args() + # Ensure no duplicates end up in the list of models + options.models = list(set(options.models)) + logger.debug("Command-line arguments: " + str(options)) + return options + +def main(): + __initLogger() + logger.info("Starting purgeAllModelData.") + options = __parseCommandLine() + + client = ThriftClient.ThriftClient(options.host, options.port) + for model in options.models: + try: + logger.info("Deleting all data for model [" + model + "]...") + req = DeleteAllModelDataRequest(model) + client.sendRequest(req) + logger.info("Model data for model [" + model + "] successfully deleted...") + except Exception: + logger.exception("Could not purge data for model [" + model + "]:") + logger.info("purgeAllModelData is complete.") + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/__init__.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/__init__.py index 5b50d7706f..f73c59de6b 100644 --- a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/__init__.py +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/__init__.py @@ -21,7 +21,8 @@ # File auto-generated by PythonFileGenerator __all__ = [ - 'gfe' + 'gfe', + 'grib' ] diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py new file mode 100644 index 0000000000..057decc980 --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py @@ -0,0 +1,44 @@ +## +# 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. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +import abc + + +class AbstractGfeRequest(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __init__(self): + self.siteID = None + self.workstationID = None + + def getSiteID(self): + return self.siteID + + def setSiteID(self, siteID): + self.siteID = siteID + + def getWorkstationID(self): + return self.workstationID + + def setWorkstationID(self, workstationID): + self.workstationID = workstationID diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/ClearPracticeVTECTableRequest.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/ClearPracticeVTECTableRequest.py new file mode 100644 index 0000000000..a478846e05 --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/ClearPracticeVTECTableRequest.py @@ -0,0 +1,45 @@ +## +# 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. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import AbstractGfeRequest + + +class ClearPracticeVTECTableRequest(AbstractGfeRequest): + + def __init__(self): + super(ClearPracticeVTECTableRequest, self).__init__() + self.requestedSiteId = None + self.mode = None + + def getRequestedSiteId(self): + return self.requestedSiteId + + def setRequestedSiteId(self, requestedSiteId): + self.requestedSiteId = requestedSiteId + + def getMode(self): + return self.mode + + def setMode(self, mode): + if mode not in ['OPERATIONAL', 'PRACTICE']: + raise ValueError("Invalid value " + mode + " specified for ActiveTableMode.") + self.mode = mode diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py index c969f576df..254921cff2 100644 --- a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py @@ -21,6 +21,8 @@ # File auto-generated by PythonFileGenerator __all__ = [ + 'AbstractGfeRequest', + 'ClearPracticeVTECTableRequest', 'CommitGridsRequest', 'ConfigureTextProductsRequest', 'CreateNetCDFGridRequest', @@ -48,6 +50,8 @@ __all__ = [ ] from CommitGridsRequest import CommitGridsRequest +from AbstractGfeRequest import AbstractGfeRequest +from ClearPracticeVTECTableRequest import ClearPracticeVTECTableRequest from ConfigureTextProductsRequest import ConfigureTextProductsRequest from CreateNetCDFGridRequest import CreateNetCDFGridRequest from ExecuteIscMosaicRequest import ExecuteIscMosaicRequest diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py index 3a0b745cd4..80f8fd0a17 100644 --- a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py @@ -56,4 +56,7 @@ class ServerResponse(object): for serverMsg in self.messages: compMessage += serverMsg.getMessage() + "\n" - return compMessage \ No newline at end of file + return compMessage + + def __str__(self): + return self.message() \ No newline at end of file diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/__init__.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/__init__.py new file mode 100644 index 0000000000..eaa0c74aed --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/__init__.py @@ -0,0 +1,27 @@ +## +# 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. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'request' + ] + + diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/request/DeleteAllModelDataRequest.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/request/DeleteAllModelDataRequest.py new file mode 100644 index 0000000000..6bb7c6cff7 --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/request/DeleteAllModelDataRequest.py @@ -0,0 +1,33 @@ +## +# 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. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +class DeleteAllModelDataRequest(object): + + def __init__(self, modelName=None): + self.modelName = modelName + + def getModelName(self): + return self.modelName + + def setModelName(self, modelName): + self.modelName = modelName + diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/request/__init__.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/request/__init__.py new file mode 100644 index 0000000000..1bfd9bf59b --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grib/request/__init__.py @@ -0,0 +1,28 @@ +## +# 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. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'DeleteAllModelDataRequest' + ] + +from DeleteAllModelDataRequest import DeleteAllModelDataRequest +