dao.PersonalinfoDaoDb.java Source code

Java tutorial

Introduction

Here is the source code for dao.PersonalinfoDaoDb.java

Source

/**
* Copyright (c) 2001-2012 "Redbasin Networks, INC" [http://redbasin.org]
*
* This file is part of Redbasin OpenDocShare community project.
*
* Redbasin OpenDocShare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package dao;

import java.sql.Connection;
import java.util.List;
import javax.sql.DataSource;
import model.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import util.DbConstants;
import util.DiaryAdmin;
import util.MyUtils;
import util.RegexStrUtil;

/**
  * This object implements PersonalinfoDaoDb
  *
  * @author Smitha Gudur (smitha@redbasin.com)
  * @version $Revision: 1.1 $
  */
public class PersonalinfoDaoDb extends BaseDao implements PersonalinfoDao {

    protected final Log logger = LogFactory.getLog(getClass());
    private volatile HdloginUpdateQuery updateHdloginQuery;
    protected volatile DiaryAdmin diaryAdmin;

    // BizMatchQuery BizMatchQuery
    private volatile BasicQuery isBizMatchQuery;

    //private volatile PersonalinfoAddQuery addUserQuery;
    private volatile BaseCommonQuery addUserQuery;
    private volatile PersonalinfoUpdateQuery updateQuery;

    private volatile HdprofileQuery profileQuery;
    //private volatile HdprofileAddExistingMemberQuery addPreferencesQuery;
    private volatile BaseCommonQuery addPreferencesQuery;
    private volatile HdprofileUpdateQuery profileUpdateQuery;

    private volatile MykeywordsDeleteQuery myKeywordsDeleteQuery;
    private volatile MykeywordsAddQuery myKeywordsAddQuery;
    private volatile MykeywordsQuery myKeywordsQuery;

    private volatile YourkeywordsQuery yourKeywordsQuery;
    private volatile YourkeywordsDeleteQuery yourKeywordsDeleteQuery;
    private volatile YourkeywordsAddQuery yourKeywordsAddQuery;

    private volatile UserpageQuery userpageQuery;
    private volatile BaseCommonQuery addVisitQuery;

    /**
     * Given a login return the updated personal info page.
     * @param member
     * @param dob
     * @param title
     * @param ihave
     * @param iwant
     * @param industry
     * @param company
     * @param pwebsite
     * @param cwebsite
     * @param blogsite
     * @param education
     * @param city
     * @param state
     * @param country
     * @param description
     * @param interests
     * @param zipcode
     * @param pm
     * @param bb
     * @param fd
     * @param mykeywords
     * @param yourkeywords
     * @param fname
     * @param lname
     * @param mname
     * @param email
     * @param gender
     * @param nickname
     * @param designation
     * @param bcity
     * @param bstate
     * @param bcountry
     * @param bzipcode
     * @param hphone
     * @param cphone
     * @param bphone
     * @param blobStreamLabel 
     * @param docLabel - the documents label
     * @param password - password
     * @param street - street
     * @param bstreet - busstreet
     * @param zone - zone
     * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect
     */
    public void updatePersonalinfo(String member, String dob, String title, String ihave, String iwant,
            String industry, String company, String pwebsite, String cwebsite, String blogsite, String education,
            String city, String state, String country, String description, String interests, String zipcode, int pm,
            int bb, int fd, String mykeywords, String yourkeywords, String fname, String lname, String mname,
            String email, int gender, String nickname, String designation, String bcity, String bstate,
            String bcountry, String bzipcode, String hphone, String cphone, String bphone, String yim, String aim,
            String msn, String icq, String blobStreamLabel, String docLabel, String password, String street,
            String bstreet, String zone, String contact) throws BaseDaoException {

        Hdlogin hdlogin = getLoginid(member);
        if (hdlogin == null) {
            throw new BaseDaoException("hdlogin is null for member " + member);
        }

        String memberId = hdlogin.getValue(DbConstants.LOGIN_ID);
        if (RegexStrUtil.isNull(memberId)) {
            throw new BaseDaoException("memberId is null for member " + member);
        }

        Object[] params = { (Object) memberId };

        boolean myUsertabExists, myHdprofileExists, myKeywordsExists, yourKeywordExists;
        myUsertabExists = myHdprofileExists = myKeywordsExists = yourKeywordExists = false;

        myUsertabExists = doesMyUserTabExist(params);
        myHdprofileExists = doesMyHdprofileExist(params);
        myKeywordsExists = doesMyKeywordExist(params);
        yourKeywordExists = doesYourKeywordExist(params);

        /**
         *  Get scalability datasource for usertab/hdprofile/mykeywords/yourkeywords - not partitioned
         */
        String sourceName = scalabilityManager.getWriteZeroScalability();
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, updatePersonalInfo() " + sourceName);
        }

        Connection conn = null;
        try {
            conn = ds.getConnection();
            conn.setAutoCommit(false);

            /**
             *  hdlogin is not partitioned 
             */
            updateHdloginQuery.run(conn, memberId, fname, lname, mname, email, password, contact);

            // no entry? add entry 
            if (!myUsertabExists) {
                String[] myparams = new String[35];
                myparams[0] = dob;
                myparams[1] = title;
                myparams[2] = ihave;
                myparams[3] = iwant;
                myparams[4] = industry;
                myparams[5] = company;
                myparams[6] = pwebsite;
                myparams[7] = cwebsite;
                myparams[8] = blogsite;
                myparams[9] = education;
                myparams[10] = city;
                myparams[11] = state;
                myparams[12] = country;
                myparams[13] = description;
                myparams[14] = interests;
                myparams[15] = zipcode;
                myparams[16] = new Integer(gender).toString();
                myparams[17] = nickname;
                myparams[18] = designation;
                myparams[19] = bcity;
                myparams[20] = bstate;
                myparams[21] = bcountry;
                myparams[22] = bzipcode;
                myparams[23] = hphone;
                myparams[24] = cphone;
                myparams[25] = bphone;
                myparams[26] = yim;
                myparams[27] = aim;
                myparams[28] = msn;
                myparams[29] = icq;
                // memberid is the LAST_INSERT_ID
                myparams[30] = blobStreamLabel;
                myparams[31] = docLabel;
                myparams[32] = street;
                myparams[33] = bstreet;
                myparams[34] = zone;

                String queryName = scalabilityManager.getWriteZeroScalability("personalinfoaddquery");
                addUserQuery = getQueryMapper().getCommonQuery(queryName);
                addUserQuery.run(conn, myparams);
                //addUserQuery.run(conn, dob, title, ihave, iwant, industry, company, pwebsite, cwebsite, blogsite, education, city, state, country, description, interests, zipcode, gender, nickname, designation, bcity, bstate, bcountry, bzipcode, hphone, cphone, bphone,  yim, aim, msn,icq, memberId, blobStreamLabel, docLabel);
            } else {
                // exists! update entry
                updateQuery.run(conn, dob, title, ihave, iwant, industry, company, pwebsite, cwebsite, blogsite,
                        education, city, state, country, description, interests, zipcode, gender, nickname,
                        designation, bcity, bstate, bcountry, bzipcode, hphone, cphone, bphone, yim, aim, msn, icq,
                        memberId, blobStreamLabel, docLabel, street, bstreet, zone);
            }

            /**
             *  hdprofile - not partitioned
                  *  no entry? add entry
               addUserQuery.run(conn, params);
               //addUserQuery.run(conn, dob, title, ihave, iwant, industry, company, pwebsite, cwebsite, blogsite, education, city, state, country, description, interests, zipcode, gender, nickname, designation, bcity, bstate, bcountry, bzipcode, hphone, cphone, bphone,  yim, aim, msn,icq, memberId, blobStreamLabel, docLabel);
                 } else {
                    // exists! update entry
               updateQuery.run(conn, dob, title, ihave, iwant, industry, company, pwebsite, cwebsite, blogsite, education, city, state, country, description, interests, zipcode, gender, nickname, designation, bcity, bstate, bcountry, bzipcode, hphone, cphone, bphone, yim, aim, msn, icq, memberId, blobStreamLabel, docLabel);
                 }
                
            /**
             *  hdprofile - not partitioned
                  *  no entry? add entry
             */
            if (!myHdprofileExists) {
                String pmStr = new Integer(pm).toString();
                String bbStr = new Integer(bb).toString();
                String fdStr = new Integer(fd).toString();
                String profileParams[] = { pmStr, bbStr, fdStr, memberId };

                String queryName = scalabilityManager.getWriteZeroScalability("addpreferencesquery");
                addPreferencesQuery = getQueryMapper().getCommonQuery(queryName);
                addPreferencesQuery.run(conn, profileParams);
            } else {
                /**
                *  add entry in hdprofile - not partitioned
                 **/
                profileUpdateQuery.run(conn, pm, bb, fd, memberId);
            }

            /**
             *  mykeywords - not partitioned
             *  Add mykeywords
                  *  exists! zap keywords
             */
            if (myKeywordsExists) {
                myKeywordsDeleteQuery.run(conn, memberId);
            }
            if (!RegexStrUtil.isNull(mykeywords)) {
                String[] mykeys = mykeywords.split(",");
                for (int i = 0; i < mykeys.length; i++) {
                    myKeywordsAddQuery.run(conn, mykeys[i], memberId);
                }
            }

            /**
             *  Add yourkeywords
             *  yourkeywords - not partitioned
             */
            if (yourKeywordExists) {
                yourKeywordsDeleteQuery.run(conn, memberId);
            }
            if (!RegexStrUtil.isNull(yourkeywords)) {
                String[] yourkeys = yourkeywords.split(",");
                for (int i = 0; i < yourkeys.length; i++) {
                    yourKeywordsAddQuery.run(conn, yourkeys[i], memberId);
                }
            }
        } catch (Exception e) {
            try {
                conn.rollback();
            } catch (Exception e1) {
                try {
                    if (conn != null) {
                        conn.setAutoCommit(true);
                        conn.close();
                    }
                } catch (Exception e2) {
                    throw new BaseDaoException(
                            "connection close exception for preferences/deleting/adding keywords", e2);
                }
                throw new BaseDaoException(
                        "error occured while rollingback entries updateing preferences/deleting/adding mykeywords/your keywords ",
                        e1);
            }
            throw new BaseDaoException(
                    "error occured while updating preferences/deleting/adding mykeywords/yourkeywords", e);
        }

        // committing transaction
        try {
            conn.commit();
        } catch (Exception e3) {
            throw new BaseDaoException("commit exception for preferences/deleting/adding keywords", e3);
        }
        try {
            if (conn != null) {
                conn.setAutoCommit(true);
                conn.close();
            }
        } catch (Exception e4) {
            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (Exception e1) {
                throw new BaseDaoException("connection close exception", e1);
            }

            throw new BaseDaoException("connection close exception for preferences/deleting/adding keywords", e4);
        }

        // currently not used as it always updates it
        Fqn fqn = cacheUtil.fqn(DbConstants.ID_INFO);
        if (treeCache.exists(fqn, member)) {
            treeCache.remove(fqn, member);
        }

        fqn = cacheUtil.fqn(DbConstants.LOGIN_INFO);
        if (treeCache.exists(fqn, memberId)) {
            treeCache.remove(fqn, memberId);
        }

        fqn = cacheUtil.fqn(DbConstants.USER_PAGE);
        if (treeCache.exists(fqn, member)) {
            treeCache.remove(fqn, member);
        }

        fqn = cacheUtil.fqn(DbConstants.AUTHORS_LIST);
        if (treeCache.exists(fqn, member)) {
            treeCache.remove(fqn, member);
        }

        Object dirs = null;
        fqn = cacheUtil.fqn(DbConstants.AUTHORS_DIRECTORIES);
        if (treeCache.exists(fqn, member)) {
            dirs = treeCache.get(fqn, member);
            treeCache.remove(fqn, member);
        }

        fqn = cacheUtil.fqn(DbConstants.AUTHOR_BLOCKED_DIRS);
        if (treeCache.exists(fqn, memberId)) {
            treeCache.remove(fqn, memberId);
        }

        fqn = cacheUtil.fqn(DbConstants.DIR_COPY);
        if (treeCache.exists(fqn, memberId)) {
            treeCache.remove(fqn, memberId);
        }

        fqn = cacheUtil.fqn(DbConstants.DIR_MOVE);
        if (treeCache.exists(fqn, memberId)) {
            treeCache.remove(fqn, memberId);
        }

        StringBuffer sb = new StringBuffer();
        if (dirs != null) {
            for (int i = 0; i < ((List) dirs).size(); i++) {
                String directoryId = ((Directory) ((List) dirs).get(i)).getValue(DbConstants.DIRECTORY_ID);
                sb.delete(0, sb.length());
                sb.append(directoryId);
                sb.append("-");
                sb.append(memberId);
                String key = sb.toString();
                fqn = cacheUtil.fqn(DbConstants.DIR_AUTHOR);
                if (treeCache.exists(fqn, key)) {
                    treeCache.remove(fqn, key);
                }

                fqn = cacheUtil.fqn(DbConstants.DIRECTORY);
                if (treeCache.exists(fqn, directoryId)) {
                    treeCache.remove(fqn, directoryId);
                }
            }
        }
        /*
        fqn = cacheUtil.fqn(DbConstants.COLLABRUM_LIST);
        if (treeCache.exists(fqn, directoryId)) {
            treeCache.remove(fqn, directoryId);
        }
        */

        // delete collabrum related cache
        Object collabrums = null;
        fqn = cacheUtil.fqn(DbConstants.MEM_AS_ORGANIZER_LIST);
        if (treeCache.exists(fqn, member)) {
            collabrums = treeCache.get(fqn, member);
            treeCache.remove(fqn, member);
        }

        fqn = cacheUtil.fqn(DbConstants.MEM_AS_MODERATOR_LIST);
        if (treeCache.exists(fqn, member)) {
            treeCache.remove(fqn, member);
        }

        fqn = cacheUtil.fqn(DbConstants.BLOCKED_COLLABRUM_LIST);
        if (treeCache.exists(fqn, memberId)) {
            treeCache.remove(fqn, memberId);
        }

        /** get authors related collabrums */
        if (collabrums != null) {
            for (int i = 0; i < ((List) collabrums).size(); i++) {
                String collabrumId = ((Collabrum) ((List) collabrums).get(i)).getValue(DbConstants.COLLABRUM_ID);

                /*
                           fqn = cacheUtil.fqn(DbConstants.COLLABRUM_EDIT);
                           if (treeCache.exists(fqn, collabrumId)) {
                               treeCache.remove(fqn, collabrumId);
                           } 
                */

                fqn = cacheUtil.fqn(DbConstants.COLLABRUM);
                if (treeCache.exists(fqn, collabrumId)) {
                    treeCache.remove(fqn, collabrumId);
                }

                fqn = cacheUtil.fqn(DbConstants.ORGANIZERS);
                if (treeCache.exists(fqn, collabrumId)) {
                    treeCache.remove(fqn, collabrumId);
                }

                sb.delete(0, sb.length());
                sb.append(collabrumId);
                sb.append("-");
                sb.append(memberId);
                fqn = cacheUtil.fqn(DbConstants.ORGANIZER);
                if (treeCache.exists(fqn, sb.toString())) {
                    treeCache.remove(fqn, sb.toString());
                }
            }
        }
    }

    /*
     * Given a login, return the profile
     * @param login
     * @param loginInfo - the member bean that contains information about this member
     *           (fname, lname, mname, email)
     * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect
     */
    public Userpage getMyProfile(String loginId, Hdlogin hdlogin) {

        Object[] params = { (Object) loginId };

        /** Jboss methods
         * fqn - full qualified name
         * check if the userpage already set in the cache
         * If it exists, return the userpage from the cache.
         */

        String login = hdlogin.getValue(DbConstants.LOGIN);

        /**
         *  Get scalability datasource for usertab/mykeywords/hdprofile - not partitioned
         */
        String sourceName = scalabilityManager.getReadZeroScalability();
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, getMyProfile() " + sourceName);
        }

        List uResult = null;
        try {
            uResult = userpageQuery.execute(params);
        } catch (Exception e) {
            throw new BaseDaoException("exception occured in executing UserpageQuery() " + userpageQuery.getSql()
                    + ", loginId = " + loginId, e);
        }

        if (uResult == null) {
            return null;
        }

        Userpage userpage = (Userpage) uResult.get(0);
        String dob = userpage.getValue(DbConstants.DOB);
        MyUtils myutils = new MyUtils();

        if (!RegexStrUtil.isNull(dob)) {
            userpage.setValue(DbConstants.BMONTH, myutils.getMonth(dob));
            userpage.setValue(DbConstants.BYEAR, myutils.getYear(dob));
            userpage.setValue(DbConstants.BDAY, myutils.getDay(dob));
            userpage.setValue(DbConstants.BMONTH_NUM, myutils.getMonthNum(dob));
        }
        if (hdlogin != null) {
            userpage.setValue(DbConstants.FIRST_NAME, hdlogin.getValue(DbConstants.FIRST_NAME));
            userpage.setValue(DbConstants.LAST_NAME, hdlogin.getValue(DbConstants.LAST_NAME));
            userpage.setValue(DbConstants.MIDDLE_NAME, hdlogin.getValue(DbConstants.MIDDLE_NAME));
            userpage.setValue(DbConstants.EMAIL, hdlogin.getValue(DbConstants.EMAIL));
            userpage.setValue(DbConstants.PASSWORD, hdlogin.getValue(DbConstants.PASSWORD));
        }

        // for profile preferences
        List prefResult = null;
        try {
            prefResult = profileQuery.execute(params);
        } catch (Exception e) {
            throw new BaseDaoException("exception occured in executing HdprofileQuery() " + profileQuery.getSql(),
                    e);
        }

        if (prefResult != null) {
            if (prefResult.size() == 1) {
                Hdprofile hdprofile = (Hdprofile) prefResult.get(0);
                userpage.setValue(DbConstants.INFORM_PM, hdprofile.getValue(DbConstants.INFORM_PM));
                userpage.setValue(DbConstants.INFORM_BB, hdprofile.getValue(DbConstants.INFORM_BB));
                userpage.setValue(DbConstants.INFORM_FD, hdprofile.getValue(DbConstants.INFORM_FD));
            }
        }

        List result = null;
        try {
            result = myKeywordsQuery.execute(loginId);
        } catch (Exception e) {
            throw new BaseDaoException("exception occured in executing MykeywordsQuery() "
                    + myKeywordsQuery.getSql() + ", loginId = " + loginId, e);
        }

        if (result != null) {
            int size = result.size();
            StringBuffer allMywords = new StringBuffer();
            if ((size > 0)) {
                for (int i = 0; i < size; i++) {
                    Mykeywords mywords = (Mykeywords) result.get(i);
                    allMywords = allMywords.append(mywords.getValue("keyword"));
                    allMywords = allMywords.append(",");
                }
                allMywords = allMywords.deleteCharAt(allMywords.length() - 1);
                userpage.setValue(DbConstants.MYKEYWORDS, allMywords.toString());
            }
        }

        getYourkeywords(loginId, userpage);
        /*
           if (userpage != null) {
              treeCache.put(fqn, login, userpage);
           }
        */
        return userpage;
    }

    private void getYourkeywords(String loginId, Userpage userpage) {

        if (RegexStrUtil.isNull(loginId) || (userpage == null)) {
            return;
        }

        /**
         *  Get scalability datasource for yourkeywords - not partitioned
         */
        String sourceName = scalabilityManager.getReadZeroScalability();
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, getYourKeywords() " + sourceName);
        }

        List result = null;
        try {
            result = yourKeywordsQuery.execute(loginId);
        } catch (Exception e) {
            throw new BaseDaoException("exception occured in executing YourkeywordsQuery() "
                    + yourKeywordsQuery.getSql() + ", loginId = " + loginId, e);
        }

        StringBuffer allwords = new StringBuffer();
        int size = result.size();
        if ((size > 0)) {
            for (int i = 0; i < size; i++) {
                Yourkeywords yourwords = (Yourkeywords) result.get(i);
                allwords = allwords.append(yourwords.getValue(DbConstants.YOURKEYWORD));
                allwords = allwords.append(",");
            }
            allwords = allwords.deleteCharAt(allwords.length() - 1);
            userpage.setValue(DbConstants.YOURKEYWORDS, allwords.toString());
        }
    }

    /*
     * Given a login params, check if usertab entry exists
     * @param params
     * @return boolean
     * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect
     */
    private boolean doesMyUserTabExist(Object[] params) throws BaseDaoException {

        if (params == null) {
            return false;
        }
        /**
         *  Get scalability datasource for userpage - not partitioned
         */
        String sourceName = scalabilityManager.getReadZeroScalability();
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null " + sourceName);
        }

        List uResult = null;
        try {
            uResult = userpageQuery.execute(params);
        } catch (Exception e) {
            throw new BaseDaoException("exception occured in executing UserpageQuery() in doesMyUserTabExist() "
                    + userpageQuery.getSql(), e);
        }

        if (uResult != null) {
            if (uResult.size() > 0) {
                return true;
            }
        }
        return false;
    }

    /*
     * Given a login params, check if hdprofile entry exists
     * @param params
     * @return boolean
     * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect
     */
    private boolean doesMyHdprofileExist(Object[] params) throws BaseDaoException {

        if (params == null) {
            return false;
        }

        /**
         *  Get scalability datasource for hdprofile - not partitioned
         */
        String sourceName = scalabilityManager.getReadZeroScalability();
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null " + sourceName);
        }

        List uResult = null;
        try {
            uResult = profileQuery.execute(params);
        } catch (Exception e) {
            throw new BaseDaoException("exception occured in executing HdprofileQuery() in doesMyHdprofilExist() "
                    + profileQuery.getSql(), e);
        }

        if (uResult != null) {
            if (uResult.size() > 0) {
                return true;
            }
        }
        return false;
    }

    /*
     * Given a login params, check if mykeyword entry exists
     * @param params
     * @return boolean
     * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect
     */
    private boolean doesMyKeywordExist(Object[] params) throws BaseDaoException {

        if (params == null) {
            return false;
        }

        /**
         *  Get scalability datasource for mykeywords - not partitioned
         */
        String sourceName = scalabilityManager.getReadZeroScalability();
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null " + sourceName);
        }

        List uResult = null;
        try {
            uResult = myKeywordsQuery.execute(params);
        } catch (Exception e) {
            throw new BaseDaoException("exception occured in executing MykeywordsQuery() in doesMyKeywordExist() "
                    + myKeywordsQuery.getSql(), e);
        }

        if (uResult != null) {
            if (uResult.size() > 0) {
                return true;
            }
        }
        return false;
    }

    /*
     * Given a login params, check if yourkeyword entry exists.
     * @param params
     * @return boolean
     * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect
     */
    private boolean doesYourKeywordExist(Object[] params) throws BaseDaoException {

        if (params == null) {
            return false;
        }

        /**
         *  Get scalability datasource for yourkeywords - not partitioned
         */
        String sourceName = scalabilityManager.getReadZeroScalability();
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null " + sourceName);
        }

        List uResult = null;
        try {
            uResult = yourKeywordsQuery.execute(params);
        } catch (Exception e) {
            throw new BaseDaoException(
                    "exception occured in executing YourkeywordsQuery() in doesYourKeywordExist() "
                            + yourKeywordsQuery.getSql(),
                    e);
        }
        if (uResult != null) {
            if (uResult.size() > 0) {
                return true;
            }
        }
        return false;
    }

    /**
     *  This method checks:
     *      - if there is a biz account match between the login and member or
     *      - business that the member belongs to allows searching  or 
     *      - the member does not belong to a business
     *  @param login - login
     *  @param member - member
     *  @param search - search flag (1 for accessible, 0 for not-accessible)
     *  @param accessFlag - the accessflag
     *  @return boolean - true if any of the above conditions are true
     *  @return false - there is no match
     *
     */
    public boolean isBizMatch(String login, String member, String search, int accessFlag) {

        if (RegexStrUtil.isNull(login) || RegexStrUtil.isNull(member)) {
            throw new BaseDaoException("params are null");
        }

        /** 
         *  admin is allowed to access any page
         */
        if (diaryAdmin.isDiaryAdmin(login)) {
            return true;
        }

        String queryName = null;

        if (accessFlag == 1) {
            queryName = scalabilityManager.getWriteZeroScalability("bizmatchQuery");
        } else {
            queryName = scalabilityManager.getReadZeroScalability("bizmatchQuery");
        }

        isBizMatchQuery = getQueryMapper().getQuery(queryName);
        try {
            Object[] params = { (Object) login, (Object) member, (Object) member, (Object) search };
            List result = isBizMatchQuery.execute(params);
            logger.info("isBizMatchQuery = " + isBizMatchQuery.getSql());
            if (result != null && result.size() > 0) {
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            throw new BaseDaoException("isBizMatchQuery error" + isBizMatchQuery.getSql(), e);
        }
    }

    /**
     *  This method adds visit traffic
     *  @param login - login
     *  @param ipaddress - ipaddress
     *  @param referer - referer
     *  @param url - url
     *  @param method - method
     *  @param host - host
     */
    public void addVisitTraffic(String login, String ipaddress, String referer, String url, String method,
            String host) throws BaseDaoException {

        String sourceName = scalabilityManager.getWriteZeroScalability();
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null " + sourceName);
        }

        String queryName = scalabilityManager.getWriteZeroScalability("addvisittrafficquery");
        addVisitQuery = getQueryMapper().getCommonQuery(queryName);

        Connection conn = null;
        try {
            conn = ds.getConnection();
            String[] params = { login, ipaddress, referer, url, method, host };
            addVisitQuery.run(conn, params);
        } catch (Exception e) {
            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (Exception e1) {
                throw new BaseDaoException("conn.close() error, addVisitQuery()", e1);
            }
            throw new BaseDaoException("error executing dbquery, addVisitQuery()", e);
        }

        try {
            if (conn != null) {
                conn.close();
            }
        } catch (Exception e) {
            throw new BaseDaoException("conn.close() error after executing, addVisitQuery ", e);
        }
    }

    /**
     *  This property is setby spring automatically at web.xml startup
     *  @param ds - this is JDBC datasource bean that is connection from the pool
     */
    public void setJdbcSource(DataSource ds) {
        this.ds = ds;
    }

    public void setpersonalinfoaddQuery(BaseCommonQuery daq) {
        this.addUserQuery = daq;
    }

    public void setpersonalinfoupdateQuery(PersonalinfoUpdateQuery daq) {
        this.updateQuery = daq;
    }

    public void sethdprofileQuery(HdprofileQuery daq) {
        this.profileQuery = daq;
    }

    public void sethdprofileupdateQuery(HdprofileUpdateQuery daq) {
        this.profileUpdateQuery = daq;
    }

    public void setmykeywordsdeleteQuery(MykeywordsDeleteQuery daq) {
        this.myKeywordsDeleteQuery = daq;
    }

    public void setmykeywordsaddQuery(MykeywordsAddQuery daq) {
        this.myKeywordsAddQuery = daq;
    }

    public void setmykeywordsQuery(MykeywordsQuery daq) {
        this.myKeywordsQuery = daq;
    }

    public void setyourkeywordsQuery(YourkeywordsQuery daq) {
        this.yourKeywordsQuery = daq;
    }

    public void setyourkeywordsdeleteQuery(YourkeywordsDeleteQuery daq) {
        this.yourKeywordsDeleteQuery = daq;
    }

    public void setyourkeywordsaddQuery(YourkeywordsAddQuery daq) {
        this.yourKeywordsAddQuery = daq;
    }

    public void setuserpageQuery(UserpageQuery daq) {
        this.userpageQuery = daq;
    }

    public void sethdloginupdateQuery(HdloginUpdateQuery daq) {
        this.updateHdloginQuery = daq;
    }

    public void setdiaryadmin(DiaryAdmin daq) {
        this.diaryAdmin = daq;
    }

}