Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
*
* This software was written by Cove Software, LLC ("COVE") under contract
* to the United States Government.
*
* No warranty is provided or implied other than specific contractual terms
* between COVE and the U.S. Government
*
* Copyright 2016 U.S. Army Corps of Engineers, Hydrologic Engineering Center.
* All rights reserved.
*/
package decodes.cwms.rating;
import ilex.util.TextUtil;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TimeZone;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import opendcs.dao.DaoBase;
import decodes.cwms.BadRatingException;
import decodes.cwms.CwmsTimeSeriesDb;
import decodes.sql.DbKey;
import decodes.tsdb.DbIoException;
import hec.data.RatingException;
import hec.data.cwmsRating.AbstractRating;
import hec.data.cwmsRating.RatingSet;
public class CwmsRatingDao extends DaoBase
{
private static final Logger log = LoggerFactory.getLogger(CwmsRatingDao.class);
public static final String module = "CwmsRatingDao";
public static final String cwms_v_rating_columns =
"RATING_CODE, RATING_ID, EFFECTIVE_DATE, CREATE_DATE, ACTIVE_FLAG";
private String officeId = null;
class RatingWrapper
{
Date timeLoaded = null;
Date lastTimeUsed = null;
RatingSet ratingSet = null;
RatingWrapper(Date timeLoaded, RatingSet ratingSet, Date lastTimeUsed)
{
this.timeLoaded = timeLoaded;
this.ratingSet = ratingSet;
this.lastTimeUsed = lastTimeUsed;
}
}
static HashMap ratingCache = new HashMap();
public static final int MAX_CACHED = 400;
// Ratings older than this in the cache are discarded.
private long MAX_AGE_MSEC = 9 * 3600000L;
public CwmsRatingDao(CwmsTimeSeriesDb tsdb)
{
super(tsdb, "CwmsRatingDao");
officeId = tsdb.getDbOfficeId();
setUseReference(true);
}
public void setUseReference(boolean useReference)
{
System.setProperty("hec.data.cwmsRating.RatingSet.databaseLoadMethod",
useReference ? "reference" : "eager");
}
public void setOfficeId(String oid)
{
officeId = oid;
}
private CwmsRatingRef rs2rr(ResultSet rs)
throws SQLException, BadRatingException
{
return new CwmsRatingRef(DbKey.createDbKey(rs, 1), officeId,
rs.getString(2), db.getFullDate(rs, 3),
db.getFullDate(rs, 4), TextUtil.str2boolean(rs.getString(5)));
}
/**
* List all the rating objects for this office ID.
* Results are not sorted in any particular way.
* @param locationId location ID or null for no filter
* @return list of CwmsRatingRef objects
* @throws DbIoException if any error occurs in the query.
*/
List listRatings(String locationId)
throws DbIoException
{
String officeId = ((CwmsTimeSeriesDb)db).getDbOfficeId();
String q = "select distinct " + cwms_v_rating_columns
+ " from CWMS_V_RATING"
+ " where upper(OFFICE_ID) = upper(?)";
ArrayList