head	1.8;
access;
symbols
	TIGRIS_0_9_2_4:1.4
	TIGRIS_0_9_2_3:1.4
	HELM_PEER_PORT_BRANCH:1.6.0.2
	TURBINE_PEER:1.6
	TIGRIS_0_9_2_1:1.6
	TIGRIS_0_9_2:1.4.0.2;
locks; strict;
comment	@# @;


1.8
date	2001.02.21.04.14.34;	author edk;	state dead;
branches;
next	1.7;

1.7
date	2001.02.02.01.10.22;	author elicia;	state Exp;
branches;
next	1.6;

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

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

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

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

1.2
date	2000.12.30.01.03.32;	author leonardr;	state Exp;
branches;
next	1.1;

1.1
date	2000.12.29.17.11.54;	author leonardr;	state Exp;
branches;
next	;

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


desc
@@


1.8
log
@these appear to have been subsummed by the peer port
@
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 user 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.tool.paginate;

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

import org.webmacro.util.Log;

import com.workingdogs.village.*;

import org.joist.database.*;
import org.tigris.helm.domain.NewsItem;
import org.tigris.helm.database.ProjectNewsManager;
import org.tigris.helm.security.AccessControlList;

/**
 * A paginatable list of news items.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Id: PaginatableNewsItemList.java,v 1.7 2001/02/02 01:10:22 elicia Exp $
 */
public class PaginatableNewsItemList extends PaginatableDatabaseBackedList
{   
    private static Log log = new Log("PNewsList", "PaginatableNewsItemList");
    private static final boolean debug = true;

    public static final Map filterableFields = new HashMap();

    static
    { 
        filterableFields.put("Headline", ProjectNewsManager.HEADLINE);
        filterableFields.put("Body", ProjectNewsManager.BODY);
    };    

    public Map getFilterableFields()
    {
        return filterableFields;
    }

    protected AccessControlList acl;

    public PaginatableNewsItemList(Connection connection, DataManager dMgr,
                                   Integer itemsPerPage, String baseQuery, 
                                   Criterion criterion, String orderBy,
                                   AccessControlList acl)
    {                
        super(connection, dMgr, itemsPerPage, baseQuery, criterion, orderBy);
        this.acl = acl;
    }
   
    public PaginatableNewsItemList(Connection connection, DataManager dMgr,
                                   Integer itemsPerPage, String baseQuery, 
                                   Criterion criterion, AccessControlList acl)
    {
        this(connection, dMgr, itemsPerPage, baseQuery, criterion, 
              ProjectNewsManager.EVENT_DATE, acl);
    }


    /**
     * Oh, this is ugly. We have to make all the news items into objects
     * to figure out which ones should be shown. Then we make a chunk of
     * them into objects again in objectifyRecords(). This is not good at
     * all. FIXME!
     */
    public void retrieveRecords()
        throws DataSetException, SQLException
    {
        List unfilteredRecords = runQuery();
        for (Iterator i = unfilteredRecords.iterator(); i.hasNext();)
        {
            Record r = (Record)i.next();
            NewsItem n = null;
            try {
                n = new NewsItem(connection, dMgr, r);
            } catch (org.tigris.helm.DoesNotExist ignore) {}
            
            String projectID = r.getValue(ProjectNewsManager.PROJECT_ID)
                .asString();

            try {
                if (acl.hasPermissionForProject
                    (n.requiredViewPermission(acl), projectID))
                {    
                    add(r);
                }
            } catch (java.text.ParseException e) {
                throw new DataSetException("Could not get required view permission for news item.");
            } catch (JoistDatabaseException e) {
                throw new DataSetException("Joist database exception.");
            }
        }
        dirty = false;    
    }

    protected List objectifyRecords(List list)
    throws DataSetException
    {
        List objects = new ArrayList();
        Record r = null;
        NewsItem n = null;
        for (Iterator i = list.iterator(); i.hasNext();)
        {
            r = (Record)i.next();
            try {
                n = new NewsItem(connection, dMgr, r);
            } catch (org.tigris.helm.DoesNotExist ignore) {}
            objects.add(n);
        }
        return objects;
    }
}
@


1.7
log
@now the user who proposed the news item can edit and delete it
@
text
@d65 1
a65 1
 * @@version $Id: PaginatableNewsItemList.java,v 1.6 2001/01/26 18:29:11 edk Exp $
@


1.6
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d65 1
a65 1
 * @@version $Id: PaginatableNewsItemList.java,v 1.4 2001/01/10 23:12:26 leonardr Exp $
d128 1
a128 1
                    (n.requiredViewPermission(), projectID))
@


1.6.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d65 1
a65 1
 * @@version $Id: PaginatableNewsItemList.java,v 1.6 2001/01/26 18:29:11 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
@@


1.4
log
@Upgraded searchability of PaginatableNewsItemList
@
text
@d65 1
a65 1
 * @@version $Id: PaginatableNewsItemList.java,v 1.3 2001/01/02 17:19:57 leonardr Exp $
@


1.3
log
@Split PaginatableList into subclasses PaginatableDatabaseBackedList and PaginatablePrebuiltList. If you want to do simple pagination without messing with the database, use PaginatablePrebuiltList. Note that your list will not be filterable.
@
text
@d65 1
a65 1
 * @@version $Id: PaginatableNewsItemList.java,v 1.2 2000/12/30 01:03:32 leonardr Exp $
d79 5
@


1.2
log
@More pagination changes--allow paginated lists to filter out items already in a group.
@
text
@d65 1
a65 1
 * @@version $Id: PaginatableNewsItemList.java,v 1.1 2000/12/29 17:11:54 leonardr Exp $
d67 1
a67 1
public class PaginatableNewsItemList extends PaginatableList
d125 1
a125 1
                    matchingRecords.add(r);
@


1.1
log
@Many, many pagination changes.
@
text
@d65 1
a65 1
 * @@version $Id: PaginatableUserList.java,v 1.4 2000/12/28 00:12:44 leonardr Exp $
d106 1
a106 1
    protected void retrieveRecords()
@

