gt: 			throw new EJBException(sqle.getMessage());
context: package is.idega.idegaweb.egov.message.data;
  
  import java.util.Collection;
  
  import javax.ejb.EJBException;
  import javax.ejb.FinderException;
  
  import com.idega.block.process.data.AbstractCaseBMPBean;
  import com.idega.block.process.data.Case;
  import com.idega.core.file.data.ICFile;
  import com.idega.data.IDOException;
  import com.idega.data.IDORuntimeException;
  import com.idega.data.query.Criteria;
  import com.idega.data.query.InCriteria;
  import com.idega.data.query.MatchCriteria;
  import com.idega.data.query.SelectQuery;
  import com.idega.user.data.Group;
  import com.idega.user.data.User;
  import com.idega.util.IWTimestamp;
  
  /**
   * Title: Description: Copyright: Copyright (c) 2002 Company:
   *
   * @author Anders Lindman
   * @version 1.0
   */
  public class PrintedLetterMessageBMPBean extends AbstractCaseBMPBean implements PrintedLetterMessage, PrintMessage, Case {
  
  	private static final long serialVersionUID = -3476359538719379553L;
  
  	private static final String COLUMN_SUBJECT = "SUBJECT";
  
  	private static final String COLUMN_BODY = "BODY";
  
  	private static final String COLUMN_MESSAGE_TYPE = "MESSAGE_TYPE";
  
  	private static final String COLUMN_MESSAGE_DATA = "MESSAGE_DATA";
  
  	private static final String COLUMN_LETTER_TYPE = "LETTER_TYPE";
  
  	private static final String COLUMN_BULK_DATA = "BULK_DATA";
  
  	private static final String COLUMN_CONTENT_CODE = "CONTENT_CODE";
  
  	private static final String CASE_CODE_KEY = "SYMEBRV";
  
  	private static final String CASE_CODE_DESCRIPTION = "Letter Message";
  
  	@Override
  	public String getEntityName() {
  		return "MSG_LETTER_MESSAGE";
  	}
  
  	@Override
  	public void initializeAttributes() {
  		addGeneralCaseRelation();
  		this.addAttribute(COLUMN_SUBJECT, "Message subject", String.class);
  		this.addAttribute(COLUMN_BODY, "Message body", String.class, 4000);
  		this.addAttribute(COLUMN_MESSAGE_TYPE, "Message type", String.class, 20);
  		this.addManyToOneRelationship(COLUMN_MESSAGE_DATA, "Message data", ICFile.class);
  		this.addAttribute(COLUMN_LETTER_TYPE, "Message SubType", String.class, 4);
  		this.addManyToOneRelationship(COLUMN_BULK_DATA, "Message bulk data", ICFile.class);
  		this.addAttribute(COLUMN_CONTENT_CODE, "Message contentcode", String.class, 20);
  	}
  
  	@Override
  	public String getCaseCodeKey() {
  		return CASE_CODE_KEY;
  	}
  
  	@Override
  	public String getCaseCodeDescription() {
  		return CASE_CODE_DESCRIPTION;
  	}
  
  	@Override
  	public void setDefaultValues() {
  		setLetterType(MessageConstants.LETTER_TYPE_DEFAULT);
  	}
  
  	@Override
  	public User getSender() {
  		throw new UnsupportedOperationException();
  	}
  
  	@Override
  	public void setSender(User sender) {
  		throw new UnsupportedOperationException();
  	}
  
  	@Override
  	public int getSenderID() {
  		throw new UnsupportedOperationException();
  	}
  
  	@Override
  	public void setSenderID(int senderID) {
  		throw new UnsupportedOperationException();
  	}
  
  	@Override
  	public void setSubject(String subject) {
  		this.setColumn(COLUMN_SUBJECT, subject);
  	}
  
  	@Override
  	public String getSubject() {
  		return this.getStringColumnValue(COLUMN_SUBJECT);
  	}
  
  	@Override
  	public void setBody(String body) {
  		this.setColumn(COLUMN_BODY, body);
  	}
  
  	@Override
  	public String getBody() {
  		return this.getStringColumnValue(COLUMN_BODY);
  	}
  
  	@Override
  	public String getMessageType() {
  		return this.getStringColumnValue(COLUMN_MESSAGE_TYPE);
  	}
  
  	@Override
  	public boolean isPrinted() {
  		return this.getCaseStatus().getStatus().equals(getCaseStatusReady());
  	}
  
  	@Override
  	public void setMessageType(String type) {
  		this.setColumn(COLUMN_MESSAGE_TYPE, type);
  	}
  
  	@Override
  	public ICFile getMessageData() {
  		return (ICFile) this.getColumnValue(COLUMN_MESSAGE_DATA); // Replace this
  																															// later
  	}
  
  	@Override
  	public int getMessageDataFileID() {
  		return this.getIntColumnValue(COLUMN_MESSAGE_DATA);
  	}
  
  	@Override
  	public void setMessageData(ICFile file) { // Temp (test) method
  		this.setColumn(COLUMN_MESSAGE_DATA, file);
  	}
  
  	@Override
  	public void setMessageData(int fileID) { // Temp (test) method
  		this.setColumn(COLUMN_MESSAGE_DATA, fileID);
  	}
  
  	/*
  	 * (non-Javadoc)
  	 *
  	 * @see se.idega.idegaweb.commune.message.data.PrintMessage#getContentType()
  	 */
  	@Override
  	public String getContentCode() {
  		return this.getStringColumnValue(COLUMN_CONTENT_CODE);
  	}
  
  	@Override
  	public void setContentCode(String contentCode) {
  		this.setColumn(COLUMN_CONTENT_CODE, contentCode);
  	}
  
  	@Override
  	public ICFile getMessageBulkData() {
  		return (ICFile) this.getColumnValue(COLUMN_BULK_DATA); // Replace this
  																														// later
  	}
  
  	@Override
  	public int getMessageBulkDataFileID() {
  		return this.getIntColumnValue(COLUMN_BULK_DATA);
  	}
  
  	@Override
  	public void setMessageBulkData(ICFile file) { // Temp (test) method
  		this.setColumn(COLUMN_BULK_DATA, file);
  	}
  
  	@Override
  	public void setMessageBulkData(int fileID) { // Temp (test) method
  		this.setColumn(COLUMN_BULK_DATA, fileID);
  	}
  
  	@Override
  	public String getSenderName() {
  		return getOwner().getName();
  	}
  
  	@Override
  	public String getDateString() {
  		/**
  		 * @todo: implement
  		 */
  		return "";
  	}
  
  	@Override
  	public void setLetterType(String letterType) {
  		setColumn(COLUMN_LETTER_TYPE, letterType);
  	}
  
  	@Override
  	public String getLetterType() {
  		return getStringColumnValue(COLUMN_LETTER_TYPE);
  	}
  
  	@Override
  	public void setAsPasswordLetter() {
  		setLetterType(MessageConstants.LETTER_TYPE_PASSWORD);
  	}
  
  	public Collection ejbFindMessages(User user) throws FinderException {
  		return super.ejbFindAllCasesByUser(user);
  	}
  
  	public Collection ejbFindMessagesByStatus(User user, String[] status) throws FinderException {
  		return super.ejbFindAllCasesByUserAndStatusArray(user, status);
  	}
  
  	public Collection ejbFindAllUnPrintedLetters() throws FinderException {
  		return super.ejbFindAllCasesByStatus(super.getCaseStatusOpen());
  	}
  
  	public Collection ejbFindAllPrintedLetters() throws FinderException {
  		return super.ejbFindAllCasesByStatus(super.getCaseStatusReady());
  	}
  
  	protected SelectQuery idoSelectQueryGetCountDefaultLettersWithStatus(String caseStatus) {
  		return idoSelectQueryGetLettersCountByStatusAndType(caseStatus, MessageConstants.LETTER_TYPE_DEFAULT);
  	}
  
  	protected SelectQuery idoSelectQueryGetCountPasswordLettersWithStatus(String caseStatus) {
  		return idoSelectQueryGetLettersCountByStatusAndType(caseStatus, COLUMN_LETTER_TYPE);
  	}
  
  	@Override
  	public String getUnPrintedCaseStatusForType(String type) {
  		return getCaseStatusOpen();
  	}
  
  	@Override
  	public String getPrintedCaseStatusForType(String type) {
  		return getCaseStatusReview();
  	}
  
  	/**
  	 * Counts the number of unprinted letters of the given type.
  	 */
  	public int ejbHomeGetNumberOfUnprintedLettersByType(String letterType) {
  		try {
  			SelectQuery sql = idoSelectQueryGetLettersCountByStatusAndType(getUnPrintedCaseStatusForType(letterType),
  					letterType);
  			return super.idoGetNumberOfRecords(sql);
  		}
  		catch (IDOException sqle) {
  			throw new EJBException(sqle.getMessage());
  		}
  	}
  
  	/**
  	 * Counts the number of printed letters of the given type.
  	 */
  	public int ejbHomeGetNumberOfPrintedLettersByType(String letterType) {
  		try {
  			SelectQuery sql = idoSelectQueryGetLettersCountByStatusAndType(getUnPrintedCaseStatusForType(letterType),
  					letterType);
  			return super.idoGetNumberOfRecords(sql);
  		}
  		catch (IDOException sqle) {
  