Example usage for java.util Map containsValue

List of usage examples for java.util Map containsValue

Introduction

In this page you can find the example usage for java.util Map containsValue.

Prototype

boolean containsValue(Object value);

Source Link

Document

Returns true if this map maps one or more keys to the specified value.

Usage

From source file:com.stratio.morphlines.refererparser.Parser.java

/**
 * Builds the map of hosts to referers from the
 * input YAML file.//from   w ww. ja v a 2 s  . co m
 *
 * @param referersYaml An InputStream containing the
 *                     referers database in YAML format.
 * @return a Map where the key is the hostname of each
 * referer and the value (RefererLookup)
 * contains all known info about this referer
 */
private Map<String, RefererLookup> loadReferers(InputStream referersYaml) throws RefererParserException {

    Yaml yaml = new Yaml(new SafeConstructor());
    Map<String, Map<String, Map>> rawReferers = (Map<String, Map<String, Map>>) yaml.load(referersYaml);

    // This will store all of our referers
    Map<String, RefererLookup> referers = new HashMap<String, RefererLookup>();

    // Outer loop is all referers under a given medium
    for (Map.Entry<String, Map<String, Map>> mediumReferers : rawReferers.entrySet()) {

        Medium medium = Medium.fromString(mediumReferers.getKey());

        // Inner loop is individual referers
        for (Map.Entry<String, Map> referer : mediumReferers.getValue().entrySet()) {

            String sourceName = referer.getKey();
            Map<String, List<String>> refererMap = referer.getValue();

            // Validate
            List<String> parameters = refererMap.get("parameters");
            if (medium == Medium.SEARCH) {
                if (parameters == null) {
                    throw new RefererParserException(
                            "No parameters found for search referer '" + sourceName + "'");
                }
            } else {
                if (parameters != null) {
                    throw new RefererParserException(
                            "Parameters not supported for non-search referer '" + sourceName + "'");
                }
            }
            List<String> domains = refererMap.get("domains");
            if (domains == null) {
                throw new RefererParserException("No domains found for referer '" + sourceName + "'");
            }

            // Our hash needs referer domain as the
            // key, so let's expand
            for (String domain : domains) {
                if (referers.containsValue(domain)) {
                    throw new RefererParserException("Duplicate of domain '" + domain + "' found");
                }
                referers.put(domain, new RefererLookup(medium, sourceName, parameters));
            }
        }
    }

    return referers;
}

From source file:com.mss.mirage.employee.Reviews.ReviewsAction.java

public String getMyReview() {
    setResultType(LOGIN);//from   w  w  w . j  a  va  2s.  c o m

    if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID) != null) {
        if (AuthorizationManager.getInstance().isAuthorizedUser("GET_EMP_SEARCH_ALL", userRoleId)) {

            try {
                dataSourceDataProvider = DataSourceDataProvider.getInstance();
                //    setReviewList(dataSourceDataProvider.getInstance().getMyReviews());
                Map rolesMap = (Map) httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_MY_ROLES);
                if (rolesMap.containsValue("Sales"))
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(1));// 1 for employee and sales(flag 1 and 4)
                else
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(0));
                setCurrentAction("doAddReview");
                setResultType(SUCCESS);
            } catch (Exception ex) {
                //List errorMsgList = ExceptionToListUtility.errorMessages(ex);
                ex.printStackTrace();
                httpServletRequest.getSession(false).setAttribute("errorMessage", ex.toString());
                setResultType(ERROR);
            }

        }
    }
    return getResultType();
}

From source file:com.mss.mirage.employee.Reviews.ReviewsAction.java

public String deleteReview() {
    setResultType(LOGIN);/*from   w w w  . j ava 2  s .  c o  m*/

    if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID) != null) {
        if (AuthorizationManager.getInstance().isAuthorizedUser("GET_EMP_SEARCH_ALL", userRoleId)) {

            try {
                dataSourceDataProvider = DataSourceDataProvider.getInstance();
                setCurrentAction("doEditReview");
                //  setReviewList(dataSourceDataProvider.getInstance().getMyReviews());
                Map rolesMap = (Map) httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_MY_ROLES);
                if (rolesMap.containsValue("Sales"))
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(1));// 1 for employee and sales(flag 1 and 4)
                else
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(0));
                setCreatedBy(httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_USER_ID).toString());
                //setCurrentReview(ServiceLocator.getReviewsService().getReview(getReviewId()));
                // ServiceLocator.getReviewsService().deleteReview(getReviewId()); 
                setSearchReviewMap(dataSourceDataProvider.getInstance().getAllReviewTypes());
                boolean isDeleted = ServiceLocator.getReviewsService().deleteReview(getReviewId());
                //System.out.println("isDeleted-->"+isDeleted);
                if (!isDeleted) {
                    setResultMessage("<font color=green size=2px>Review deleted successfully.</font>");
                } else {
                    setResultMessage("<font color=red size=2px>Please try again.</font>");
                }
                setResultType(SUCCESS);
            } catch (Exception ex) {
                //List errorMsgList = ExceptionToListUtility.errorMessages(ex);
                ex.printStackTrace();
                setResultMessage("<font color=red size=2px>" + ex.getMessage() + "</font>");
                httpServletRequest.getSession(false).setAttribute("errorMessage", ex.toString());
                setResultType(ERROR);
            }

        }
    }
    httpServletRequest.setAttribute("resultMessage", getResultMessage());
    return getResultType();
}

From source file:org.nuclos.server.masterdata.ejb3.MasterDataFacadeBean.java

/**
 * read all dependant masterdata recursively if necessary, mark the read data
 * as removed/*from  www  . j av a 2s.  c  o  m*/
 *
 * @param sEntityName
 * @param mdvo
 */
@RolesAllowed("Login")
public DependantMasterDataMap readAllDependants(String sEntityName, Integer iId,
        DependantMasterDataMap mpDependants, Boolean bRemoved, String sParentEntity,
        Map<EntityAndFieldName, String> mpEntityAndParentEntityName) {
    Collection<EntityObjectVO> collmdvo = Collections.<EntityObjectVO>emptyList();

    // last subform in hierarchie found
    if (mpEntityAndParentEntityName.containsValue(sParentEntity)) {
        for (EntityAndFieldName eafn : mpEntityAndParentEntityName.keySet()) {
            // first subform in hierarchie found or
            // child subfrom found
            final String entity = eafn.getEntityName();
            EntityMetaDataVO eMeta = MetaDataServerProvider.getInstance().getEntity(entity);
            if (!eMeta.isEditable()) {
                continue;
            }
            if ((mpEntityAndParentEntityName.get(eafn) == null && sParentEntity == null)
                    || (mpEntityAndParentEntityName.get(eafn) != null
                            && mpEntityAndParentEntityName.get(eafn).equals(sParentEntity))) {
                if (!mpDependants.getData(entity).isEmpty()) {
                    collmdvo = CollectionUtils.emptyIfNull(mpDependants.getData(entity));
                } else {
                    if (iId != null) {
                        Collection<EntityObjectVO> col = CollectionUtils.transform(
                                getDependantMasterData(entity,
                                        helper.getForeignKeyFieldName(sEntityName, entity,
                                                mpEntityAndParentEntityName),
                                        iId),
                                new MasterDataToEntityObjectTransformer(entity));

                        collmdvo = CollectionUtils.emptyIfNull(col);
                        mpDependants.addAllData(entity, collmdvo);
                    }
                }

                for (EntityObjectVO dmdvo : collmdvo) {
                    if (bRemoved) {
                        dmdvo.flagRemove();
                    }
                    dmdvo.setDependants(readAllDependants(eafn.getEntityName(),
                            IdUtils.unsafeToId(dmdvo.getId()), dmdvo.getDependants(), dmdvo.isFlagRemoved(),
                            eafn.getEntityName(), mpEntityAndParentEntityName));
                }
            }
        }
    }
    return mpDependants;
}

From source file:com.mss.mirage.employee.Reviews.ReviewsAction.java

public String getMyReviewList() {
    setResultType(LOGIN);//from www .  j  av  a  2 s .c  o  m

    if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID) != null) {
        if (AuthorizationManager.getInstance().isAuthorizedUser("GET_EMP_SEARCH_ALL", userRoleId)) {

            try {

                setEndDate(DateUtility.getInstance().getCurrentMySqlDate());
                setOverlayReviewDate(DateUtility.getInstance().getCurrentMySqlDate());
                //  setDateAssigned(DateUtility.getInstance().getCurrentMySqlDate());
                //  setStartDate(DateUtility.getInstance().FirstDateOfLastMonth());
                setStartDate(DateUtility.getInstance().getDateOfLastYear());
                dataSourceDataProvider = DataSourceDataProvider.getInstance();

                Map rolesMap = (Map) httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_MY_ROLES);
                if (rolesMap.containsValue("Sales") && rolesMap.containsValue("Recruitment"))
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(3));// 3 for employee and sales(flag 1 and 4 and 5)
                else if (rolesMap.containsValue("Sales"))
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(1));// 1 for employee and sales(flag 1 and 4)
                else if (rolesMap.containsValue("Recruitment"))
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(2));// 2 for employee and sales(flag 1 and 5)
                else
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(0));
                //setSearchReviewMap(dataSourceDataProvider.getInstance().getAllReviewTypes());
                empId = Integer.parseInt(httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_EMP_ID).toString());
                if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_ROLE_NAME)
                        .toString().equalsIgnoreCase("Operations"))
                    setEmpnamesList(dataSourceDataProvider.getInstance()
                            .getEmployeeNamesByID((httpServletRequest.getSession(false)
                                    .getAttribute(ApplicationConstants.WORKING_COUNTRY).toString())));
                queryString = "SELECT  CONCAT(tblEmployee.FName,' ',tblEmployee.MName,'.',tblEmployee.LName) AS EmployeeName,ReviewType,EmpId,ReviewTypeId,tblEmpReview.Status,EmpComments,tblEmpReview.CreatdBy,tblEmpReview.CreatedDate,AttachmentName,AttachmentLocation,ReviewName,tblEmpReview.Id AS Id,HrComments,TLComments,ReviewDate,TLRating,HRRating,MaxPoints,ApprovedBy1,Approver1Date,Approver2Date,ApprovedBy2,tblEmpReview.UserId as UserId,tblEmpReview.HrStatus FROM tblEmpReview JOIN tblLkReviews ON (ReviewTypeId = tblLkReviews.Id) JOIN tblEmployee ON (tblEmpReview.UserId = tblEmployee.LoginId) WHERE 1=1 ";

                // queryString=queryString+" AND tblEmpReview.EmpId="+empId;  
                queryString = queryString + " AND tblEmpReview.UserId='"
                        + httpServletRequest.getSession(false)
                                .getAttribute(ApplicationConstants.SESSION_USER_ID).toString()
                        + "' AND CreatdBy='" + httpServletRequest.getSession(false)
                                .getAttribute(ApplicationConstants.SESSION_USER_ID).toString()
                        + "' ";

                queryString = queryString + " AND tblEmpReview.ReviewDate between '"
                        + DateUtility.getInstance().convertDateToMySql1(
                                DateUtility.getInstance().convertStringToMySql(getStartDate()))
                        + "' AND '" + DateUtility.getInstance().convertDateToMySql1(
                                DateUtility.getInstance().convertStringToMySql(getEndDate()))
                        + "'";

                queryString = queryString + " ORDER BY ReviewDate DESC";
                httpServletRequest.setAttribute(ApplicationConstants.EMP_REVIEWS_LIST, queryString);
                setResultType(SUCCESS);
            } catch (Exception ex) {
                //List errorMsgList = ExceptionToListUtility.errorMessages(ex);
                ex.printStackTrace();
                httpServletRequest.getSession(false).setAttribute("errorMessage", ex.toString());
                setResultType(ERROR);
            }

        }
    }
    return getResultType();
}

From source file:com.mss.mirage.employee.Reviews.ReviewsAction.java

public String doReviewSearch() {
    setResultType(LOGIN);//from   w  w w  .  ja  va 2  s  .  c om

    if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID) != null) {
        if (AuthorizationManager.getInstance().isAuthorizedUser("GET_EMP_SEARCH_ALL", userRoleId)) {

            try {
                setReviewFlag(getReviewFlag());
                setOverlayReviewDate(DateUtility.getInstance().getCurrentMySqlDate());
                dataSourceDataProvider = DataSourceDataProvider.getInstance();
                //  setReviewList(dataSourceDataProvider.getInstance().getMyReviews());
                Map rolesMap = (Map) httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_MY_ROLES);
                if (rolesMap.containsValue("Sales") && rolesMap.containsValue("Recruitment"))
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(3));// 3 for employee and sales(flag 1 and 4 and 5)
                else if (rolesMap.containsValue("Sales"))
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(1));// 1 for employee and sales(flag 1 and 4)
                else if (rolesMap.containsValue("Recruitment"))
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(2));// 2 for employee and sales(flag 1 and 5)
                else
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(0));
                //  setSearchReviewMap(dataSourceDataProvider.getInstance().getAllReviewTypes());
                empId = Integer.parseInt(httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_EMP_ID).toString());
                //  queryString="SELECT ReviewType,EmpId,ReviewTypeId,EmpComments,CreatdBy,CreatedDate,AttachmentName,AttachmentLocation,ReviewName,tblEmpReview.Id as Id FROM tblEmpReview JOIN tblLkReviews ON (ReviewTypeId = tblLkReviews.Id) where EmpId= "+empId ;
                queryString = "SELECT  CONCAT(tblEmployee.FName,' ',tblEmployee.MName,'.',tblEmployee.LName) AS EmployeeName,ReviewDate,ReviewType,EmpId,ReviewTypeId,EmpComments,tblEmpReview.CreatdBy,tblEmpReview.Status,tblEmpReview.CreatedDate,AttachmentName,AttachmentLocation,ReviewName,tblEmpReview.Id AS Id,HrComments,TLComments,TLRating,HRRating,MaxPoints,ApprovedBy1,Approver1Date,Approver2Date,ApprovedBy2,tblEmpReview.UserId as UserId,tblEmpReview.HrStatus FROM tblEmpReview JOIN tblLkReviews ON (ReviewTypeId = tblLkReviews.Id) JOIN tblEmployee ON (tblEmpReview.UserId = tblEmployee.LoginId) WHERE 1=1 ";
                //    if(httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_ROLE_NAME).toString().equalsIgnoreCase("Employee")&&getReviewFlag()==0){

                //   queryString=queryString+" AND tblEmpReview.UserId='"+httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID).toString()+"'";   
                queryString = queryString + " AND tblEmpReview.UserId='"
                        + httpServletRequest.getSession(false)
                                .getAttribute(ApplicationConstants.SESSION_USER_ID).toString()
                        + "' AND CreatdBy='" + httpServletRequest.getSession(false)
                                .getAttribute(ApplicationConstants.SESSION_USER_ID).toString()
                        + "' ";
                // }

                if (!getStartDate().equals("") && !getEndDate().equals("")) {
                    queryString = queryString + " AND tblEmpReview.ReviewDate between '"
                            + DateUtility.getInstance().convertDateToMySql1(
                                    DateUtility.getInstance().convertStringToMySql(getStartDate()))
                            + "' AND '" + DateUtility.getInstance().convertDateToMySql1(
                                    DateUtility.getInstance().convertStringToMySql(getEndDate()))
                            + "'";

                }
                if (!"".equals(getReviewType()) && getReviewType() != null) {
                    queryString = queryString + " AND ReviewTypeId=" + getReviewType();
                }
                /*if(!"".equals(getReviewStatus()) && getReviewStatus()!=null){
                queryString = queryString +" AND tblEmpReview.Status='"+ getReviewStatus()+"'";  
                }*/
                if (!"".equals(getReviewTlStatus()) && getReviewTlStatus() != null) {
                    queryString = queryString + " AND tblEmpReview.Status='" + getReviewTlStatus() + "'";
                }
                if (!"".equals(getReviewHrStatus()) && getReviewHrStatus() != null) {
                    queryString = queryString + " AND tblEmpReview.HrStatus='" + getReviewHrStatus() + "'";
                }

                if (!"".equals(getReviewName()) && getReviewName() != null) {
                    queryString = queryString + " AND ReviewName like '%" + getReviewName().trim() + "%'";
                }

                queryString = queryString + " ORDER BY ReviewDate DESC";
                httpServletRequest.setAttribute(ApplicationConstants.EMP_REVIEWS_LIST, queryString);
                setResultType(SUCCESS);
            } catch (Exception ex) {
                //List errorMsgList = ExceptionToListUtility.errorMessages(ex);
                ex.printStackTrace();
                httpServletRequest.getSession(false).setAttribute("errorMessage", ex.toString());
                setResultType(ERROR);
            }

        }
    }
    return getResultType();

}

From source file:com.mss.mirage.employee.Reviews.ReviewsAction.java

public String getInsertReview() {

    setResultType(LOGIN);/*from   ww w  .j  a va 2  s  .c  o  m*/

    if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID) != null) {
        userRoleId = Integer.parseInt(httpServletRequest.getSession(false)
                .getAttribute(ApplicationConstants.SESSION_ROLE_ID).toString());
        setEmpId(Integer.parseInt(httpServletRequest.getSession(false)
                .getAttribute(ApplicationConstants.SESSION_EMP_ID).toString()));
        setCreatedBy(httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID)
                .toString());
        //  setEmpId(empId);
        setResultType("accessFailed");
        if (AuthorizationManager.getInstance().isAuthorizedUser("GET_EMP_SEARCH_ALL", userRoleId)) {
            try {
                if (getSubmitFrom() == null) {

                    attachmentService = ServiceLocator.getAttachmentService();
                    //  setCurrentTask(tasksVTO);
                    generatedPath = null;
                    //   setCreatedBy(httpServletRequest.getSession(false).getAttribute("userId").toString());

                    //  setReviewList(dataSourceDataProvider.getInstance().getMyReviews());
                    Map rolesMap = (Map) httpServletRequest.getSession(false)
                            .getAttribute(ApplicationConstants.SESSION_MY_ROLES);
                    if (rolesMap.containsValue("Sales"))
                        setReviewList(dataSourceDataProvider.getInstance().getMyReviews(1));// 1 for employee and sales(flag 1 and 4)
                    else
                        setReviewList(dataSourceDataProvider.getInstance().getMyReviews(0));

                    if (getUploadFileName() != null) {
                        generatedPath = attachmentService
                                .generatePath(Properties.getProperty("Attachments.Path"), "Emp Reviews");
                        File targetDirectory = new File(generatedPath
                                + Properties.getProperty("OS.Compatabliliy.Download") + getUploadFileName());
                        setAttachmentLocation(targetDirectory.toString());
                        FileUtils.copyFile(getUpload(), targetDirectory);
                        setObjectType("Emp Reviews");
                    } else {
                        this.objectType = "NoFile";
                        this.setAttachmentLocation("");
                        this.setFilepath("");
                        this.attachmentName = "";
                    }
                    System.out.println("filename" + getAttachmentName());
                    System.out.println("filename" + getAttachmentLocation());
                    System.out.println("filename" + getUploadFileName());
                    if (!ServiceLocator.getReviewsService().getInsertReview(this)) {
                        setResultMessage("<font color=green size=2px>Review added successfully.</font>");
                    } else {
                        setResultMessage("<font color=red size=2px>Please try again.</font>");
                    }

                    //  ServiceLocator.getReviewsService().addAttachmentLocation(this);
                    httpServletRequest.getSession(false).setAttribute("resultMsg",
                            "Task Attachment uploaded successfully");
                    // System.out.println("After insertion");
                    setResultType(SUCCESS);

                }

                setResultType(SUCCESS);
            } catch (Exception ex) {
                //List errorMsgList = ExceptionToListUtility.errorMessages(ex);
                setResultMessage("<font color=red size=2px>" + ex.getMessage() + "</font>");
                httpServletRequest.getSession(false).setAttribute("errorMessage", ex.toString());
                setResultType(ERROR);
            }
        } //END-Authorization Checking
    } //Close Session Checking
    httpServletRequest.setAttribute("resultMessage", getResultMessage());
    return getResultType();

}

From source file:com.mss.mirage.employee.Reviews.ReviewsAction.java

public String teamReviewList() {
    setResultType(LOGIN);//w  w  w. j a  va 2 s.  co m

    if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID) != null) {
        String roleName = httpServletRequest.getSession(false)
                .getAttribute(ApplicationConstants.SESSION_ROLE_NAME).toString();
        int isManager = Integer.parseInt(httpServletRequest.getSession(false)
                .getAttribute(ApplicationConstants.SESSION_IS_USER_MANAGER).toString());
        int isTeamLead = Integer.parseInt(httpServletRequest.getSession(false)
                .getAttribute(ApplicationConstants.SESSION_IS_TEAM_LEAD).toString());

        setResultType("accessFailed");
        //  if(AuthorizationManager.getInstance().isAuthorizedUser("GET_EMP_SEARCH_ALL",userRoleId))
        if ((roleName.equalsIgnoreCase("Employee") && (isManager == 1 || isTeamLead == 1))
                || roleName.equalsIgnoreCase("Operations")) {

            try {
                setOverlayReviewDate(DateUtility.getInstance().getCurrentMySqlDate());
                // setReviewFlag(getReviewFlag());
                dataSourceDataProvider = DataSourceDataProvider.getInstance();
                setSearchReviewMap(dataSourceDataProvider.getInstance().getAllReviewTypes());
                setEndDate(DateUtility.getInstance().getCurrentMySqlDate());

                //  setDateAssigned(DateUtility.getInstance().getCurrentMySqlDate());
                //  setStartDate(DateUtility.getInstance().FirstDateOfLastMonth());
                setStartDate(DateUtility.getInstance().getDateOfLastYear());
                empId = Integer.parseInt(httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_EMP_ID).toString());
                //  if(httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_ROLE_NAME).toString().equalsIgnoreCase("Hr"))
                // setEmpnamesList(dataSourceDataProvider.getInstance().getEmployeeNamesByID((httpServletRequest.getSession(false).getAttribute(ApplicationConstants.WORKING_COUNTRY).toString())));
                // queryString="SELECT  CONCAT(tblEmployee.FName,' ',tblEmployee.MName,'.',tblEmployee.LName) AS EmployeeName,ReviewType,EmpId,ReviewTypeId,ReviewTypeId,EmpComments,tblEmpReview.CreatdBy,tblEmpReview.CreatedDate,AttachmentName,AttachmentLocation,ReviewName,tblEmpReview.Id AS Id,HrComments,TLComments,ReviewDate,tblEmpReview.STATUS,Approver1Comments FROM tblEmpReview JOIN tblLkReviews ON (ReviewTypeId = tblLkReviews.Id) JOIN tblEmployee ON (tblEmpReview.EmpId = tblEmployee.Id) WHERE 1=1 ";
                queryString = "SELECT  CONCAT(tblEmployee.FName,' ',tblEmployee.MName,'.',tblEmployee.LName) AS EmployeeName,ReviewDate,ReviewType,EmpId,ReviewTypeId,EmpComments,tblEmpReview.CreatdBy,tblEmpReview.Status,tblEmpReview.CreatedDate,AttachmentName,AttachmentLocation,ReviewName,tblEmpReview.Id AS Id,HrComments,TLComments,TLRating,HRRating,MaxPoints,ApprovedBy1,Approver1Date,Approver2Date,ApprovedBy2,tblEmpReview.UserId as UserId,HRStatus FROM tblEmpReview JOIN tblLkReviews ON (ReviewTypeId = tblLkReviews.Id) JOIN tblEmployee ON (tblEmpReview.UserId = tblEmployee.LoginId) WHERE 1=1 ";

                if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_ROLE_NAME)
                        .toString().equalsIgnoreCase("Employee")) {

                    setReviewList(dataSourceDataProvider.getInstance().getTeamReviewTypes(3));
                    // Map myTeamMemebrs = dataSourceDataProvider.getMyTeamMembersForReview(httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID).toString(),httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_MY_DEPT_ID).toString());
                    Map myTeamMemebrs = (Map) httpServletRequest.getSession(false)
                            .getAttribute(ApplicationConstants.SESSION_MY_TEAM_MAP);
                    //   Map myTeamMemebrs = dataSourceDataProvider.getMyTeamMembersForReview(httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID).toString(),httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_MY_DEPT_ID).toString());
                    //     List myTeamList = dataSourceDataProvider.getListFromMap(myTeamMemebrs);
                    String teamList = dataSourceDataProvider.getTeamLoginIdList(myTeamMemebrs);
                    setEmpnamesList(myTeamMemebrs);

                    // System.out.println("setEmpnamesList-->"+getEmpnamesList());
                    if (!"".equals(teamList)) {
                        queryString = queryString + " AND tblEmpReview.UserId IN(" + teamList + ")";
                    } else {
                        queryString = queryString + " AND tblEmpReview.UserId IN('')";
                    }

                } else if (httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_ROLE_NAME).toString()
                        .equalsIgnoreCase("Operations")) {
                    setReviewList(dataSourceDataProvider.getInstance().getTeamReviewTypes(2));

                    // setEmpnamesList(dataSourceDataProvider.getInstance().getEmployeeNamesByOperationsContactId((httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_EMP_ID).toString())));

                    //queryString=queryString+" AND tblEmployee.OpsContactId="+httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_EMP_ID); 

                    String teamList = "";
                    Map myTeamMemebrs;
                    // Map myTeamMemebrs = dataSourceDataProvider.getMyTeamMembersForReview(httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID).toString(),httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_MY_DEPT_ID).toString());
                    Map rolesMap = (Map) httpServletRequest.getSession(false)
                            .getAttribute(ApplicationConstants.SESSION_MY_ROLES);
                    if (rolesMap.containsValue("Admin")) {
                        myTeamMemebrs = dataSourceDataProvider.getAllEmployees();
                        teamList = dataSourceDataProvider.getTeamLoginIdList(myTeamMemebrs);
                        setEmpnamesList(myTeamMemebrs);
                        queryString = queryString + " AND tblEmpReview.UserId IN(" + teamList + ")";
                    } else {
                        setEmpnamesList(dataSourceDataProvider.getInstance()
                                .getEmployeeNamesByOperationsContactId((httpServletRequest.getSession(false)
                                        .getAttribute(ApplicationConstants.SESSION_EMP_ID).toString())));
                        queryString = queryString + " AND tblEmployee.OpsContactId=" + httpServletRequest
                                .getSession(false).getAttribute(ApplicationConstants.SESSION_EMP_ID);

                    }

                }

                queryString = queryString + " AND tblEmpReview.ReviewDate between '"
                        + DateUtility.getInstance().convertDateToMySql1(
                                DateUtility.getInstance().convertStringToMySql(getStartDate()))
                        + "' AND '" + DateUtility.getInstance().convertDateToMySql1(
                                DateUtility.getInstance().convertStringToMySql(getEndDate()))
                        + "'";

                queryString = queryString + " ORDER BY ReviewDate DESC";
                httpServletRequest.setAttribute(ApplicationConstants.EMP_REVIEWS_LIST, queryString);
                setResultType(SUCCESS);
            } catch (Exception ex) {
                //List errorMsgList = ExceptionToListUtility.errorMessages(ex);
                ex.printStackTrace();
                httpServletRequest.getSession(false).setAttribute("errorMessage", ex.toString());
                setResultType(ERROR);
            }

        }
    }
    return getResultType();
}

From source file:com.mss.mirage.employee.Reviews.ReviewsAction.java

public String doTeamReviewSearch() {
    setResultType(LOGIN);//from   ww w  .j  av  a  2 s.c  om
    // System.out.println("in team reviews list");
    if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID) != null) {
        String roleName = httpServletRequest.getSession(false)
                .getAttribute(ApplicationConstants.SESSION_ROLE_NAME).toString();
        int isManager = Integer.parseInt(httpServletRequest.getSession(false)
                .getAttribute(ApplicationConstants.SESSION_IS_USER_MANAGER).toString());
        int isTeamLead = Integer.parseInt(httpServletRequest.getSession(false)
                .getAttribute(ApplicationConstants.SESSION_IS_TEAM_LEAD).toString());

        setResultType("accessFailed");
        //  if(AuthorizationManager.getInstance().isAuthorizedUser("GET_EMP_SEARCH_ALL",userRoleId))
        if ((roleName.equalsIgnoreCase("Employee") && (isManager == 1 || isTeamLead == 1))
                || roleName.equalsIgnoreCase("Operations")) {

            try {
                // System.out.println("in team reviews list");
                //setReviewFlag(getReviewFlag());
                setOverlayReviewDate(DateUtility.getInstance().getCurrentMySqlDate());
                dataSourceDataProvider = DataSourceDataProvider.getInstance();
                // setReviewList(dataSourceDataProvider.getInstance().getMyReviews());
                Map rolesMap = (Map) httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_MY_ROLES);
                if (rolesMap.containsValue("Sales"))
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(1));// 1 for employee and sales(flag 1 and 4)
                else
                    setReviewList(dataSourceDataProvider.getInstance().getMyReviews(0));

                setSearchReviewMap(dataSourceDataProvider.getInstance().getAllReviewTypes());
                empId = Integer.parseInt(httpServletRequest.getSession(false)
                        .getAttribute(ApplicationConstants.SESSION_EMP_ID).toString());
                //  queryString="SELECT ReviewType,EmpId,ReviewTypeId,EmpComments,CreatdBy,CreatedDate,AttachmentName,AttachmentLocation,ReviewName,tblEmpReview.Id as Id FROM tblEmpReview JOIN tblLkReviews ON (ReviewTypeId = tblLkReviews.Id) where EmpId= "+empId ;
                //   queryString="SELECT  CONCAT(tblEmployee.FName,' ',tblEmployee.MName,'.',tblEmployee.LName) AS EmployeeName,ReviewDate,ReviewType,EmpId,ReviewTypeId,EmpComments,tblEmpReview.CreatdBy,tblEmpReview.Status,tblEmpReview.CreatedDate,AttachmentName,AttachmentLocation,ReviewName,tblEmpReview.Id AS Id,HrComments,Approver1Comments FROM tblEmpReview JOIN tblLkReviews ON (ReviewTypeId = tblLkReviews.Id) JOIN tblEmployee ON (tblEmpReview.EmpId = tblEmployee.Id) WHERE 1=1 ";
                queryString = "SELECT  CONCAT(tblEmployee.FName,' ',tblEmployee.MName,'.',tblEmployee.LName) AS EmployeeName,ReviewDate,ReviewType,EmpId,ReviewTypeId,EmpComments,tblEmpReview.CreatdBy,tblEmpReview.Status,tblEmpReview.CreatedDate,AttachmentName,AttachmentLocation,ReviewName,tblEmpReview.Id AS Id,HrComments,TLComments,TLRating,HRRating,MaxPoints,ApprovedBy1,Approver1Date,Approver2Date,ApprovedBy2,tblEmpReview.UserId as UserId,HRStatus FROM tblEmpReview JOIN tblLkReviews ON (ReviewTypeId = tblLkReviews.Id) JOIN tblEmployee ON (tblEmpReview.UserId = tblEmployee.LoginId) WHERE 1=1 ";

                //   String teamList = dataSourceDataProvider.getTeamLoginIdList(myTeamMemebrs);

                if (httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_ROLE_NAME)
                        .toString().equalsIgnoreCase("Employee")) {
                    setReviewList(dataSourceDataProvider.getInstance().getTeamReviewTypes(3));
                    Map myTeamMemebrs = (Map) httpServletRequest.getSession(false)
                            .getAttribute(ApplicationConstants.SESSION_MY_TEAM_MAP);
                    String teamList = dataSourceDataProvider.getTeamLoginIdList(myTeamMemebrs);
                    setEmpnamesList(myTeamMemebrs);
                    if (getEmpnameById().equals("-1")) {
                        if (!"".equals(teamList)) {
                            queryString = queryString + " AND tblEmpReview.UserId IN(" + teamList + ")";
                        } else {
                            queryString = queryString + " AND tblEmpReview.UserId IN('')";
                        }
                    } else {
                        queryString = queryString + " AND tblEmpReview.UserId IN('" + getEmpnameById() + "')";
                    }
                } else {
                    setReviewList(dataSourceDataProvider.getInstance().getTeamReviewTypes(2));
                    //                       setEmpnamesList(dataSourceDataProvider.getInstance().getEmployeeNamesByOperationsContactId((httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_EMP_ID).toString())));
                    //                      if(getEmpnameById().equals("-1")){
                    //                      queryString=queryString+" AND tblEmployee.OpsContactId="+httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_EMP_ID); 
                    //                        }else{
                    //                            queryString=queryString+" AND tblEmpReview.UserId IN('"+getEmpnameById() +"')";  
                    //                        }
                    String teamList = "";
                    Map myTeamMemebrs;
                    // Map myTeamMemebrs = dataSourceDataProvider.getMyTeamMembersForReview(httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_USER_ID).toString(),httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_MY_DEPT_ID).toString());
                    if (rolesMap.containsValue("Admin")) {
                        myTeamMemebrs = dataSourceDataProvider.getAllEmployees();
                        teamList = dataSourceDataProvider.getTeamLoginIdList(myTeamMemebrs);
                        setEmpnamesList(myTeamMemebrs);
                        if (getEmpnameById().equals("-1")) {
                            queryString = queryString + " AND tblEmpReview.UserId IN(" + teamList + ")";
                        } else {
                            queryString = queryString + " AND tblEmpReview.UserId IN('" + getEmpnameById()
                                    + "')";
                        }
                    } else {
                        setEmpnamesList(dataSourceDataProvider.getInstance()
                                .getEmployeeNamesByOperationsContactId((httpServletRequest.getSession(false)
                                        .getAttribute(ApplicationConstants.SESSION_EMP_ID).toString())));

                        // setEmpnamesList(dataSourceDataProvider.getInstance().getEmployeeNamesByWorkingCountry((httpServletRequest.getSession(false).getAttribute(ApplicationConstants.WORKING_COUNTRY).toString())));
                        if (getEmpnameById().equals("-1")) {
                            //  queryString = queryString+" AND  WorkingCountry LIKE '"+httpServletRequest.getSession(false).getAttribute(ApplicationConstants.WORKING_COUNTRY).toString()+"'";
                            queryString = queryString + " AND tblEmployee.OpsContactId=" + httpServletRequest
                                    .getSession(false).getAttribute(ApplicationConstants.SESSION_EMP_ID);
                        } else {
                            queryString = queryString + " AND tblEmpReview.UserId IN('" + getEmpnameById()
                                    + "')";
                        }
                    }

                }

                if (!getStartDate().equals("") && !getEndDate().equals("")) {
                    queryString = queryString + " AND tblEmpReview.ReviewDate between '"
                            + DateUtility.getInstance().convertDateToMySql1(
                                    DateUtility.getInstance().convertStringToMySql(getStartDate()))
                            + "' AND '" + DateUtility.getInstance().convertDateToMySql1(
                                    DateUtility.getInstance().convertStringToMySql(getEndDate()))
                            + "'";

                }
                if (!"".equals(getReviewType()) && getReviewType() != null) {
                    queryString = queryString + " AND ReviewTypeId=" + getReviewType();
                }
                /*   if(!"".equals(getReviewStatus()) && getReviewStatus()!=null){
                   queryString = queryString +" AND tblEmpReview.Status='"+ getReviewStatus()+"'";  
                  }*/
                if (!"".equals(getReviewTlStatus()) && getReviewTlStatus() != null) {
                    queryString = queryString + " AND tblEmpReview.Status='" + getReviewTlStatus() + "'";
                }
                if (!"".equals(getReviewHrStatus()) && getReviewHrStatus() != null) {
                    queryString = queryString + " AND tblEmpReview.HrStatus='" + getReviewHrStatus() + "'";
                }

                if (!"".equals(getReviewName()) && getReviewName() != null) {
                    queryString = queryString + " AND ReviewName like '%" + getReviewName().trim() + "%'";
                }
                /* if(!"-1".equals(getEmpnameById())){
                   int empId=  DataSourceDataProvider.getInstance().getEmpIdByLoginId(getEmpnameById());
                queryString = queryString +" AND tblEmpReview.EmpId="+ empId;  
                }    */
                /*  if(httpServletRequest.getSession(false).getAttribute(ApplicationConstants.SESSION_ROLE_NAME).toString().equalsIgnoreCase("Hr")){
                        if(getEmpnameById()!=-1){
                   queryString = queryString +" AND tblEmpReview.EmpId="+ getEmpnameById();  
                  }
                  }*/
                queryString = queryString + " ORDER BY ReviewDate DESC";
                httpServletRequest.setAttribute(ApplicationConstants.EMP_REVIEWS_LIST, queryString);
                setResultType(SUCCESS);
            } catch (Exception ex) {
                //List errorMsgList = ExceptionToListUtility.errorMessages(ex);
                ex.printStackTrace();
                httpServletRequest.getSession(false).setAttribute("errorMessage", ex.toString());
                setResultType(ERROR);
            }

        }
    }
    return getResultType();

}