/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.community;

import java.util.*;
import com.silverwrist.dynamo.db.OpsBase;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.SearchMode;

abstract class CommunityManagerOps extends OpsBase
{
  /*--------------------------------------------------------------------------------
   * Static data members
   *--------------------------------------------------------------------------------
   */

  static final String KEY_CID = "cid";
  static final String KEY_MEMBER_GID = "member_gid";
  static final String KEY_HOST_GID = "host_gid";
  static final String KEY_HOST_UID = "host_uid";
  static final String KEY_ACLID = "aclid";
  static final String KEY_CATID = "catid";
  static final String KEY_VISIBILITY = "visibility";
  static final String KEY_NAME = "name";
  static final String KEY_ALIAS = "alias";
  static final String KEY_CREATE = "created";
  static final String KEY_ACCESS = "access";
  static final String KEY_UPDATE = "update";

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  protected CommunityManagerOps(DBConnectionPool pool)
  {
    super(pool);

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Abstract operations
   *--------------------------------------------------------------------------------
   */

  abstract CommunityOps getCommunityOps();

  abstract Map lookupCommunity(int cid) throws DatabaseException;

  abstract Map lookupCommunity(String alias) throws DatabaseException;

  abstract int[] getMemberCommunityIDs(int uid) throws DatabaseException;

  abstract int[] getCommunityIDsInCategory(int catid, boolean show_all, int offset, int count)
      throws DatabaseException;

  abstract int getNumCommunityIDsInCategory(int catid, boolean show_all) throws DatabaseException;

  abstract int[] searchProperty(int nsid, String name, SearchMode mode, String term, boolean show_all, int offset,
				int count) throws DatabaseException;

  abstract int searchPropertyCount(int nsid, String name, SearchMode mode, String term, boolean show_all)
      throws DatabaseException;

  abstract int[] searchName(SearchMode mode, String term, boolean show_all, int offset, int count)
      throws DatabaseException;

  abstract int searchNameCount(SearchMode mode, String term, boolean show_all) throws DatabaseException;

  /*--------------------------------------------------------------------------------
   * External static operations
   *--------------------------------------------------------------------------------
   */

  static CommunityManagerOps get(DBConnectionPool pool) throws ConfigException
  {
    return (CommunityManagerOps)get(pool,CommunityManagerOps.class.getClassLoader(),
                                    CommunityManagerOps.class.getName() + "_","CommunityManagerOps");

  } // end get

} // end class CommunityManagerOps
