Example usage for java.lang Integer equals

List of usage examples for java.lang Integer equals

Introduction

In this page you can find the example usage for java.lang Integer equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:eus.ixa.ixa.pipe.convert.AbsaSemEval.java

private static List<Opinion> getOpinionsBySentence(KAFDocument kaf, Integer sentNumber) {
    List<Opinion> opinionList = kaf.getOpinions();
    List<Opinion> opinionsBySentence = new ArrayList<>();
    for (Opinion opinion : opinionList) {
        if (sentNumber.equals(opinion.getOpinionExpression().getSpan().getFirstTarget().getSent())) {
            opinionsBySentence.add(opinion);
        }//from   ww  w.  jav  a 2s . co  m
    }
    return opinionsBySentence;
}

From source file:edu.cornell.kfs.vnd.batch.service.impl.VendorBatchServiceImpl.java

private VendorPhoneNumber getVendorPhoneNumber(VendorDetail vDetail,
        Integer vendorPhoneNumberGeneratedIdentifier) {
    if (CollectionUtils.isNotEmpty(vDetail.getVendorPhoneNumbers())) {
        for (VendorPhoneNumber vPhoneNumber : vDetail.getVendorPhoneNumbers()) {
            if (vendorPhoneNumberGeneratedIdentifier.equals(vPhoneNumber.getVendorPhoneGeneratedIdentifier())) {
                return vPhoneNumber;
            }/*from  ww w . j  av  a 2  s  . c  o m*/
        }
    }
    return new VendorPhoneNumber();
}

From source file:com.xumpy.thuisadmin.services.implementations.BedragenSrvImpl.java

@Override
@Transactional//from w ww . j  a  va2 s  .c o m
public OverzichtGroepBedragenTotal rapportOverzichtGroepBedragen(Integer typeGroepId,
        Integer typeGroepKostOpbrengst, Date beginDate, Date eindDate, Integer showBedragPublicGroep,
        OverzichtGroepBedragenTotal overzichtGroepBedragenTotal) {
    List<? extends Bedragen> lstBedragenInPeriode = bedragenDao.BedragInPeriode(beginDate, eindDate, null,
            showBedragPublicGroep, userInfo.getPersoon().getPk_id());

    Groepen groepenSrv = groepenDao.findOne(typeGroepId);

    Integer negatief = new Integer(0);

    if (typeGroepKostOpbrengst.equals(1)) {
        negatief = 0;
    } else {
        negatief = 1;
    }
    List<? extends Bedragen> lstBedragen = getBedragenInGroep(lstBedragenInPeriode, groepenSrv, negatief);

    List<OverzichtGroepBedragen> overzichtGroepBedragen = new ArrayList<OverzichtGroepBedragen>();

    BigDecimal somOverzicht = new BigDecimal(0);

    for (Bedragen bedrag : lstBedragen) {
        OverzichtGroepBedragen overzichtGroepBedrag = new OverzichtGroepBedragen();
        overzichtGroepBedrag.setWithBedrag(bedrag);

        overzichtGroepBedragen.add(overzichtGroepBedrag);
        somOverzicht = somOverzicht.add(overzichtGroepBedrag.getBedrag());
    }
    overzichtGroepBedragenTotal.setSomBedrag(somOverzicht);

    overzichtGroepBedragenTotal.setOverzichtGroepBedragen(overzichtGroepBedragen);

    return overzichtGroepBedragenTotal;
}

From source file:com.aurel.track.admin.project.ProjectConfigBL.java

/**
 * Validates the child status depending on parent status
 *///from  w  w w.  j  a v a2 s . co m
private static String validateStatus(boolean confirmSave, TProjectBean projectBean, Integer projectStatusOld,
        Integer projectStatusNew, Locale locale) {
    if (projectStatusOld != null && projectStatusNew != null && !projectStatusOld.equals(projectStatusNew)) {
        Integer statusFlagOld = SystemStatusBL
                .getStatusFlagForStatusID(TSystemStateBean.ENTITYFLAGS.PROJECTSTATE, projectStatusOld);
        Integer statusFlagNew = SystemStatusBL
                .getStatusFlagForStatusID(TSystemStateBean.ENTITYFLAGS.PROJECTSTATE, projectStatusNew);
        if (statusFlagOld != null && statusFlagNew != null
                && EqualUtils.notEqual(statusFlagOld, statusFlagNew)) {
            boolean notClosedToClosed = statusFlagOld.intValue() != TSystemStateBean.STATEFLAGS.CLOSED
                    && statusFlagNew.intValue() == TSystemStateBean.STATEFLAGS.CLOSED;
            boolean activeToInactive = statusFlagOld.intValue() == TSystemStateBean.STATEFLAGS.ACTIVE
                    && statusFlagNew.intValue() == TSystemStateBean.STATEFLAGS.INACTIVE;
            boolean closedToNotClosed = statusFlagOld.intValue() == TSystemStateBean.STATEFLAGS.CLOSED
                    && statusFlagNew.intValue() != TSystemStateBean.STATEFLAGS.CLOSED;
            boolean inactiveToActive = statusFlagOld.intValue() == TSystemStateBean.STATEFLAGS.INACTIVE
                    && statusFlagNew.intValue() == TSystemStateBean.STATEFLAGS.ACTIVE;
            Integer projectID = projectBean.getObjectID();
            if (notClosedToClosed || activeToInactive) {
                List<TProjectBean> inconsistenSubrojects = null;
                if (projectID != null) {
                    if (notClosedToClosed) {
                        inconsistenSubrojects = ProjectBL.loadActiveInactiveSubrojects(projectID);
                    } else {
                        inconsistenSubrojects = ProjectBL.loadActiveSubrojects(projectID);
                    }
                }
                if (inconsistenSubrojects != null && !inconsistenSubrojects.isEmpty()) {
                    if (confirmSave) {
                        for (TProjectBean childProjectBean : inconsistenSubrojects) {
                            changeDescendantsStatus(childProjectBean, activeToInactive, projectStatusNew);
                        }
                    } else {
                        String titleKey = null;
                        String errorReasonKey = null;
                        String errorResolutionKey = null;
                        if (notClosedToClosed) {
                            titleKey = "admin.project.err.closeOpenDescendantTitle";
                            errorReasonKey = "admin.project.err.closedDescendant";
                            errorResolutionKey = "admin.project.err.closeOpenDescendant";
                        } else {
                            titleKey = "admin.project.err.deactivateActivDescendantTitle";
                            errorReasonKey = "admin.project.err.activChildInInactiveParent";
                            errorResolutionKey = "admin.project.err.deactivateActivDescendant";
                        }
                        return ReleaseJSON.saveFailureJSON(JSONUtility.EDIT_ERROR_CODES.NEED_CONFIRMATION,
                                LocalizeUtil.getLocalizedTextFromApplicationResources(titleKey, locale),
                                LocalizeUtil.getLocalizedTextFromApplicationResources(errorReasonKey, locale)
                                        + " " + LocalizeUtil.getLocalizedTextFromApplicationResources(
                                                errorResolutionKey, locale));
                    }
                }
            } else {
                if (closedToNotClosed || inactiveToActive) {
                    Integer parentProjectID = projectBean.getParent();
                    if (parentProjectID != null) {
                        TProjectBean parentProjectBean = ProjectBL.loadByPrimaryKey(parentProjectID);
                        if (parentProjectBean != null) {
                            Integer projectStatusParent = parentProjectBean.getStatus();
                            if (projectStatusParent != null) {
                                Integer parentStatusFlag = SystemStatusBL.getStatusFlagForStatusID(
                                        TSystemStateBean.ENTITYFLAGS.PROJECTSTATE, projectStatusParent);
                                boolean inconsistentParent = false;
                                if (closedToNotClosed) {
                                    inconsistentParent = parentStatusFlag
                                            .intValue() == TSystemStateBean.STATEFLAGS.CLOSED;
                                } else {
                                    inconsistentParent = parentStatusFlag
                                            .intValue() == TSystemStateBean.STATEFLAGS.INACTIVE;
                                }
                                if (inconsistentParent) {
                                    if (confirmSave) {
                                        changeAscendentsStatus(parentProjectBean, inactiveToActive,
                                                projectStatusNew);
                                    } else {
                                        String titleKey = null;
                                        String errorReasonKey = null;
                                        String errorResolutionKey = null;
                                        if (closedToNotClosed) {
                                            titleKey = "admin.project.err.openClosedAncestorsTitle";
                                            errorReasonKey = "admin.project.err.closedDescendant";
                                            errorResolutionKey = "admin.project.err.openClosedAncestors";
                                        } else {
                                            titleKey = "admin.project.err.activateInactiveAscendentTitle";
                                            errorReasonKey = "admin.project.err.activChildInInactiveParent";
                                            errorResolutionKey = "admin.project.err.activateInactiveAscendent";
                                        }
                                        return ReleaseJSON.saveFailureJSON(
                                                JSONUtility.EDIT_ERROR_CODES.NEED_CONFIRMATION,
                                                LocalizeUtil.getLocalizedTextFromApplicationResources(titleKey,
                                                        locale),
                                                LocalizeUtil.getLocalizedTextFromApplicationResources(
                                                        errorReasonKey, locale) + " "
                                                        + LocalizeUtil.getLocalizedTextFromApplicationResources(
                                                                errorResolutionKey, locale));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}

From source file:it.eng.spagobi.profiling.dao.SbiUserDAOHibImpl.java

/**
 * Check if the user identifier in input is valid (for insertion or modification) for the user with the input integer id.
 * In case of user insertion, id should be null.
 * /*from w  w  w . j a v a 2s .  c om*/
 * @param userId The user identifier to check
 * @param id The id of the user to which the user identifier should be validated
 * 
 * @throws a EMFUserError with severity EMFErrorSeverity.ERROR and code 400 in case the user id is already in use
 */
public void checkUserId(String userId, Integer id) throws EMFUserError {
    // if id == 0 means you are in insert case check user name is not already used
    logger.debug("Check if user identifier " + userId + " is already present ...");
    Integer existingId = this.isUserIdAlreadyInUse(userId);
    if (id != null) {
        // case of user modification
        if (existingId != null && !id.equals(existingId)) {
            logger.error("User identifier is already present : [" + userId + "]");
            throw new EMFUserError(EMFErrorSeverity.ERROR, "400");
        }
    } else {
        // case of user insertion
        if (existingId != null) {
            logger.error("User identifier is already present : [" + userId + "]");
            throw new EMFUserError(EMFErrorSeverity.ERROR, "400");
        }
    }
    logger.debug("User identifier " + userId + " is valid.");
}

From source file:com.bizintelapps.bugtracker.service.impl.ReportServiceImpl.java

/**
 *
 * @param userId// ww w.  j  av a 2s  . co  m
 * @param ownerId
 * @param assignedBy
 * @param assignDate
 * @param eh
 */
private void addTaskAssigned(Integer userId, Integer ownerId, Integer assignedBy, double hoursSpend, double eh,
        boolean isNew, Date dt) {
    Calendar c = Calendar.getInstance();
    if (!isNew) {
        c.setTime(dt);
    }
    UserReport userReport1 = userReportDao.findByUserMonthAndYear(userId, c.get(Calendar.MONTH),
            c.get(Calendar.YEAR));
    if (userReport1 == null) { // new entity
        userReport1 = new UserReport(null, c.get(Calendar.MONTH), c.get(Calendar.YEAR), 0);
        userReport1.setUser(userId);
        userReportDao.create(userReport1);
        //userReport1 = userReportDao.findByUserMonthAndYear(userId, c.get(Calendar.MONTH), c.get(Calendar.YEAR));
    }
    if (ownerId.equals(userId) && assignedBy.equals(userId)) {
        userReport1.setCreatedSelfAssigned(userReport1.getCreatedSelfAssigned() + 1);
    } else if (assignedBy.equals(userId)) {
        userReport1.setSelfAssigned(userReport1.getSelfAssigned() + 1);
    } else {
        userReport1.setAssigned(userReport1.getAssigned() + 1);
    }

    userReport1.setTotalAssigned(userReport1.getTotalAssigned() + 1);
    userReport1.setEstimatedHours(userReport1.getEstimatedHours() + eh);
    userReport1.setHoursSpend(userReport1.getHoursSpend() + hoursSpend);
    userReportDao.update(userReport1);
}

From source file:com.jd.survey.web.security.DepartmentController.java

@Secured({ "ROLE_ADMIN" })
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "s", required = false) Integer showDeleteFailMessage,
        @RequestParam(value = "page", required = false) Integer page,
        @RequestParam(value = "size", required = false) Integer size, Principal principal, Model uiModel) {
    try {//  w ww  .  jav  a2s  .c o m
        if (page != null || size != null) {
            int sizeNo = size == null ? 10 : size.intValue();
            final int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo;
            uiModel.addAttribute("departments", surveySettingsService.department_findAll(firstResult, sizeNo));
            float nrOfPages = (float) surveySettingsService.department_getCount() / sizeNo;
            uiModel.addAttribute("maxPages",
                    (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
        } else {
            uiModel.addAttribute("departments", surveySettingsService.department_findAll());
        }
        if (showDeleteFailMessage != null && showDeleteFailMessage.equals(1)) {
            uiModel.addAttribute("showDeletedFailed", true);
        }

        return "security/departments/list";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

From source file:edu.ku.brc.specify.datamodel.SpecifyUser.java

/**
 * Returns the user principal, that is, that principal that is from the sub-class UserPrincipal.
 * This principal represents the user (as opposed as a user group) in JAAS 
 * @return the user principal//  w  w w .  ja  v  a  2 s. c  om
 */
@Transient
public SpPrincipal getUserPrincipal(final String groupClassStr, final Integer collectionID) {
    if (collectionID != null) {
        for (SpPrincipal principal : getSpPrincipals()) {
            if (groupClassStr.equals(principal.getGroupSubClass())) {
                Integer colId = SpPrincipal.getUserGroupScopeFromPrincipal(principal.getId());
                //Integer colId = principal.getScope() != null ? principal.getScope().getId() : null;
                //System.err.println(String.format("getUserPrincipal[%d]: [%d][%d]", principal.getId(), colId != null ? colId : -1, collectionID));
                if (colId != null && collectionID.equals(colId)) {
                    return principal;
                }
            }
        }
    }

    // Data inconsistency: we shouldn't really get here 
    // because every user must have its own UserPrincipal
    return null;
}

From source file:com.aurel.track.admin.user.person.PersonConfigBL.java

/**
 * Whether the number of users is exceeded
 * @param actualActive/*w  ww . jav a  2s.  co  m*/
 * @param selectedPersonIDList
 * @param maxActive
 * @param locale
 * @param newUserLevel
 * @param onlyFull only full active users or all active users
 * @param activateDisabledUsers wheter the users will be activated or the user level is set
 * @return error message if exceeded
 */
private static String activeUsersExceeded(int actualActive, List<Integer> selectedPersonIDList, int maxActive,
        Locale locale, Integer newUserLevel, boolean onlyFull, boolean activateDisabledUsers) {
    int numberOfPersonsToChange = 0;
    boolean addNewPerson = false;
    if (selectedPersonIDList == null || selectedPersonIDList.isEmpty()) {
        //add a new person
        numberOfPersonsToChange = 1;
        addNewPerson = true;
    } else {
        numberOfPersonsToChange = selectedPersonIDList.size();
    }
    if (actualActive + numberOfPersonsToChange > maxActive) {
        //possible exceeding
        int countActiveToAdd = 0;
        if (addNewPerson && addInCount(onlyFull, newUserLevel)) {
            //add a new person
            countActiveToAdd++;
        } else {
            //set user level for users or enable users
            List<TPersonBean> selectedPersons = PersonBL.loadByKeys(selectedPersonIDList);
            if (selectedPersons != null) {
                for (TPersonBean personBean : selectedPersons) {
                    Integer personUserLevel = personBean.getUserLevel();
                    boolean disabled = personBean.isDisabled();
                    if (activateDisabledUsers) {
                        //enable selected users
                        if (disabled && addInCount(onlyFull, personUserLevel)) {
                            //count only if the user to enable was disabled before
                            countActiveToAdd++;
                        }
                    } else {
                        if (!disabled && newUserLevel != null
                                && !newUserLevel.equals(TPersonBean.USERLEVEL.CLIENT)) {
                            //change user level of the selected active (not disabled) users
                            if (onlyFull) {
                                //count only the users which are about to be changed from easy to full
                                if (personUserLevel == null
                                        || TPersonBean.USERLEVEL.CLIENT.equals(personUserLevel)) {
                                    countActiveToAdd++;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (countActiveToAdd > 0 && actualActive + countActiveToAdd > maxActive) {
            //real exceeding
            String errorKey = null;
            if (onlyFull) {
                errorKey = "admin.user.manage.err.fullUsersExceed";
            } else {
                errorKey = "admin.user.manage.err.usersExceed";
            }
            return LocalizeUtil.getParametrizedString(errorKey, new Object[] { maxActive, actualActive },
                    locale);
        }
    }
    return null;
}

From source file:com.aurel.track.fieldType.runtime.custom.select.CustomDependentSelectRT.java

/**
 * Loads the settings for a specific field like default value(s),
 * datasources (for lists) etc./*w w w  .j  ava2s  . c  om*/
 * @see loadEditSettings
 * @param selectContext
 * @return
 */
@Override
public List loadCreateDataSource(SelectContext selectContext) {
    TWorkItemBean workItemBean = selectContext.getWorkItemBean();
    //get the parent options 
    Integer[] parentOptionIDs = CustomSelectUtil
            .getSelectedOptions(workItemBean.getAttribute(selectContext.getFieldID(), parentID));
    if (parentOptionIDs == null || parentOptionIDs.length == 0) {
        LOGGER.debug("No parent option seleced by loading the create data source for child");
        return new LinkedList();
    }
    TOptionBean optionBean = OptionBL.loadByPrimaryKey(parentOptionIDs[0]);
    Integer parentListID = optionBean.getList();
    //get the childNumber'th child list of the parentListID
    TListBean childListBean = ListBL.getChildList(parentListID, childNumber);
    if (childListBean != null) {
        Integer[] childOptionIDs = CustomSelectUtil.getSelectedOptions(
                workItemBean.getAttribute(selectContext.getFieldID(), selectContext.getParameterCode()));
        Integer childOption = null;
        if (childOptionIDs != null && childOptionIDs.length > 0) {
            childOption = childOptionIDs[0];
        }
        //TODO later filter first by configOptionRoleDAO.loadCreateOptionsByConfigForRoles(configID, person, project);
        List<ILabelBean> options = LocalizeUtil.localizeDropDownList(
                optionDAO.loadCreateDataSourceByListAndParents(childListBean.getObjectID(), parentOptionIDs),
                selectContext.getLocale());
        if (options != null && !options.isEmpty()) {
            boolean found = false;
            for (ILabelBean labelBean : options) {
                if (childOption != null && childOption.equals(labelBean.getObjectID())) {
                    found = true;
                    break;
                }
            }
            if (!found && selectContext.getFieldConfigBean().isRequiredString()) {
                workItemBean.setAttribute(selectContext.getFieldID(), selectContext.getParameterCode(),
                        new Integer[] { options.get(0).getObjectID() });
            }
        }
        return options;
    }
    return new LinkedList();
}