Issue #1257: Fix Tropical Test Tool
Change-Id: I50c1d7e703d0d5e825ab9825f7fdbcd17ac0e49b Former-commit-id:e3da5faf40
[formerly ffb46aa8beab26ce61aa27eaeb8da41a417a24c0] Former-commit-id:45b25ead66
This commit is contained in:
parent
5edafa6c86
commit
449ad67f82
2 changed files with 40 additions and 21 deletions
|
@ -460,21 +460,45 @@ public abstract class PluginDao extends CoreDao {
|
|||
* If problems occur while interacting with the data stores
|
||||
*/
|
||||
public void purgeAllData() throws PluginException {
|
||||
purgeAllData(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purges all data associated with the productKeys and owning plugin
|
||||
*
|
||||
* @throws PluginException
|
||||
* If problems occur while interacting with the data stores
|
||||
*/
|
||||
public void purgeAllData(Map<String, String> productsKeys)
|
||||
throws PluginException {
|
||||
boolean purgeHdf5Data = false;
|
||||
try {
|
||||
// Determine if this plugin uses HDF5 to store data
|
||||
purgeHdf5Data = (PluginFactory.getInstance()
|
||||
.getPluginRecordClass(pluginName).newInstance() instanceof IPersistable);
|
||||
} catch (Exception e) {
|
||||
PurgeLogger.logError(
|
||||
"Unabled to determine if plugin has HDF5 data to purge",
|
||||
this.pluginName, e);
|
||||
}
|
||||
|
||||
try {
|
||||
List<Date> allRefTimes = getRefTimes();
|
||||
Map<String, List<String>> filesToDelete = new HashMap<String, List<String>>();
|
||||
for (Date d : allRefTimes) {
|
||||
this.purgeDataByRefTime(d, null, true, false, filesToDelete);
|
||||
this.purgeDataByRefTime(d, productsKeys, purgeHdf5Data, false,
|
||||
filesToDelete);
|
||||
}
|
||||
for (String file : filesToDelete.keySet()) {
|
||||
try {
|
||||
IDataStore ds = DataStoreFactory
|
||||
.getDataStore(new File(file));
|
||||
ds.deleteFiles(null);
|
||||
} catch (Exception e) {
|
||||
PurgeLogger.logError(
|
||||
"Error occurred purging file: " + file,
|
||||
this.pluginName, e);
|
||||
if (purgeHdf5Data) {
|
||||
for (String file : filesToDelete.keySet()) {
|
||||
try {
|
||||
IDataStore ds = DataStoreFactory.getDataStore(new File(
|
||||
file));
|
||||
ds.deleteFiles(null);
|
||||
} catch (Exception e) {
|
||||
PurgeLogger.logError("Error occurred purging file: "
|
||||
+ file, this.pluginName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -1072,7 +1096,9 @@ public abstract class PluginDao extends CoreDao {
|
|||
/**
|
||||
* Purges data from the database for this plugin with the given reference
|
||||
* time matching the given productKeys. If refTime is null, will purge all
|
||||
* data associated with the productKeys.
|
||||
* data associated with the productKeys. Hdf5 must be purged separately as
|
||||
* most hdf5 files can't be purged with a single reference time. Use the
|
||||
* passed map to track what needs to be done with hdf5.
|
||||
*
|
||||
* @param refTime
|
||||
* The reftime to delete data for. A null will purge all data for
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.plugin.grid.handler;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.grid.request.DeleteAllGridDataRequest;
|
||||
|
@ -59,19 +57,14 @@ public class DeleteAllGridDataHandler implements
|
|||
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
|
||||
*/
|
||||
@Override
|
||||
public Integer handleRequest(DeleteAllGridDataRequest request)
|
||||
public Boolean handleRequest(DeleteAllGridDataRequest request)
|
||||
throws Exception {
|
||||
Map<String, String> productKeys = new HashMap<String, String>();
|
||||
productKeys.put("info.datasetId", request.getModelName());
|
||||
GridDao dao = new GridDao();
|
||||
List<Date> times = dao.getRefTimesForCriteria(productKeys);
|
||||
int recsDeleted = 0;
|
||||
for (Date time : times) {
|
||||
recsDeleted += dao.purgeDataByRefTime(time, productKeys);
|
||||
}
|
||||
dao.purgeAllData(productKeys);
|
||||
|
||||
EDEXUtil.getMessageProducer().sendAsyncUri(PLUGIN_PURGED_TOPIC, "grid");
|
||||
|
||||
return recsDeleted;
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue