Merge "Omaha #3788 Switch satellite_spatial.gid to a sequence." into omaha_14.4.1
Former-commit-id: 4b78380f15df6a8d9a35eb7a2b976b982e949243
This commit is contained in:
commit
9047da36ae
4 changed files with 115 additions and 25 deletions
12
deltaScripts/14.4.1/DR3788/updateSatSpatial.sh
Normal file
12
deltaScripts/14.4.1/DR3788/updateSatSpatial.sh
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
# DR #3788 - this update script will adjust the satellite_spatial to support sequenced gids.
|
||||
|
||||
PSQL="/awips2/psql/bin/psql"
|
||||
|
||||
echo "INFO: Updating satellite spatial table"
|
||||
|
||||
${PSQL} -U awips -d metadata -q -c "ALTER TABLE satellite_spatial DROP CONSTRAINT IF EXISTS uk_fdpq7gpkgi3r3k76j83x7axb1"
|
||||
${PSQL} -U awips -d metadata -c "ALTER TABLE satellite_spatial ADD CONSTRAINT uk_fdpq7gpkgi3r3k76j83x7axb1 UNIQUE (minx, miny, dx, dy, nx, ny, crswkt)"
|
||||
${PSQL} -U awips -d metadata -c "CREATE SEQUENCE satspatial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;"
|
||||
|
||||
echo "INFO: Satellite spatial table successfully updated."
|
|
@ -23,6 +23,12 @@ package com.raytheon.edex.plugin.satellite.dao;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
|
@ -36,12 +42,12 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
|
|||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 7/24/07 353 bphillip Initial Check in
|
||||
* - AWIPS2 Baseline Repository --------
|
||||
* 06/27/2012 798 jkorman Corrected id query type.
|
||||
* 10/02/2013 2333 mschenke Removed unused code
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- --------- --------------------------
|
||||
* Jul 24, 2007 353 bphillip Initial Check in
|
||||
* Jun 27, 2012 798 jkorman Corrected id query type.
|
||||
* Oct 02, 2013 2333 mschenke Removed unused code
|
||||
* Nov 05, 2014 3788 bsteffen add getOrCreateCoverage
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -70,6 +76,74 @@ public class SatMapCoverageDao extends CoreDao {
|
|||
return (SatMapCoverage) this.queryById(mapId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to retrieve a SatelliteMapCoverage from the database
|
||||
* given a map ID
|
||||
*
|
||||
* @param mapId
|
||||
* The Map ID
|
||||
* @return A SatelliteMapCoverage object with the corresponding ID. Null if
|
||||
* not found.
|
||||
*/
|
||||
public SatMapCoverage getOrCreateCoverage(SatMapCoverage coverage) {
|
||||
Session sess = null;
|
||||
Transaction trans = null;
|
||||
try {
|
||||
sess = getSessionFactory().openSession();
|
||||
trans = sess.beginTransaction();
|
||||
SatMapCoverage result = query(coverage, sess);
|
||||
if (result != null) {
|
||||
return result;
|
||||
} else {
|
||||
try {
|
||||
sess.save(coverage);
|
||||
trans.commit();
|
||||
return coverage;
|
||||
} catch (ConstraintViolationException e) {
|
||||
trans.rollback();
|
||||
trans = sess.beginTransaction();
|
||||
/*
|
||||
* To support multithreading/clustering its possible it
|
||||
* could have been created elsewhere between the query and
|
||||
* the save, so requery and throw an exception if it is not
|
||||
* found.
|
||||
*/
|
||||
result = query(coverage, sess);
|
||||
trans.commit();
|
||||
if (result == null) {
|
||||
logger.error(
|
||||
"Unable to create entry in satellite_coverage table.",
|
||||
e);
|
||||
return coverage;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (sess != null) {
|
||||
try {
|
||||
sess.close();
|
||||
} catch (Exception e) {
|
||||
logger.error("Error occurred closing session", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SatMapCoverage query(SatMapCoverage coverage, Session sess) {
|
||||
Criteria crit = sess.createCriteria(coverage.getClass());
|
||||
|
||||
crit.add(Restrictions.eq("nx", coverage.getNx()));
|
||||
crit.add(Restrictions.eq("ny", coverage.getNy()));
|
||||
crit.add(Restrictions.eq("dx", coverage.getDx()));
|
||||
crit.add(Restrictions.eq("dy", coverage.getDy()));
|
||||
crit.add(Restrictions.eq("minX", coverage.getMinX()));
|
||||
crit.add(Restrictions.eq("minY", coverage.getMinY()));
|
||||
crit.add(Restrictions.eq("crsWKT", coverage.getCrsWKT()));
|
||||
return (SatMapCoverage) crit.uniqueResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all satellite map coverage windows for a given type. <br>
|
||||
* These types include IR, Visible, and Water Vapor
|
||||
|
|
|
@ -44,8 +44,10 @@ import com.vividsolutions.jts.geom.Envelope;
|
|||
* Apr 15, 2014 3017 bsteffen Add new getCoverage methods to support
|
||||
* either one corner + dx/dy or two corners.
|
||||
* Jun 05, 2014 3243 bsteffen Remove deprecated lambert conformal call.
|
||||
* Sep 15, 2014 DR 17303 jgerth Support for second standard latitude
|
||||
* Sep 15, 2014 17303 jgerth Support for second standard latitude
|
||||
* Nov 05, 2014 2714 bclement replaced DecoderException with SatelliteDecoderException
|
||||
* Nov 05, 2014 3788 bsteffen use getOrCreateCoverage in place of queryByMapId
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
|
@ -290,11 +292,7 @@ public class SatSpatialFactory {
|
|||
/** Load or persist a {@link SatMapCoverage} */
|
||||
private synchronized SatMapCoverage checkPersisted(
|
||||
SatMapCoverage mapCoverage) {
|
||||
SatMapCoverage persisted = satDao.queryByMapId(mapCoverage.getGid());
|
||||
if (persisted == null) {
|
||||
persisted = mapCoverage;
|
||||
satDao.persist(persisted);
|
||||
}
|
||||
SatMapCoverage persisted = satDao.getOrCreateCoverage(mapCoverage);
|
||||
return persisted;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,13 @@ import java.awt.geom.Rectangle2D;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
@ -65,22 +69,24 @@ import com.vividsolutions.jts.geom.Polygon;
|
|||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 24, 2007 353 bphillip Initial Checkin
|
||||
* Jul 12, 2012 798 jkorman Changed projection "magic" numbers
|
||||
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
|
||||
* spatial
|
||||
* Sep 30, 2013 2333 mschenke Refactored to store coordinates in CRS
|
||||
* space
|
||||
* Apr 11, 2014 2947 bsteffen Fix equals
|
||||
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 24, 2007 353 bphillip Initial Checkin
|
||||
* Jul 12, 2012 798 jkorman Changed projection "magic" numbers
|
||||
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
|
||||
* spatial
|
||||
* Sep 30, 2013 2333 mschenke Refactored to store coordinates in CRS
|
||||
* space
|
||||
* Apr 11, 2014 2947 bsteffen Fix equals
|
||||
* Oct 16, 2014 3454 bphillip Upgrading to Hibernate 4
|
||||
* Nov 05, 2014 3788 bsteffen Make gid a sequence instead of a hash.
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "satellite_spatial")
|
||||
@Table(name = "satellite_spatial", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
||||
"minX", "minY", "dx", "dy", "nx", "ny", "crsWKT" }) })
|
||||
@SequenceGenerator(name = "SATELLITE_SPATIAL_GENERATOR", sequenceName = "satspatial_seq", allocationSize = 1)
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class SatMapCoverage extends PersistableDataObject<Object> implements
|
||||
|
@ -89,6 +95,7 @@ public class SatMapCoverage extends PersistableDataObject<Object> implements
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SATELLITE_SPATIAL_GENERATOR")
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 0)
|
||||
private int gid;
|
||||
|
@ -219,7 +226,6 @@ public class SatMapCoverage extends PersistableDataObject<Object> implements
|
|||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
this.crsObject = crs;
|
||||
this.gid = hashCode();
|
||||
if (latLonGeometry == null) {
|
||||
try {
|
||||
latLonGeometry = EnvelopeIntersection
|
||||
|
|
Loading…
Add table
Reference in a new issue