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:com.aurel.track.fieldType.runtime.system.text.SystemLookupBaseRT.java

/**
 * Get the ILabelBean by primary key //from  ww  w  .j  ava2  s  . com
 * @return
 */
public ILabelBean getLabelBean(Integer optionID, Locale locale) {
    if (optionID != null && (optionID.equals(MatcherContext.LOGGED_USER_SYMBOLIC)
            || optionID.equals(MatcherContext.PARAMETER))) {
        TPersonBean personBean = new TPersonBean();
        String localizedName;
        if (optionID.equals(MatcherContext.LOGGED_USER_SYMBOLIC)) {
            localizedName = MatcherContext.getLocalizedLoggedInUser(locale);
        } else {
            localizedName = MatcherContext.getLocalizedParameter(locale);
        }
        personBean.setLastName(localizedName);
        personBean.setObjectID(optionID);
        return personBean;
    }
    return PersonBL.loadByPrimaryKey(optionID);
}

From source file:gov.nih.nci.cabig.caaers.web.ae.ListAdverseEventsController.java

@Override
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {
    ListAdverseEventsCommand listAECommand = (ListAdverseEventsCommand) command;
    ModelAndView modelAndView = super.processFormSubmission(request, response, listAECommand, errors);

    ListAdverseEventsCommand listAECmd = (ListAdverseEventsCommand) command;

    String userId = SecurityUtils.getUserLoginName();
    Boolean isStaff = true;/*from   w  w  w. j  av a2 s.  co m*/
    Person loggedInPerson = personDao.getByLoginId(userId);
    if (loggedInPerson instanceof Investigator) {
        isStaff = false;
    }
    request.setAttribute("isStaff", isStaff);
    listAECmd.setUserId(userId);
    boolean noStudy = listAECmd.getStudy() == null;
    boolean noParticipant = listAECmd.getParticipant() == null;

    if (!noStudy && noParticipant) {
        listAECmd.setStudyCentric(true);
        listAECmd.setParticipantCentric(false);
    } else if (noStudy && !noParticipant) {
        listAECmd.setParticipantCentric(true);
        listAECmd.setStudyCentric(false);
    } else {
        listAECmd.setStudyCentric(false);
        listAECmd.setParticipantCentric(false);
    }

    if (!errors.hasErrors()) {
        //if there is no validation error, update the report submitability
        listAECmd.updateSubmittability();
        listAECmd.updateSubmittabilityBasedOnReportStatus();
        listAECmd.updateOptions();
    }

    processPaginationSubmission(request, listAECommand, modelAndView);
    String numberOfResultsPerPage = (String) findInRequest(request, "numberOfResultsPerPage");
    if (numberOfResultsPerPage == null)
        modelAndView.getModel().put("numberOfResultsPerPage", 5);
    else
        modelAndView.getModel().put("numberOfResultsPerPage", Integer.parseInt(numberOfResultsPerPage));

    Integer currentPageNumber = (Integer) request.getSession().getAttribute(CURRENT_PAGE_NUMBER);
    if (currentPageNumber.equals(1))
        modelAndView.getModel().put("isFirstPage", true);
    else
        modelAndView.getModel().put("isFirstPage", false);
    if (isLastPage(request, listAECommand))
        modelAndView.getModel().put("isLastPage", true);
    else
        modelAndView.getModel().put("isLastPage", false);

    return modelAndView;
}

From source file:de.ingrid.importer.udk.strategy.v1.IDCStrategy1_0_5.java

private void updateSysList() throws Exception {
    if (log.isInfoEnabled()) {
        log.info("Updating sys_list...");
    }/*  w  w w  . j  a v a 2 s. c  o  m*/

    // ---------------------------------------------

    int lstId = UtilsCountryCodelist.COUNTRY_SYSLIST_ID;
    if (log.isInfoEnabled()) {
        log.info("Updating syslist " + lstId + " Country ...");
    }

    // clean up, to guarantee no old values !
    sqlStr = "DELETE FROM sys_list where lst_id = " + lstId;
    jdbc.executeUpdate(sqlStr);

    // german syslist
    HashMap<Integer, String> newSyslistCountry_de = UtilsCountryCodelist.countryCodelist_de;
    // english syslist
    HashMap<Integer, String> newSyslistCountry_en = UtilsCountryCodelist.countryCodelist_en;

    Iterator<Integer> itr = newSyslistCountry_de.keySet().iterator();
    while (itr.hasNext()) {
        Integer key = itr.next();
        // german version
        String isDefault = (key.equals(UtilsCountryCodelist.NEW_COUNTRY_KEY_GERMANY)) ? "'Y'" : "'N'";
        jdbc.executeUpdate(
                "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES ("
                        + getNextId() + ", " + lstId + ", " + key + ", 'de', '" + newSyslistCountry_de.get(key)
                        + "', 0, " + isDefault + ")");
        // english version
        isDefault = (key.equals(UtilsCountryCodelist.NEW_COUNTRY_KEY_GBR)) ? "'Y'" : "'N'";
        jdbc.executeUpdate(
                "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES ("
                        + getNextId() + ", " + lstId + ", " + key + ", 'en', '" + newSyslistCountry_en.get(key)
                        + "', 0, " + isDefault + ")");
    }

    // ---------------------------------------------

    lstId = UtilsLanguageCodelist.LANGUAGE_SYSLIST_ID;
    if (log.isInfoEnabled()) {
        log.info("Updating syslist " + lstId + " Language ...");
    }

    // clean up, to guarantee no old values !
    sqlStr = "DELETE FROM sys_list where lst_id = " + lstId;
    jdbc.executeUpdate(sqlStr);

    // german syslist
    HashMap<Integer, String> newSyslistLanguage_de = UtilsLanguageCodelist.languageCodelist_de;
    // english syslist
    HashMap<Integer, String> newSyslistLanguage_en = UtilsLanguageCodelist.languageCodelist_en;

    itr = newSyslistLanguage_de.keySet().iterator();
    while (itr.hasNext()) {
        Integer key = itr.next();
        // german version
        String isDefault = (key.equals(UtilsLanguageCodelist.IGC_CODE_GERMAN)) ? "'Y'" : "'N'";
        jdbc.executeUpdate(
                "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES ("
                        + getNextId() + ", " + lstId + ", " + key + ", 'de', '" + newSyslistLanguage_de.get(key)
                        + "', 0, " + isDefault + ")");
        // english version
        isDefault = (key.equals(UtilsLanguageCodelist.IGC_CODE_ENGLISH)) ? "'Y'" : "'N'";
        jdbc.executeUpdate(
                "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES ("
                        + getNextId() + ", " + lstId + ", " + key + ", 'en', '" + newSyslistLanguage_en.get(key)
                        + "', 0, " + isDefault + ")");
    }

    if (log.isInfoEnabled()) {
        log.info("Updating sys_list... done");
    }
}

From source file:org.gatein.sso.agent.opensso.OpenSSOAgentImpl.java

/**
 * Validation of various criterias in {@link CDMessageContext}
 *
 * @param httpRequest/*  www .j  av a 2  s.co m*/
 * @param context
 */
protected void validateCDMessageContext(HttpServletRequest httpRequest, CDMessageContext context) {
    // First validate if context contains success
    if (!context.getSuccess()) {
        throwIllegalStateException(
                "CDMessageContext contains success=false. Check SAML message from CDCServlet");
    }

    // Now validate inResponseTo
    Integer inResponseToFromCDC = context.getInResponseTo();
    Integer inResponseToFromSession = (Integer) httpRequest.getSession().getAttribute(IN_RESPONSE_TO_ATTR);
    if (inResponseToFromSession == null || inResponseToFromCDC == null
            || !inResponseToFromCDC.equals(inResponseToFromSession)) {
        throwIllegalStateException("inResponseTo from CDC message is " + inResponseToFromCDC
                + ", inResponseTo from Http session is " + inResponseToFromSession
                + ". Both should have same value");
    }

    // TODO: validate dates notBefore and notOnOrAfter

    // Validate that token is present
    if (context.getSsoToken() == null) {
        throwIllegalStateException("No token found in CDMessageContext. Check SAML message from CDCServlet");
    }
}

From source file:com.logicaalternativa.ejemplomock.repository.mock.PromotionRepositoryMock.java

private int findIndex(final Integer idPromotion) {

    if (idPromotion == null || getPromotions() == null) {

        return -1;

    }/* w w  w  .j a  v a2  s  .c  om*/

    for (int i = 0; i < getPromotions().size(); i++) {

        final Promotion promotion = getPromotions().get(i);

        final Integer idProIntegerReg = promotion != null ? promotion.getIdPromotion() : null;

        if (idPromotion.equals(idProIntegerReg)) {

            return i;

        }

    }

    return -1;

}

From source file:business.controllers.SelectionController.java

@PreAuthorize("isAuthenticated() and " + "hasRole('requester') and " + "hasPermission(#id, 'isRequester')")
@RequestMapping(value = "/requests/{id}/selection/csv", method = RequestMethod.POST)
public Integer uploadExcerptSelection(UserAuthenticationToken user, @PathVariable String id,
        @RequestParam("flowFilename") String name, @RequestParam("flowTotalChunks") Integer chunks,
        @RequestParam("flowChunkNumber") Integer chunk, @RequestParam("flowIdentifier") String flowIdentifier,
        @RequestParam("file") MultipartFile file) {
    log.info("POST /requests/" + id + "/selection/csv: chunk " + chunk + " / " + chunks);

    Task task = requestService.getTaskByRequestId(id, "data_delivery");

    Integer selectedCount = 0;//from   w  w  w .  ja  va 2s. c om

    File attachment = fileService.uploadPart(user.getUser(), name, File.AttachmentType.EXCERPT_SELECTION, file,
            chunk, chunks, flowIdentifier);
    if (attachment != null) {

        // process list
        try {
            InputStream input = fileService.getInputStream(attachment);
            List<Integer> selected = excerptListService.processExcerptSelection(input);
            selectedCount = selected.size();
            try {
                input.close();
            } catch (IOException e) {
                log.error("Error while closing input stream: " + e.getMessage());
            }
            // if not exception thrown, save selection
            ExcerptList excerptList = excerptListService.findByProcessInstanceId(id);
            excerptList.deselectAll();
            log.info("Saving selection.");
            for (Integer number : selected) {
                ExcerptEntry entry = excerptList.getEntries().get(number - 1);
                if (entry == null) {
                    log.warn("Null entry in selection (for number '" + number + "').");
                } else if (!number.equals(entry.getSequenceNumber())) {
                    log.error("Excerpt list " + excerptList.getId() + " is inconsistent: "
                            + "entry with sequence number " + entry.getSequenceNumber() + " at index "
                            + number);
                    throw new ExcerptListUploadError("Excerpt list is inconsistent.");
                } else {
                    entry.setSelected(true);
                }
            }
            excerptListService.save(excerptList);
            log.info("Done.");
        } catch (RuntimeException e) {
            // revert uploading
            fileService.removeAttachment(attachment);
            throw e;
        }
    }
    return selectedCount;
}

From source file:org.openmrs.module.diagnosiscapturerwanda.DiagnosisCaptureController.java

/**
 * utility build the primary diagnosis obs tree and attach to encounter
 *///from   ww w .j  a v  a  2 s.  c  o  m
private Encounter constructDiagnosisObsTree(Encounter enc, Concept diagnosis, Integer primarySecondary,
        Concept confirmedSusptectedAnswer, String other) {

    //determine primary or secondary; 0 = primary 1=secondary
    Concept c = primarySecondary.equals(0)
            ? MetadataDictionary.CONCEPT_SET_PRIMARY_CARE_PRIMARY_DIAGNOSIS_CONSTRUCT
            : MetadataDictionary.CONCEPT_SET_PRIMARY_CARE_SECONDARY_DIAGNOSIS_CONSTRUCT;

    //build the obsGroup
    Obs oParent = DiagnosisUtil.buildObs(enc.getPatient(), c, enc.getEncounterDatetime(), null, null, null,
            enc.getLocation());
    //build the children
    Obs oDiagnosis = DiagnosisUtil.buildObs(enc.getPatient(), MetadataDictionary.CONCEPT_PRIMARY_CARE_DIAGNOSIS,
            enc.getEncounterDatetime(), diagnosis, null, null, enc.getLocation());
    Obs oConfirmedSuspected = DiagnosisUtil.buildObs(enc.getPatient(),
            MetadataDictionary.CONCEPT_DIAGNOSIS_CONFIRMED_SUSPECTED, enc.getEncounterDatetime(),
            confirmedSusptectedAnswer, null, null, enc.getLocation());
    Obs oOther = DiagnosisUtil.buildObs(enc.getPatient(), MetadataDictionary.CONCEPT_DIAGNOSIS_NON_CODED,
            enc.getEncounterDatetime(), null, other, null, enc.getLocation());

    oParent.addGroupMember(oDiagnosis);
    oParent.addGroupMember(oConfirmedSuspected);
    oParent.addGroupMember(oOther);

    enc.addObs(oParent);

    return enc;
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.AccountingTimeMatcherRT.java

/**
 * Whether the value matches or not//from www .  j a v a2s.c om
 * 
 * @param attributeValue
 * @return
 */
@Override
public boolean match(Object attributeValue) {
    Boolean nullMatch = nullMatcher(attributeValue);
    if (nullMatch != null) {
        return nullMatch.booleanValue();
    }
    if (attributeValue == null || matchValue == null) {
        return false;
    }
    AccountingTimeTO attributeValueAccountingTime = null;
    AccountingTimeTO matcherValueAccountingTime = null;
    try {
        attributeValueAccountingTime = (AccountingTimeTO) attributeValue;
    } catch (Exception e) {
        LOGGER.error("Converting the attribute value " + attributeValue + " of type "
                + attributeValue.getClass().getName() + " to AccountingTimeTO failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
        return false;
    }
    try {
        matcherValueAccountingTime = (AccountingTimeTO) matchValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the matcher value " + matchValue + " of type " + matchValue.getClass().getName()
                + " to AccountingTimeTO failed with " + e.getMessage(), e);
        return false;
    }

    Double attributeValueDouble = attributeValueAccountingTime.getValue();
    Double matcherValueDouble = matcherValueAccountingTime.getValue();
    if (attributeValueDouble == null || matcherValueDouble == null) {
        return false;
    }
    Integer attributeValueUnit = attributeValueAccountingTime.getUnit();
    Integer matcherValueUnit = matcherValueAccountingTime.getUnit();
    if (attributeValueUnit == null) {
        attributeValueUnit = TIMEUNITS.HOURS;
    }
    if (matcherValueUnit == null) {
        matcherValueUnit = TIMEUNITS.HOURS;
    }
    if (!attributeValueUnit.equals(matcherValueUnit)) {
        if (attributeValueUnit.intValue() != TIME_UNIT.HOUR) {

            attributeValueDouble = AccountingBL.transformToTimeUnits(attributeValueDouble,
                    this.getHourPerWorkday(), attributeValueUnit, TIME_UNIT.HOUR).doubleValue();
        }
        if (matcherValueUnit.intValue() != TIME_UNIT.HOUR) {
            matcherValueDouble = AccountingBL.transformToTimeUnits(matcherValueDouble, this.getHourPerWorkday(),
                    matcherValueUnit, TIME_UNIT.HOUR).doubleValue();
        }
    }
    switch (relation) {
    case MatchRelations.EQUAL:
        return (Double.doubleToRawLongBits(attributeValueDouble.doubleValue())
                - Double.doubleToRawLongBits(matcherValueDouble.doubleValue()) == 0);
    case MatchRelations.NOT_EQUAL:
        return (Double.doubleToRawLongBits(attributeValueDouble.doubleValue())
                - Double.doubleToRawLongBits(matcherValueDouble.doubleValue()) != 0);
    case MatchRelations.GREATHER_THAN:
        return attributeValueDouble.doubleValue() > matcherValueDouble.doubleValue();
    case MatchRelations.GREATHER_THAN_EQUAL:
        return attributeValueDouble.doubleValue() >= matcherValueDouble.doubleValue();
    case MatchRelations.LESS_THAN:
        return attributeValueDouble.doubleValue() < matcherValueDouble.doubleValue();
    case MatchRelations.LESS_THAN_EQUAL:
        return attributeValueDouble.doubleValue() <= matcherValueDouble.doubleValue();
    default:
        return false;
    }
}

From source file:de.kapsi.net.daap.bio.DaapServerBIO.java

/**
 * Retrieves a DaapConnection for a session ID or <code>null</code>.
 * //from   w  ww.j a  v  a 2 s . co m
 * <p>DO NOT CALL THIS METHOD! THIS METHOD IS ONLY PUBLIC 
 * DUE TO SOME DESIGN ISSUES!</p>
 * 
 * @param sessionId a session ID
 * @return a DaapConnection or <code>null</code>
 */
public DaapConnection getConnection(Integer sessionId) {
    synchronized (connections) {
        Iterator it = connections.iterator();
        while (it.hasNext()) {
            DaapConnection connection = (DaapConnection) it.next();
            DaapSession session = connection.getSession(false);
            if (session != null) {
                Integer sid = session.getSessionId();
                if (sid.equals(sessionId)) {
                    return connection;
                }
            }
        }
        return null;
    }
}

From source file:org.elasticsearch.river.jolokia.strategy.simple.SimpleRiverSource.java

public void fetch(String hostname) {
    String url = "?";
    String objectName = "?";
    String[] attributeNames = new String[] {};
    try {/*from w ww.  ja v a  2  s.  co m*/
        String catalogue = getCatalogue(hostname);
        String host = getHost(hostname);
        String port = getPort(hostname);
        String userName = getUser(hostname);
        String password = getPassword(hostname);
        url = getUrl((null == port ? host : (host + ":" + port)) + catalogue);
        objectName = setting.getObjectName();
        Map<String, String> transforms = getAttributeTransforms();

        attributeNames = getAttributeNames();

        J4pClient j4pClient = useBasicAuth(userName, password)
                ? J4pClient.url(url).user(userName).password(password).build()
                : J4pClient.url(url).build();

        J4pReadRequest req = new J4pReadRequest(objectName, attributeNames);

        logger.info("Executing {}, {}, {}", url, objectName, attributeNames);
        J4pReadResponse resp = j4pClient.execute(req);

        if (setting.getOnlyUpdates() && null != resp.asJSONObject().get("value")) {
            Integer oldValue = setting.getLastValueAsHash();
            setting.setLastValueAsHash(resp.asJSONObject().get("value").toString().hashCode());
            if (null != oldValue && oldValue.equals(setting.getLastValueAsHash())) {
                logger.info("Skipping " + objectName + " since no values has changed");
                return;
            }
        }

        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("rhino");

        for (ObjectName object : resp.getObjectNames()) {
            StructuredObject reading = createReading(host, catalogue, getObjectName(object));
            for (String attrib : attributeNames) {
                try {
                    Object v = resp.getValue(object, attrib);

                    // Transform
                    if (transforms.containsKey(attrib)) {
                        String function = transforms.get(attrib)
                                .replaceFirst("^\\s*function\\s+([^\\s\\(]+)\\s*\\(.*$", "$1");
                        engine.eval(transforms.get(attrib));
                        v = convert(engine.eval(function + "(" + JSONValue.toJSONString(v) + ")"));
                    }

                    reading.source(setting.getPrefix() + attrib, v);
                } catch (Exception e) {
                    reading.source(ERROR_PREFIX + setting.getPrefix() + attrib, e.getMessage());
                }
            }
            createReading(reading);
        }
    } catch (Exception e) {
        try {
            logger.info("Failed to execute request {} {} {}", url, objectName, attributeNames, e);
            StructuredObject reading = createReading(getHost(hostname), getCatalogue(hostname),
                    setting.getObjectName());
            reading.source(ERROR_TYPE, e.getClass().getName());
            reading.source(ERROR, e.getMessage());
            int rc = HttpStatus.SC_INTERNAL_SERVER_ERROR;
            if (e instanceof J4pRemoteException) {
                rc = ((J4pRemoteException) e).getStatus();
            }
            reading.source(RESPONSE, rc);
            createReading(reading);
        } catch (Exception e1) {
            logger.error("Failed to store error message", e1);
        }
    }
}