Issue #851 Fixed issues with DatabaseID.dateFormat
Change-Id: Ia5d99932059cec78074096e9ef08fa7b90b13e72 Former-commit-id:b52f1400ef
[formerly 1816e3f6c96b1064d52a2cbdf75ae02fb27e3693] Former-commit-id:1f2e581534
This commit is contained in:
parent
286274aed0
commit
21431b2693
8 changed files with 61 additions and 46 deletions
|
@ -21,6 +21,7 @@ package com.raytheon.viz.gfe.core.internal;
|
|||
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -31,6 +32,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.eclipse.core.runtime.ListenerList;
|
||||
|
||||
|
@ -104,6 +106,13 @@ public abstract class AbstractParmManager implements IParmManager {
|
|||
|
||||
private static final int NOTIFICATION_THREADS = 4;
|
||||
|
||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
|
||||
DatabaseID.MODEL_TIME_FORMAT);
|
||||
|
||||
static {
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
|
||||
protected class ParmIDVis {
|
||||
private ParmID pid;
|
||||
|
||||
|
@ -469,8 +478,8 @@ public abstract class AbstractParmManager implements IParmManager {
|
|||
if (string.length() - pos == 14) {
|
||||
try {
|
||||
dtg = string.substring(pos + 1);
|
||||
synchronized (DatabaseID.dateFormat) {
|
||||
DatabaseID.dateFormat.parse(dtg);
|
||||
synchronized (dateFormat) {
|
||||
dateFormat.parse(dtg);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
|
|
|
@ -917,11 +917,8 @@ public class GFEDao extends DefaultPluginDao {
|
|||
|
||||
for (int i = 0; i < result.getResultCount(); i++) {
|
||||
DatabaseID dbId = null;
|
||||
synchronized (DatabaseID.dateFormat) {
|
||||
dbId = new DatabaseID(siteID, DataType.GRID, "D2D", gfeModel,
|
||||
DatabaseID.dateFormat.format(result.getRowColumnValue(
|
||||
i, 0)));
|
||||
}
|
||||
dbId = new DatabaseID(siteID, DataType.GRID, "D2D", gfeModel,
|
||||
(Date) result.getRowColumnValue(i, 0));
|
||||
if (!dbInventory.contains(dbId)) {
|
||||
dbInventory.add(dbId);
|
||||
}
|
||||
|
|
|
@ -113,8 +113,7 @@ public class GfeIngestNotificationFilter {
|
|||
// ignore if no mapping
|
||||
if (gfeModel != null && gfeModel.length() > 0) {
|
||||
DatabaseID dbId = new DatabaseID(site, DataType.GRID,
|
||||
"D2D", gfeModel, DatabaseID.dateFormat.format(grib
|
||||
.getDataTime().getRefTime()));
|
||||
"D2D", gfeModel, grib.getDataTime().getRefTime());
|
||||
|
||||
if ((!D2DParmIdCache.getInstance().getDatabaseIDs()
|
||||
.contains(dbId))
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.gfe.smartinit;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
@ -55,9 +54,6 @@ public class InitModules {
|
|||
|
||||
private static final Log logger = LogFactory.getLog(InitModules.class);
|
||||
|
||||
public static final SimpleDateFormat dateFormat = (SimpleDateFormat) DatabaseID.dateFormat
|
||||
.clone();
|
||||
|
||||
// Counter used to simply force one full model run to complete a smart init
|
||||
// before another when many inits started at once
|
||||
private static long manualOffset = 0;
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
package com.raytheon.edex.plugin.gfe.smartinit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
|
@ -28,6 +30,7 @@ import javax.persistence.EnumType;
|
|||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
@ -56,6 +59,13 @@ public class SmartInitRecordPK implements ISerializableObject, Serializable,
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
|
||||
DatabaseID.MODEL_TIME_FORMAT);
|
||||
|
||||
static {
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
|
||||
public enum State {
|
||||
PENDING, RUNNING
|
||||
};
|
||||
|
@ -139,28 +149,37 @@ public class SmartInitRecordPK implements ISerializableObject, Serializable,
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SmartInitRecordPK other = (SmartInitRecordPK) obj;
|
||||
if (initName == null) {
|
||||
if (other.initName != null)
|
||||
if (other.initName != null) {
|
||||
return false;
|
||||
} else if (!initName.equals(other.initName))
|
||||
}
|
||||
} else if (!initName.equals(other.initName)) {
|
||||
return false;
|
||||
}
|
||||
if (state == null) {
|
||||
if (other.state != null)
|
||||
if (other.state != null) {
|
||||
return false;
|
||||
} else if (!state.equals(other.state))
|
||||
}
|
||||
} else if (!state.equals(other.state)) {
|
||||
return false;
|
||||
}
|
||||
if (validTime == null) {
|
||||
if (other.validTime != null)
|
||||
if (other.validTime != null) {
|
||||
return false;
|
||||
} else if (!validTime.equals(other.validTime))
|
||||
}
|
||||
} else if (!validTime.equals(other.validTime)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -170,8 +189,8 @@ public class SmartInitRecordPK implements ISerializableObject, Serializable,
|
|||
tmp.append(initName);
|
||||
tmp.append(" ValidTime: ");
|
||||
if (validTime != null) {
|
||||
synchronized (InitModules.dateFormat) {
|
||||
tmp.append(InitModules.dateFormat.format(validTime));
|
||||
synchronized (dateFormat) {
|
||||
tmp.append(dateFormat.format(validTime));
|
||||
}
|
||||
} else {
|
||||
tmp.append("null");
|
||||
|
|
|
@ -36,12 +36,10 @@ from java.util import ArrayList
|
|||
from com.raytheon.edex.plugin.gfe.config import IFPServerConfig
|
||||
from com.raytheon.edex.plugin.gfe.config import IFPServerConfigManager
|
||||
from com.raytheon.edex.plugin.gfe.util import CartDomain2D
|
||||
from com.raytheon.uf.common.dataplugin.gfe.db.objects import DatabaseID
|
||||
from com.raytheon.uf.common.dataplugin.gfe.db.objects import GridLocation
|
||||
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceData
|
||||
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceID
|
||||
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceData_CoordinateType as CoordinateType
|
||||
from com.raytheon.uf.common.dataplugin.gfe.util import GfeUtil
|
||||
|
||||
from com.vividsolutions.jts.geom import Coordinate
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class DatabaseID implements Serializable, Comparable<DatabaseID>,
|
|||
|
||||
public static final String MODEL_TIME_FORMAT = "yyyyMMdd_HHmm";
|
||||
|
||||
public static final SimpleDateFormat dateFormat = new SimpleDateFormat(
|
||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
|
||||
MODEL_TIME_FORMAT);
|
||||
|
||||
static {
|
||||
|
@ -150,7 +150,14 @@ public class DatabaseID implements Serializable, Comparable<DatabaseID>,
|
|||
*/
|
||||
public DatabaseID(String siteId, DataType format, String dbType,
|
||||
String modelName, Date modelTime) {
|
||||
this(siteId, format, dbType, modelName, dateFormat.format(modelTime));
|
||||
this.siteId = siteId;
|
||||
this.format = format;
|
||||
this.dbType = dbType;
|
||||
this.modelName = modelName;
|
||||
synchronized (dateFormat) {
|
||||
this.modelTime = dateFormat.format(modelTime);
|
||||
}
|
||||
encodeIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,10 +352,15 @@ public class DatabaseID implements Serializable, Comparable<DatabaseID>,
|
|||
}
|
||||
|
||||
private boolean decodeDtg(String dtgString) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmm");
|
||||
if (dtgString == null
|
||||
|| dtgString.length() != MODEL_TIME_FORMAT.length()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Date date = sdf.parse(dtgString);
|
||||
modelTime = sdf.format(date);
|
||||
synchronized (dateFormat) {
|
||||
dateFormat.parse(dtgString);
|
||||
}
|
||||
modelTime = dtgString;
|
||||
} catch (ParseException e) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -209,21 +209,6 @@ public class GfeUtil {
|
|||
return new File(hdf5DirPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a calendar to a model time used by DatabaseID
|
||||
*
|
||||
* @param refTime
|
||||
* The model time as a calendar
|
||||
* @return The string representation of the model time for use with
|
||||
* DatabaseID
|
||||
*/
|
||||
public static String modelTimeToString(Calendar refTime) {
|
||||
Date time = refTime.getTime();
|
||||
synchronized (DatabaseID.dateFormat) {
|
||||
return DatabaseID.dateFormat.format(time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a specified data into GMT
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue