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:gr.abiss.calipso.wicket.asset.AssetCustomAttributeFormPanel.java

private void addType(final CompoundPropertyModel model, final boolean isMandatory) {
    // attributeTypeList is a an object that contains a list of
    // attributeTypes
    // and a Map of pairs (AttributeTypes,AttributeTypes)
    //final AttributeTypes attributeTypesList = new AttributeTypes();

    logger.debug("addType, isMandatory: " + isMandatory);
    type = new DropDownChoice<Integer>("formType", new ArrayList<Integer>(CustomAttribute.FORM_TYPES),
            new IChoiceRenderer<Integer>() {
                @Override//from  w w  w .  j  a v  a2  s  .  c o  m
                public Object getDisplayValue(Integer o) {
                    return localize("asset.attributeType_" + o.toString());
                }

                @Override
                public String getIdValue(Integer object, int index) {
                    return index + "";
                }
            }) {
        private static final long serialVersionUID = 1L;

        /**
         * @see org.apache.wicket.Component#initModel()
         */
        @Override
        protected boolean wantOnSelectionChangedNotifications() {
            return true;
        }

        //         @Override
        //         protected void onSelectionChanged(Integer newSelection) {
        //            if (isMandatory) {
        //               AssetCustomAttributeFormPanel.this.remove(validPanel);
        //               if (newSelection.equals(AssetTypeCustomAttribute.FORM_TYPE_MULTISELECT)
        //                     || newSelection.equals(AssetTypeCustomAttribute.FORM_TYPE_SELECT)
        //                     || newSelection.equals(AssetTypeCustomAttribute.FORM_TYPE_OPTIONS_TREE)) {
        //                  optionsPanel = new CustomAttributeOptionsPanel("optionTranslationsPanel", (AssetTypeCustomAttribute) model.getObject(), getCalipso().getSupportedLanguages(), textAreaOptions);
        //                  AssetCustomAttributeFormPanel.this.add(validPanel);
        //               }
        //               else if (newSelection.equals(AssetTypeCustomAttribute.FORM_TYPE_TEXT)) {
        //                     validPanel = new ValidationPanel("validPanel", model, isMandatory);
        //                     AssetCustomAttributeFormPanel.this.add(validPanel);
        //                  }
        //                  else{
        //                  AssetCustomAttributeFormPanel.this.add(new EmptyPanel("validPanel"));
        //               }
        //            }
        //            setModelObject(newSelection);
        //         }

        //         /**
        //          * @see
        //          * org.apache.wicket.markup.html.form.AbstractSingleSelectChoice
        //          * #getDefaultChoice(java.lang.Object)
        //          */
        //         @Override
        //         protected CharSequence getDefaultChoice(Object selected) {
        //            // TODO Auto-generated method stub
        //            return super
        //                  .getDefaultChoice(AssetTypeCustomAttribute.FORM_TYPE_TEXT);
        //         }
    };
    type.setOutputMarkupId(true);
    type.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            logger.info("onUpdate");
            if (isMandatory) {
                // AssetCustomAttributeFormPanel.this.remove(validPanel);
                Integer selected = type.getModelObject();

                if (selected.equals(AssetTypeCustomAttribute.FORM_TYPE_MULTISELECT)
                        || selected.equals(AssetTypeCustomAttribute.FORM_TYPE_SELECT)
                        || selected.equals(AssetTypeCustomAttribute.FORM_TYPE_OPTIONS_TREE)) {
                    optionsPanel.setVisible(true);
                    validPanel.setVisible(false);
                } else if (selected.equals(AssetTypeCustomAttribute.FORM_TYPE_TEXT)) {
                    optionsPanel.setVisible(false);
                    validPanel.setVisible(true);
                } else {
                    optionsPanel.setVisible(false);
                    validPanel.setVisible(false);
                }
                target.add(optionsPanelContainer);
                target.add(validPanelContainer);
            }
        }
    });

    type.setNullValid(false);
    type.setEnabled(this.assetTypeCanBeModified);
    type.setOutputMarkupId(true);
    add(type);

    type.setModel(new PropertyModel(model.getObject(), "formType"));
    // form label for form type
    type.setLabel(new ResourceModel("asset.customAttributes.type"));

    add(new SimpleFormComponentLabel("formTypeLabel", type));
    if (isMandatory) {
        type.setRequired(true);
        type.add(new ErrorHighlighter());
    }
}

From source file:backend.facades.UserController.java

public List<UserEntity> getUserList() {
    List<UserEntity> userList = new ArrayList<UserEntity>();
    String sort = "registeredDate";
    String order = "desc";
    DBObject sortCriteria = new BasicDBObject(sort, "desc".equals(order) ? -1 : 1);
    BasicDBObject query = new BasicDBObject();

    DBCursor cursor = userCollection.find(query).sort(sortCriteria);
    try {//w  ww .  j  a  va2s  .c o  m
        while (cursor.hasNext()) {
            DBObject document = cursor.next();
            UserEntity userEntity = new UserEntity();
            userEntity.setId((Long) document.get("_id"));
            userEntity.setUsername((String) document.get("username"));
            userEntity.setEmail((String) document.get("email"));
            userEntity.setFirstname((String) document.get("firstname"));
            userEntity.setPasswd((String) document.get("passwd"));
            userEntity.setLastname((String) document.get("lastname"));
            userEntity.setStatus((Integer) document.get("status"));
            userEntity.setImageId((String) document.get("imageId"));
            userEntity.setRegisteredDate((Date) document.get("registeredDate"));
            userEntity.setLastLoginDate((Date) document.get("lastLoginDate"));
            userEntity.setLanguageCode((String) document.get("languageCode"));
            userEntity.setUserRole((Integer) document.get("userRole"));
            userEntity.setModeratorValue((Integer) document.get("moderator"));
            Integer value = (Integer) document.get("subscribe");
            userEntity.setPersonalWebPage((String) document.get("webpage"));
            if (value != null && value.equals(StatusTypes.ACCEPT_LICENSE)) {
                userEntity.setAcceptSubscr(true);
            } else {
                userEntity.setAcceptSubscr(false);
            }
            userList.add(userEntity);
        }
    } finally {
        cursor.close();
    }
    return userList;
}

From source file:fr.paris.lutece.plugins.suggest.business.SubmitFilter.java

/**
 * @param nSort The sort/*from  w  ww  .ja  v  a 2 s .  c o  m*/
 * @return true if the filter contain the sort
 */
public boolean containsSortBy(Integer nSort) {
    if ((nSort != null) && (_listSortBy != null) && (_listSortBy.size() != 0)) {
        for (Integer nSortBy : _listSortBy) {
            if (nSortBy.equals(nSort)) {
                return true;
            }
        }
    }

    return false;
}

From source file:edu.byu.mpn.rest.DeviceController.java

private Response validateUpdateDevice(Integer id, Device device, String proxyId) {
    String errorMessage = null;/*from   w ww  .j av  a 2  s.  c  o m*/
    if (device == null) {
        errorMessage = EX_EMPTY_REQUEST;
    } else if (device.getId() == null) {
        errorMessage = EX_MISSING_ID;
    } else if (!id.equals(device.getId())) {
        errorMessage = EX_ID_CONFLICT;
    } else if (device.getPersonId() == null || device.getPersonId().isEmpty()) {
        errorMessage = EX_PERSONID_MISSING;
    } else if (device.getToken() == null || device.getToken().isEmpty()) {
        errorMessage = EX_TOKEN_MISSING;
    }
    if (errorMessage != null) {
        return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessage(errorMessage)).build();
    }

    Device oldDevice = deviceDao.getDeviceById(id);
    if (oldDevice == null) {
        return Response.status(Response.Status.NOT_FOUND).build();
    } else if (!device.getPersonId().equals(getPersonId(proxyId))) {
        return Response.status(Response.Status.FORBIDDEN).entity(new ResponseMessage(EX_NACHO_PERSONID))
                .build();
    } else if (!(device.getPersonId().equals(oldDevice.getPersonId()) || oldDevice.getPersonId() == null
            || oldDevice.getPersonId().isEmpty())) {
        return Response.status(Response.Status.FORBIDDEN).entity(new ResponseMessage(EX_NACHO_DEVICE)).build();
    }
    return null;
}

From source file:com.github.braully.graph.hn.GraphWS.java

private String saveTmpFileGraphInCsr(UndirectedSparseGraphTO<Integer, Integer> undGraph) {
    String strFile = null;// ww  w. j ava 2  s .c o m
    if (undGraph != null && undGraph.getVertexCount() > 0) {
        try {
            int vertexCount = undGraph.getVertexCount();
            int edegeCount = undGraph.getEdgeCount();
            File file = new File(COMMAND_GRAPH_HN + "graph-csr-" + vertexCount + "-" + edegeCount + ".txt");
            //                file.deleteOnExit();

            strFile = file.getAbsolutePath();
            FileWriter writer = new FileWriter(file);
            writer.write("#Graph |V| = " + vertexCount + "\n");

            int sizeRowOffset = 0;
            List<Integer> csrColIdxs = new ArrayList<>();
            List<Integer> rowOffset = new ArrayList<>();

            int idx = 0;
            for (Integer i = 0; i < vertexCount; i++) {
                csrColIdxs.add(idx);
                Collection<Integer> neighbors = undGraph.getNeighbors(i);
                Set<Integer> neighSet = new HashSet<>();
                neighSet.addAll(neighbors);
                for (Integer vn : neighSet) {
                    if (!vn.equals(i)) {
                        rowOffset.add(vn);
                        idx++;
                    }
                }
            }
            csrColIdxs.add(idx);

            for (Integer i : csrColIdxs) {
                writer.write("" + i);
                writer.write(" ");
            }
            writer.write("\n");
            for (Integer i : rowOffset) {
                writer.write("" + i);
                writer.write(" ");
            }
            writer.write("\n");
            writer.close();
        } catch (IOException ex) {
            log.log(Level.SEVERE, null, ex);
        }
    }
    log.log(Level.INFO, "File tmp graph: {0}", strFile);
    return strFile;
}

From source file:ch.puzzle.itc.mobiliar.presentation.resourcesedit.EditResourceView.java

public void onChangedRelation(@Observes ChangeSelectedRelationEvent relationEvent) {
    if (relationEvent != null && relationEvent.getRelation() != null) {
        ResourceEditRelation relation = relationEvent.getRelation();
        if (relation.isResourceTypeRelation()) {
            Integer resRelTypeId = relation.getResRelTypeId();
            if (resRelTypeId != null && !resRelTypeId.equals(relationIdViewParam)) {
                relationIdViewParam = relation.getResRelTypeId();
            }//from www. j ava 2  s.  c o m
        } else {
            Integer resRelId = relation.getResRelId();
            if (resRelId != null && !resRelId.equals(relationIdViewParam)) {
                relationIdViewParam = relation.getResRelId();
            }
        }
    }
}

From source file:com.aurel.track.item.ItemBL.java

public static ItemLocationForm getItemLocation(Locale locale, TPersonBean user, Integer defaultProjectID,
        Integer defaultIssueTypeID, Integer parentWorkItemID) {
    LOGGER.debug("getItemLocation() defaultProjectID=" + defaultProjectID + ", defaultIssueTypeID="
            + defaultIssueTypeID);/*from ww  w. j a  v a  2 s  . c o  m*/
    ItemLocationForm form = new ItemLocationForm();
    Integer personID = user.getObjectID();
    List<Integer> accessRights = new LinkedList<Integer>();
    accessRights.add(Integer.valueOf(AccessBeans.AccessFlagIndexes.CREATETASK));
    int[] rights = GeneralUtils.createIntArrFromIntegerList(accessRights);
    List<TreeNode> projectTree = ProjectBL.getProjectNodesByRightEager(true, user, false, rights, false, false);
    form.setProjectTree(projectTree);
    if (projectTree == null || projectTree.isEmpty()) {
        return null;
    }
    Integer projectID = null;
    Integer issueTypeID = null;
    TWorkItemBean defaultWorkItemBean = ItemBL.loadLastCreated(personID);
    //projectID
    if (defaultProjectID == null && defaultWorkItemBean != null) {
        defaultProjectID = defaultWorkItemBean.getProjectID();
    }
    List<Integer> projectIDs = ProjectBL.getProjectIDsFromTree(projectTree);
    if (defaultProjectID != null) {
        Iterator<Integer> iterator = projectIDs.iterator();
        while (iterator.hasNext()) {
            Integer projectIDCrt = iterator.next();
            if (projectIDCrt.equals(defaultProjectID)) {
                projectID = defaultProjectID;
                break;
            }
        }
    }
    if (projectID == null && !projectIDs.isEmpty()) {
        projectID = projectIDs.get(0);
    }
    List<TListTypeBean> issueTypeList = IssueTypeBL.loadByPersonAndProjectAndCreateRight(personID, projectID,
            null, parentWorkItemID, locale);
    if (issueTypeList == null || issueTypeList.isEmpty()) {
        LOGGER.warn("No issue type is allowed in project " + projectID + " for person " + personID
                + " parent workItem " + parentWorkItemID);
    } else {
        //issueTypeID
        if (defaultIssueTypeID == null) {
            TProjectBean projectBean = LookupContainer.getProjectBean(projectID);
            Integer prefill = null;
            if (projectBean != null) {
                prefill = ProjectConfigBL.getPrefillValue(projectBean);
            }
            if (prefill != null && prefill.intValue() == TProjectBean.PREFILL.PROJECTDEFAULT) {
                defaultIssueTypeID = ProjectConfigBL.getDefaultFieldValueForProject(
                        SystemFields.INTEGER_ISSUETYPE, projectBean, personID, issueTypeID, null);
            } else {
                if (defaultWorkItemBean != null) {
                    defaultIssueTypeID = defaultWorkItemBean.getListTypeID();
                }
            }
        }
        Iterator<TListTypeBean> iterator = issueTypeList.iterator();
        while (iterator.hasNext()) {
            TListTypeBean issueTypeBean = iterator.next();
            if (issueTypeBean.getObjectID().equals(defaultIssueTypeID)) {
                issueTypeID = defaultIssueTypeID;
                break;
            }
        }
        if (issueTypeID == null) {
            issueTypeID = issueTypeList.get(0).getObjectID();
        }
    }
    form.setProjectID(projectID);
    //form.setProjectList(GeneralUtils.createIntegerStringBeanListFromLabelBeanList(projectList));

    form.setIssueTypeID(issueTypeID);
    form.setIssueTypeList(GeneralUtils.createIntegerStringBeanListFromLabelBeanList(issueTypeList));

    updateItemLocationFormLabels(form, locale, projectID, issueTypeID, user);

    return form;
}

From source file:com.sapienter.jbilling.server.process.AgeingBL.java

/**
 * Will move the user one step forward in the ageing proces ONLY IF
 * the user has been long enough in the present status. (for a user
 * in active status, it always moves it to the first ageing step).
 * @param userId/*from  www. j a  v  a 2 s.  c  o  m*/
 * @throws NamingException
 * @throws SessionInternalError
 */
public void age(UserDTO user, Date today) throws NamingException, SessionInternalError {
    LOG.debug("Ageing user:" + user.getUserId());
    Integer status = user.getStatus().getId();
    Integer nextStatus = null;
    if (status.equals(UserDTOEx.STATUS_ACTIVE)) {
        // welcome to the ageing process
        nextStatus = getNextStep(user.getEntity(), UserDTOEx.STATUS_ACTIVE);
    } else {
        LOG.debug("she's already in the ageing");
        // this guy is already in the ageing
        AgeingEntityStepDTO step = new AgeingEntityStepDAS().findStep(user.getEntity().getId(), status);
        if (step != null) {
            ageing = ageingDas.find(step.getId());

            // verify if it is time for another notch
            GregorianCalendar cal = new GregorianCalendar();
            Date lastChange = user.getLastStatusChange();
            if (lastChange == null) {
                lastChange = user.getCreateDatetime();
            }
            cal.setTime(lastChange);
            cal.add(Calendar.DATE, ageing.getDays());
            LOG.debug("last time + days=" + cal.getTime() + " today " + today + "compare="
                    + cal.getTime().compareTo(today));
            if (cal.getTime().compareTo(today) <= 0) {
                nextStatus = getNextStep(user.getEntity(), user.getStatus().getId());
            } else {
                return;
            }
        } else {
            // this user is an ageing status that has been removed.
            // may be this is a bug, and a currently-in-use status
            // should not be removable.
            // Now it will simple jump to the next status.
            nextStatus = getNextStep(user.getEntity(), user.getStatus().getId());
        }
    }
    if (nextStatus != null) {
        setUserStatus(null, user.getUserId(), nextStatus, today);
    } else {
        eLogger.warning(user.getEntity().getId(), user.getUserId(), user.getUserId(),
                EventLogger.MODULE_USER_MAINTENANCE, EventLogger.NO_FURTHER_STEP, Constants.TABLE_BASE_USER);
    }
}

From source file:com.telefonica.euro_iaas.sdc.util.CommandExecutorShellImpl.java

/**
 * <p>//from w  w  w . j a va2s .c  om
 * executeCommand
 * </p>
 * 
 * @param command
 *            a {@link java.lang.String} object.
 * @return an array of {@link java.lang.String} objects.
 * @throws java.io.IOException
 *             if any.
 */
public String[] executeCommand(String command) throws ShellCommandException {
    String[] outputCommand = new String[2];

    try {
        // Command is executed
        logger.log(Level.INFO, "Executing command: " + command);
        Process p = Runtime.getRuntime().exec(command);

        // Leemos la salida del comando
        outputCommand[0] = IOUtils.toString(p.getInputStream());
        outputCommand[1] = IOUtils.toString(p.getErrorStream());

        Integer exitValue = null;
        // this bucle is because sometimes the flows continues and the
        // comand
        // does not finish yet.
        while (exitValue == null) {
            try {
                exitValue = p.exitValue();
            } catch (IllegalThreadStateException e) {
                logger.log(Level.FINEST, "The command does not finished yet");
            }
        }

        if (!exitValue.equals(0)) {
            logger.log(Level.SEVERE, "Error executing command: " + outputCommand[1]);
            throw new ShellCommandException(outputCommand[1]);
        }
        return outputCommand;
    } catch (IOException e) {
        throw new ShellCommandException("Unexpected exception", e);
    }
}

From source file:es.sm2.openppm.core.plugin.action.GenericAction.java

/**
 * Is user in role/*from   w  w  w  .j  ava  2 s  .  c  o  m*/
 *
 * @param rol
 * @return
 */
public boolean isUserRole(Integer rol) {

    boolean isUserRole = false;

    if (rol.equals(getSessionAttributes().get("rolPrincipal"))) {
        isUserRole = true;
    }

    return isUserRole;
}