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.mirth.connect.server.controllers.DefaultChannelController.java

@Override
public List<ChannelSummary> getChannelSummary(Map<String, ChannelHeader> clientChannels,
        boolean ignoreNewChannels) throws ControllerException {
    logger.debug("getting channel summary");
    List<ChannelSummary> channelSummaries = new ArrayList<ChannelSummary>();

    try {/*w  w w  .ja va  2  s.c  om*/
        Map<String, Channel> serverChannels = new HashMap<String, Channel>();
        List<Channel> channels = getChannels(ignoreNewChannels ? clientChannels.keySet() : null);
        for (Channel serverChannel : channels) {
            serverChannels.put(serverChannel.getId(), serverChannel);
        }

        Map<String, Long> localChannelIds;
        if (donkey == null) {
            donkey = Donkey.getInstance();
        }

        DonkeyDao dao = donkey.getDaoFactory().getDao();

        try {
            localChannelIds = dao.getLocalChannelIds();
        } finally {
            dao.close();
        }

        /*
         * Iterate through the cached channel list and check if a channel with the id exists on
         * the server. If it does, and the revision numbers aren't equal, then add the channel
         * to the updated list. If the cached deployed date is outdated, also add the updated
         * deployed channel info (date and revision delta). Otherwise, if the channel is not
         * found, add it to the deleted list.
         */
        for (String cachedChannelId : clientChannels.keySet()) {
            ChannelSummary summary = new ChannelSummary(cachedChannelId);
            boolean addSummary = false;
            if (localChannelIds != null) {
                summary.getChannelStatus().setLocalChannelId(localChannelIds.get(cachedChannelId));
            }

            if (serverChannels.containsKey(cachedChannelId)) {
                ChannelHeader header = clientChannels.get(cachedChannelId);

                // If the revision numbers aren't equal, add the updated Channel object
                Integer revision = serverChannels.get(cachedChannelId).getRevision();
                boolean channelOutdated = !revision.equals(header.getRevision());
                if (channelOutdated) {
                    summary.getChannelStatus().setChannel(serverChannels.get(cachedChannelId));
                    addSummary = true;
                }

                DeployedChannelInfo deployedChannelInfo = getDeployedChannelInfoById(cachedChannelId);
                boolean serverChannelDeployed = deployedChannelInfo != null;
                boolean clientChannelDeployed = header.getDeployedDate() != null;

                if (!serverChannelDeployed) {
                    if (clientChannelDeployed) {
                        // The channel is not deployed, but the client still thinks it's deployed
                        summary.setUndeployed(true);
                        addSummary = true;
                    }
                } else {
                    if (channelOutdated || !clientChannelDeployed
                            || deployedChannelInfo.getDeployedDate().compareTo(header.getDeployedDate()) != 0) {
                        // The channel is deployed, but the client doesn't think it's deployed, or it's deployed date/revision is outdated
                        summary.getChannelStatus()
                                .setDeployedRevisionDelta(revision - deployedChannelInfo.getDeployedRevision());
                        summary.getChannelStatus().setDeployedDate(deployedChannelInfo.getDeployedDate());
                        addSummary = true;
                    }

                    summary.getChannelStatus().setCodeTemplatesChanged(
                            !codeTemplateController.getCodeTemplateRevisionsForChannel(cachedChannelId)
                                    .equals(deployedChannelInfo.getCodeTemplateRevisions()));
                    if (summary.getChannelStatus().isCodeTemplatesChanged() != header
                            .isCodeTemplatesChanged()) {
                        addSummary = true;
                    }
                }
            } else {
                // If a channel with the ID is never found on the server, add it as deleted
                summary.setDeleted(true);
                addSummary = true;
            }

            if (addSummary) {
                channelSummaries.add(summary);
            }
        }

        /*
         * Add summaries for any entries on the server but not in the client's cache.
         */
        for (String serverChannelId : serverChannels.keySet()) {
            if (!clientChannels.containsKey(serverChannelId)) {
                ChannelSummary summary = new ChannelSummary(serverChannelId);
                summary.getChannelStatus().setChannel(serverChannels.get(serverChannelId));
                summary.getChannelStatus()
                        .setLocalChannelId(com.mirth.connect.donkey.server.controllers.ChannelController
                                .getInstance().getLocalChannelId(serverChannelId));

                DeployedChannelInfo deployedChannelInfo = getDeployedChannelInfoById(serverChannelId);
                boolean serverChannelDeployed = deployedChannelInfo != null;
                if (serverChannelDeployed) {
                    summary.getChannelStatus()
                            .setDeployedRevisionDelta(serverChannels.get(serverChannelId).getRevision()
                                    - deployedChannelInfo.getDeployedRevision());
                    summary.getChannelStatus().setDeployedDate(deployedChannelInfo.getDeployedDate());

                    if (!codeTemplateController.getCodeTemplateRevisionsForChannel(serverChannelId)
                            .equals(deployedChannelInfo.getCodeTemplateRevisions())) {
                        summary.getChannelStatus().setCodeTemplatesChanged(true);
                    }
                }

                channelSummaries.add(summary);
            }
        }

        return channelSummaries;
    } catch (Exception e) {
        throw new ControllerException(e);
    }
}

From source file:org.kuali.coeus.s2sgen.impl.generate.S2SBaseFormGenerator.java

/**
 *
 * This method is used to get the child question answer for a particular Questionnaire question
 * question based on the question id./*ww w . j a v  a2  s  .  co  m*/
 * @param parentQuestionSeqId
 *            the parentQuestion id to be passed.
 * @param questionSeqId
 *            the question id to be passed.
 * @return returns the answer for a particular
 *         question based on the question id passed.
 */
protected String getChildQuestionAnswer(Integer parentQuestionSeqId, Integer questionSeqId,
        List<? extends AnswerHeaderContract> answerHeaders) {
    for (AnswerHeaderContract answerHeader : answerHeaders) {
        if (answerHeader != null) {
            List<? extends AnswerContract> answerDetails = answerHeader.getAnswers();
            for (AnswerContract answers : answerDetails) {
                if (answers.getParentAnswers() != null) {
                    AnswerContract parentAnswer = answers.getParentAnswers().get(0);
                    if (questionSeqId
                            .equals(getQuestionAnswerService().findQuestionById(answers.getQuestionId())
                                    .getQuestionSeqId())
                            && parentQuestionSeqId.equals(getQuestionAnswerService()
                                    .findQuestionById(parentAnswer.getQuestionId()).getQuestionSeqId())) {
                        return answers.getAnswer();
                    }
                }
            }
        }
    }

    return null;

}

From source file:com.digitalizat.control.TdocController.java

@RequestMapping(value = "guardarFichero", method = RequestMethod.POST)
public String guardarFichero(@RequestParam(value = "file", required = true) CommonsMultipartFile file,
        @RequestParam(value = "idFolder", required = true) Integer idFolder, HttpServletRequest request,
        Model m) throws FileNotFoundException, IOException, Exception {
    HttpSession sesion = request.getSession();
    User usuarioLogado;//ww  w .java2s.  c om
    if (sesion.getAttribute("user") == null && (!(Boolean) sesion.getAttribute("logged"))) {
        throw new Exception("Login requerido");
    } else {
        usuarioLogado = (User) sesion.getAttribute("user");
    }
    File localFile = new File(serverProperties.getRutaGestorDocumental() + file.getOriginalFilename());
    FileOutputStream os;
    os = new FileOutputStream(localFile);
    os.write(file.getBytes());

    Document doc = new Document();
    doc.setBasePath(serverProperties.getRutaGestorDocumental());
    doc.setPathdoc("/" + usuarioLogado.getBranch().getId() + "/");
    doc.setBranch(usuarioLogado.getBranch());
    doc.setFileName(file.getOriginalFilename());
    if (idFolder != null && !idFolder.equals(new Integer(0))) {
        doc.setParent(tdocManager.getDocument(idFolder));
    }
    doc.setFolder(Boolean.FALSE);
    tdocManager.addDocument(doc);
    return "index.html#/tdoc";
}

From source file:it.eng.spagobi.behaviouralmodel.analyticaldriver.service.DetailParameterModule.java

/**
 * Controls if the name of the Parameter is already in use.
 * //  w  w w. j av  a  2s.  c o  m
 * @param parameter The Parameter to check
 * @param operation Defines if the operation is of insertion or modify
 * @throws EMFUserError If any Exception occurred
 */
private void parameterLabelControl(Parameter parameter, String operation) throws EMFUserError {
    String labelToCheck = parameter.getLabel();
    List allparameters = DAOFactory.getParameterDAO().loadAllParameters();
    if (operation.equalsIgnoreCase("INSERT")) {
        Iterator i = allparameters.iterator();
        while (i.hasNext()) {
            Parameter aParameter = (Parameter) i.next();
            String label = aParameter.getLabel();
            if (label.equals(labelToCheck)) {
                HashMap params = new HashMap();
                params.put(AdmintoolsConstants.PAGE, ListParametersModule.MODULE_PAGE);
                EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "label", "1031",
                        new Vector(), params);
                errorHandler.addError(error);
            }
        }
    } else {
        Integer currentId = parameter.getId();
        Iterator i = allparameters.iterator();
        while (i.hasNext()) {
            Parameter aParameter = (Parameter) i.next();
            String label = aParameter.getLabel();
            Integer id = aParameter.getId();
            if (label.equals(labelToCheck) && (!id.equals(currentId))) {
                HashMap params = new HashMap();
                params.put(AdmintoolsConstants.PAGE, ListParametersModule.MODULE_PAGE);
                EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "label", "1031",
                        new Vector(), params);
                errorHandler.addError(error);
            }
        }
    }
}

From source file:com.sapienter.jbilling.common.GatewayBL.java

private void userRequest(String action) {

    try {/*from ww  w .j a va 2  s. co  m*/

        if (action.equals("authenticate")) {
            String password = getStringPar("s_password");
            UserDTOEx user = new UserDTOEx();
            user.setUserName(userDto.getUserName());
            user.setPassword(password);
            user.setEntityId(entityId);
            if (!validate("User", user)) {
                return;
            }

            if (userSession.authenticate(user) == null) {
                code = RES_CODE_ERROR;
                subCode = RES_SUB_CODE_ERR_NOAUTH;
                text = MSG_NOAUTH;
            }
        } else if (action.equals("create")) {
            String password = getStringPar("s_password", true);
            if (password == null || !vSize("s_password", 6, 20)) {
                return;
            }
            UserDTOEx user = new UserDTOEx();
            user.setUserName(username);
            user.setPassword(password);
            user.setEntityId(entityId);
            user.setCurrency(new CurrencyDTO(getIntPar("s_currency_id")));
            user.setLanguage(new LanguageDTO(getIntPar("s_language_id")));
            // only partners and customers are allowed
            Integer type = getIntPar("s_type_id", true);
            if (type == null)
                return;
            if (!type.equals(Constants.TYPE_PARTNER) && !type.equals(Constants.TYPE_CUSTOMER)) {
                code = RES_CODE_ERROR;
                subCode = RES_SUB_CODE_ERR_USER_TYPE;
                text = MSG_USER_TYPE;
                return;
            }
            user.setMainRoleId(type);
            user.getRoles().add(new RoleDTO(type));

            // see if this is a partner
            if (type.equals(Constants.TYPE_PARTNER)) {
                Partner partner = new Partner();
                partner.setAutomaticProcess(getIntPar("s_batch"));
                partner.setOneTime(getIntPar("s_one_time"));
                partner.setPeriodUnit(new PeriodUnitDTO(getIntPar("s_period_unit")));
                partner.setPeriodValue(getIntPar("s_period_value"));
                partner.setNextPayoutDate(getDatePar("s_next_payout"));
                partner.setBalance(BigDecimal.ZERO);
                partner.setPercentageRate(getDecimalPar("s_rate"));
                partner.setReferralFee(getDecimalPar("s_fee"));
                partner.setFeeCurrency(new CurrencyDTO(getIntPar("s_fee_currency_id")));
                partner.setRelatedClerkUserId(getIntPar("s_clerk"));
                if (!validate("Partner", partner)) {
                    return;
                }
                user.setPartner(partner);
            } else {
                Integer partnerId = getIntPar("s_partner_id");
                CustomerDTO customer = new CustomerDTO();
                // the customer might belong to a partner
                customer.setPartner(new Partner(partnerId));
                customer.setReferralFeePaid(new Integer(0));
                user.setCustomer(customer);
            }

            // there might be a whole bunch of error at this point
            if (code != RES_CODE_OK) {
                return;
            }

            // proceed now with the contact
            ContactDTOEx contact = new ContactDTOEx();
            contact.setEmail(getStringPar("s_email"));
            contact.setAddress1(getStringPar("s_address1"));
            contact.setAddress2(getStringPar("s_address2"));
            contact.setCity(getStringPar("s_city"));
            contact.setCountryCode(getStringPar("s_country_code"));
            contact.setFaxAreaCode(getIntPar("s_fax_area_code"));
            contact.setFaxCountryCode(getIntPar("s_fax_country_code"));
            contact.setFaxNumber(getStringPar("s_fax_number"));
            contact.setFirstName(getStringPar("s_first_name"));
            contact.setInitial(getStringPar("s_initial"));
            contact.setLastName(getStringPar("s_last_name"));
            contact.setOrganizationName(getStringPar("s_organization"));
            contact.setPhoneAreaCode(getIntPar("s_phone_area_code"));
            contact.setPhoneCountryCode(getIntPar("s_phone_country_code"));
            contact.setPhoneNumber(getStringPar("s_phone_number"));
            contact.setPostalCode(getStringPar("s_postal_code"));
            contact.setStateProvince(getStringPar("s_state_province"));
            contact.setTitle(getStringPar("s_title"));

            if (!validate("Contact", contact)) {
                return;
            }
            Integer result = userSession.create(user, contact);
            if (result == null) {
                code = RES_CODE_ERROR;
                subCode = RES_SUB_CODE_ERR_TAKEN;
                text = MSG_NAME_TAKEN;
            } else if (result.intValue() == -1) {
                code = RES_CODE_ERROR;
                subCode = RES_SUB_CODE_ERR_CLERK;
                text = MSG_BAD_CLERK;
            } else {
                // it's good, return the new user id
                RetValue ret = new RetValue("r_user_id", result.toString());
                resultFields.add(ret);
            }
        } else if (action.equals("delete")) {
            userSession.delete(userDto.getUserName(), entityId);
        } else if (action.equals("creditcard")) { // create or update the
                                                  // cc
                                                  // the db support many cc per user, but the server doesn't right
                                                  // now

            CreditCardDTO creditCard = parseCreditCard();
            if (creditCard != null) {
                userSession.updateCreditCard(userDto.getUserName(), entityId, creditCard);
            }
        } else { // wrong action
            code = RES_CODE_ERROR;
            subCode = RES_SUB_CODE_ERR_ACTION;
            text = MSG_BAD_ACTION;
        }
    } catch (SessionInternalError e) {
        code = RES_CODE_ERROR;
        subCode = RES_SUB_CODE_ERR_WRONG;
        text = MSG_BAD_DATA;
    } catch (Exception e) {
        code = RES_CODE_ERROR;
        subCode = RES_SUB_CODE_ERR_INTERNAL;
        text = MSG_INTERNAL;

        log.error("Exception in user", e);
    }

}

From source file:com.heliumv.api.worktime.WorktimeApi.java

@DELETE
@Path("/{worktimeId}")
@Override//from  w w  w  .j  a  v a2  s.co  m
public void removeWorktime(@QueryParam("userId") String userId, @PathParam("worktimeId") Integer worktimeId,
        @QueryParam("forStaffId") Integer forStaffId, @QueryParam("forStaffCnr") String forStaffCnr) {
    if (connectClient(userId) == null)
        return;
    Integer personalId = globalInfo.getTheClientDto().getIDPersonal();
    try {
        ValidPersonalId validator = new ValidPersonalId(personalId, forStaffId, forStaffCnr);
        if (!validator.validate())
            return;
        personalId = validator.getStaffIdToUse();

        ZeitdatenDto zDto = zeiterfassungCall.zeitdatenFindByPrimaryKey(worktimeId);
        if (zDto == null) {
            respondBadRequest("worktimeId", worktimeId.toString());
            return;
        }

        if (personalId.equals(zDto.getPersonalIId())) {
            zeiterfassungCall.removeZeitdaten(zDto);
        } else {
            respondUnauthorized();
        }
    } catch (NamingException e) {
        respondUnavailable(e);
    } catch (RemoteException e) {
        respondUnavailable(e);
    } catch (EJBExceptionLP e) {
        respondBadRequest(e);
    }
}

From source file:it.eng.spagobi.behaviouralmodel.analyticaldriver.service.DetailParameterModule.java

/**
 * Controls if the name of the ParameterUse is already in use.
 * /*from w w  w.  j  a  v a2 s.com*/
 * @param paruse The paruse to check
 * @param operation Defines if the operation is of insertion or modify
 * @throws EMFUserError If any Exception occurred
 */
private void parameterUseLabelControl(ParameterUse paruse, String operation) throws EMFUserError {

    Integer parId = paruse.getId();
    String labelToCheck = paruse.getLabel();
    List allParametersUse = DAOFactory.getParameterUseDAO().loadParametersUseByParId(parId);
    //cannot have two ParametersUse with the same label and the same par_id
    if (operation.equalsIgnoreCase("INSERT")) {
        Iterator i = allParametersUse.iterator();
        while (i.hasNext()) {
            ParameterUse aParameterUse = (ParameterUse) i.next();
            String label = aParameterUse.getLabel();
            if (label.equals(labelToCheck)) {
                HashMap params = new HashMap();
                params.put(AdmintoolsConstants.PAGE, ListParametersModule.MODULE_PAGE);
                params.put(AdmintoolsConstants.ID_DOMAIN, parId);
                EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "paruseLabel", "1025",
                        new Vector(), params);
                errorHandler.addError(error);
            }
        }
    } else {
        Integer currentUseId = paruse.getUseID();
        Iterator i = allParametersUse.iterator();
        while (i.hasNext()) {
            ParameterUse aParameterUse = (ParameterUse) i.next();
            String label = aParameterUse.getLabel();
            Integer useId = aParameterUse.getUseID();

            if (label.equals(labelToCheck) && (!useId.equals(currentUseId))) {
                HashMap params = new HashMap();
                params.put(AdmintoolsConstants.PAGE, ListParametersModule.MODULE_PAGE);
                params.put(AdmintoolsConstants.ID_DOMAIN, parId);
                EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "paruseLabel", "1025",
                        new Vector(), params);
                errorHandler.addError(error);
            }
        }
    }
}

From source file:fr.paris.lutece.plugins.suggest.service.SuggestSubmitService.java

/**
 * {@inheritDoc}/*from  w  w w  .  j ava  2  s .  co m*/
 */
@Override
@Transactional("suggest.transactionManager")
public void updateSuggestSubmitOrder(Integer nPositionElement, Integer nNewPositionElement, int nIdSuggest,
        boolean bListPinned, Plugin plugin) {
    SubmitFilter filter = new SubmitFilter();
    filter.setIdSuggest(nIdSuggest);

    List<Integer> listSortByManually = new ArrayList<Integer>();
    listSortByManually.add(SubmitFilter.SORT_MANUALLY);
    filter.setSortBy(listSortByManually);
    //
    filter.setIdPinned(bListPinned ? SubmitFilter.ID_TRUE : SubmitFilter.ID_FALSE);

    List<Integer> listIdSuggestDubmit = getSuggestSubmitListId(filter, plugin);

    if ((listIdSuggestDubmit != null) && (listIdSuggestDubmit.size() > 0)) {
        if ((nPositionElement != null) && (nNewPositionElement != null)
                && (!nPositionElement.equals(nNewPositionElement))) {
            if (((nPositionElement > 0) && (nPositionElement <= (listIdSuggestDubmit.size() + 1)))
                    && ((nNewPositionElement > 0)
                            && (nNewPositionElement <= (listIdSuggestDubmit.size() + 1)))) {
                SuggestUtils.moveElement(nPositionElement, nNewPositionElement,
                        (ArrayList<Integer>) listIdSuggestDubmit);
            }
        }

        int nNewOrder = 1;

        //update all Suggest submit
        for (Integer nIdSuggestSubmit : listIdSuggestDubmit) {
            SuggestSubmitHome.updateSuggestSubmitOrder(nNewOrder++, nIdSuggestSubmit, plugin);
        }
    }
}

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

private VendorContact getVendorContact(VendorDetail vDetail, Integer vendorContactGeneratedIdentifier) {
    if (CollectionUtils.isNotEmpty(vDetail.getVendorContacts())) {
        for (VendorContact vContact : vDetail.getVendorContacts()) {
            if (vendorContactGeneratedIdentifier.equals(vContact.getVendorContactGeneratedIdentifier())) {
                return vContact;
            }/*from  w ww . ja  v  a  2s .  c  o m*/
        }
    }
    return new VendorContact();
}

From source file:model.DecomposableModel.java

/**
 * Export a Netica representation of a BN equivalent to the MRF
 * /*from  w ww. j  a  v a 2  s .  co m*/
 * @param file
 *            the file to save the representation to
 * @param variableNames
 *            the names of the variables
 */
public void exportBNNetica(File file, String[] variableNames, String[][] outcomes) {
    try {
        PrintWriter out = new PrintWriter(new FileOutputStream(file), true);
        out.println("// ~->[DNET-1]->~");
        out.println("bnet Unnamed_1 {");
        out.println("\tautoupdate = FALSE;");
        DirectedAcyclicGraph<Integer, DefaultEdge> bn = graph.getBayesianNetwork();
        for (Integer varIndex : bn.vertexSet()) {
            out.print("\tnode ");
            out.print("v" + varIndex);
            out.println("{");
            if (variableNames != null) {
                out.println("\t\ttitle = \"" + variableNames[varIndex] + "\";");
            }
            out.println("\t\tkind = NATURE;");
            out.println("\t\tdiscrete = TRUE;");
            out.print("\t\tstates = (");
            String outcome = "\"" + outcomes[varIndex][0] + "\"";
            out.print(outcome);
            for (int i = 1; i < outcomes[varIndex].length; i++) {
                outcome = "\"" + outcomes[varIndex][i] + "\"";
                out.print("," + outcome);
            }
            out.println(");");

            out.print("\t\tparents = (");
            String listOfParents = "";
            Set<DefaultEdge> edgesOfNode = bn.edgesOf(varIndex);
            for (DefaultEdge e : edgesOfNode) {
                Integer source = graph.getEdgeSource(e);
                if (!source.equals(varIndex)) {
                    listOfParents += ",v" + source;
                }
            }
            if (listOfParents.length() > 0) {
                out.println(listOfParents.substring(1) + ");");
            } else {
                out.println(");");
            }
            out.println("\t};");
            out.println();

        }
        out.println("};");

        out.close();
    } catch (FileNotFoundException e1) {
        e1.printStackTrace();
    } catch (CycleFoundException e) {
        e.printStackTrace();
    }

}