diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java index 5ea9c066f0..619a4f31ff 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java @@ -95,6 +95,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * 05/20/13 #2127 rjpeter Set session's to read only and switched to stateless where possible. * 08/08/13 DR16485 ryu Remove call to getDatabaseId() from getMaxInsertTimeByDbId() * so new GFE databases aren't accidentally created. + * 09/30/2013 #2147 rferrel Changes to archive hdf5 files. * * * @author bphillip @@ -106,6 +107,7 @@ public class GFEDao extends DefaultPluginDao { public GFEDao() throws PluginException { super("gfe"); + this.pathProvider = new GFEPathProvider(); } /** @@ -115,6 +117,7 @@ public class GFEDao extends DefaultPluginDao { */ public GFEDao(String pluginName) throws PluginException { super(pluginName); + this.pathProvider = new GFEPathProvider(); } /** diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEPathProvider.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEPathProvider.java new file mode 100644 index 0000000000..9a0d37c4e5 --- /dev/null +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEPathProvider.java @@ -0,0 +1,97 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.edex.plugin.gfe.db.dao; + +import java.io.File; + +import com.raytheon.edex.plugin.gfe.server.database.GridDatabase; +import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord; +import com.raytheon.uf.common.dataplugin.gfe.util.GfeUtil; +import com.raytheon.uf.common.dataplugin.persist.DefaultPathProvider; +import com.raytheon.uf.common.dataplugin.persist.IPersistable; + +/** + * Provider for GFE that uses the GfeUtil to get the HDF5 path and file names. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Sep 23, 2013 rferrel Initial creation + * + *+ * + * @author rferrel + * @version 1.0 + */ + +public class GFEPathProvider extends DefaultPathProvider { + + /** + * Constructor. + */ + public GFEPathProvider() { + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.common.dataplugin.persist.DefaultPathProvider#getHDFFileName + * (java.lang.String, + * com.raytheon.uf.common.dataplugin.persist.IPersistable) + */ + @Override + public String getHDFFileName(String pluginName, IPersistable persistable) { + String name = null; + if (persistable instanceof GFERecord) { + GFERecord gfeRecord = (GFERecord) persistable; + File hdf5File = GfeUtil.getHdf5File(GridDatabase.gfeBaseDataDir, + gfeRecord.getParmId(), gfeRecord.getTimeRange()); + name = hdf5File.toString(); + name = name.substring(name.lastIndexOf(File.separator) + 1); + } + return name; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.common.dataplugin.persist.DefaultPathProvider#getHDFPath + * (java.lang.String, + * com.raytheon.uf.common.dataplugin.persist.IPersistable) + */ + @Override + public String getHDFPath(String pluginName, IPersistable persistable) { + String path = null; + path = super.getHDFPath(pluginName, persistable); + if (persistable instanceof GFERecord) { + GFERecord gfeRecord = (GFERecord) persistable; + File pathDir = GfeUtil.getHdf5Dir(GridDatabase.gfeBaseDataDir, + gfeRecord.getDbId()); + path = pathDir.toString(); + path = path.substring(pluginName.length() + 1); + } + return path; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/objects/GFERecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/objects/GFERecord.java index 489dfb9319..347f7eab1e 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/objects/GFERecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/objects/GFERecord.java @@ -25,6 +25,7 @@ package com.raytheon.uf.common.dataplugin.gfe.db.objects; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; +import java.util.Date; import java.util.List; import java.util.TimeZone; @@ -47,6 +48,7 @@ import org.hibernate.annotations.OnDeleteAction; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.annotations.DataURI; import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory; +import com.raytheon.uf.common.dataplugin.persist.IPersistable; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.time.DataTime; @@ -78,6 +80,7 @@ import com.raytheon.uf.common.time.TimeRange; * May 13, 2013 1869 bsteffen Remove DataURI column from GFE. * Jun 20, 2013 2127 rjpeter Added OnDelete annotation. * Aug 30, 2013 2298 rjpeter Make getPluginName abstract + * Sep 20, 2013 2147 rferrel Changes to archive hdf5 files. * * * @@ -96,7 +99,7 @@ import com.raytheon.uf.common.time.TimeRange; "refTime", "forecastTime" }) }) @DynamicSerialize @BatchSize(size = 500) -public class GFERecord extends PluginDataObject { +public class GFERecord extends PluginDataObject implements IPersistable { private static final long serialVersionUID = 1L; @@ -281,4 +284,16 @@ public class GFERecord extends PluginDataObject { public String getPluginName() { return "gfe"; } + + @Override + public Date getPersistenceTime() { + return getInsertTime().getTime(); + } + + @Override + public void setPersistenceTime(Date persistTime) { + Calendar pTime = Calendar.getInstance(); + pTime.setTime(persistTime); + setInsertTime(pTime); + } }