head	1.12;
access;
symbols
	TIGRIS_0_9_2_4:1.2.2.1
	TIGRIS_0_9_2_3:1.2
	HELM_PEER_PORT_BRANCH:1.10.0.2
	TURBINE_PEER:1.10
	TIGRIS_0_9_2_1:1.10
	TIGRIS_0_9_2:1.2.0.2;
locks; strict;
comment	@# @;


1.12
date	2001.02.21.03.23.56;	author edk;	state dead;
branches;
next	1.11;

1.11
date	2001.02.02.22.38.56;	author elicia;	state Exp;
branches;
next	1.10;

1.10
date	2001.01.26.18.29.00;	author edk;	state Exp;
branches
	1.10.2.1;
next	1.9;

1.9
date	2001.01.26.05.24.05;	author edk;	state dead;
branches;
next	1.8;

1.8
date	2001.01.26.02.03.14;	author elicia;	state Exp;
branches;
next	1.7;

1.7
date	2001.01.25.03.18.33;	author stack;	state Exp;
branches;
next	1.6;

1.6
date	2001.01.25.02.53.24;	author leonardr;	state Exp;
branches;
next	1.5;

1.5
date	2001.01.24.22.24.36;	author leonardr;	state Exp;
branches;
next	1.4;

1.4
date	2001.01.24.20.42.46;	author dlr;	state Exp;
branches;
next	1.3;

1.3
date	2001.01.23.02.29.40;	author elicia;	state Exp;
branches;
next	1.2;

1.2
date	2001.01.17.18.27.00;	author elicia;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2000.12.30.05.04.53;	author elicia;	state Exp;
branches;
next	;

1.2.2.1
date	2001.02.01.18.49.24;	author jrobbins;	state Exp;
branches;
next	;

1.10.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	;


desc
@@


1.12
log
@delete stuff from the head which is obsolete in the branch (more changes
are still needed for a clean compile)
@
text
@/* ================================================================
 * Copyright (c) 2000 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.collab.net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */

package org.tigris.helm.database;

import java.io.*;
import java.util.*;
import java.sql.*;

import org.webmacro.util.Log;

import com.workingdogs.village.*;

import org.joist.database.*;

import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.tool.*;
import org.tigris.helm.project.Section;

/**
 * Project document sections.
 *
 * @@author <a href="mailto:elicia@@collab.net">Elicia David</a>
 * @@version $Id: ProjectSectionManager.java,v 1.11 2001/02/02 22:38:56 elicia Exp $
 *
 * Copyright (c) 2000 CollabNet, Inc.
 */
public class ProjectSectionManager extends TableManager
{
    /**
     * The name of the database table that this <code>TableManager</code> 
     * manages.
     */
    public static final String TABLE_NAME = "HELM_PROJECTSECTION";

    /**
     * A database key field.
     */
    public static final String SECTION_ID = "SECTION_ID";

    /**
     * A database key field.
     */
    public static final String PROJECT_ID = "PROJECT_ID";

    /**
     * A database key field.
     */
    public static final String PARENT_ID = "PARENT_ID";

    /**
     * The name of the section.
     */
    public static final String NAME = "NAME";

    /**
     * Description of the file.
     */
    public static final String DESCRIPTION = "DESCRIPTION";

    /**
     * User ID of the person who approved this upload.
     */
    public static final String APPROVED_BY = "APPROVED_BY";

    /**
     * User ID of the person who uploaded.
     */
    public static final String SUGGESTED_BY = "SUGGESTED_BY";

    /**
     * The logger instance for all instances of this class.
     */
    private static Log log = new Log ("secMgr", "ProjectSectionManager");

    /**
     * Whether we want debugging information.
     */
    private static final boolean debug = true;

    /**
     * Creates a new instance.
     *
     * @@param dataMgr The manager of this instance.
     */
    public ProjectSectionManager (DataManager dataMgr)
    {
        super (dataMgr);
    }

    /**
     * Retrieves section by ID
     *
     * @@param    conn    A JDBC database connection
     * @@return           a Record
     * @@exception    SQLException
     * @@exception    DataSetException
     */
    public Record getSectionForID (Connection conn, String sectionID)
        throws SQLException, DataSetException
    {
        TableDataSet section = null;

        try
        {
            section = new TableDataSet (conn, TABLE_NAME);
            section.where(SECTION_ID + '=' + sectionID);
            section.fetchRecords();
        }
        finally
        {
            registerToClose (section);
        }

        return section.getRecord(0);
    }

    /**
     * Retrieves top level sections for a project.
     *
     * @@param conn      The JDBC database connection to use.
     * @@param projectID The project to retrieve sections for.
     * @@return          The any sections for the project.
     *
     * @@exception DataSetException
     * @@exception SQLException
     */
    public DataSet getTopLevelSectionsForProject (Connection conn, 
                                                  String projectID)
        throws SQLException, DataSetException
    {
        TableDataSet sections = null;
        try
        {
            sections = new TableDataSet(conn, TABLE_NAME);
            sections.where(PROJECT_ID + '=' + projectID 
                           + " and " + PARENT_ID + '=' + 0);
            sections.fetchRecords();
        }
        finally
        {
            registerToClose(sections);
        }
        return sections;
    }

    /**
     * Retrieves subsections for a section.
     *
     * @@param conn      The JDBC database connection to use.
     * @@param sectionID The section to retrieve subsections for.
     * @@return          The any subsections for the section.
     *
     * @@exception DataSetException
     * @@exception SQLException
     */
    public DataSet getSubsections (Connection conn, String sectionID)
        throws SQLException, DataSetException
    {
        TableDataSet subsections = null;
        try
        {
            subsections = new TableDataSet(conn, TABLE_NAME);
            subsections.where(PARENT_ID + '=' + sectionID);
            subsections.fetchRecords();
        }
        finally
        {
            registerToClose(subsections);
        }
        return subsections;
    }

    /**
     * Approves the section in the name of the given userID.
     *
     * @@param conn         The JDBC database connection to use.
     * @@param sectionID   The document to approve.
     * @@param userID      The user approving the project.
     *
     * @@exception SQLException
     * @@exception DataSetException 
     */
    public void approveSection(Connection conn, String sectionID, 
                               String userID)
        throws SQLException, DataSetException, JoistDatabaseException,
               UpdateException              
    {
        Record sc = null;
        TableDataSet sections = null;

        try
        {
            sections = new TableDataSet(conn, TABLE_NAME,
                                         new KeyDef().addAttrib(SECTION_ID));
            if (sectionID != null)
            {
                sections.where(SECTION_ID + '=' + sectionID);
                sections.fetchRecords();
                sc = sections.getRecord(0);
            }
            setField(sc, APPROVED_BY, userID);
            sc.save();

        }
        finally
        {
            registerToClose(sections);
        }
    }

    /**
     * Approves the section in the name of the given userID.
     *
     * @@param conn         The JDBC database connection to use.
     * @@param sectionID   The document to approve.
     * @@param userID      The user approving the project.
     *
     * @@exception SQLException
     * @@exception DataSetException 
     */
    public void moveToTop(Connection conn, String sectionID)
        throws SQLException, DataSetException, JoistDatabaseException,
               UpdateException              
    {
        Record sc = null;
        TableDataSet sections = null;

        try
        {
            sections = new TableDataSet(conn, TABLE_NAME,
                                        new KeyDef().addAttrib(SECTION_ID));
            if (sectionID != null)
            {
                sections.where(SECTION_ID + '=' + sectionID);
                sections.fetchRecords();
                sc = sections.getRecord(0);
            }
            setField(sc, PARENT_ID, "0");
            sc.save();

        }
        finally
        {
            registerToClose(sections);
        }
    }

    /**
     * Adds a section.
     *
     * @@param conn       The JDBC database connection to use.
     * @@param projectID  The database key of the project to do the add for.
     * @@param name             The name of the section.
     * @@param descrip    The section's description.
     * @@param suggestedBy The database key of the user doing the upload.
     * @@param approvedBy The database key of the user approving the upload.
     */
    public Record addSection (Connection conn, String projectID,
                              String parentID, String name, String descrip, 
                              String suggestedBy, String approvedBy)
        throws SQLException, DataSetException
    {
        return updateSection(conn, null, projectID, parentID, name, 
                              descrip, suggestedBy, approvedBy);
    }

    /**
     * Updates or adds a section.
     *
     * @@param conn       The JDBC database connection to use.
     * @@param sectionID The database key of the section to update, or
     *                   <code>null</code> if the section is new.
     * @@param parentID The database key of the parent section 
     * @@param name       The name of the section.
     * @@param descrip    The section's description.
     * @@param suggestedBy The database key of the user doing the upload.
     * @@param approvedBy The database key of the user approving the upload.
     * @@return           The database key of the section.
     *
     * @@exception SQLException
     * @@exception DataSetException
     */
    private Record updateSection (Connection conn, String sectionID, 
                                  String projectID, String parentID,
                                  String name,  String descrip, 
                                  String suggestedBy, String approvedBy)
        throws SQLException, DataSetException
    {
        Record sec = null;

        TableDataSet sections = null;
        try
        {
            sections = new TableDataSet(conn, TABLE_NAME,
                                         new KeyDef().addAttrib(SECTION_ID));
            if (sectionID != null)
            {
                // Updating existing section.
                sections.where(SECTION_ID + '=' + sectionID);
                sections.fetchRecords();
                sec = sections.getRecord(0);
            }
            else
            {
                // Adding new section.
                sec = sections.addRecord();
                setField(sec, SUGGESTED_BY, suggestedBy);
            }
            setField(sec, PROJECT_ID, projectID);
            setField(sec, DESCRIPTION, descrip);
            setField(sec, PARENT_ID, parentID);
            setField(sec, NAME, name);
            setField(sec, APPROVED_BY, approvedBy);
            sec.save();
   
            // Update the association between document and section
            
        }
        finally
        {
            registerToClose(sections);
        }

        return sec;
    }

    /**
     * Updates the specified section.
     *
     * @@param conn        The JDBC database connection to use.
     * @@param sectionID  The database key of the section to update, or
     *                    <code>null</code> if the section is new.
     * @@param descrip     The section's description.
     * @@param approvedBy  The database key of the approving user.
     *
     * @@exception SQLException
     * @@exception DataSetException
     */
    public void editSection (Connection conn, String sectionID, 
                             String parentID, String name, String descrip)
        throws SQLException, DataSetException
    {
        updateSection(conn, sectionID, null, parentID, name, descrip,
                       null, null);
    }

    /**
     * Deletes an existing section from the database
     *
     * @@param      conn the JDBC database connection
     * @@param      sectionID       the ID of the section to delete
     * @@exception SQLException
     */
    public void deleteSection (Connection conn, String sectionID)
        throws SQLException, DataSetException
    {
        TableDataSet sections = null;
        try
        {
            
            sections = new TableDataSet (conn, TABLE_NAME,
                                          new KeyDef().addAttrib(SECTION_ID));
            sections.where (SECTION_ID + '=' + sectionID);
            sections.fetchRecords();
            if (sections.containsRecord(0)) 
            {
                Record r = sections.getRecord(0);
                r.markToBeDeleted();
                r.save();
            }
        }
        finally
        {
            registerToClose(sections);
        }
    }

    public DataSet getUnapprovedSectionsForProject (Connection conn, 
                                                    String projectID)
        throws SQLException, DataSetException, JoistDatabaseException
    {
        TableDataSet sections = null;
        try
        {
            sections = new TableDataSet(conn, TABLE_NAME);
            sections.where(PROJECT_ID + '=' + projectID);
            UserUserGroupManager usrGrpMgr = 
               (UserUserGroupManager)getDataManager().getManager
               ("org.tigris.helm.database.UserUserGroupManager");
            String nobodyID = usrGrpMgr.getNobodyUserID(conn);
            sections.where(APPROVED_BY + '=' + nobodyID);
            sections.fetchRecords();
        }
        finally
        {
            registerToClose(sections);
        }
        return sections;
    }
}
@


1.11
log
@fixed where clause in getTopLevelSections method
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.10 2001/01/26 18:29:00 edk Exp $
@


1.10
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.3 2001/01/23 02:29:40 elicia Exp $
d179 2
a180 2
            sections.where(PROJECT_ID + '=' + projectID);
            sections.where(PARENT_ID + '=' + 0);
a280 1
                  log.info("dataMgr" + sc);
@


1.10.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.10 2001/01/26 18:29:00 edk Exp $
@


1.9
log
@revert this stuff to its state as of 2001/01/24 12:42:00 GMT -- with
the following exceptions, which have some different modifications so
they'll work with changes which have happened in joist:

ProjectNewsEdit.java
SkinManager.java
SkinStyleElementValueManager.java
StyleElementManager.java
StyleManager.java

it compiles.  i dunno if it works, though.
@
text
@a56 3
import org.apache.turbine.services.db.*;
import org.apache.turbine.util.db.pool.*;

a60 1
import org.tigris.helm.DoesNotExist;
d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.8 2001/01/26 02:03:14 elicia Exp $
d131 1
a131 1
        super(dataMgr, new KeyDef().addAttrib(SECTION_ID));
a133 4
    ////////////////////////////////////////////////////////////////
    // Accessor methods.
    ////////////////////////////////////////////////////////////////

d137 1
d139 2
a140 3
     *
     * @@exception DBException if a database error occurs.
     * @@exception DBException if the section ID is invalid.
d142 2
a143 2
    public Record getSectionForID (String sectionID)
        throws DBException, DoesNotExist
d145 3
a147 3
        Criterion c = new Criterion(SECTION_ID, sectionID);
        Record section = getFirstMatchingRecord(c);
        if (section == null)
d149 3
a151 1
            throw new DoesNotExist("Section with ID " + sectionID);
d153 6
a158 1
        return section;
d164 1
d168 2
a169 1
     * @@exception DBException if a database error occurs.
d171 3
a173 2
    public DataSet getTopLevelSectionsForProject (String projectID)
        throws DBException
d175 13
a187 3
        Criterion c = new Criterion(PROJECT_ID, projectID);
        c.and(new Criterion(PARENT_ID, "0"));
        return getRecords(c);
d193 1
d197 2
a198 1
     * @@exception DBException if a database error occurs.
d200 2
a201 2
    public DataSet getSubsections (String sectionID)
        throws DBException
d203 12
a214 2
        Criterion c = new Criterion(PARENT_ID, sectionID);
        return getRecords(c);
d218 1
a218 2
     * Retrieves unapproved document sections associated with a
     * given project.
d220 3
a222 2
     * @@param projectID The section to retrieve subsections for.
     * @@return          All appropriate sections.
d224 2
a225 1
     * @@exception DBException if a database error occurs.
d227 4
a230 2
    public DataSet getUnapprovedSectionsForProject (String projectID)
        throws DBException
d232 2
a233 3
        UserManager uMgr = (UserManager)getDataManager().getManager
            ("org.tigris.helm.database.UserManager");
        String nobodyID = uMgr.getNobodyUserID();
d235 5
a239 22
        Criterion c = new Criterion(PROJECT_ID, projectID);
        c.and(new Criterion(APPROVED_BY, nobodyID));
        return getRecords(c);
    }
    
    /**
     * Returns the first record matching a given Criterion. 
     *
     * @@param criterion Criterion to use in select.
     *
     * @@exception DBException if a database error occurs.
     *
     * @@return Null if no matching record, first record in recordset
     * otherwise.  
     */
    private Record getFirstMatchingRecord(Criterion criterion)
        throws DBException
    {
        Record r = null;
        try {
            DataSet s = getRecords(criterion);
            if (s != null && s.containsRecord(0))
d241 3
a243 1
                r = s.getRecord(0);
d245 7
a251 2
        } catch (DataSetException e) {
            throw new DBException(e);
a252 2

        return r;
d256 1
a256 1
     * Returns records matching a given Criterion.
d258 3
a260 1
     * @@param criterion Criterion to use in select.
d262 2
a263 1
     * @@exception DBException if a database error occurs.
d265 3
a267 2
    public DataSet getRecords(Criterion criterion)
        throws DBException
d269 21
a289 5
        DataSet s = null;
        try {
            s = runSelect(TABLE_NAME, criterion, NAME);
        } catch (Exception e) {
            throw new DBException(e);
a290 1
        return s;
a292 4
    ////////////////////////////////////////////////////////////////
    // Mutator methods.
    ////////////////////////////////////////////////////////////////

d303 2
a304 2
    public Record addSection (String projectID, String parentID, 
                              String name, String descrip, 
d306 1
a306 24
        throws DBException
    {
        Record section = null;
        try {
            section = updateSection(null, projectID, parentID, name, 
                                    descrip, suggestedBy, approvedBy);
        } catch (DoesNotExist ignore) {}
        return section;
    }

    /**
     * Updates the specified section.
     *
     * @@param conn        The JDBC database connection to use.
     * @@param sectionID  The database key of the section to update, or
     *                    <code>null</code> if the section is new.
     * @@param descrip     The section's description.
     * @@param approvedBy  The database key of the approving user.
     *
     * @@exception DBException
     */
    public void editSection (String sectionID, String parentID, String name, 
                             String descrip)
        throws DBException, DoesNotExist
d308 2
a309 1
        updateSection(sectionID, null, parentID, name, descrip, null, null);
d325 2
a326 1
     * @@exception DBException
d328 5
a332 5
    private Record updateSection (String sectionID, String projectID, 
                                  String parentID, String name, 
                                  String descrip, String suggestedBy, 
                                  String approvedBy)
        throws DBException, DoesNotExist
a333 2
        DBConnection dbConn = null;
        Connection connection = null;
d335 1
a336 1

d339 2
d344 6
a349 2
                sec = getSectionForID(sectionID);
            } else {
a350 4
                dbConn = TurbineDB.getConnection();
                connection = dbConn.getConnection();           

                sections = new TableDataSet (connection, TABLE_NAME, keydef);
a353 1

a362 12
        } 
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
        {
            throw new DBException(e);
        }
        catch (Exception e)
        {
            throw new DBException(e);
a366 5
            try {
                TurbineDB.releaseConnection(dbConn);
            } catch (Exception e) {
                throw new DBException(e);
            }
d368 1
d373 1
a373 1
     * Approves the section in the name of the given userID.
d375 5
a379 2
     * @@param sectionID   The document to approve.
     * @@param userID      The user approving the project.
d381 2
a382 2
     * @@exception DBException if a database error occurs.
     * @@exception DoesNotExist if the section ID is invalid.
d384 3
a386 2
    public void approveSection(String sectionID, String userID)
        throws DBException, DoesNotExist
d388 3
a390 25
        Record sec = null;

        if (sectionID != null)
        {
            sec= getSectionForID(sectionID);
            if (sec == null)
            {
                throw new DoesNotExist("Section with ID " + sectionID);
            } else {
                try
                {
                    setField(sec, APPROVED_BY, userID);
                    sec.save();
                }
                catch (DataSetException e)
                {
                    throw new DBException(e);
                }
                catch (SQLException e)
                {
                    throw new DBException(e);
                }
            }
         } 
      }
d393 1
a393 1
     * Moves the section to the top level of a document.
d395 3
a397 4
     * @@param sectionID   The section to move.
     *
     * @@exception DBException if a database error occurs.
     * @@exception DoesNotExist if the section ID is invalid.
d399 2
a400 2
    public void moveToTop(String sectionID)
        throws DBException, DoesNotExist
d402 2
a403 3
        Record sec = null;
        sec= getSectionForID(sectionID);
        if (sec == null)
d405 6
a410 3
            throw new DoesNotExist("Section ID=" + sectionID);
        } else {
            try
d412 9
a420 12
                setField(sec, PARENT_ID, "0");
                sec.save();
            } 
                catch (SQLException e)
                {
                    throw new DBException(e);
                }
                catch (DataSetException e)
                {
                    throw new DBException(e);
                }
        } 
d423 3
a425 9
    /**
     * Deletes an existing section from the database
     *
     * @@param      sectionID       the ID of the section to delete
     *
     * @@exception DBException
     */
    public void deleteSection (String sectionID)
        throws DBException, DoesNotExist
d427 15
a441 20
        Record sec = null;
        sec= getSectionForID(sectionID);
         
        if (sec == null)
        { 
            throw new DoesNotExist("Section ID= " + sectionID);
        } else {
            try
            {
                sec.markToBeDeleted();
                sec.save();
            }
            catch (DataSetException e)
            {
                throw new DBException(e);
            }
            catch (SQLException e)
            {
                throw new DBException(e);
            }
d443 2
a444 1
    } 
@


1.8
log
@cleanup
@
text
@d71 1
a71 1
 * @@version $Id: ProjectSectionManager.java,v 1.7 2001/01/25 03:18:33 stack Exp $
@


1.7
log
@Fixed semantic error
@
text
@d57 3
d64 1
d71 1
a71 1
 * @@version $Id: ProjectSectionManager.java,v 1.6 2001/01/25 02:53:24 leonardr Exp $
d154 2
a155 2
        Record r = getFirstMatchingRecord(c);
        if (r == null)
d159 1
d210 1
a210 1
        c.add(APPROVED_BY, nobodyID);
d253 1
a253 1
            s = runSelect(tableName, criterion, PROJECT_NAME);
d274 2
a275 2
    public Record addSection (Connection conn, String projectID,
                              String parentID, String name, String descrip, 
d281 1
a281 1
            section = updateSection(conn, null, projectID, parentID, name, 
d330 1
d336 1
a336 1
                sec = getSectionByID(sectionID);
d356 7
a362 1
        } catch (DataSetException e) {
d364 3
a366 1
        } catch (SQLException e) {
d368 3
a370 1
        } finally {
d393 3
a395 2
        Record section = getSectionByID(sectionID);
        try
d397 21
a417 8
            setField(section, APPROVED_BY, userID);
            sc.save();
        } catch (DataSetException e) {
            throw new DBException(e);
        } catch (SQLException e ) {
            throw new DBException(e);
        }
    }
d427 1
a427 1
    public void moveToTop(Connection conn, String sectionID)
d430 3
a432 2
        Record section = getSectionByID(sectionID);
        try
d434 16
a449 7
            setField(section, PARENT_ID, "0");
            sc.save();
        } catch (DataSetException e) {
            throw new DBException(e);
        } catch (SQLException e ) {
            throw new DBException(e);
        }
d460 1
a460 1
        throws DBException
d462 14
a475 11
        Record section = null;
        try {
            section = getSectionByID(sectionID);
        } catch (DoesNotExist ignore) {}

        if (section != null)
        {
            try {
                r.markToBeDeleted();
                r.save();
            } catch (DataSetException e) {
d477 3
a479 1
            } catch (SQLException e) {
d483 1
a483 2

    }
@


1.6
log
@More converted TableManagers.
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.5 2001/01/24 22:24:36 leonardr Exp $
d384 1
a384 1
        } catch (SQLException e e) {
d407 1
a407 1
        } catch (SQLException e e) {
@


1.5
log
@Moved TableManagers to new keydef constructor and keydef-less runSelect.
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.4 2001/01/24 20:42:46 dlr Exp $
d134 4
a140 1
     * @@param    conn    A JDBC database connection
d143 2
a144 1
     * @@exception DBException
d146 2
a147 2
    public Record getSectionForID (Connection conn, String sectionID)
        throws DBException
d149 3
a151 13
        TableDataSet section = null;

        try
        {
            section = new TableDataSet (conn, TABLE_NAME);
            section.where(SECTION_ID + '=' + sectionID);
            section.fetchRecords();
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        finally
d153 1
a153 1
            registerToClose (section);
a154 2

        return section.getRecord(0);
a159 1
     * @@param conn      The JDBC database connection to use.
d163 1
a163 2
     * @@exception DataSetException
     * @@exception SQLException
d165 1
a165 2
    public DataSet getTopLevelSectionsForProject (Connection conn, 
                                                  String projectID)
d168 3
a170 17
        TableDataSet sections = null;
        try
        {
            sections = new TableDataSet(conn, TABLE_NAME);
            sections.where(PROJECT_ID + '=' + projectID);
            sections.where(PARENT_ID + '=' + 0);
            sections.fetchRecords();
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        finally
        {
            registerToClose(sections);
        }
        return sections;
a175 1
     * @@param conn      The JDBC database connection to use.
d179 1
a179 2
     * @@exception DataSetException
     * @@exception SQLException
d181 1
a181 1
    public DataSet getSubsections (Connection conn, String sectionID)
d184 2
a185 16
        TableDataSet subsections = null;
        try
        {
            subsections = new TableDataSet(conn, TABLE_NAME);
            subsections.where(PARENT_ID + '=' + sectionID);
            subsections.fetchRecords();
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        finally
        {
            registerToClose(subsections);
        }
        return subsections;
d189 24
a212 1
     * Approves the section in the name of the given userID.
d214 1
a214 3
     * @@param conn         The JDBC database connection to use.
     * @@param sectionID   The document to approve.
     * @@param userID      The user approving the project.
d216 2
a217 2
     * @@exception SQLException
     * @@exception DataSetException 
d219 1
a219 2
    public void approveSection(Connection conn, String sectionID, 
                               String userID)
d222 4
a225 7
        Record sc = null;
        TableDataSet sections = null;

        try
        {
            sections = new TableDataSet(conn, TABLE_NAME, keydef);
            if (sectionID != null)
d227 1
a227 3
                sections.where(SECTION_ID + '=' + sectionID);
                sections.fetchRecords();
                sc = sections.getRecord(0);
d229 1
a229 6
            setField(sc, APPROVED_BY, userID);
            sc.save();

        }
        catch (DataSetException e)
        {
d232 2
a233 4
        finally
        {
            registerToClose(sections);
        }
d237 1
a237 1
     * Approves the section in the name of the given userID.
d239 1
a239 3
     * @@param conn         The JDBC database connection to use.
     * @@param sectionID   The document to approve.
     * @@param userID      The user approving the project.
d241 1
a241 2
     * @@exception SQLException
     * @@exception DataSetException 
d243 1
a243 1
    public void moveToTop(Connection conn, String sectionID)
d246 4
a249 19
        Record sc = null;
        TableDataSet sections = null;

        try
        {
            sections = new TableDataSet(conn, TABLE_NAME, keydef);
            if (sectionID != null)
            {
                sections.where(SECTION_ID + '=' + sectionID);
                sections.fetchRecords();
                sc = sections.getRecord(0);
                  log.info("dataMgr" + sc);
            }
            setField(sc, PARENT_ID, "0");
            sc.save();

        }
        catch (DataSetException e)
        {
d252 1
a252 4
        finally
        {
            registerToClose(sections);
        }
d255 4
d274 24
a297 2
        return updateSection(conn, null, projectID, parentID, name, 
                              descrip, suggestedBy, approvedBy);
d315 5
a319 5
    private Record updateSection (Connection conn, String sectionID, 
                                  String projectID, String parentID,
                                  String name,  String descrip, 
                                  String suggestedBy, String approvedBy)
        throws DBException
d321 2
a323 1

a326 1
            sections = new TableDataSet(conn, TABLE_NAME, keydef);
d330 2
a331 6
                sections.where(SECTION_ID + '=' + sectionID);
                sections.fetchRecords();
                sec = sections.getRecord(0);
            }
            else
            {
d333 4
d340 1
d350 11
d362 17
a378 1
        catch (DataSetException e)
d380 5
a386 6
        finally
        {
            registerToClose(sections);
        }

        return sec;
d390 1
a390 1
     * Updates the specified section.
d392 1
a392 5
     * @@param conn        The JDBC database connection to use.
     * @@param sectionID  The database key of the section to update, or
     *                    <code>null</code> if the section is new.
     * @@param descrip     The section's description.
     * @@param approvedBy  The database key of the approving user.
d394 2
a395 1
     * @@exception DBException
d397 2
a398 3
    public void editSection (Connection conn, String sectionID, 
                             String parentID, String name, String descrip)
        throws DBException
d400 10
a409 2
        updateSection(conn, sectionID, null, parentID, name, descrip,
                       null, null);
a414 1
     * @@param      conn the JDBC database connection
d419 1
a419 1
    public void deleteSection (Connection conn, String sectionID)
d422 6
a427 2
        TableDataSet sections = null;
        try
d429 1
a429 7
            
            sections = new TableDataSet (conn, TABLE_NAME, keydef);
            sections.where (SECTION_ID + '=' + sectionID);
            sections.fetchRecords();
            if (sections.containsRecord(0)) 
            {
                Record r = sections.getRecord(0);
d432 4
a437 9
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        finally
        {
            registerToClose(sections);
        }
    }
a438 25
    public DataSet getUnapprovedSectionsForProject (Connection conn, 
                                                    String projectID)
        throws DBException
    {
        TableDataSet sections = null;
        try
        {
            sections = new TableDataSet(conn, TABLE_NAME);
            sections.where(PROJECT_ID + '=' + projectID);
            UserUserGroupManager usrGrpMgr = 
               (UserUserGroupManager)getDataManager().getManager
               ("org.tigris.helm.database.UserUserGroupManager");
            String nobodyID = usrGrpMgr.getNobodyUserID(conn);
            sections.where(APPROVED_BY + '=' + nobodyID);
            sections.fetchRecords();
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        finally
        {
            registerToClose(sections);
        }
        return sections;
@


1.4
log
@Making use of DBException.
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.3 2001/01/23 02:29:40 elicia Exp $
d131 1
a131 1
        super (dataMgr);
d248 1
a248 2
            sections = new TableDataSet(conn, TABLE_NAME,
                                         new KeyDef().addAttrib(SECTION_ID));
d287 1
a287 2
            sections = new TableDataSet(conn, TABLE_NAME,
                                        new KeyDef().addAttrib(SECTION_ID));
d354 1
a354 2
            sections = new TableDataSet(conn, TABLE_NAME,
                                         new KeyDef().addAttrib(SECTION_ID));
d424 1
a424 2
            sections = new TableDataSet (conn, TABLE_NAME,
                                          new KeyDef().addAttrib(SECTION_ID));
@


1.3
log
@added moveToTop method to move sections up a level
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.2 2001/01/17 18:27:00 elicia Exp $
d139 2
a140 2
     * @@exception    SQLException
     * @@exception    DataSetException
d143 1
a143 1
        throws SQLException, DataSetException
d153 4
d177 1
a177 1
        throws SQLException, DataSetException
d187 4
d209 1
a209 1
        throws SQLException, DataSetException
d218 4
d241 1
a241 2
        throws SQLException, DataSetException, JoistDatabaseException,
               UpdateException              
d260 4
d281 1
a281 2
        throws SQLException, DataSetException, JoistDatabaseException,
               UpdateException              
d301 4
d324 1
a324 1
        throws SQLException, DataSetException
d343 1
a343 2
     * @@exception SQLException
     * @@exception DataSetException
d349 1
a349 1
        throws SQLException, DataSetException
d381 4
d402 1
a402 2
     * @@exception SQLException
     * @@exception DataSetException
d406 1
a406 1
        throws SQLException, DataSetException
d417 2
a418 1
     * @@exception SQLException
d421 1
a421 1
        throws SQLException, DataSetException
d438 4
d450 1
a450 1
        throws SQLException, DataSetException, JoistDatabaseException
d463 4
@


1.2
log
@added getUnapprovedSectionsForProject method
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.1 2000/12/30 05:04:53 elicia Exp $
d246 38
@


1.2.2.1
log
@moved changed from HEAD for ProjectDocuments and ProjectDownloads
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.10 2001/01/26 18:29:00 edk Exp $
a245 38
            sc.save();

        }
        finally
        {
            registerToClose(sections);
        }
    }

    /**
     * Approves the section in the name of the given userID.
     *
     * @@param conn         The JDBC database connection to use.
     * @@param sectionID   The document to approve.
     * @@param userID      The user approving the project.
     *
     * @@exception SQLException
     * @@exception DataSetException 
     */
    public void moveToTop(Connection conn, String sectionID)
        throws SQLException, DataSetException, JoistDatabaseException,
               UpdateException              
    {
        Record sc = null;
        TableDataSet sections = null;

        try
        {
            sections = new TableDataSet(conn, TABLE_NAME,
                                        new KeyDef().addAttrib(SECTION_ID));
            if (sectionID != null)
            {
                sections.where(SECTION_ID + '=' + sectionID);
                sections.fetchRecords();
                sc = sections.getRecord(0);
                  log.info("dataMgr" + sc);
            }
            setField(sc, PARENT_ID, "0");
@


1.1
log
@initial revision
@
text
@d67 1
a67 1
 * @@version $Id: ProjectSectionManager.java,v 1.21 2000/12/12 23:03:48 dlr Exp $
d87 1
a87 1
    public static final String SECTION_PROJECT_ID = "PROJECT_ID";
d179 1
a179 1
            sections.where(SECTION_PROJECT_ID + '=' + projectID);
d221 1
a221 1
     * @@param sectionID   The section to approve.
d227 2
a228 1
    public void approveSection(Connection conn, String sectionID, String userID)
d232 21
a252 3
        Record section = getSectionForID(conn, sectionID);
        section.setValue(APPROVED_BY, userID);
        section.save();
d316 1
a316 1
            setField(sec, SECTION_PROJECT_ID, projectID);
d383 23
@

