| # == Schema Information |
| # Schema version: 1 |
| # |
| # Table name: baselines |
| # |
| # id :integer(11) not null, primary key |
| # baseline :string(250) default(), not null |
| # buildid :string(250) default(), not null |
| # description :text |
| # created_on :datetime |
| # updated_on :datetime |
| # |
| |
| # A Baseline is established when a baseline process is created, see Site.new_baseline_process. |
| # Therefore: a Baseline has one baseline process from which it was created. |
| # |
| # More information: |
| # * {EPF Wiki Data model}[link:files/doc/DATAMODEL.html] |
| #-- |
| # TODO R? remove baseline table. The idea of this table is that we could |
| # remove a baseline process site and keep information about the baseline. |
| # A better approach problably is to not delete baseline process sites but |
| # make them obsolote or something. To save disk space we can remove content |
| # of a baseline process site when it has become obsolete. |
| #++ |
| #--###################################################################### |
| # Copyright (c) 2006 LogicaCMG |
| # |
| # All rights reserved. This program and the accompanying materials |
| # are made available under the terms of the Eclipse Public License v1.0 |
| # which accompanies this distribution, and is available at |
| # http://www.eclipse.org/legal/epl-v10.html |
| # |
| # Contributors: |
| # |
| # Onno van der Straaten:: initial implementation |
| #++###################################################################### |
| # {Copyright (c) 2006 LogicaCMG}[link:files/COPYRIGHT.html] |
| class Baseline < ActiveRecord::Base |
| |
| has_and_belongs_to_many :pages |
| has_and_belongs_to_many :sites |
| has_many :comments |
| has_many :versions |
| has_many :checkouts |
| |
| validates_presence_of :baseline |
| validates_uniqueness_of :baseline |
| |
| def pages_count |
| return Page.count_by_sql("select count(*) from baselines_pages where baseline_id=" + self.id.to_s ) |
| end |
| |
| # method #sites_current returns collection of Site records where the Baseline is the current. |
| def sites_current |
| return Site.find(:all, :conditions => ['baseline_id = ?', self.id], :order => 'created_on DESC') |
| end |
| |
| def wikis_current |
| return Site.find(:all, :conditions => ['baseline_id =? and site_type = ?', self.id, 'W']) |
| end |
| |
| def baseline_process |
| return Site.find(:first, :conditions => ['baseline_id =? and site_type = ?', self.id, 'S']) |
| end |
| end |