All Downloads are FREE. Search and download functionalities are using the official Maven repository.

decodes.cwms.rating.CwmsRatingRef Maven / Gradle / Ivy

Go to download

A collection of software for aggregatting and processing environmental data such as from NOAA GOES satellites.

The newest version!
/**
 * $Id$
 * 
 * $Log$
 * Revision 1.1.1.1  2014/05/19 15:28:59  mmaloney
 * OPENDCS 6.0 Initial Checkin
 *
 * Revision 1.4  2013/03/21 18:27:40  mmaloney
 * DbKey Implementation
 *
 * 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 java.util.Date;

import decodes.cwms.BadRatingException;
import decodes.db.Constants;
import decodes.sql.DbKey;

/**
 * Bean holding a reference to a rating in the CWMS database.
 * This is the information in the CWMS_V_RATING view.
 * @author mmaloney
 *
 */
public class CwmsRatingRef
{
	/** surrogate key */
	private DbKey ratingCode = Constants.undefinedId;
	
	/** office ID */
	private String officeId = null;
	
	/** CWMS Location ID = CWMS Site name Value */
	private String location = null;
	
	/** Independent 'Param' IDs */
	private String indep[] = new String[0];
	
	/** Dependent 'Param' ID */
	private String dep = null;
	
	/** Version of the Rating Template */
	private String tplVersion = null;
	
	/** Version of the Rating Specification */
	private String specVersion = null;
	
	/** Effective Date */
	private Date effectiveDate = null;
	
	/** Date created in the DB */
	private Date createDate = null;
	
	/** Active flag */
	private boolean active = false;

	/**
	 * Constructor called from CwmsRatingDao after reading CWMS_V_RATING
	 * @param ratingCode
	 * @param ratingId
	 * @param effectiveDate
	 * @param createDate
	 * @param active
	 */
	public CwmsRatingRef(DbKey ratingCode, String officeId, String ratingId, 
		Date effectiveDate,
		Date createDate, boolean active)
		throws BadRatingException
	{
		this.ratingCode = ratingCode;
		this.officeId = officeId;
		this.effectiveDate = effectiveDate;
		this.createDate = createDate;
		this.active = active;
		
		String parts[] = ratingId.split("\\.");
		if (parts.length != 4)
			throw new BadRatingException("Only " + parts.length
				+ " parts in id '" + ratingId + "'");
		
		this.location = parts[0];
		this.tplVersion = parts[2];
		this.specVersion = parts[3];
		
		String params[] = parts[1].split("[,;]");
		if (params.length < 2)
			throw new BadRatingException("Only " + params.length
				+ " params in id '" + ratingId + "'");
		indep = new String[params.length-1];
		for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy