 /*
 	File : BBSController.java
 */
 
package com.etri.groupware.bbs;

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

public class BBSController implements BBSControllerInterface 
{
    private static BBSController bbsController = null;
	private static BBSDBManagerInterface bbsDBManager;
		
	private BBSController()
	{
	}
	
	public static BBSController init ( BBSDBManagerInterface db ) { 
		if(bbsController == null){
			bbsDBManager = db ;
		        bbsDBManager.init();
		        bbsController = new BBSController ( ) ;
		}
		return bbsController;        
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: listItem<br>
	 [기능]: option에 맞는 item 배열과 total 갯수<br>
	 [파라미터]: String boardName, OptionProperty option<br>
	 [호출자] : BBSListServlet<br>
	 */
	/*--------------------------------------------------------------- */	
	public Item[] listItem(String boardName, OptionProperty option) 
	{
		Item[] items;
		items = bbsDBManager.listItem(boardName, option);
				
		return items;
	}
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: searchItems<br>
	 [기능]: searchProperty에 적합한 데이타 검색<br>
	 [파라미터]: String boardName, SearchProperty search, OptionProperty option<br>
	 [호출자] : BBSListServlet<br>
	 */
	/*--------------------------------------------------------------- */		
	public Item[] searchItems(String boardName, SearchProperty search, OptionProperty option)
	{
		Item[] items;
		items = bbsDBManager.searchItems(boardName, search, option);
		
		return items;
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: readItem<br>
	 [기능]: number의 게시물 읽어 오기<br>
	 [파라미터]: String id, String boardName,int number, boolean increate<br>
	 [호출자] : BBSReadItemServlet, BBSUpdatingItemServlet<br>
	 */
	/*--------------------------------------------------------------- */		
	public Item readItem(String id, String boardName,int number, boolean increate)
	{
		Item item;
		item = bbsDBManager.readItem(id, boardName, number, increate);
		
		return item;
	}
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: checkDocumentOpen<br>
	 [기능]: number의 게시물을 사용자가 읽었었나, 안읽었었나<br>
	 [파라미터]: String id, int number<br>
	 [호출자] : BBSListServlet, BBSFirstServlet<br>
	 */
	/*--------------------------------------------------------------- */			
	public BBSResultStatus checkDocumentOpen(String id, int number)
	{
		BBSResultStatus state = bbsDBManager.checkDocumentOpen(id, number);
		
		return state;
	}
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: addItem<br>
	 [기능]: 게시물을 등록<br>
	 [파라미터]: Item item<br>
	 [호출자] : BBSWriteServlet<br>
	 */
	/*--------------------------------------------------------------- */				
	public BBSResultStatus addItem(Item item)
	{
		
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.addItem(item);
		
		return bbsResultStatus;
		
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: modifyItem<br>
	 [기능]: 게시물을 수정<br>
	 [파라미터]: String boardName, Item newItem, int number<br>
	 [호출자] : BBSUpdatingItemServlet<br>
	 */
	/*--------------------------------------------------------------- */		
	public BBSResultStatus modifyItem(String boardName, Item newItem, int number)
	{
	
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.modifyItem(boardName, newItem, number);
		
		return bbsResultStatus;
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: deleteItem<br>
	 [기능]: 게시물을 삭제<br>
	 [파라미터]: String boardName, int number<br>
	 [호출자] : BBSDeleteItemServlet<br>
	 */
	/*--------------------------------------------------------------- */				
	public BBSResultStatus deleteItem(String boardName, int number)
	{
	
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.deleteItem(boardName, number);
		
		return bbsResultStatus;
	}
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: setPersonalOption<br>
	 [기능]: 개인 정보 입력<br>
	 [파라미터]: String id,OptionProperty option<br>
	 [호출자] : BBSOptionPropertyServlet<br>
	 */
	/*--------------------------------------------------------------- */
	public BBSResultStatus setPersonalOption(String id,OptionProperty option)
	{
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.setPersonalOption(id, option);
		
		return bbsResultStatus;
	}
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: getPersonalOption<br>
	 [기능]: 개인정보 가져오기<br>
	 [파라미터]: String id<br>
	 [호출자] : BBSOptionPropertyServlet<br>
	 */
	/*--------------------------------------------------------------- */
	public OptionProperty getPersonalOption(String id)
	{
		OptionProperty option = bbsDBManager.getPersonalOption(id);
		
		return option;
	}
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: createBBS<br>
	 [기능]: 새로운 게시판을 만들자.<br>
	 [파라미터]: String DepartmentID, String TeamID, String BBSBoardName<br>
	 [호출자] : BBSCreateBBSServlet<br>
	 */
	/*--------------------------------------------------------------- */
	public BBSResultStatus createBBS(String DepartmentID, String TeamID, String BBSBoardName)
	{
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.createBBS(DepartmentID, TeamID, BBSBoardName);
		
		return bbsResultStatus;
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: deleteBBS<br>
	 [기능]: 게시판 삭제<br>
	 [파라미터]: String BBSBoardName<br>
	 [호출자] : BBSManagerBBSServlet<br>
	 */
	/*--------------------------------------------------------------- */
	public BBSResultStatus deleteBBS(String BBSBoardName)
	{
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.deleteBBS(BBSBoardName);
		
		return bbsResultStatus;
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: renameBBS<br>
	 [기능]: 게시판이름 변경<br>
	 [파라미터]: String oldBBSBoardName, String newBBSBoardName<br>
	 [호출자] : BBSManagerBBSServlet<br>
	 */
	/*--------------------------------------------------------------- */
	public BBSResultStatus renameBBS(String oldBBSBoardName, String newBBSBoardName)
	{
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.renameBBS(oldBBSBoardName, newBBSBoardName);
		
		return bbsResultStatus;
	}
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: getBBStree<br>
	 [기능]: 게시판 트리구조를 표여주기 위해서 필요한 함수.<br>
	 [파라미터]: 없음<br>
	 [호출자] : BBSTreeServlet<br>
	 */
	/*--------------------------------------------------------------- */
	public String[][][] getBBStree ( )
	{
		return bbsDBManager.getBBStree();
	}
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: checkBBS<br>
	 [기능]: Option에 설정된 게시판의 유무 확인<br>
	 [파라미터]: 없음<br>
	 [호출자] : ShowMainMenuServlet<br>
	 */
	/*--------------------------------------------------------------- */
	public BBSResultStatus checkBBS( String boardName )
	{
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.checkBBS( boardName);
		return bbsResultStatus;
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: getClubTree<br>
	 [기능]: 동아리 트리 가져오기...<br>
	 [파라미터]: 없음<br>
	 [호출자] : BBSTreeServlet<br>
	 */
	/*--------------------------------------------------------------- */
	public String[][] getClubTree()
	{
		return bbsDBManager.getClubTree();
	}	
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: clubInsert<br>
	 [기능]: 동아리 회원을 추가하는 기능<br>
	 [파라미터]: String name, String memeber<br>
	 [호출자] : ClubMemeberManagerServlet<br>
	 */
	/*--------------------------------------------------------------- */	
	public BBSResultStatus clubInsert( String name, String memeber)
	{
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.clubInsert(name, memeber);
		
		return bbsResultStatus;
	}
		
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: clubDelete<br>
	 [기능]: 동아리 회원을 탈퇴하는 기능<br>
	 [파라미터]: String name, String memeber<br>
	 [호출자] : ClubMemeberManagerServlet<br>
	 */
	/*--------------------------------------------------------------- */		
	public BBSResultStatus clubDelete( String name, String memeber)
	{
		BBSResultStatus bbsResultStatus;
		bbsResultStatus = bbsDBManager.clubDelete(name, memeber);
		
		return bbsResultStatus;
	}
	
	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: getClub<br>
	 [기능]: 사용자가 들어있는 동아리 리스트를 가져오는 기능<br>
	 [파라미터]:  String id<br>
	 [호출자] : BBSOptionPropertyServlet<br>
	 */
	/*--------------------------------------------------------------- */		
	public String[] getClub( String id)
	{
		String[] club = bbsDBManager.getClub( id );
		return club;
	}
			
}