

/*
  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.CallableStatement;
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.gebo.util.Q;

/**
 * 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 CalhounTranscript extends CalhounFeature implements
       CalhounDeletableFeature {

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

 
    public CalhounTranscript(Sequence sequence, FeatureTrack track, ResultSet resultSet)
            throws SQLException {
        super(sequence, track, resultSet, false, true, 0);
        
    }

    public void delete() throws DataAccessException {
        try {
            String sql = "delete from ap_feature where ap_id = ?";
            Q.startStopWatch(sql);
            CallableStatement statement = CalhounConnectionManager
                    .getInstance().getConnection().prepareCall(sql);
            Q.setLongOrNull(1, getId(), statement);
            statement.execute();
            statement.close();
        } catch (Throwable t) {
            throw new DataAccessException(t);
        }
    }

    public boolean isDeletable(){
        return getSequence().isEditable();
    }
    
}