org.opensha.sha.cybershake.db
Class SiteInfo2DB

java.lang.Object
  extended by org.opensha.sha.cybershake.db.SiteInfo2DB
All Implemented Interfaces:
SiteInfo2DBAPI

public class SiteInfo2DB
extends Object
implements SiteInfo2DBAPI


Constructor Summary
SiteInfo2DB(DBAccess dbaccess)
           
 
Method Summary
 int deleteRegionsForSite(int siteId)
           
 int deleteRupturesForSite(int siteId)
           
 int deleteSiteRecord(int siteId)
           
 ArrayList<String> getAllSites()
           
 ArrayList<CybershakeSite> getAllSitesFromDB()
          Gets all CybershakeSite's from the Database
 LocationList getAllSitesLocation()
           
 ArrayList<Integer> getERFsForSite(int siteID)
           
 Location getLocationForSite(String site)
           
 ArrayList<Integer> getRupIdsForSite(int siteID, int erf_id, int srcId)
           
 ArrayList<Integer> getRupIdsForSite(String siteShortName, int erf_id, int srcId)
           
 double getSiteCutoffDistance(int siteID)
          Returns the site id of the cybershake site for the corresponding cybershake_short_site_name
 double getSiteCutoffDistance(String cybershakeShortSiteName)
          Returns the site id of the cybershake site for the corresponding cybershake_short_site_name
 CybershakeSite getSiteFromDB(int siteID)
          Gets a CybershakeSite from the Database
 CybershakeSite getSiteFromDB(String shortName)
          Gets a CybershakeSite from the Database
 int getSiteId(double lat, double lon)
          Returns the site id the cybershake site with given lat and lon
 int getSiteId(String cybershakeShortSiteName)
          Returns the site id of the cybershake site for the corresponding cybershake_short_site_name
 ArrayList<CybershakeSiteType> getSiteTypes()
           
 ArrayList<Integer> getSrcIdsForSite(int siteID, int erf_id)
           
 ArrayList<Integer> getSrcIdsForSite(String siteShortName, int erf_id)
           
 void getSrcIfoForSite(int siteID, int erf_id, ArrayList<Integer> ids)
           
 void getSrcIfoForSite(String siteShortName, int erf_id, ArrayList<Integer> ids)
           
 void insertSite_RuptureInfo(int siteId, int erfId, int sourceId, int ruptureId, double cutOffDistance)
          Inserts the rupture ids that correspond to a given site within given cutoff distance inside the table CyberShake_Site_Ruptures
 void insertSite_RuptureInfoList(int siteId, int erfId, int sourceId, ArrayList<Integer> ruptureId, ArrayList<Double> rupDists, double cutOffDistance)
          Inserts thelist of rupture ids that correspond to a given site within given cutoff distance inside the table Site_Ruptures.
 int insertSite(String siteName, String siteShortName, double lat, double lon)
          Inserts the new site in the database table CyberShake_Sites
 void insertSiteRegionalBounds(int siteId, int erfId, double cutOffDistance, double maxLat, int maxLatSrcId, int maxLatRupId, double minLat, int minLatSrcId, int minLatRupId, double maxLon, int maxLonSrcId, int maxLonRupId, double minLon, int minLonSrcId, int minLonRupId)
          Inserts the regional bounds (min/max lat/lon) for all cybershake sites in table CyberShake_Site_Regions
 boolean isRupInDB(int erfID, int sourceID, int rupID)
          Find out if the given rupture is already in the database
 boolean isSiteRupInDB(int erfID, int sourceID, int rupID, int siteID)
          Find out if the given rupture is already in the database
static void main(String[] args)
          tester main function
 void setSiteLongName(int siteID, String longName)
           
 void setSiteType(int siteID, int typeID)
           
 void updateSiteRegionalBounds(int siteId, int erfId, double cutOffDistance, double maxLat, int maxLatSrcId, int maxLatRupId, double minLat, int minLatSrcId, int minLatRupId, double maxLon, int maxLonSrcId, int maxLonRupId, double minLon, int minLonSrcId, int minLonRupId)
          Inserts the regional bounds (min/max lat/lon) for all cybershake sites in table CyberShake_Site_Regions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SiteInfo2DB

public SiteInfo2DB(DBAccess dbaccess)
Method Detail

insertSite

public int insertSite(String siteName,
                      String siteShortName,
                      double lat,
                      double lon)
Inserts the new site in the database table CyberShake_Sites

Specified by:
insertSite in interface SiteInfo2DBAPI
Parameters:
siteName -
siteShortName -
lat -
lon -
Returns:
the Site Id for the last inserted Site

setSiteType

public void setSiteType(int siteID,
                        int typeID)

setSiteLongName

public void setSiteLongName(int siteID,
                            String longName)

getSiteId

public int getSiteId(String cybershakeShortSiteName)
Returns the site id of the cybershake site for the corresponding cybershake_short_site_name

Specified by:
getSiteId in interface SiteInfo2DBAPI
Parameters:
cybershakeShortSiteName -
Returns:

getSiteCutoffDistance

public double getSiteCutoffDistance(String cybershakeShortSiteName)
Returns the site id of the cybershake site for the corresponding cybershake_short_site_name

Parameters:
cybershakeShortSiteName -
Returns:

getSiteCutoffDistance

public double getSiteCutoffDistance(int siteID)
Returns the site id of the cybershake site for the corresponding cybershake_short_site_name

Parameters:
cybershakeShortSiteName -
Returns:

getSiteId

public int getSiteId(double lat,
                     double lon)
Returns the site id the cybershake site with given lat and lon

Specified by:
getSiteId in interface SiteInfo2DBAPI
Parameters:
lat -
lon -
Returns:

insertSiteRegionalBounds

public void insertSiteRegionalBounds(int siteId,
                                     int erfId,
                                     double cutOffDistance,
                                     double maxLat,
                                     int maxLatSrcId,
                                     int maxLatRupId,
                                     double minLat,
                                     int minLatSrcId,
                                     int minLatRupId,
                                     double maxLon,
                                     int maxLonSrcId,
                                     int maxLonRupId,
                                     double minLon,
                                     int minLonSrcId,
                                     int minLonRupId)
Inserts the regional bounds (min/max lat/lon) for all cybershake sites in table CyberShake_Site_Regions

Specified by:
insertSiteRegionalBounds in interface SiteInfo2DBAPI
Parameters:
siteId -
erfId -
cutOffDistance -
maxLat -
maxLatSrcId -
maxLatRupId -
minLat -
minLatSrcId -
minLatRupId -
maxLon -
maxLonSrcId -
maxLonRupId -
minLon -
minLonSrcId -
minLonRupId -

updateSiteRegionalBounds

public void updateSiteRegionalBounds(int siteId,
                                     int erfId,
                                     double cutOffDistance,
                                     double maxLat,
                                     int maxLatSrcId,
                                     int maxLatRupId,
                                     double minLat,
                                     int minLatSrcId,
                                     int minLatRupId,
                                     double maxLon,
                                     int maxLonSrcId,
                                     int maxLonRupId,
                                     double minLon,
                                     int minLonSrcId,
                                     int minLonRupId)
Inserts the regional bounds (min/max lat/lon) for all cybershake sites in table CyberShake_Site_Regions

Specified by:
updateSiteRegionalBounds in interface SiteInfo2DBAPI
Parameters:
siteId -
erfId -
cutOffDistance -
maxLat -
maxLatSrcId -
maxLatRupId -
minLat -
minLatSrcId -
minLatRupId -
maxLon -
maxLonSrcId -
maxLonRupId -
minLon -
minLonSrcId -
minLonRupId -

insertSite_RuptureInfo

public void insertSite_RuptureInfo(int siteId,
                                   int erfId,
                                   int sourceId,
                                   int ruptureId,
                                   double cutOffDistance)
Inserts the rupture ids that correspond to a given site within given cutoff distance inside the table CyberShake_Site_Ruptures

Specified by:
insertSite_RuptureInfo in interface SiteInfo2DBAPI
Parameters:
siteId -
erfId -
sourceId -
ruptureId -
cutoffDistance -

insertSite_RuptureInfoList

public void insertSite_RuptureInfoList(int siteId,
                                       int erfId,
                                       int sourceId,
                                       ArrayList<Integer> ruptureId,
                                       ArrayList<Double> rupDists,
                                       double cutOffDistance)
Description copied from interface: SiteInfo2DBAPI
Inserts thelist of rupture ids that correspond to a given site within given cutoff distance inside the table Site_Ruptures.

Specified by:
insertSite_RuptureInfoList in interface SiteInfo2DBAPI
ruptureId - - list of Rupture IDs

isRupInDB

public boolean isRupInDB(int erfID,
                         int sourceID,
                         int rupID)
Find out if the given rupture is already in the database

Specified by:
isRupInDB in interface SiteInfo2DBAPI
Parameters:
erfID -
sourceID -
rupID -
Returns:

isSiteRupInDB

public boolean isSiteRupInDB(int erfID,
                             int sourceID,
                             int rupID,
                             int siteID)
Find out if the given rupture is already in the database

Specified by:
isSiteRupInDB in interface SiteInfo2DBAPI
Parameters:
erfID -
sourceID -
rupID -
siteID -
Returns:

getAllSitesLocation

public LocationList getAllSitesLocation()
Specified by:
getAllSitesLocation in interface SiteInfo2DBAPI
Returns:
the list of all cybershake site locations

getAllSites

public ArrayList<String> getAllSites()
Specified by:
getAllSites in interface SiteInfo2DBAPI
Returns:
the ArrayList of short site names for all Cybershake

getRupIdsForSite

public ArrayList<Integer> getRupIdsForSite(String siteShortName,
                                           int erf_id,
                                           int srcId)
Specified by:
getRupIdsForSite in interface SiteInfo2DBAPI
Parameters:
siteShortName -
srcId -
Returns:
the list of rupture ids

getRupIdsForSite

public ArrayList<Integer> getRupIdsForSite(int siteID,
                                           int erf_id,
                                           int srcId)
Specified by:
getRupIdsForSite in interface SiteInfo2DBAPI
Parameters:
siteShortName -
srcId -
Returns:
the list of rupture ids

getSrcIfoForSite

public void getSrcIfoForSite(String siteShortName,
                             int erf_id,
                             ArrayList<Integer> ids)
Parameters:
siteShortName - short site name as in database for Cybershake site

getSrcIfoForSite

public void getSrcIfoForSite(int siteID,
                             int erf_id,
                             ArrayList<Integer> ids)
Parameters:
siteShortName - short site name as in database for Cybershake site

getSrcIdsForSite

public ArrayList<Integer> getSrcIdsForSite(String siteShortName,
                                           int erf_id)
Specified by:
getSrcIdsForSite in interface SiteInfo2DBAPI
Parameters:
siteShortName - short site name as in database for Cybershake site
Returns:
the Earthquake rupture forecast source id's for a given cybershake site.

getSrcIdsForSite

public ArrayList<Integer> getSrcIdsForSite(int siteID,
                                           int erf_id)
Specified by:
getSrcIdsForSite in interface SiteInfo2DBAPI
Parameters:
siteShortName - short site name as in database for Cybershake site
Returns:
the Earthquake rupture forecast source id's for a given cybershake site.

getLocationForSite

public Location getLocationForSite(String site)
Specified by:
getLocationForSite in interface SiteInfo2DBAPI
Parameters:
site -
Returns:
the Location for the given cybershake site location

getSiteFromDB

public CybershakeSite getSiteFromDB(String shortName)
Gets a CybershakeSite from the Database

Specified by:
getSiteFromDB in interface SiteInfo2DBAPI
Parameters:
shortName -
Returns:

getSiteFromDB

public CybershakeSite getSiteFromDB(int siteID)
Gets a CybershakeSite from the Database

Specified by:
getSiteFromDB in interface SiteInfo2DBAPI
Parameters:
shortName -
Returns:

getAllSitesFromDB

public ArrayList<CybershakeSite> getAllSitesFromDB()
Gets all CybershakeSite's from the Database

Specified by:
getAllSitesFromDB in interface SiteInfo2DBAPI
Returns:

getSiteTypes

public ArrayList<CybershakeSiteType> getSiteTypes()

getERFsForSite

public ArrayList<Integer> getERFsForSite(int siteID)

deleteRupturesForSite

public int deleteRupturesForSite(int siteId)

deleteRegionsForSite

public int deleteRegionsForSite(int siteId)

deleteSiteRecord

public int deleteSiteRecord(int siteId)

main

public static void main(String[] args)
tester main function

Parameters:
args -