

/*
  The Broad Institute
  SOFTWARE COPYRIGHT NOTICE AGREEMENT
  This software and its documentation are copyright (2006) by the
  Broad Institute/Massachusetts Institute of Technology. All rights are
  reserved.

  This software is supplied without any warranty or guaranteed support
  whatsoever. Neither the Broad Institute nor MIT can be responsible for its
  use, misuse, or functionality.
*/

package calhoun.gebo.internal.db;

import java.sql.ResultSet;
import java.sql.SQLException;

import calhoun.gebo.db.DataAccessException;
import calhoun.gebo.model.FeatureTrack;
import calhoun.gebo.model.Sequence;
import calhoun.service.ArgoTranscriptService;

/**
 * Eventually stick functionality here. For now, just to make conditionals
 * prettier.
 * 
 * @author <a href="mailto:reinhard@genome.wi.mit.edu">Reinhard Engels </a>
 */
public class PolyASignal extends CalhounFeature implements
        CalhounInsertableFeature, CalhounDeletableFeature {

    ///////////////////////////////////////////////////////////////////////////
    // Constructors.
    ///////////////////////////////////////////////////////////////////////////

    /**
     * Creates a new <code>Feature</code> instance.
     * 
     * @param segment
     *            a <code>SegmentModel</code> value
     * @param label
     *            a <code>String</code> value
     * @param id
     *            a <code>String</code> value
     * @param start
     *            an <code>int</code> value
     * @param stop
     *            an <code>int</code> value
     * @param track
     *            a <code>Track</code> value
     * @param strand
     *            a <code>Strand</code> value
     */
    public PolyASignal(Sequence sequence, FeatureTrack track, ResultSet resultSet)
            throws SQLException {
        super(sequence, track, resultSet, false, true, 0);
    }

    public String insert() throws DataAccessException {
        try {
        	ArgoTranscriptService service = new ArgoTranscriptService(CalhounConnectionManager
                    .getInstance().getConnection());
        	service.insertUtrElement(
        			getSequence().getId(),
					getStart(),
					getStop(),
					getStrand().toString(),
					getPropertyValue(AP.TRANSCRIPT_ID),
					Integer.parseInt(getPropertyValue(AP.TRANSCRIPT_START)),
					Integer.parseInt(getPropertyValue(AP.TRANSCRIPT_STOP)),
					getTrack().getId(),
					getLabel());
            return  "I know we should return a feature id but we don't";//statement.getLong(22);
        } catch (Throwable t) {
            throw new DataAccessException(t);
        }
    }

    
    public void delete() throws DataAccessException {
        try {
        	ArgoTranscriptService service = new ArgoTranscriptService(CalhounConnectionManager
                    .getInstance().getConnection());
        	service.deleteUtrElement(getId());
        } catch (Throwable t) {
            throw new DataAccessException(t);
        }
    }



    
}