head	1.7;
access;
symbols
	TIGRIS_0_9_2_4:1.1.1.1
	TIGRIS_0_9_2_3:1.1.1.1
	HELM_PEER_PORT_BRANCH:1.6.0.2
	TURBINE_PEER:1.6
	TIGRIS_0_9_2_1:1.6
	TIGRIS_0_9_2:1.1.1.1.0.6
	TIGRIS_0_9_0:1.1.1.1.0.4
	TIGRIS_0_8_4:1.1.1.1.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.7
date	2001.02.21.03.23.56;	author edk;	state dead;
branches;
next	1.6;

1.6
date	2001.01.26.18.29.00;	author edk;	state Exp;
branches
	1.6.2.1;
next	1.5;

1.5
date	2001.01.26.05.24.05;	author edk;	state dead;
branches;
next	1.4;

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

1.3
date	2001.01.24.21.41.48;	author leonardr;	state Exp;
branches;
next	1.2;

1.2
date	2001.01.24.20.42.46;	author dlr;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.12.21.14.54;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.12.21.14.54;	author dlr;	state Exp;
branches;
next	;

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


desc
@@


1.7
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.sql.*;

import com.workingdogs.village.*;

import org.joist.database.TableManager;
import org.joist.database.DataManager;

import org.webmacro.util.*;

/**
 * This class performs associations between "base" versions of
 * database records and "composite" versions of those same records (a
 * boolean field in the table schema distringuishes between base and
 * composites). To use this class for a particular table, subclass it
 * and override its String properties.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: CompositeManager.java,v 1.6 2001/01/26 18:29:00 edk Exp $
 */

abstract public class CompositeManager extends TableManager
{
    private static Log log = new Log("cmpstMgr", "CompositeManager");

    /**
     * The base unit field name in the join table.
     */
    protected String joinBaseField;

    /**
     * The composite field name in the join table.
     */
    protected String joinCompositeField;

    /**
     * The table name of the base unit that the composite is made up of.
     */
    protected String unitTable;

    /**
     * The join table that links many base units to a single composite.
     */
    protected String joinTable;

    /**
     * The field in the base table whose values indicate whether the record is 
     * a composite or base unit.
     */
    protected String typeField;

    /**
     * The values for the <code>typeField</code> which indicate that the 
     * record is a base unit.
     */
    protected String[] baseValues;

    /**
     * The values for the <code>typeField</code> which indicate that the 
     * record is a composite.
     */
    protected String[] compositeValues;

    /** 
     * Creates a new instance.
     */
    protected CompositeManager(DataManager dataMgr, String joinBaseField, 
                               String joinCompositeField, String unitTable, 
                               String joinTable, String typeField, 
                               String[] baseValues, String[] compositeValues)
    {
        super(dataMgr);

        this.joinBaseField = joinBaseField;
        this.joinCompositeField = joinCompositeField;
        this.unitTable = unitTable;
        this.joinTable = joinTable;
        this.typeField = typeField;
    }
    
    public String getJoinCompositeField()
    {
        return joinCompositeField;
    }

    /**
     * Retrieve a list of composites.
     *
     * @@param connection A database connection
     * @@return a Dataset containing all the composite members of the unitTable.
     */
    public DataSet getComposites(Connection connection)
        throws SQLException, DataSetException
    {
        TableDataSet composites = null;
        try
        {
            composites = new TableDataSet(connection, unitTable);
            composites.where(getTypeClause(false));
            composites.fetchRecords();
        }
        finally
        {
            registerToClose(composites);
        }
        return composites;
    }

    /**
     * Retrieve a list of bases.
     *
     * @@param conn A database connection
     * @@return     All the base members of the <code>unitTable</code>.
     */
    public DataSet getBases(Connection conn)
        throws SQLException, DataSetException
    {
        TableDataSet bases = null;
        try
        {
            bases = new TableDataSet(conn, unitTable);
            bases.where(getTypeClause(true));
            bases.fetchRecords();
        }
        finally
        {
            registerToClose(bases);
        }
        return bases;
    }

    /**
     * Retrieve a list of composites for a base.
     *
     * @@param connection A database connection
     * @@return a Dataset containing all the composites in which the
     *         base takes part.  
     */
    public TableDataSet getCompositesForBase(Connection connection, 
                                             String baseID)
        throws SQLException, DataSetException 
    {
        TableDataSet composites = null;
        try
        {
            KeyDef kd = new KeyDef().addAttrib(joinBaseField)
                .addAttrib(joinCompositeField);
            composites = new TableDataSet(connection, joinTable, kd);
            composites.where(joinBaseField + "=" + baseID);
            composites.fetchRecords();
        }
        finally
        {
            registerToClose(composites);
        }
        return composites;
    }

    /**
     * Retrieve a list of bases for a composite.
     *
     * @@param connection A database connection
     * @@return a Dataset containing all the bases which take part in
     *         the composite.
     */
    public TableDataSet getBasesForComposite(Connection connection, 
                                             String compositeID)
        throws SQLException, DataSetException 
    {
        TableDataSet bases = null;
        try
        {
            KeyDef kd = new KeyDef().addAttrib(joinBaseField)
                .addAttrib(joinCompositeField);
            bases = new TableDataSet(connection, joinTable, kd);
            bases.where(joinCompositeField + "=" + compositeID);
            bases.fetchRecords();
        }
        finally
        {
            registerToClose(bases);
        }
        return bases;
    }

    /**
     * Associate a base with a composite. Does not yet check to make
     * sure the composite is indeed composite. Should there be a
     * special exception for this?
     *
     * @@param connection A database connection
     * @@param baseID The base ID to add to the composite
     * @@param compositeID The composite ID to add to.
     *
     * @@exception SQLException if there is a database error
     * @@exception DataSetException if something goes wrong with the DataSet.
     */
    public void addBaseToComposite(Connection connection, String baseID, 
                                   String compositeID)
        throws SQLException, DataSetException
    {
        TableDataSet tds = null;
        try
        {
            KeyDef kd = new KeyDef().addAttrib(joinBaseField)
                .addAttrib(joinCompositeField);
            tds = new TableDataSet(connection, joinTable);
            StringBuffer buf = new StringBuffer();
            buf.append(joinBaseField).append('=').append(baseID)
                .append(" AND ").append(joinCompositeField).append('=')
                .append(compositeID);
            tds.where(buf.toString());
            if (!tds.fetchRecords().containsRecord(0)) {
                Record r = tds.addRecord();
                r.setValue(joinBaseField,baseID);
                r.setValue(joinCompositeField,compositeID);
                r.save();
            }
        }
        finally
        {
            if (tds != null) tds.close();
        }
    }

    /**
     * Disassociate a base from a composite.
     *
     * @@param connection A database connection
     * @@param baseID The base ID to remove from the composite
     * @@param compositeID The composite ID from which to remove the base
     *
     * @@exception SQLException if there is a database error
     * @@exception DataSetException if something goes wrong with the DataSet.
     */
    public void removeBaseFromComposite(Connection connection, String baseID, 
                                        String compositeID)
        throws SQLException, DataSetException
    {
        TableDataSet tds = null;
        try
        {
            KeyDef kd = new KeyDef().addAttrib(joinBaseField)
                .addAttrib(joinCompositeField);    
            tds = new TableDataSet(connection, joinTable, kd);
            tds.where(joinBaseField + '=' + baseID + " AND " + 
                      joinCompositeField + '=' + compositeID);
            DataSet d = tds.fetchRecords();
            if (d.containsRecord(0)) {
                Record r = d.getRecord(0);
                r.markToBeDeleted();
                r.save();
            }
        }
        finally
        {
            if (tds != null) tds.close();
        }
    }

    /**
     * Disassociate a base from all composites in which it takes part.
     *
     * @@param connection A database connection
     * @@param baseID The base ID to remove from all composites.
     *
     * @@exception SQLException if there is a database error
     * @@exception DataSetException if something goes wrong with the DataSet.
     */
    public void removeBaseFromComposites(Connection connection, String baseID)
        throws SQLException, DataSetException
    {
        TableDataSet tds = getCompositesForBase(connection, baseID);
        for (int i = 0; i < tds.size(); i++)
        {
            Record r = tds.getRecord(i);
            r.markToBeDeleted();
            r.save();
        }
    }

    /**
     * Generates a <code>where</code> clause for <code>typeField</code>.
     */
    private String getTypeClause (boolean isForBase)
    {
        StringBuffer buf = new StringBuffer();
        String[] values = (isForBase ? baseValues : compositeValues);

        if (values.length > 0)
        {
            buf.append(typeField);
            if (values.length == 1)
            {
                buf.append('=').append(escapeAndQuoteSQL(values[0]));
            }
            else
            {
                buf.append(" in (").append(escapeAndQuoteSQL(values[0]));
                for (int i = 1; i < values.length; i++)
                {
                    buf.append(", ").append(escapeAndQuoteSQL(values[i]));
                }
                buf.append(')');
            }
        }
        return buf.toString();
    }
}
@


1.6
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d68 1
a68 1
 * @@version $Id: CompositeManager.java,v 1.1 2000/11/12 21:14:54 dlr Exp $
@


1.6.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d68 1
a68 1
 * @@version $Id: CompositeManager.java,v 1.6 2001/01/26 18:29:00 edk Exp $
@


1.5
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
@a55 1
import org.joist.database.Criterion;
a58 2
import org.tigris.helm.database.DBException;

d68 1
a68 1
 * @@version $Id: CompositeManager.java,v 1.4 2001/01/24 22:24:36 leonardr Exp $
d121 1
a121 2
        super(dataMgr, new KeyDef().addAttrib(joinBaseField)
            .addAttrib(joinCompositeField));
d136 1
a136 1
     * Retrieve a list of mappings of a specified base to its composites.
d138 2
a139 4
     * @@param compositeID
     * @@return a Dataset containing all the bases which take part in
     *         the composite.
     * @@exception DBException if a database error occurs.
d141 2
a142 2
    public DataSet getCompositesForBase(String baseID)
        throws DBException 
d144 12
a155 2
        Criterion c = new Criterion(joinBaseField, baseID);
        return getMappings(c);
d159 1
a159 1
     * Retrieve a list of mappings of bases to a specified composite.
d161 2
a162 4
     * @@param compositeID
     * @@return a Dataset containing all the bases which take part in
     *         the composite.
     * @@exception DBException if a database error occurs.
d164 2
a165 2
    public DataSet getBasesForComposite(String compositeID)
        throws DBException 
d167 12
a178 2
        Criterion c = new Criterion(joinCompositeField, compositeID);
        return getMappings(c);
d182 1
a182 1
     * Retrieve a list of base-composite mappings which match a Criterion.
d184 7
a190 6
     * @@param criterion A Criterion describing the match.
     * @@return a Dataset containing all the mappings matching the Criterion
     * @@throws DBException if a database error occurs.
     */
    public DataSet getMappings(Criterion criterion)
        throws DBException 
d192 8
a199 5
        DataSet s = null;
        try {
            s = runSelect(joinTable, criterion);
        } catch (Exception e) {
            throw new DBException(e);
d201 5
a205 1
        return s;
d209 5
a213 3
     * Generates a <code>where</code> clause for <code>typeField</code>.
     * <p>
     * NOTE: This may go away now.
d215 3
a217 1
    private String getTypeClause (boolean isForBase)
d219 10
a228 4
        StringBuffer buf = new StringBuffer();
        String[] values = (isForBase ? baseValues : compositeValues);

        if (values.length > 0)
d230 1
a230 14
            buf.append(typeField);
            if (values.length == 1)
            {
                buf.append('=').append(escapeAndQuoteSQL(values[0]));
            }
            else
            {
                buf.append(" in (").append(escapeAndQuoteSQL(values[0]));
                for (int i = 1; i < values.length; i++)
                {
                    buf.append(", ").append(escapeAndQuoteSQL(values[i]));
                }
                buf.append(')');
            }
d232 1
a232 1
        return buf.toString();
a234 4
    ////////////////////////////////////////////////////////////////
    // Mutator methods.
    ////////////////////////////////////////////////////////////////

d236 3
a238 3
     * Associate a base with a composite. <b>TODO:</b> Does not yet
     * check to make sure the composite is indeed composite. Should
     * there be a special exception for this?
d240 1
d244 2
a245 1
     * @@exception DBException if a database error occurs.  
d247 3
a249 2
    public void addBaseToComposite(String baseID, String compositeID)
        throws DBException
d251 2
a252 4
        Criterion c = new Criterion(joinBaseField, baseID);
        c.and(new Criterion(joinCompositeField, compositeID));
        DataSet mappings = getMappings(c);
        if (!mappings.containsRecord(0))
d254 10
a263 2
            try {
                Record r = mappings.addRecord();
a266 4
            } catch (SQLException e) {
                throw new DBException(e);
            } catch (DataSetException e) {
                throw new DBException(e);
d269 4
d278 1
d282 2
a283 1
     * @@exception DBException if a database error occurs.  
d285 3
a287 2
    public void removeBaseFromComposite(String baseID, String compositeID)
        throws DBException
d289 2
a290 4
        Criterion c = new Criterion(joinBaseField, baseID);
        c.and(new Criterion(joinCompositeField, compositeID));
        DataSet mappings = getMappings(c);
        if (mappings.containsRecord(0))
d292 8
a299 2
            try {
                Record r = mappings.getRecord(0);
a301 4
            } catch (SQLException e) {
                throw new DBException(e);
            } catch (DataSetException e) {
                throw new DBException(e);
d304 4
d313 1
d316 17
a332 1
     * @@exception DBException if a database error occurs.  
d334 1
a334 2
    public void removeBaseFromComposites(String baseID)
        throws DBException
d336 7
a342 3
        DataSet d = getCompositesForBase(baseID);
        try {
            for (int i = 0; i < d.size(); i++)
d344 10
a353 3
                Record r = d.getRecord(i);
                r.markToBeDeleted();
                r.save();
d355 2
a356 5
        } catch (SQLException e) {
            throw new DBException(e);
        } catch (DataSetException e) {
            throw new DBException(e);
        }        
@


1.4
log
@Moved TableManagers to new keydef constructor and keydef-less runSelect.
@
text
@d71 1
a71 1
 * @@version $Id: CompositeManager.java,v 1.3 2001/01/24 21:41:48 leonardr Exp $
@


1.3
log
@Ported UserManager and RoleManager to Helm. Started moving other TableManagers toward a grab-connection-on-demand model. Massive breakage ensues. dlr and I are working on it.
@
text
@d71 1
a71 1
 * @@version $Id: CompositeManager.java,v 1.2 2001/01/24 20:42:46 dlr Exp $
a115 9
    /**
     * Returns a KeyDef object appropriate for this table.
     */
    private KeyDef keydef()
    {
        return new KeyDef().addAttrib(joinBaseField)
            .addAttrib(joinCompositeField);
    }

d124 2
a125 1
        super(dataMgr);
d181 1
a181 1
            s = runSelect(joinTable, keydef(), criterion);
@


1.2
log
@Making use of DBException.
@
text
@d56 1
d60 2
d71 1
a71 1
 * @@version $Id: CompositeManager.java,v 1.1.1.1 2000/11/12 21:14:54 dlr Exp $
d116 9
d148 1
a148 1
     * Retrieve a list of composites.
d150 4
a153 2
     * @@param connection A database connection
     * @@return a Dataset containing all the composite members of the unitTable.
d155 2
a156 2
    public DataSet getComposites(Connection connection)
        throws DBException
d158 2
a159 20
        TableDataSet composites = null;
        try
        {
            composites = new TableDataSet(connection, unitTable);
            composites.where(getTypeClause(false));
            composites.fetchRecords();
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
        {
            throw new DBException(e);
        }
        finally
        {
            registerToClose(composites);
        }
        return composites;
d163 1
a163 1
     * Retrieve a list of bases.
d165 4
a168 2
     * @@param conn A database connection
     * @@return     All the base members of the <code>unitTable</code>.
d170 2
a171 2
    public DataSet getBases(Connection conn)
        throws DBException
d173 2
a174 20
        TableDataSet bases = null;
        try
        {
            bases = new TableDataSet(conn, unitTable);
            bases.where(getTypeClause(true));
            bases.fetchRecords();
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
        {
            throw new DBException(e);
        }
        finally
        {
            registerToClose(bases);
        }
        return bases;
d178 1
a178 1
     * Retrieve a list of composites for a base.
d180 3
a182 3
     * @@param connection A database connection
     * @@return a Dataset containing all the composites in which the
     *         base takes part.  
d184 2
a185 3
    public TableDataSet getCompositesForBase(Connection connection, 
                                             String baseID)
        throws DBException
d187 4
a190 11
        TableDataSet composites = null;
        try
        {
            KeyDef kd = new KeyDef().addAttrib(joinBaseField)
                .addAttrib(joinCompositeField);
            composites = new TableDataSet(connection, joinTable, kd);
            composites.where(joinBaseField + "=" + baseID);
            composites.fetchRecords();
        }
        catch (DataSetException e)
        {
d193 1
a193 9
        catch (SQLException e)
        {
            throw new DBException(e);
        }
        finally
        {
            registerToClose(composites);
        }
        return composites;
d197 3
a199 5
     * Retrieve a list of bases for a composite.
     *
     * @@param connection A database connection
     * @@return a Dataset containing all the bases which take part in
     *         the composite.
d201 1
a201 3
    public TableDataSet getBasesForComposite(Connection connection, 
                                             String compositeID)
        throws DBException
d203 4
a206 2
        TableDataSet bases = null;
        try
d208 14
a221 5
            KeyDef kd = new KeyDef().addAttrib(joinBaseField)
                .addAttrib(joinCompositeField);
            bases = new TableDataSet(connection, joinTable, kd);
            bases.where(joinCompositeField + "=" + compositeID);
            bases.fetchRecords();
d223 1
a223 13
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
        {
            throw new DBException(e);
        }
        finally
        {
            registerToClose(bases);
        }
        return bases;
d226 4
d231 3
a233 3
     * Associate a base with a composite. Does not yet check to make
     * sure the composite is indeed composite. Should there be a
     * special exception for this?
a234 1
     * @@param connection A database connection
d238 1
a238 1
     * @@exception DBException
d240 1
a240 2
    public void addBaseToComposite(Connection connection, String baseID, 
                                   String compositeID)
d243 4
a246 2
        TableDataSet tds = null;
        try
d248 2
a249 10
            KeyDef kd = new KeyDef().addAttrib(joinBaseField)
                .addAttrib(joinCompositeField);
            tds = new TableDataSet(connection, joinTable);
            StringBuffer buf = new StringBuffer();
            buf.append(joinBaseField).append('=').append(baseID)
                .append(" AND ").append(joinCompositeField).append('=')
                .append(compositeID);
            tds.where(buf.toString());
            if (!tds.fetchRecords().containsRecord(0)) {
                Record r = tds.addRecord();
d253 4
a256 26
            }
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
        {
            throw new DBException(e);
        }
        finally
        {
            if (tds != null)
            {
                try
                {
                    tds.close();
                }
                catch (DataSetException e)
                {
                    throw new DBException(e);
                }
                catch (SQLException e)
                {
                    throw new DBException(e);
                }
a263 1
     * @@param connection A database connection
d267 1
a267 1
     * @@exception DBException
d269 1
a269 2
    public void removeBaseFromComposite(Connection connection, String baseID, 
                                        String compositeID)
d272 4
a275 2
        TableDataSet tds = null;
        try
d277 2
a278 8
            KeyDef kd = new KeyDef().addAttrib(joinBaseField)
                .addAttrib(joinCompositeField);    
            tds = new TableDataSet(connection, joinTable, kd);
            tds.where(joinBaseField + '=' + baseID + " AND " + 
                      joinCompositeField + '=' + compositeID);
            DataSet d = tds.fetchRecords();
            if (d.containsRecord(0)) {
                Record r = d.getRecord(0);
d281 4
a284 26
            }
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
        {
            throw new DBException(e);
        }
        finally
        {
            if (tds != null)
            {
                try
                {
                    tds.close();
                }
                catch (DataSetException e)
                {
                    throw new DBException(e);
                }
                catch (SQLException e)
                {
                    throw new DBException(e);
                }
a291 1
     * @@param connection A database connection
d294 1
a294 1
     * @@exception DBException
d296 1
a296 1
    public void removeBaseFromComposites(Connection connection, String baseID)
d299 3
a301 4
        TableDataSet tds = getCompositesForBase(connection, baseID);
        try
        {
            for (int i = 0; i < tds.size(); i++)
d303 1
a303 1
                Record r = tds.getRecord(i);
d307 1
a307 3
        }
        catch (DataSetException e)
        {
d309 1
a309 3
        }
        catch (SQLException e)
        {
d311 1
a311 29
        }
    }

    /**
     * Generates a <code>where</code> clause for <code>typeField</code>.
     */
    private String getTypeClause (boolean isForBase)
    {
        StringBuffer buf = new StringBuffer();
        String[] values = (isForBase ? baseValues : compositeValues);

        if (values.length > 0)
        {
            buf.append(typeField);
            if (values.length == 1)
            {
                buf.append('=').append(escapeAndQuoteSQL(values[0]));
            }
            else
            {
                buf.append(" in (").append(escapeAndQuoteSQL(values[0]));
                for (int i = 1; i < values.length; i++)
                {
                    buf.append(", ").append(escapeAndQuoteSQL(values[i]));
                }
                buf.append(')');
            }
        }
        return buf.toString();
@


1.1
log
@Initial revision
@
text
@d68 1
a68 1
 * @@version $Id: CompositeManager.java,v 1.14 2000/11/11 08:04:35 edk Exp $
d142 1
a142 1
        throws SQLException, DataSetException
d151 8
d173 1
a173 1
        throws SQLException, DataSetException
d182 8
d206 1
a206 1
        throws SQLException, DataSetException 
d217 8
d241 1
a241 1
        throws SQLException, DataSetException 
d252 8
d276 1
a276 2
     * @@exception SQLException if there is a database error
     * @@exception DataSetException if something goes wrong with the DataSet.
d280 1
a280 1
        throws SQLException, DataSetException
d300 8
d310 15
a324 1
            if (tds != null) tds.close();
d335 1
a335 2
     * @@exception SQLException if there is a database error
     * @@exception DataSetException if something goes wrong with the DataSet.
d339 1
a339 1
        throws SQLException, DataSetException
d356 8
d366 15
a380 1
            if (tds != null) tds.close();
d390 1
a390 2
     * @@exception SQLException if there is a database error
     * @@exception DataSetException if something goes wrong with the DataSet.
d393 1
a393 1
        throws SQLException, DataSetException
d396 14
a409 1
        for (int i = 0; i < tds.size(); i++)
d411 1
a411 3
            Record r = tds.getRecord(i);
            r.markToBeDeleted();
            r.save();
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@@
