head	1.9;
access;
symbols
	TIGRIS_1_1_0RC2:1.2.6.1
	TIGRIS_1_1_0RC1:1.2.6.1
	TIGRIS_1_1:1.2.6.1.0.2
	TIGRIS_1_0_8:1.2.6.1
	TIGRIS_1_0_8RC3:1.2.6.1
	TIGRIS_1_0_8RC2:1.2.6.1
	TIGRIS_1_0_8RC1:1.2.6.1
	TIGRIS_1_0_7:1.2.6.1
	TIGRIS_1_0_7RC3:1.2.6.1
	TIGRIS_1_0_7RC2:1.2.6.1
	TIGRIS_1_0_7RC1:1.2.6.1
	TIGRIS_1_0_6:1.2.6.1
	TIGRIS_1_0_6RC5:1.2.6.1
	TIGRIS_1_0_6RC4:1.2.6.1
	TIGRIS_1_0_6RC3:1.2.6.1
	TIGRIS_1_0_6RC2:1.2.6.1
	TIGRIS_1_0_6RC1:1.2.6.1
	TIGRIS_1_0_5:1.2.6.1
	TIGRIS_1_0_5RC6:1.2.6.1
	TIGRIS_1_0_5RC5:1.2.6.1
	TIGRIS_1_0_5RC4:1.2.6.1
	TIGRIS_1_0_5RC3:1.2.6.1
	TIGRIS_1_0_5RC2:1.2.6.1
	TIGRIS_1_0_5RC1:1.2.6.1
	TIGRIS_1_0_4:1.2.6.1
	TIGRIS_1_0_3:1.2.6.1
	TIGRIS_1_0_2:1.2.6.1
	TIGRIS_1_0_1:1.2
	TIGRIS_1_0:1.2.0.6
	TIGRIS_1_0_0:1.2
	TIGRIS_1_0_0_RC1:1.2.0.2;
locks; strict;
comment	@# @;


1.9
date	2001.06.13.21.33.57;	author elicia;	state dead;
branches;
next	1.8;

1.8
date	2001.04.24.18.28.27;	author dlr;	state Exp;
branches;
next	1.7;

1.7
date	2001.04.24.03.48.48;	author dlr;	state Exp;
branches;
next	1.6;

1.6
date	2001.04.24.03.23.13;	author dlr;	state Exp;
branches;
next	1.5;

1.5
date	2001.04.24.03.22.51;	author dlr;	state Exp;
branches;
next	1.4;

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

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

1.2
date	2001.03.07.01.53.22;	author lucas;	state Exp;
branches
	1.2.6.1;
next	1.1;

1.1
date	2001.03.07.01.13.15;	author lucas;	state Exp;
branches;
next	;

1.2.6.1
date	2001.04.24.20.32.59;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.9
log
@removed - replaced by ProjectDocuments
@
text
@/* ================================================================
 * Copyright (c) 2000-2001 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.om;

import java.util.HashMap;
import java.util.Map;

import org.apache.turbine.util.db.Criteria;
import org.apache.turbine.om.SimpleKey;
import org.apache.turbine.om.NumberKey;

import org.tigris.helm.tool.FileArtifactTool;

/**
 * Extension of generated Peer BaseProjectdownloadPeer.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 */
public class ProjectDownloadPeer extends BaseProjectDownloadPeer
{
    //
    // Special data structures and methods for paginating lists of downloads.
    //     

    public static Map filterableFields = new HashMap();
    
    /**
     * How objects of this type should be ordered in lists.
     */
    public static final String DEFAULT_ORDER_BY = UPLOADED_DATE;

    /**
     * Static initializer; initializes the filterableFields data structure.
     */
    static
    { 
        filterableFields.put("File Name", ProjectDownloadPeer.FILE_NAME);
        filterableFields.put("Description", ProjectDownloadPeer.DESCRIPTION);
        filterableFields.put("Proposed by", ProjectDownloadPeer.PROPOSED_BY);
    }

    /**
     * @@param id The database key of the role.
     */
    public static ProjectDownload getInstance(String id)
        throws Exception
    {
        return retrieveByPK(new NumberKey(id));
    }

    /**
     * Returns the corresponding file artifact, or <code>null</code> iff
     * one couldn't be found.
     *
     * @@param project The project to look for the file in.
     * @@param proposing The user proposing the artifact.
     * @@param fileName  The file whose attributes to match.
     */
    public static ProjectDownload getInstanceByFileName(Project project,
                                                        User proposing,
                                                        String fileName)
        throws Exception
    {
        if (project != null && proposing != null && fileName != null)
        {
            Criteria c = new Criteria()
                .add(PROJECT_ID, project.getProjectId())
                .add(PROPOSED_BY, proposing.getUserId())
                .add(FILE_NAME, fileName);
            return (ProjectDownload) FileArtifactTool
                .getFileArtifact("ProjectDownloadPeer.getInstanceByFile",
                                 fileName, doSelect(c));
        }
        else
        {
            // All inputs are required to find a unique record.
            return null;
        }
    }
}
@


1.8
log
@All inputs are required to find a unique record.
@
text
@@


1.7
log
@Check project, user, and file name for maximum accuracy.
@
text
@d109 15
a123 7
        Criteria c = new Criteria()
            .add(PROJECT_ID, project.getProjectId())
            .add(PROPOSED_BY, proposing.getUserId())
            .add(FILE_NAME, fileName);
        return (ProjectDownload) FileArtifactTool
            .getFileArtifact("ProjectDownloadPeer.getInstanceByFile",
                             fileName, doSelect(c));
@


1.6
log
@Added self to author's list.
@
text
@d49 2
a50 2
import java.io.File;
import java.util.*;
d101 2
a102 1
     * @@param file    The file whose attributes to match.
d104 3
a106 1
    public static ProjectDownload getInstanceByFile(Project project, File file)
d111 2
a112 2
            .add(LOCATION, FileArtifactTool.extractLocation(file))
            .add(FILE_NAME, file.getName());
d115 1
a115 2
                             file.getName(),
                             doSelect(c));
@


1.5
log
@Removed import of classes from the same package that this class lives
in.
@
text
@d62 1
@


1.4
log
@Added getInstanceByFile(Project, File) class method.
@
text
@a55 1
import org.tigris.helm.om.*;
@


1.3
log
@changed equality test for requiredViewPermission method
@
text
@d49 1
d52 1
d57 1
d85 1
a85 1
    };
d96 19
@


1.2
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d49 2
d63 21
@


1.2.6.1
log
@Added getInstanceByFileName implementations to minimize servlet code and perform a search with the database instead of with Java code (use the right tool).
@
text
@a48 4
import java.util.HashMap;
import java.util.Map;

import org.apache.turbine.util.db.Criteria;
d52 1
a52 1
import org.tigris.helm.tool.FileArtifactTool;
a57 1
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
a60 21
    //
    // Special data structures and methods for paginating lists of downloads.
    //     

    public static Map filterableFields = new HashMap();
    
    /**
     * How objects of this type should be ordered in lists.
     */
    public static final String DEFAULT_ORDER_BY = UPLOADED_DATE;

    /**
     * Static initializer; initializes the filterableFields data structure.
     */
    static
    { 
        filterableFields.put("File Name", ProjectDownloadPeer.FILE_NAME);
        filterableFields.put("Description", ProjectDownloadPeer.DESCRIPTION);
        filterableFields.put("Proposed by", ProjectDownloadPeer.PROPOSED_BY);
    }

a69 29
    /**
     * Returns the corresponding file artifact, or <code>null</code> iff
     * one couldn't be found.
     *
     * @@param project The project to look for the file in.
     * @@param proposing The user proposing the artifact.
     * @@param fileName  The file whose attributes to match.
     */
    public static ProjectDownload getInstanceByFileName(Project project,
                                                        User proposing,
                                                        String fileName)
        throws Exception
    {
        if (project != null && proposing != null && fileName != null)
        {
            Criteria c = new Criteria()
                .add(PROJECT_ID, project.getProjectId())
                .add(PROPOSED_BY, proposing.getUserId())
                .add(FILE_NAME, fileName);
            return (ProjectDownload) FileArtifactTool
                .getFileArtifact("ProjectDownloadPeer.getInstanceByFile",
                                 fileName, doSelect(c));
        }
        else
        {
            // All inputs are required to find a unique record.
            return null;
        }
    }
@


1.1
log
@Moved in from peer package to handle Torque changes. -dlr
@
text
@a53 1

@

