Issue #2361 replace hibernatables being detected by SerializableManager with detection from open source reflections

Change-Id: I33ddc5eb2acb909d79f6d1121747dc2aa7489c2e

Former-commit-id: b49a2ceb2f [formerly 16205ab7302195e99c8af69f9d24b41bca869ce3]
Former-commit-id: 40847d0edf
This commit is contained in:
Nate Jensen 2013-10-14 12:35:23 -05:00 committed by Gerrit Code Review
parent 36176665ff
commit 9e4100b0e1
50 changed files with 448 additions and 727 deletions

View file

@ -81,4 +81,10 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.reflections"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="reflections-0.9.9-RC1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.reflections</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Reflections
Bundle-SymbolicName: org.reflections
Bundle-Version: 0.9.9
Bundle-ClassPath: reflections-0.9.9-RC1.jar
Export-Package: org.reflections,
org.reflections.adapters,
org.reflections.scanners,
org.reflections.serializers,
org.reflections.util,
org.reflections.vfs
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -0,0 +1,2 @@
bin.includes = META-INF/,\
reflections-0.9.9-RC1.jar

Binary file not shown.

View file

@ -7,17 +7,29 @@
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
http://www.springframework.org/schema/tx/spring-tx.xsd">
<tx:annotation-driven transaction-manager="metadataTxManager"
proxy-target-class="true" />
<!-- The db class finder will search the packages listed for classes with @Entity or @Embeddable -->
<bean id="dbClassFinder" class="com.raytheon.uf.edex.database.DatabaseClassAnnotationFinder" >
<constructor-arg>
<list>
<value>com.raytheon</value>
<value>gov.noaa</value>
</list>
</constructor-arg>
</bean>
<bean id="metadataDbSessionConfig"
class="com.raytheon.uf.edex.database.DatabaseSessionConfiguration">
<property name="classFinder" ref="dbClassFinder" />
<property name="excludes">
<list>
<value>com.raytheon.uf.common.dataplugin.text</value>
<value>com.raytheon.edex.plugin.shef</value>
<value>com.raytheon.uf.common.dataplugin.shef</value>
<value>com.raytheon.edex.plugin.shef</value>
</list>
</property>
</bean>

View file

@ -155,11 +155,12 @@
<property name="dao" value="com.raytheon.edex.db.dao.DefaultPluginDao" />
<property name="initialRetentionTime" value="24" />
<property name="pathProvider" ref="defaultPathProvider"/>
</bean>
</bean>
<!-- This causes database tables to be initialized when a db plugin is registered -->
<bean id="schemaManager" class="com.raytheon.edex.db.purge.SchemaManager"
<bean id="schemaManager" class="com.raytheon.uf.edex.database.schema.SchemaManager"
factory-method="getInstance" />
<bean factory-bean="dbPluginRegistry" factory-method="addListener">
<constructor-arg><ref bean="schemaManager"/></constructor-arg>
</bean>

View file

@ -1,2 +0,0 @@
com.raytheon.edex.subscription.data.ReplacementRecord
com.raytheon.edex.subscription.data.SubscriptionRecord

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.subscription.data;
package com.raytheon.edex.autobldsrv.data;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -32,123 +32,139 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
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;
/**
* TODO Add Description
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
*
*
*
* </pre>
*
*
* @author mfegan
* @version 1.0
* @version 1.0
*/
@Entity
@Table(name="replacements",schema="subscription")
@Table(name = "replacements", schema = "subscription")
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class ReplacementRecord extends PersistableDataObject implements ISerializableObject {
public class ReplacementRecord extends PersistableDataObject {
private static final long serialVersionUID = 1L;
@XmlAttribute
@DynamicSerializeElement
@Id
@GeneratedValue
private long id;
@ManyToOne
@JoinColumn(name="subscription", nullable=false)
@JoinColumn(name = "subscription", nullable = false)
private SubscriptionRecord subscription;
@XmlAttribute
@DynamicSerializeElement
@Column(length=50)
@Column(length = 50)
private String key;
@XmlAttribute
@DynamicSerializeElement
@Column(length=2048)
@Column(length = 2048)
private String value;
/**
* Constructor.
*/
public ReplacementRecord() {
super();
}
/**
* Constructor. Creates a replacement record bound to the specified
* subscription record.
*
* @param parent the subscription record
* @param key the replacement key
* @param value the replacement value
* @param parent
* the subscription record
* @param key
* the replacement key
* @param value
* the replacement value
*/
public ReplacementRecord(SubscriptionRecord parent, String key, String value) {
this.subscription = parent;
this.key = key;
this.value = value;
}
/**
* @return the id
*/
public long getId() {
return id;
}
/**
* @param id the id to set
* @param id
* the id to set
*/
public void setId(long id) {
this.id = id;
}
/**
* @return the subscription
*/
public SubscriptionRecord getSubscription() {
return subscription;
}
/**
* @param subscription the subscription to set
* @param subscription
* the subscription to set
*/
public void setSubscription(SubscriptionRecord subscription) {
this.subscription = subscription;
}
/**
* @return the key
*/
public String getKey() {
return key;
}
/**
* @param key the key to set
* @param key
* the key to set
*/
public void setKey(String key) {
this.key = key;
}
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value the value to set
* @param value
* the value to set
*/
public void setValue(String value) {
this.value = value;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
@ -157,7 +173,7 @@ public class ReplacementRecord extends PersistableDataObject implements ISeriali
return false;
if (getClass() != obj.getClass())
return false;
ReplacementRecord other = (ReplacementRecord)obj;
ReplacementRecord other = (ReplacementRecord) obj;
if (this.key == null) {
if (other.key != null) {
return false;
@ -174,6 +190,7 @@ public class ReplacementRecord extends PersistableDataObject implements ISeriali
}
return true;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.subscription.data;
package com.raytheon.edex.autobldsrv.data;
import java.util.Date;
import java.util.HashMap;

View file

@ -21,4 +21,4 @@
* Contains classes mapped to tables in the subscription database
* schema.
*/
package com.raytheon.edex.subscription.data;
package com.raytheon.edex.autobldsrv.data;

View file

@ -31,8 +31,8 @@ import javax.xml.bind.JAXBException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.subscription.data.ReplacementRecord;
import com.raytheon.edex.subscription.data.SubscriptionRecord;
import com.raytheon.edex.autobldsrv.data.ReplacementRecord;
import com.raytheon.edex.autobldsrv.data.SubscriptionRecord;
import com.raytheon.edex.subscription.runners.ISubscribeRunner;
import com.raytheon.edex.subscription.runners.SubscribeRunner;
import com.raytheon.edex.subscription.util.Tools;

View file

@ -27,7 +27,7 @@ import java.util.Map;
import org.hibernate.Query;
import com.raytheon.edex.subscription.data.SubscriptionRecord;
import com.raytheon.edex.autobldsrv.data.SubscriptionRecord;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.dataquery.db.QueryParam;
import com.raytheon.uf.common.message.Property;

View file

@ -23,8 +23,8 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.raytheon.edex.autobldsrv.data.SubscriptionRecord;
import com.raytheon.edex.subscription.dao.SubscriptionDAO;
import com.raytheon.edex.subscription.data.SubscriptionRecord;
import com.raytheon.edex.subscription.util.Tools;
import com.raytheon.uf.common.message.Message;
import com.raytheon.uf.common.message.Property;

View file

@ -22,8 +22,8 @@ package com.raytheon.edex.subscription.runners;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.edex.autobldsrv.data.SubscriptionRecord;
import com.raytheon.edex.subscription.dao.SubscriptionDAO;
import com.raytheon.edex.subscription.data.SubscriptionRecord;
import com.raytheon.edex.subscription.util.Tools;
import com.raytheon.uf.common.message.Message;
import com.raytheon.uf.common.message.Property;

View file

@ -22,8 +22,8 @@ package com.raytheon.edex.subscription.runners;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.edex.autobldsrv.data.SubscriptionRecord;
import com.raytheon.edex.subscription.dao.SubscriptionDAO;
import com.raytheon.edex.subscription.data.SubscriptionRecord;
import com.raytheon.edex.subscription.util.Tools;
import com.raytheon.uf.common.message.Message;
import com.raytheon.uf.common.message.Property;

View file

@ -22,8 +22,8 @@ package com.raytheon.edex.subscription.runners;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.edex.autobldsrv.data.SubscriptionRecord;
import com.raytheon.edex.subscription.dao.SubscriptionDAO;
import com.raytheon.edex.subscription.data.SubscriptionRecord;
import com.raytheon.edex.subscription.util.Tools;
import com.raytheon.uf.common.message.Header;
import com.raytheon.uf.common.message.Message;

View file

@ -22,8 +22,8 @@ package com.raytheon.edex.subscription.runners;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.edex.autobldsrv.data.SubscriptionRecord;
import com.raytheon.edex.subscription.dao.SubscriptionDAO;
import com.raytheon.edex.subscription.data.SubscriptionRecord;
import com.raytheon.edex.subscription.util.Tools;
import com.raytheon.uf.common.message.Header;
import com.raytheon.uf.common.message.Message;

View file

@ -11,7 +11,6 @@ Export-Package: com.raytheon.edex.colormap,
com.raytheon.edex.db.dao,
com.raytheon.edex.db.mapping,
com.raytheon.edex.db.objects.hibernate,
com.raytheon.edex.db.purge,
com.raytheon.edex.esb,
com.raytheon.edex.exception,
com.raytheon.edex.msg,

View file

@ -1,210 +0,0 @@
/**
* 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.util.grib;
import javax.measure.unit.Unit;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.Type;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* Represents a grib level
* <p>
* Refer to the files grib1levels.xml and grib2levels.xml. This class maps to
* the levels defined in those files.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 9/26/07 381 bphillip Initial creation
*
*
* </pre>
*/
@Entity
@Table(name = "grib_levels")
public class GribLevel extends PersistableDataObject implements
ISerializableObject {
private static final long serialVersionUID = 1L;
@Id
private Integer id;
@Column
private Integer layerNumber;
@Column
private Integer edition;
/** The name of the level */
@Column(length = 127)
private String name;
/** The unit associated with the level */
@Column
@Type(type = "com.raytheon.edex.objects.hibernate.grib.UnitType")
private Unit<?> unit;
/** The number of surfaces described by this level */
@Column(name = "layers")
private int numLayers;
public GribLevel() {
}
/**
* Constructor
*
* @param name
* The name of the level
* @param unit
* The unit associated with the level
* @param numLayers
* The number of surfaces described by this level
*/
public GribLevel(String name, Unit<?> unit, int numLayers) {
this.name = name;
this.unit = unit;
this.numLayers = numLayers;
}
/**
* Gets the name
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name
*
* @param name
* The name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the unit
*
* @return The unit
*/
public Unit<?> getUnit() {
return unit;
}
/**
* Sets the unit
*
* @param unit
* The unit
*/
public void setUnit(Unit<?> unit) {
this.unit = unit;
}
/**
* Gets the number of layers
*
* @return the number of layers
*/
public int getNumLayers() {
return numLayers;
}
/**
* Sets the number of layers
*
* @param numLayers
* the number of layers
*/
public void setNumLayers(int numLayers) {
this.numLayers = numLayers;
}
public Integer getEdition() {
return edition;
}
public void setEdition(Integer edition) {
this.edition = edition;
}
public Integer getNumber() {
return layerNumber;
}
public void setNumber(Integer number) {
this.layerNumber = number;
}
public boolean equals(Object obj) {
if (obj instanceof GribLevel) {
GribLevel level = (GribLevel) obj;
if (this.layerNumber == level.layerNumber
&& this.edition == level.edition
&& this.unit.equals(level.unit)
&& this.name.equals(level.name)
&& this.numLayers == level.numLayers) {
return true;
} else {
return false;
}
} else {
return false;
}
}
public int hashCode() {
return new HashCodeBuilder(17, 37).append(layerNumber).append(edition)
.append(name).append(unit).append(numLayers).toHashCode();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getLayerNumber() {
return layerNumber;
}
public void setLayerNumber(Integer layerNumber) {
this.layerNumber = layerNumber;
}
}

View file

@ -1,6 +0,0 @@
com.raytheon.edex.util.satellite.SatelliteSource
com.raytheon.edex.util.satellite.SatelliteCreatingEntity
com.raytheon.edex.util.satellite.SatelliteSectorId
com.raytheon.edex.util.satellite.SatellitePhysicalElement
com.raytheon.edex.util.satellite.SatelliteUnit
com.raytheon.edex.util.satellite.SatellitePosition

View file

@ -33,9 +33,9 @@ import java.util.zip.Inflater;
import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.satellite.dao.SatelliteDao;
import com.raytheon.edex.plugin.satellite.gini.SatellitePosition;
import com.raytheon.edex.plugin.satellite.gini.SatelliteUnit;
import com.raytheon.edex.util.satellite.SatSpatialFactory;
import com.raytheon.edex.util.satellite.SatellitePosition;
import com.raytheon.edex.util.satellite.SatelliteUnit;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage;
import com.raytheon.uf.common.dataplugin.satellite.SatelliteMessageData;

View file

@ -20,7 +20,7 @@
package com.raytheon.edex.plugin.satellite.dao;
import com.raytheon.edex.util.satellite.SatelliteCreatingEntity;
import com.raytheon.edex.plugin.satellite.gini.SatelliteCreatingEntity;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;

View file

@ -27,12 +27,12 @@ import java.util.Map;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.edex.util.satellite.SatelliteCreatingEntity;
import com.raytheon.edex.util.satellite.SatellitePhysicalElement;
import com.raytheon.edex.util.satellite.SatellitePosition;
import com.raytheon.edex.util.satellite.SatelliteSectorId;
import com.raytheon.edex.util.satellite.SatelliteSource;
import com.raytheon.edex.util.satellite.SatelliteUnit;
import com.raytheon.edex.plugin.satellite.gini.SatelliteCreatingEntity;
import com.raytheon.edex.plugin.satellite.gini.SatellitePhysicalElement;
import com.raytheon.edex.plugin.satellite.gini.SatellitePosition;
import com.raytheon.edex.plugin.satellite.gini.SatelliteSectorId;
import com.raytheon.edex.plugin.satellite.gini.SatelliteSource;
import com.raytheon.edex.plugin.satellite.gini.SatelliteUnit;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.persist.IPersistable;

View file

@ -19,7 +19,7 @@
**/
package com.raytheon.edex.plugin.satellite.dao;
import com.raytheon.edex.util.satellite.SatellitePhysicalElement;
import com.raytheon.edex.plugin.satellite.gini.SatellitePhysicalElement;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;

View file

@ -20,7 +20,7 @@
package com.raytheon.edex.plugin.satellite.dao;
import com.raytheon.edex.util.satellite.SatellitePosition;
import com.raytheon.edex.plugin.satellite.gini.SatellitePosition;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;

View file

@ -20,7 +20,7 @@
package com.raytheon.edex.plugin.satellite.dao;
import com.raytheon.edex.util.satellite.SatelliteSectorId;
import com.raytheon.edex.plugin.satellite.gini.SatelliteSectorId;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;

View file

@ -22,7 +22,7 @@ package com.raytheon.edex.plugin.satellite.dao;
import java.util.List;
import com.raytheon.edex.util.satellite.SatelliteSource;
import com.raytheon.edex.plugin.satellite.gini.SatelliteSource;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;

View file

@ -19,7 +19,7 @@
**/
package com.raytheon.edex.plugin.satellite.dao;
import com.raytheon.edex.util.satellite.SatelliteUnit;
import com.raytheon.edex.plugin.satellite.gini.SatelliteUnit;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.edex.util.satellite;
package com.raytheon.edex.plugin.satellite.gini;
import java.io.Serializable;
@ -28,7 +28,6 @@ import javax.persistence.Id;
import javax.persistence.Table;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* A satellite creating entity
@ -46,7 +45,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
@Entity
@Table(name = "satellite_creating_entities")
public class SatelliteCreatingEntity extends PersistableDataObject implements
Serializable, ISerializableObject {
Serializable {
private static final long serialVersionUID = -4678013903413236803L;

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.edex.util.satellite;
package com.raytheon.edex.plugin.satellite.gini;
import java.io.Serializable;
@ -28,7 +28,6 @@ import javax.persistence.Id;
import javax.persistence.Table;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* A satellite physical element
@ -46,7 +45,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
@Entity
@Table(name = "satellite_physical_elements")
public class SatellitePhysicalElement extends PersistableDataObject implements
Serializable, ISerializableObject {
Serializable {
private static final long serialVersionUID = 8429844485032687146L;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.util.satellite;
package com.raytheon.edex.plugin.satellite.gini;
import java.io.Serializable;
@ -27,7 +27,6 @@ import javax.persistence.Id;
import javax.persistence.Table;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* Object describing the position of a geostationary satellite.
@ -45,7 +44,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
@Entity
@Table(name = "satellite_geostationary_positions")
public class SatellitePosition extends PersistableDataObject implements
Serializable, ISerializableObject {
Serializable {
private static final long serialVersionUID = 1854243110517231052L;

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.edex.util.satellite;
package com.raytheon.edex.plugin.satellite.gini;
import java.io.Serializable;
@ -28,7 +28,6 @@ import javax.persistence.Id;
import javax.persistence.Table;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* A satellite sector id
@ -46,7 +45,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
@Entity
@Table(name = "satellite_sector_ids")
public class SatelliteSectorId extends PersistableDataObject implements
Serializable, ISerializableObject {
Serializable {
private static final long serialVersionUID = 2745578024205645114L;

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.edex.util.satellite;
package com.raytheon.edex.plugin.satellite.gini;
import java.io.Serializable;
@ -28,7 +28,6 @@ import javax.persistence.Id;
import javax.persistence.Table;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* A satellite source i.e. NESDIS
@ -47,7 +46,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
@Entity
@Table(name = "satellite_sources")
public class SatelliteSource extends PersistableDataObject implements
Serializable, ISerializableObject {
Serializable {
private static final long serialVersionUID = 5855029407853840979L;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.util.satellite;
package com.raytheon.edex.plugin.satellite.gini;
import java.io.Serializable;
@ -27,12 +27,11 @@ import javax.persistence.Id;
import javax.persistence.Table;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
@Entity
@Table(name = "satellite_units")
public class SatelliteUnit extends PersistableDataObject implements
Serializable, ISerializableObject {
Serializable {
private static final long serialVersionUID = 1L;

View file

@ -18,6 +18,7 @@
</bean>
<bean id="fxaDbSessionConfig" class="com.raytheon.uf.edex.database.DatabaseSessionConfiguration">
<property name="classFinder" ref="dbClassFinder" />
<property name="includes">
<list>
<value>com.raytheon.uf.common.dataplugin.text</value>

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.common.serialization;
import javax.persistence.Embeddable;
/**
* Empty interface that should be implemented by any class that uses Hibernate,
* JaxB, or DynamicSerialize annotations so it is detected at runtime.
@ -44,9 +46,11 @@ package com.raytheon.uf.common.serialization;
* annotations. JAXB/XML only requires it if you use the global JAXB
* context through {@link SerializationUtil}, however that is a
* performance hit and deprecated and you should instead create your
* own {@link JAXBManager}. Hibernate still requires
* ISerializableObject but an alternative will be provided in the
* near future.
* own {@link JAXBManager}. Hibernate no longer uses it, EDEX will
* automatically detect classes with {@link Entity} or
* {@link Embeddable} annotations if their package name starts with
* the same plugin FQN that is present in the PluginProperties or
* DatabasePluginProperties.
*
*/

View file

@ -25,19 +25,13 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.ServiceConfigurationError;
import java.util.Set;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRegistry;
@ -62,6 +56,7 @@ import com.raytheon.uf.common.serialization.jaxb.JaxbDummyObject;
* Apr 24, 2013 1939 randerso Clean up code and attempt to improve speed.
* Added initializeHibernatables flag to disable
* processing hibernatables on CAVE
* Oct 14, 2013 2361 njensen Removed hibernatables
* </pre>
*
* @author njensen
@ -72,8 +67,6 @@ public class SerializableManager implements IJaxbableClassesLocator {
private static SerializableManager instance;
private final Map<String, List<Class<ISerializableObject>>> hibernatables = new HashMap<String, List<Class<ISerializableObject>>>();
private ArrayList<Class<ISerializableObject>> jaxbables = new ArrayList<Class<ISerializableObject>>();
/**
@ -90,7 +83,6 @@ public class SerializableManager implements IJaxbableClassesLocator {
private synchronized void initialize() {
// this is here in case in the future we want to re-initialize the lists
// during runtime, i.e. hot deploy of a new plugin
hibernatables.clear();
jaxbables.clear();
long realStartTime = System.currentTimeMillis();
Set<Class<ISerializableObject>> clazzSet = new HashSet<Class<ISerializableObject>>(
@ -101,36 +93,19 @@ public class SerializableManager implements IJaxbableClassesLocator {
"META-INF/services/"
+ ISerializableObject.class.getName());
// doHibernate will be false in CAVE since they are not needed
boolean doHibernate = Boolean.getBoolean("initializeHibernatables");
// In testing 1 thread is slowest, 2 threads cuts the time down
// about 50% and 3 threads cuts down another 5% or so, 4 threads
// shows no benefit over 2. These results are system specific.
int numThreads = 3;
LoadSerializableClassesThread[] threads = new LoadSerializableClassesThread[numThreads];
for (int i = 0; i < numThreads; i++) {
threads[i] = new LoadSerializableClassesThread(urls,
doHibernate);
threads[i] = new LoadSerializableClassesThread(urls);
threads[i].start();
}
for (LoadSerializableClassesThread thread : threads) {
thread.join();
clazzSet.addAll(thread.getClazzList());
if (doHibernate) {
for (Entry<String, List<Class<ISerializableObject>>> entry : thread
.getHibernatables().entrySet()) {
List<Class<ISerializableObject>> list = hibernatables
.get(entry.getKey());
if (list == null) {
list = new ArrayList<Class<ISerializableObject>>();
hibernatables.put(entry.getKey(), list);
}
list.addAll(entry.getValue());
}
}
}
} catch (Throwable e) {
e.printStackTrace();
@ -150,28 +125,24 @@ public class SerializableManager implements IJaxbableClassesLocator {
}
private static void fail(@SuppressWarnings("rawtypes") Class service,
String msg, Throwable cause)
throws ServiceConfigurationError {
String msg, Throwable cause) throws ServiceConfigurationError {
throw new ServiceConfigurationError(service.getName() + ": " + msg,
cause);
}
private static void fail(@SuppressWarnings("rawtypes") Class service,
String msg)
throws ServiceConfigurationError {
String msg) throws ServiceConfigurationError {
throw new ServiceConfigurationError(service.getName() + ": " + msg);
}
private static void fail(@SuppressWarnings("rawtypes") Class service,
URL u, int line, String msg)
throws ServiceConfigurationError {
URL u, int line, String msg) throws ServiceConfigurationError {
fail(service, u + ":" + line + ": " + msg);
}
private static int parseLine(@SuppressWarnings("rawtypes") Class service,
URL u, BufferedReader r,
int lc, List<String> names) throws IOException,
ServiceConfigurationError {
URL u, BufferedReader r, int lc, List<String> names)
throws IOException, ServiceConfigurationError {
String ln = r.readLine();
if (ln == null) {
return -1;
@ -216,40 +187,6 @@ public class SerializableManager implements IJaxbableClassesLocator {
return instance;
}
/**
* Returns the list of classes at runtime that have Hibernate annotations
*
* @return
*/
public List<Class<ISerializableObject>> getHibernatablesForPluginFQN(
String pluginFQN) {
List<Class<ISerializableObject>> list = hibernatables.get(pluginFQN);
if (list == null) {
list = Collections.<Class<ISerializableObject>> emptyList();
}
return list;
}
/**
*
*/
public Set<String> getHibernatablePluginFQNs() {
return hibernatables.keySet();
}
/**
* Returns the list of classes at runtime that have Hibernate annotations
*
* @return
*/
public List<Class<ISerializableObject>> getHibernatables() {
List<Class<ISerializableObject>> rval = new ArrayList<Class<ISerializableObject>>();
for (List<Class<ISerializableObject>> list : hibernatables.values()) {
rval.addAll(list);
}
return rval;
}
/**
* Returns the list of classes at runtime that have JaxB annotations
*
@ -264,36 +201,22 @@ public class SerializableManager implements IJaxbableClassesLocator {
private final Enumeration<URL> urls;
private final boolean doHibernate;
private final List<Class<ISerializableObject>> clazzList;
private final Map<String, List<Class<ISerializableObject>>> hibernatables;
public LoadSerializableClassesThread(Enumeration<URL> urls,
boolean doHibernate) {
public LoadSerializableClassesThread(Enumeration<URL> urls) {
this.urls = urls;
this.doHibernate = doHibernate;
this.clazzList = new ArrayList<Class<ISerializableObject>>(500);
this.hibernatables = new HashMap<String, List<Class<ISerializableObject>>>();
}
public List<Class<ISerializableObject>> getClazzList() {
return clazzList;
}
public Map<String, List<Class<ISerializableObject>>> getHibernatables() {
return hibernatables;
}
@Override
public void run() {
try {
ClassLoader cl = getClass().getClassLoader();
Set<Class<ISerializableObject>> pluginHibernateSet = null;
if (doHibernate) {
pluginHibernateSet = new HashSet<Class<ISerializableObject>>();
}
List<String> names = new ArrayList<String>();
URL u = getNextUrl();
while (u != null) {
@ -339,10 +262,6 @@ public class SerializableManager implements IJaxbableClassesLocator {
}
}
if (doHibernate) {
pluginHibernateSet.clear();
}
Iterator<String> iter = names.iterator();
while (iter.hasNext()) {
String clazz = iter.next();
@ -358,22 +277,7 @@ public class SerializableManager implements IJaxbableClassesLocator {
added = true;
}
if (doHibernate) {
if (c.getAnnotation(Entity.class) != null
|| c.getAnnotation(Embeddable.class) != null) {
pluginHibernateSet.add(c);
added = true;
}
}
long time = (System.currentTimeMillis() - t0);
if (doHibernate && !added) {
System.out
.println("Class: "
+ clazz
+ " should not be in ISerializableObject file, wasted "
+ time + "ms processing it!");
}
} catch (ClassNotFoundException e) {
System.out
.println("Unable to load class "
@ -381,12 +285,6 @@ public class SerializableManager implements IJaxbableClassesLocator {
+ ". Check that class is spelled correctly in ISerializableObject file");
}
}
if (doHibernate && pluginHibernateSet.size() > 0) {
hibernatables.put(pluginFQN,
new ArrayList<Class<ISerializableObject>>(
pluginHibernateSet));
}
u = getNextUrl();
}
} catch (Throwable e) {

View file

@ -102,4 +102,10 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.reflections"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -20,7 +20,8 @@ Require-Bundle: com.raytheon.uf.common.dataquery;bundle-version="1.0.0",
org.geotools;bundle-version="2.6.4",
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.uf.common.util,
org.slf4j;bundle-version="1.7.5"
org.slf4j;bundle-version="1.7.5",
org.reflections;bundle-version="0.9.9"
Export-Package: com.raytheon.uf.edex.database,
com.raytheon.uf.edex.database.cluster,
com.raytheon.uf.edex.database.cluster.handler,

View file

@ -0,0 +1,92 @@
/**
* 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.uf.edex.database;
import java.util.Set;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import org.reflections.Reflections;
import org.reflections.scanners.TypeAnnotationsScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
/**
* Uses the reflections package to find classes on the classpath that match the
* start of a package name and will be needed to access the database.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 11, 2013 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public class DatabaseClassAnnotationFinder {
private Set<Class<?>> dbAnnotatedClassSet;
public DatabaseClassAnnotationFinder(String... packageNames) {
dbAnnotatedClassSet = findClasses(packageNames);
}
/**
* Searches the classpath for classes that will be needed by the database
* layer.
*
* @param packageNames
* The start of pacakge names to include, e.g. com.raytheon
* @return
*/
protected Set<Class<?>> findClasses(String... packageNames) {
long t0 = System.currentTimeMillis();
ConfigurationBuilder cb = new ConfigurationBuilder();
for (String pkg : packageNames) {
cb.addUrls(ClasspathHelper.forPackage(pkg));
}
cb.setScanners(new TypeAnnotationsScanner());
Reflections reflecs = cb.build();
Set<Class<?>> set = reflecs.getTypesAnnotatedWith(Entity.class, false);
set.addAll(reflecs.getTypesAnnotatedWith(Embeddable.class, false));
long t1 = System.currentTimeMillis();
System.out.println("Found " + set.size() + " db classes in "
+ (t1 - t0) + " ms");
return set;
}
/**
* Gets the set of classes that this class finder is aware of that
* correspond to db classes.
*
* @return
*/
public Set<Class<?>> getDbAnnotatedClases() {
return dbAnnotatedClassSet;
}
}

View file

@ -21,10 +21,12 @@ package com.raytheon.uf.edex.database;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
/**
* TODO Add Description
* A configuration used to match which classes should correspond to a particular
* database session.
*
* <pre>
*
@ -32,6 +34,7 @@ import java.util.regex.Pattern;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 29, 2010 rjpeter Initial creation
* Oct 11, 2013 2361 njensen Added database class finder
*
* </pre>
*
@ -40,10 +43,13 @@ import java.util.regex.Pattern;
*/
public class DatabaseSessionConfiguration {
protected List<Pattern> includes;
protected List<Pattern> excludes;
protected DatabaseClassAnnotationFinder finder;
public void setIncludes(List<String> includes) {
if (includes != null) {
this.includes = new ArrayList<Pattern>(includes.size());
@ -67,7 +73,7 @@ public class DatabaseSessionConfiguration {
if (includes != null) {
for (Pattern p : includes) {
if (p.matcher(value).matches()) {
if (p.matcher(value).find()) {
rval = true;
break;
}
@ -78,7 +84,7 @@ public class DatabaseSessionConfiguration {
if (excludes != null) {
for (Pattern p : excludes) {
if (p.matcher(value).matches()) {
if (p.matcher(value).find()) {
rval = false;
break;
}
@ -87,4 +93,13 @@ public class DatabaseSessionConfiguration {
return rval;
}
public Set<Class<?>> getAnnotatedClasses() {
return finder.getDbAnnotatedClases();
}
public void setClassFinder(DatabaseClassAnnotationFinder finder) {
this.finder = finder;
}
}

View file

@ -31,9 +31,6 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.Dialect;
import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.SerializableManager;
/**
* Extension of the AnnotationSessionFactoryBean provided by Spring.
* <p>
@ -50,11 +47,16 @@ import com.raytheon.uf.common.serialization.SerializableManager;
* ------------ ---------- ----------- --------------------------
* 10/8/2008 1532 bphillip Initial checkin
* Jun 18, 2013 2117 djohnson Remove use of config.buildSettings().
* Oct 14, 2013 2361 njensen Changes to support new technique for finding classes
*
*
* </pre>
*
*/
public class DatabaseSessionFactoryBean extends AnnotationSessionFactoryBean {
protected Class<?>[] accessibleClasses = null;
/**
* Creates a new MetadataSessionFactoryBean.
* <p>
@ -77,7 +79,7 @@ public class DatabaseSessionFactoryBean extends AnnotationSessionFactoryBean {
* @return List of create sql.
* @throws org.hibernate.AnnotationException
*/
public String[] getCreateSql(Set<Class<ISerializableObject>> classes)
public String[] getCreateSql(Set<Class<?>> classes)
throws org.hibernate.AnnotationException {
Configuration config = getConfiguration();
AnnotationConfiguration tmp = loadNewConfigForClasses(classes);
@ -96,7 +98,7 @@ public class DatabaseSessionFactoryBean extends AnnotationSessionFactoryBean {
* @return List of create sql.
* @throws org.hibernate.AnnotationException
*/
public String[] getDropSql(Collection<Class<ISerializableObject>> classes)
public String[] getDropSql(Collection<Class<?>> classes)
throws org.hibernate.AnnotationException {
Configuration config = getConfiguration();
AnnotationConfiguration tmp = loadNewConfigForClasses(classes);
@ -105,10 +107,10 @@ public class DatabaseSessionFactoryBean extends AnnotationSessionFactoryBean {
}
private AnnotationConfiguration loadNewConfigForClasses(
Collection<Class<ISerializableObject>> classes) {
Collection<Class<?>> classes) {
AnnotationConfiguration aConfig = new AnnotationConfiguration();
for (Class<ISerializableObject> c : classes) {
for (Class<?> c : classes) {
aConfig.addAnnotatedClass(c);
}
@ -117,34 +119,40 @@ public class DatabaseSessionFactoryBean extends AnnotationSessionFactoryBean {
public void setDatabaseSessionConfiguration(
DatabaseSessionConfiguration databaseSessionConfiguration) {
SerializableManager serialManager = SerializableManager.getInstance();
// make own copy so can modify it
List<String> pluginFQNs = new ArrayList<String>(serialManager
.getHibernatablePluginFQNs());
List<Class<?>> annotatedClasses = new ArrayList<Class<?>>(
databaseSessionConfiguration.getAnnotatedClasses());
if (databaseSessionConfiguration != null) {
Iterator<String> iter = pluginFQNs.iterator();
Iterator<Class<?>> iter = annotatedClasses.iterator();
while (iter.hasNext()) {
String fqn = iter.next();
if (!databaseSessionConfiguration.matches(fqn)) {
Class<?> clazz = iter.next();
if (!databaseSessionConfiguration.matches(clazz.getName())) {
iter.remove();
}
}
}
if (pluginFQNs != null && pluginFQNs.size() > 0) {
// Get the lists of annotated classes
List<Class<ISerializableObject>> annotatedClasses = new ArrayList<Class<ISerializableObject>>(
10 * pluginFQNs.size());
for (String fqn : pluginFQNs) {
annotatedClasses.addAll(serialManager
.getHibernatablesForPluginFQN(fqn));
}
// Set the annotated classes
this.setAnnotatedClasses(annotatedClasses.toArray(new Class[] {}));
}
// Set the annotated classes
this.setAnnotatedClasses(annotatedClasses.toArray(new Class[] {}));
}
@SuppressWarnings("rawtypes")
@Override
public void setAnnotatedClasses(Class[] annotatedClasses) {
super.setAnnotatedClasses(annotatedClasses);
// overrode setter because we need access to the classes
// for determining dependent classes for create/drop SQL
this.accessibleClasses = annotatedClasses;
}
/**
* Get the annotated classes associated with the database session
*
* @return
*/
public Class<?>[] getAnnotatedClasses() {
return accessibleClasses;
}
}

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.edex.db.purge;
package com.raytheon.uf.edex.database.schema;
import java.util.ArrayList;
import java.util.List;
@ -38,8 +38,9 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 10/8/2008 1532 bphillip Initial checkin
* 2/6/2009 1990 bphillip Modified error handling
* 10/8/2008 1532 bphillip Initial checkin
* 2/6/2009 1990 bphillip Modified error handling
* 10/14/2013 2361 njensen Moved to plugin uf.edex.database
* </pre>
*
* @author bphillip

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.edex.db.purge;
package com.raytheon.uf.edex.database.schema;
import java.io.BufferedReader;
import java.io.IOException;
@ -40,10 +40,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import com.raytheon.edex.util.Util;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.SerializableManager;
import com.raytheon.uf.common.util.StringUtil;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.core.props.PropertiesFactory;
@ -66,12 +63,14 @@ import com.raytheon.uf.edex.database.plugin.PluginVersionDao;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 10/8/2008 1532 bphillip Initial checkin
* 2/9/2009 1990 bphillip Fixed index creation
* 03/20/09 njensen Implemented IPluginRegistryChanged
* Mar 29, 2013 1841 djohnson Remove unused method, warnings, and close streams with utility method.
* 10/8/2008 1532 bphillip Initial checkin
* 2/9/2009 1990 bphillip Fixed index creation
* 03/20/09 njensen Implemented IPluginRegistryChanged
* Mar 29, 2013 1841 djohnson Remove unused method, warnings, and close streams with utility method.
* Mar 02, 2013 1970 bgonzale Added check for abstract entities in sql index naming.
* Removed unused private method populateSchema.
* Removed unused private method populateSchema.
* Oct 14, 2013 2361 njensen Moved to plugin uf.edex.database
* Replaced use of SerializableManager
* </pre>
*
* @author bphillip
@ -80,8 +79,7 @@ import com.raytheon.uf.edex.database.plugin.PluginVersionDao;
public class SchemaManager implements IDatabasePluginRegistryChanged {
/** The logger */
private static final Log logger = LogFactory
.getLog(SchemaManager.class);
private static final Log logger = LogFactory.getLog(SchemaManager.class);
private static final String resourceSelect = "select relname from pg_class where relname = '";
@ -178,8 +176,20 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
"Unable to execute scripts for plugin FQN "
+ pluginFQN);
} finally {
Util.close(reader);
Util.close(stream);
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
// ignore
}
}
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
// ignore
}
}
}
}
}
@ -285,9 +295,9 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
ArrayList<String> createSql = pluginCreateSql.get(fqn);
if (createSql == null) {
// need the full dependency tree to generate the sql
Set<Class<ISerializableObject>> hibernatables = new HashSet<Class<ISerializableObject>>();
getAllRequiredHibernatables(props, hibernatables);
String[] sqlArray = sessFactory.getCreateSql(hibernatables);
String[] sqlArray = sessFactory
.getCreateSql(getTablesAndDependencies(props,
sessFactory.getAnnotatedClasses()));
createSql = new ArrayList<String>(sqlArray.length);
for (String sql : sqlArray) {
createSql.add(sql);
@ -330,9 +340,9 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
ArrayList<String> dropSql = pluginDropSql.get(fqn);
if (dropSql == null) {
// need the full dependency tree to generate the sql
Set<Class<ISerializableObject>> hibernatables = new HashSet<Class<ISerializableObject>>();
getAllRequiredHibernatables(props, hibernatables);
String[] sqlArray = sessFactory.getDropSql(hibernatables);
String[] sqlArray = sessFactory
.getDropSql(getTablesAndDependencies(props,
sessFactory.getAnnotatedClasses()));
dropSql = new ArrayList<String>(sqlArray.length);
for (String sql : sqlArray) {
dropSql.add(sql);
@ -348,10 +358,30 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
return dropSql;
}
protected void getAllRequiredHibernatables(DatabasePluginProperties props,
Set<Class<ISerializableObject>> hibernatables) {
hibernatables.addAll(SerializableManager.getInstance()
.getHibernatablesForPluginFQN(props.getPluginFQN()));
/**
* Searches the classes from the session factory to see if they match the
* plugin FQN. Recursively searches for the classes associated wtih
* dependent plugins.
*
* @param props
* the plugin to find DB classes and dependencies for
* @param allPossibleClasses
* all the classes associated with the session factory
* @return
*/
protected Set<Class<?>> getTablesAndDependencies(
DatabasePluginProperties props, Class<?>[] allPossibleClasses) {
Set<Class<?>> result = new HashSet<Class<?>>();
// add a . to the end to ensure the package name exactly matches
// and we don't pick up incorrect packages,
// e.g. common.dataplugin.cwa. vs common.dataplugin.cwat.
// There will always be a . since we're looking at class names.
Pattern p = Pattern.compile(props.getPluginFQN() + "\\.");
for (Class<?> clazz : allPossibleClasses) {
if (p.matcher(clazz.getName()).find()) {
result.add(clazz);
}
}
List<String> fqns = props.getDependencyFQNs();
if (fqns != null && fqns.size() > 0) {
for (String fqn : fqns) {
@ -360,9 +390,12 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
// recurse, may need to add short circuit logic by tracking
// plugins already processed
getAllRequiredHibernatables(dProps, hibernatables);
result.addAll(this.getTablesAndDependencies(dProps,
allPossibleClasses));
}
}
return result;
}
protected void removeAllDependentCreateSql(DatabasePluginProperties props,
@ -469,4 +502,5 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
}
}
}
}

View file

@ -1,33 +1,34 @@
/*
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 6, 2012 bclement Initial creation
*
*/
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 06, 2012 bclement Initial creation
* Oct 14, 2013 2361 njensen Changed @Entity to @MappedSuperclass
*
*/
package com.raytheon.uf.edex.ogc.common.db;
import java.util.Date;
@ -36,9 +37,9 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@ -47,11 +48,11 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.edex.ogc.common.db.LayerTransformer.TimeFormat;
/**
*
*
* @author bclement
* @version 1.0
* @version 1.0
*/
@Entity
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
@ -61,21 +62,21 @@ public abstract class PointDataLayer extends
private static final long serialVersionUID = 4301480632118555546L;
public PointDataLayer() {
}
}
public PointDataLayer(SimpleLayer<DefaultPointDataDimension> other) {
super(other);
}
super(other);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.ogc.common.db.SimpleLayer#getTimeEntries()
*/
@Override
public List<String> getTimeEntries() {
return LayerTransformer.getTimes(this, TimeFormat.HOUR_RANGES);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.ogc.common.db.SimpleLayer#getTimeEntries()
*/
@Override
public List<String> getTimeEntries() {
return LayerTransformer.getTimes(this, TimeFormat.HOUR_RANGES);
}
/*
* (non-Javadoc)
@ -92,10 +93,10 @@ public abstract class PointDataLayer extends
*
* @see com.raytheon.uf.edex.ogc.common.db.SimpleLayer#getDefaultTimeEntry()
*/
@Override
public String getDefaultTimeEntry() {
return LayerTransformer.getTimeRange(getDefaultTime());
}
@Override
public String getDefaultTimeEntry() {
return LayerTransformer.getTimeRange(getDefaultTime());
}
/**
* Create formatted time range string with range start at the latest time
@ -104,15 +105,15 @@ public abstract class PointDataLayer extends
* @param milliOffset
* @return
*/
protected <T extends PluginDataObject> String getRangeSinceLatest(
long milliOffset) {
Date end = getTimes().last();
long startTime = end.getTime() - milliOffset;
Date start = new Date(startTime);
String startStr = LayerTransformer.format(start);
String endStr = LayerTransformer.format(end);
return startStr + "/" + endStr;
}
protected <T extends PluginDataObject> String getRangeSinceLatest(
long milliOffset) {
Date end = getTimes().last();
long startTime = end.getTime() - milliOffset;
Date start = new Date(startTime);
String startStr = LayerTransformer.format(start);
String endStr = LayerTransformer.format(end);
return startStr + "/" + endStr;
}
/*
* (non-Javadoc)

View file

@ -4,8 +4,10 @@
<!-- IHFS Database Configuration-->
<bean id="ihfsDbSessionConfig" class="com.raytheon.uf.edex.database.DatabaseSessionConfiguration">
<property name="classFinder" ref="dbClassFinder" />
<property name="includes">
<list>
<value>com.raytheon.uf.common.dataplugin.shef</value>
<value>com.raytheon.edex.plugin.shef</value>
</list>
</property>

View file

@ -1,210 +0,0 @@
/**
* 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 gov.noaa.nws.ncep.edex.util.ncgrib;
import javax.measure.unit.Unit;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.Type;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* Represents a grib level
* <p>
* Refer to the files ncgrib1levels.xml and ncgrib2levels.xml. This class maps to
* the levels defined in those files.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 9/26/07 381 bphillip Initial creation
*
*
* </pre>
*/
@Entity
@Table(name = "ncgrib_levels")
public class NcgribLevel extends PersistableDataObject implements
ISerializableObject {
private static final long serialVersionUID = 1L;
@Id
private Integer id;
@Column
private Integer layerNumber;
@Column
private Integer edition;
/** The name of the level */
@Column(length = 127)
private String name;
/** The unit associated with the level */
@Column
@Type(type = "gov.noaa.nws.ncep.edex.objects.hibernate.ncgrib.UnitType")
private Unit<?> unit;
/** The number of surfaces described by this level */
@Column(name = "layers")
private int numLayers;
public NcgribLevel() {
}
/**
* Constructor
*
* @param name
* The name of the level
* @param unit
* The unit associated with the level
* @param numLayers
* The number of surfaces described by this level
*/
public NcgribLevel(String name, Unit<?> unit, int numLayers) {
this.name = name;
this.unit = unit;
this.numLayers = numLayers;
}
/**
* Gets the name
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name
*
* @param name
* The name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the unit
*
* @return The unit
*/
public Unit<?> getUnit() {
return unit;
}
/**
* Sets the unit
*
* @param unit
* The unit
*/
public void setUnit(Unit<?> unit) {
this.unit = unit;
}
/**
* Gets the number of layers
*
* @return the number of layers
*/
public int getNumLayers() {
return numLayers;
}
/**
* Sets the number of layers
*
* @param numLayers
* the number of layers
*/
public void setNumLayers(int numLayers) {
this.numLayers = numLayers;
}
public Integer getEdition() {
return edition;
}
public void setEdition(Integer edition) {
this.edition = edition;
}
public Integer getNumber() {
return layerNumber;
}
public void setNumber(Integer number) {
this.layerNumber = number;
}
public boolean equals(Object obj) {
if (obj instanceof NcgribLevel) {
NcgribLevel level = (NcgribLevel) obj;
if (this.layerNumber == level.layerNumber
&& this.edition == level.edition
&& this.unit.equals(level.unit)
&& this.name.equals(level.name)
&& this.numLayers == level.numLayers) {
return true;
} else {
return false;
}
} else {
return false;
}
}
public int hashCode() {
return new HashCodeBuilder(17, 37).append(layerNumber).append(edition)
.append(name).append(unit).append(numLayers).toHashCode();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getLayerNumber() {
return layerNumber;
}
public void setLayerNumber(Integer layerNumber) {
this.layerNumber = layerNumber;
}
}