/*
 * Created on Jun 27, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */


/*
  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 calhoun.gebo.model.FeatureTrack;
import calhoun.gebo.ui.TrackStyle;

/**
 * @author reinhard
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class CalhounPendingInsertTrackFactory {

    /**
     * 
     */
    private CalhounPendingInsertTrackFactory(String trackTypeId ) {
        m_trackTypeId= trackTypeId;
    }    
    
    public static CalhounPendingInsertTrackFactory getAnnotatedTranscript(){
        if ( ANNOTATED_TRANSCRIPT_TRACK_FACTORY == null){
            ANNOTATED_TRANSCRIPT_TRACK_FACTORY = new CalhounPendingInsertTrackFactory("5");
        }
        return ANNOTATED_TRANSCRIPT_TRACK_FACTORY;
    }
    
    public static CalhounPendingInsertTrackFactory getProGeneOld(){
        if ( PRO_GENE_OLD_TRACK_FACTORY == null){
            PRO_GENE_OLD_TRACK_FACTORY = new CalhounPendingInsertTrackFactory("17");
        }
        return PRO_GENE_OLD_TRACK_FACTORY;
    }
    
    public static CalhounPendingInsertTrackFactory getProGeneNew(){
        if ( PRO_GENE_NEW_TRACK_FACTORY == null){
            PRO_GENE_NEW_TRACK_FACTORY = new CalhounPendingInsertTrackFactory("34");
        }
        return PRO_GENE_NEW_TRACK_FACTORY;
    }
    
    public static CalhounPendingInsertTrackFactory getPolyA(){
        if ( POLY_A_TRACK_FACTORY == null){
            POLY_A_TRACK_FACTORY = new CalhounPendingInsertTrackFactory("27");
        }
        return POLY_A_TRACK_FACTORY;
    }
    
    //public static CalhounPendingInsertTrackFactory get
    
    public boolean trackMatches(FeatureTrack track){
        if ( track.getId().startsWith(m_trackTypeId + "_")){
            return true;
        }
        return false;
    }
    
    public CalhounTrack getTrack() {
        if ( m_track == null){
            CalhounTrackType trackType = CalhounTrackManager.getInstance().getTrackType(m_trackTypeId);
            m_track = CalhounTrack.intern(trackType,trackType.getSubclass(),trackType.getOntologyTerm(),"0", trackType.getName() + " (Pending Insert)",0,"");
            m_track.setMutablyEditable(true);
            m_track.setUpdatable(true);
            m_track.setDeletable(true);
            m_track.setOrder(1);
            m_track.setPending(true);
            m_track.setStyle(TrackStyle.SEGREGATED);
        }
        return m_track;
    }
    
    private String m_trackTypeId;
    private CalhounTrack m_track;
    
    private static CalhounPendingInsertTrackFactory ANNOTATED_TRANSCRIPT_TRACK_FACTORY;
    private static CalhounPendingInsertTrackFactory POLY_A_TRACK_FACTORY;
    private static CalhounPendingInsertTrackFactory PRO_GENE_OLD_TRACK_FACTORY;
    private static CalhounPendingInsertTrackFactory PRO_GENE_NEW_TRACK_FACTORY;

}
