Issue #2672 Fix problems encountered in data access layer.

Former-commit-id: 835bcc695d [formerly 41983df7a0 [formerly ec95d1af0696b1f9b0b105143e26ea40937b28a8]]
Former-commit-id: 41983df7a0
Former-commit-id: d663567b36
This commit is contained in:
Ben Steffensmeier 2014-02-12 18:35:31 -06:00
parent 1841c4f7bf
commit 5ed46c8b38
4 changed files with 31 additions and 34 deletions

View file

@ -43,7 +43,6 @@ import javax.xml.bind.annotation.XmlType;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -57,9 +56,11 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* ------------- -------- ----------- --------------------------
* Sep 03, 2009 rjpeter Initial creation.
* Dec 20, 2012 njensen Added Level(String)
* Feb 12, 2014 2672 bsteffen Allow String constructor to parse floats.
*
* </pre>
*
* @author rjpeter
@ -73,7 +74,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
@XmlType(namespace = "dataplugin-level")
public class Level extends PersistableDataObject implements ISerializableObject {
public class Level extends PersistableDataObject {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(Level.class);
@ -84,7 +85,7 @@ public class Level extends PersistableDataObject implements ISerializableObject
private static final long serialVersionUID = 1L;
private static final Pattern PATTERN = Pattern
.compile("([0-9]*)((_([0-9]*))??([a-zA-Z]+))");
.compile("^(\\d*(?:\\.\\d*)?)(?:_(\\d*(?:\\.\\d*)?))?([a-zA-Z]+)$");
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "LEVEL_GENERATOR")
@ -133,8 +134,8 @@ public class Level extends PersistableDataObject implements ISerializableObject
Matcher m = PATTERN.matcher(level);
if (m.matches()) {
String levelOne = m.group(1);
String levelTwo = m.group(4);
String name = m.group(5);
String levelTwo = m.group(2);
String name = m.group(3);
levelonevalue = Double.parseDouble(levelOne);
if (levelTwo != null) {

View file

@ -290,21 +290,21 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
}
constraints.put(PRODUCT_CODE, pcConstraint);
}
if (request.getLevels() != null) {
Level[] levels = request.getLevels();
if (levels != null && levels.length > 0) {
RequestConstraint angleConstraint = new RequestConstraint(null,
ConstraintType.IN);
for (Level level : request.getLevels()) {
for (Level level : levels) {
angleConstraint.addToConstraintValueList(level
.getLevelOneValueAsString());
}
constraints.put(PRIMARY_ANGLE, angleConstraint);
}
if (request.getLocationNames() != null) {
RequestConstraint icaoConstraint = new RequestConstraint(null,
ConstraintType.IN);
icaoConstraint.setConstraintValueList(request.getLocationNames());
constraints.put(ICAO, icaoConstraint);
String[] locations = request.getLocationNames();
if (locations != null && locations.length > 0) {
RequestConstraint rc = new RequestConstraint(locations);
constraints.put(ICAO, rc);
}
if (request.getEnvelope() != null) {

View file

@ -39,7 +39,6 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
import com.raytheon.uf.common.dataplugin.satellite.units.SatelliteUnits;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
/**
@ -85,7 +84,7 @@ public class SatelliteGridFactory extends AbstractGridDataPluginFactory
protected DefaultGridData constructGridDataResponse(IDataRequest request,
PluginDataObject pdo, GridGeometry2D gridGeometry,
DataSource dataSource) {
if(pdo instanceof SatelliteRecord == false){
if (pdo instanceof SatelliteRecord == false) {
throw new DataRetrievalException(this.getClass().getSimpleName()
+ " cannot handle " + pdo.getClass().getSimpleName());
}
@ -140,19 +139,16 @@ public class SatelliteGridFactory extends AbstractGridDataPluginFactory
.getIdentifiers().get(identifier).toString()));
}
}
if ((request.getParameters() == null) == false) {
RequestConstraint requestConstraint = new RequestConstraint();
requestConstraint.setConstraintType(ConstraintType.IN);
requestConstraint.setConstraintValueList(request.getParameters());
constraints.put(FIELD_PYHSICAL_ELEMENT, requestConstraint);
String[] parameters = request.getParameters();
if (parameters != null && parameters.length > 0) {
RequestConstraint rc = new RequestConstraint(parameters);
constraints.put(FIELD_PYHSICAL_ELEMENT, rc);
}
if ((request.getLocationNames() == null) == false) {
RequestConstraint requestConstraint = new RequestConstraint();
requestConstraint.setConstraintType(ConstraintType.IN);
requestConstraint
.setConstraintValueList(request.getLocationNames());
constraints.put(FIELD_SECTOR_ID, requestConstraint);
String[] locations = request.getLocationNames();
if (locations != null && locations.length > 0) {
RequestConstraint rc = new RequestConstraint(locations);
constraints.put(FIELD_SECTOR_ID, rc);
}
return constraints;

View file

@ -27,7 +27,7 @@
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 05/29/13 2023 dgilling Initial Creation.
#
# 02/12/14 2672 bsteffen Allow String constructor to parse floats.
#
@ -37,7 +37,7 @@ import re
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import MasterLevel
LEVEL_NAMING_REGEX = re.compile("(\d*)((_(\d*))??([a-zA-Z]+))")
LEVEL_NAMING_REGEX = re.compile("^(\d*(?:\.\d*)?)(?:_(\d*(?:\.\d*)?))?([a-zA-Z]+)$")
INVALID_VALUE = numpy.float64(-999999)
class Level(object):
@ -53,8 +53,8 @@ class Level(object):
matcher = LEVEL_NAMING_REGEX.match(str(levelString))
if matcher is not None:
self.levelonevalue = numpy.float64(matcher.group(1))
self.masterLevel = MasterLevel.MasterLevel(matcher.group(5))
levelTwo = matcher.group(4)
self.masterLevel = MasterLevel.MasterLevel(matcher.group(3))
levelTwo = matcher.group(2)
if levelTwo:
self.leveltwovalue = numpy.float64(levelTwo)