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.accessControl.AccessBeans.java

/**
 * Filters out the cost beans from the reportBeanWithHistory objects when it
 * is not the person's own cost and she has no right to see the others'
 * costs//w  ww  .  ja  v  a  2 s. c om
 *
 * @param personID
 * @param reportBeanWithHistoryList
 */
public static void filterCostBeans(Integer personID, List<ReportBeanWithHistory> reportBeanWithHistoryList) {
    if (personID == null || reportBeanWithHistoryList == null || reportBeanWithHistoryList.isEmpty()) {
        return;
    }
    Map<Integer, Set<Integer>> projectToIssueTypesMap = getProjectToIssueTypesMap(reportBeanWithHistoryList);
    List<Integer> fieldIDs = new LinkedList<Integer>();
    fieldIDs.add(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.ALL_EXPENSES);
    Map<Integer, Map<Integer, Map<Integer, Integer>>> fieldRestrictions = getFieldRestrictions(personID,
            projectToIssueTypesMap, fieldIDs, false);
    for (ReportBeanWithHistory reportBean : reportBeanWithHistoryList) {
        TWorkItemBean workItemBean = reportBean.getWorkItemBean();
        List<TCostBean> costBeans = reportBean.getCosts();
        // get the category label
        if (costBeans != null && !costBeans.isEmpty()) {
            Integer projectID = workItemBean.getProjectID();
            Integer issueTypeID = workItemBean.getListTypeID();
            Map<Integer, Map<Integer, Integer>> issueTypeRestrictions = fieldRestrictions.get(projectID);
            Map<Integer, Integer> hiddenFields = null;
            if (issueTypeRestrictions != null) {
                hiddenFields = issueTypeRestrictions.get(issueTypeID);
            }
            if (hiddenFields != null
                    && hiddenFields.containsKey(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.ALL_EXPENSES)) {
                Iterator<TCostBean> iterator = costBeans.iterator();
                while (iterator.hasNext()) {
                    TCostBean costBean = iterator.next();
                    if (!personID.equals(costBean.getChangedByID())) {
                        iterator.remove();
                    }
                }
            }
        }
    }
}

From source file:com.abiquo.api.services.cloud.VirtualMachineService.java

/**
 * Extracts the proper network configuration from the "network_configuration" link.
 * // w w w  .ja v  a 2  s  . c o m
 * @param vapp VirtualAppliance We need it to check it the link os correct.
 * @param newvm VirtualMachine new. We need to check if the configuration is correct for the
 *            current virtualmachine's NICs.
 * @param configurationRef reference to configuration.
 * @return the {@link NetworkConfiguration} object to set to VirtualMachine.
 */
public NetworkConfiguration getNetworkConfigurationFromDto(final VirtualAppliance vapp,
        final VirtualMachine newvm, final SingleResourceTransportDto dto) {
    RESTLink link = dto.searchLink(VirtualMachineNetworkConfigurationResource.DEFAULT_CONFIGURATION);
    if (link == null) {
        // we disable the default network configuration.
        return null;
    }
    String networkConfigurationTemplate = buildPath(VirtualDatacentersResource.VIRTUAL_DATACENTERS_PATH,
            VirtualDatacenterResource.VIRTUAL_DATACENTER_PARAM,
            VirtualAppliancesResource.VIRTUAL_APPLIANCES_PATH, VirtualApplianceResource.VIRTUAL_APPLIANCE_PARAM,
            VirtualMachinesResource.VIRTUAL_MACHINES_PATH, VirtualMachineResource.VIRTUAL_MACHINE_PARAM,
            VirtualMachineNetworkConfigurationResource.NETWORK,
            VirtualMachineNetworkConfigurationResource.CONFIGURATION_PATH,
            VirtualMachineNetworkConfigurationResource.CONFIGURATION_PARAM);

    MultivaluedMap<String, String> configurationValues = URIResolver
            .resolveFromURI(networkConfigurationTemplate, link.getHref());

    // URI needs to have an identifier to a VDC, another one to a Private Network
    // and another one to Private IP
    if (configurationValues == null
            || !configurationValues.containsKey(VirtualDatacenterResource.VIRTUAL_DATACENTER)
            || !configurationValues.containsKey(VirtualApplianceResource.VIRTUAL_APPLIANCE)
            || !configurationValues.containsKey(VirtualMachineResource.VIRTUAL_MACHINE)
            || !configurationValues.containsKey(VirtualMachineNetworkConfigurationResource.CONFIGURATION)) {
        throw new BadRequestException(APIError.NETWORK_INVALID_CONFIGURATION_LINK);
    }

    // Get the identifiers of the link
    Integer vdcId = Integer
            .parseInt(configurationValues.getFirst(VirtualDatacenterResource.VIRTUAL_DATACENTER));
    Integer vappId = Integer.parseInt(configurationValues.getFirst(VirtualApplianceResource.VIRTUAL_APPLIANCE));
    Integer vmId = Integer.parseInt(configurationValues.getFirst(VirtualMachineResource.VIRTUAL_MACHINE));
    Integer configId = Integer
            .parseInt(configurationValues.getFirst(VirtualMachineNetworkConfigurationResource.CONFIGURATION));

    // Check the identifiers
    if (!vdcId.equals(vapp.getVirtualDatacenter().getId())) {
        throw new BadRequestException(APIError.NETWORK_LINK_INVALID_VDC);
    }
    if (!vappId.equals(vapp.getId())) {
        throw new BadRequestException(APIError.NETWORK_LINK_INVALID_VAPP);
    }
    if (!vmId.equals(newvm.getTemporal())) // it is the new resource, the id it is in the
    // 'temporal'
    {
        throw new BadRequestException(APIError.NETWORK_LINK_INVALID_VM);
    }

    List<IpPoolManagement> ips = newvm.getIps();
    for (IpPoolManagement ip : ips) {
        if (ip.getVlanNetwork().getConfiguration().getId().equals(configId)) {
            return ip.getVlanNetwork().getConfiguration();
        }
    }

    // if we have reached this point, it means the configuratin id is not valid
    throw new BadRequestException(APIError.NETWORK_LINK_INVALID_CONFIG);
}

From source file:jp.primecloud.auto.process.puppet.PuppetComponentProcess.java

protected void startVmwareDisk(Long componentNo, Long instanceNo) {
    // SCSI ID??/* w w  w.  jav  a  2s. co m*/
    Integer scsiId = getVmwareDiskScsiId();
    if (scsiId == null) {
        // SCSI ID????????
        return;
    }

    // ??
    VmwareDisk vmwareDisk = vmwareDiskDao.readByComponentNoAndInstanceNo(componentNo, instanceNo);

    // ???????
    if (vmwareDisk == null) {
        // ??
        Integer diskSize = null;
        ComponentConfig diskSizeConfig = componentConfigDao.readByComponentNoAndConfigName(componentNo,
                ComponentConstants.CONFIG_NAME_DISK_SIZE);
        if (diskSizeConfig != null) {
            try {
                diskSize = Integer.valueOf(diskSizeConfig.getConfigValue());
            } catch (NumberFormatException ignore) {
            }
        }
        if (diskSize == null) {
            // ????????
            return;
        }

        Instance instance = instanceDao.read(instanceNo);

        vmwareDisk = new VmwareDisk();
        vmwareDisk.setFarmNo(instance.getFarmNo());
        vmwareDisk.setPlatformNo(instance.getPlatformNo());
        vmwareDisk.setComponentNo(componentNo);
        vmwareDisk.setInstanceNo(instanceNo);
        vmwareDisk.setSize(diskSize);
        vmwareDisk.setScsiId(scsiId);
        vmwareDiskDao.create(vmwareDisk);
    }
    // ?????????SCSI ID?????
    else if (BooleanUtils.isNotTrue(vmwareDisk.getAttached()) && !scsiId.equals(vmwareDisk.getScsiId())) {
        vmwareDisk.setScsiId(scsiId);
        vmwareDiskDao.update(vmwareDisk);
    }

    // VmwareProcessClient??
    VmwareProcessClient vmwareProcessClient = vmwareProcessClientFactory
            .createVmwareProcessClient(vmwareDisk.getPlatformNo());

    try {
        // ??
        vmwareDiskProcess.attachDisk(vmwareProcessClient, instanceNo, vmwareDisk.getDiskNo());

    } finally {
        vmwareProcessClient.getVmwareClient().logout();
    }
}

From source file:com.l2jfree.gameserver.handler.admincommands.AdminSmartShop.java

private Integer correctItem(String marks, Integer itemId) {

    if (itemId == null)
        return null;

    boolean returnItem = false;

    if (marks.contains("_grade=")) {
        if (!gradeList.get(smartList.indexOf(itemId)).equals(getGradeValue(stringOfMark("_grade=", marks))))
            return null;

        returnItem = true;/*  w  w  w. ja  va 2 s  . c o  m*/
    }

    if (marks.contains("_searchAll")) {
        try {
            returnItem = false;

            String itemName = ItemTable.getInstance().getTemplate(itemId).getName();
            String[] param = getSearchValues(marks, "_searchAll=");

            if (param != null)
                for (String s : param) {
                    if (itemName.toLowerCase().contains(s.toLowerCase())) {
                        returnItem = true;
                    }
                }

        } catch (Exception e) {
            returnItem = false;
        }

    }

    if (marks.contains("_idList")) {
        try {
            returnItem = false;

            String[] param = getSearchValues(marks, "_idList=");

            if (param != null)
                for (String s : param) {
                    if (itemId.equals(Integer.valueOf(s))) {
                        returnItem = true;
                    }
                }
        } catch (Exception e) {
            returnItem = false;
        }
    }

    return (returnItem) ? itemId : null;
}

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.loader.levelthree.LevelThreeLoaderFastTest.java

/**
 * Return a Matcher for the given list of Objects from miRNASeq file
 *
 * @param elementsList                  the list containing the Objects to verify
 * @param expectedMiRnaId               the expected miRNA Id
 * @param expectedReadCount             the expected read count
 * @param expectedReadsPerMillionMiRnaMapped
 *                                      the expected reads per million RNA mapped
 * @param expectedCrossMapped           the expected croos mapped
 * @param expectedIsoformCoords         the expected isoform coords
 * @param expectedMiRnaRegionAnnotation the expected miRNA Region Annotation
 * @param expectedMiRnaRegionAccession  the expected miRNA Region Accession
 * @param expectedDataSetId             the expected data set Id
 * @param expectedHybridizationRefId    the expected hybridization ref Id
 * @return the Matcher//from  ww  w  .  ja  v a 2  s .  c o  m
 */
private Matcher<List<Object[]>> checkMiRnaSeq(final List<Object[]> elementsList, final String expectedMiRnaId,
        final String expectedReadCount, final String expectedReadsPerMillionMiRnaMapped,
        final String expectedCrossMapped, final String expectedIsoformCoords,
        final String expectedMiRnaRegionAnnotation, final String expectedMiRnaRegionAccession,
        final Integer expectedDataSetId, final Integer expectedHybridizationRefId) {

    return new TypeSafeMatcher<List<Object[]>>() {

        @Override
        public boolean matchesSafely(List<Object[]> elementsList) {

            boolean result = false;

            final Object[] firstRecord = elementsList.get(0);

            if (firstRecord != null) {

                final String miRnaId = (String) firstRecord[0];
                final String readCount = (String) firstRecord[1];
                final String readsPerMillionMiRnaMapped = (String) firstRecord[2];
                final String crossMapped = (String) firstRecord[3];
                final String isoformCoords = (String) firstRecord[4];
                final String miRnaRegionAnnotation = (String) firstRecord[5];
                final String miRnaRegionAccession = (String) firstRecord[6];
                final Integer dataSetId = (Integer) firstRecord[7];
                final Integer hybridizationRefId = (Integer) firstRecord[8];

                if (miRnaId.equals(expectedMiRnaId) && readCount.equals(expectedReadCount)
                        && readsPerMillionMiRnaMapped.equals(expectedReadsPerMillionMiRnaMapped)
                        && crossMapped.equals(expectedCrossMapped)
                        && isoformCoords.equals(expectedIsoformCoords)
                        && miRnaRegionAnnotation.equals(expectedMiRnaRegionAnnotation)
                        && miRnaRegionAccession.equals(expectedMiRnaRegionAccession)
                        && dataSetId.equals(expectedDataSetId)
                        && hybridizationRefId.equals(expectedHybridizationRefId)) {

                    result = true;
                }
            }

            return result;

        }

        public void describeTo(final Description description) {
            description.appendText("Valid match");
        }
    };
}

From source file:com.lp.server.personal.ejbfac.ZutrittscontrollerFacBean.java

public void updatePersonalfinger(PersonalfingerDto personalfingerDto, TheClientDto theClientDto)
        throws EJBExceptionLP {
    if (personalfingerDto == null) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_DTO_IS_NULL, new Exception("personalfingerDto == null"));
    }//from www .j a  v a  2 s.  c om
    if (personalfingerDto.getIId() == null || personalfingerDto.getPersonalIId() == null
            || personalfingerDto.getIFingerid() == null || personalfingerDto.getOTemplate1() == null) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FELD_IN_DTO_IS_NULL, new Exception(
                "personalfingerDto.getIId() == null || personalfingerDto.getPersonalIId() == null || personalfingerDto.getIFingerid() == null || personalfingerDto.getIFingersubid() == null || personalfingerDto.getOTemplate() == null"));
    }

    Integer iId = personalfingerDto.getIId();
    // try {
    // try {
    Query query = em.createNamedQuery("PersonalfingerfindByPersonalIIdFingerartIId");
    query.setParameter(1, personalfingerDto.getPersonalIId());
    query.setParameter(2, personalfingerDto.getFingerartIId());
    Integer iIdVorhanden = ((Personalfinger) query.getSingleResult()).getIId();

    if (iId.equals(iIdVorhanden) == false) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_DUPLICATE_UNIQUE,
                new Exception("PERS_PERSONALFINGER.UK"));
    }
    // }
    // catch (FinderException ex) {
    // // nothing here
    // }
    personalfingerDto.setTAendern(new java.sql.Timestamp(System.currentTimeMillis()));
    personalfingerDto.setPersonalIIdAendern(theClientDto.getIDPersonal());

    Personalfinger personalfinger = em.find(Personalfinger.class, iId);
    if (personalfinger == null) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY, "");
    }
    setPersonalfingerFromPersonalfingerDto(personalfinger, personalfingerDto);
    // }
    // catch (FinderException ex) {
    // throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY,
    // ex);
    // }

}

From source file:com.gtwm.pb.model.manageData.DataManagement.java

public Map<BaseField, BaseValue> getTableDataRow(SessionDataInfo sessionData, TableInfo table, int rowId,
        boolean logView)
        throws SQLException, ObjectNotFoundException, CantDoThatException, CodingErrorException {
    Connection conn = null;//w  w w. j a v  a2  s . c  o m
    TableDataInfo tableData = new TableData(table);
    Map<BaseField, BaseValue> tableDataRow = null;
    // Only log the view if we're not looking at the top (default) record in
    // a report
    boolean logTheView = logView;
    if (logTheView) {
        BaseReportInfo sessionReport = sessionData.getReport();
        if (table.getReports().contains(sessionReport)) {
            Integer topRowId = topRecords.get(sessionReport);
            if (topRowId != null) {
                if (topRowId.equals(rowId)) {
                    logTheView = false;
                }
            }
        }
    }
    try {
        conn = this.dataSource.getConnection();
        conn.setAutoCommit(false);
        tableDataRow = tableData.getTableDataRow(conn, rowId, logTheView);
        conn.commit();
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
    if (tableDataRow == null) {
        return new HashMap<BaseField, BaseValue>(0);
    } else {
        return tableDataRow;
    }
}

From source file:com.lp.server.personal.ejbfac.ZutrittscontrollerFacBean.java

public void updateZutrittsklasseobjekt(ZutrittsklasseobjektDto zutrittsklasseobjektDto,
        TheClientDto theClientDto) throws EJBExceptionLP {
    if (zutrittsklasseobjektDto == null) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_DTO_IS_NULL,
                new Exception("zutrittsklasseobjektDto == null"));
    }/*from   ww w  .java  2 s  .co  m*/
    if (zutrittsklasseobjektDto.getIId() == null || zutrittsklasseobjektDto.getZutrittsklasseIId() == null
            || zutrittsklasseobjektDto.getZutrittsmodellIId() == null
            || zutrittsklasseobjektDto.getZutrittsobjektIId() == null) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FELD_IN_DTO_IS_NULL, new Exception(
                "zutrittsklasseobjektDto.getIId() == null || zutrittsklasseobjektDto.getZutrittsklasseIId() == null || zutrittsklasseobjektDto.getZutrittsmodellIId() == null || zutrittsklasseobjektDto.getZutrittsobjektIId() == null"));
    }

    Integer iId = zutrittsklasseobjektDto.getIId();

    // try {
    Query query = em.createNamedQuery("ZutrittsklasseobjektfindByZutrittsobjektIIdZutrittsklasseIId");
    query.setParameter(1, zutrittsklasseobjektDto.getZutrittsobjektIId());
    query.setParameter(2, zutrittsklasseobjektDto.getZutrittsklasseIId());
    Integer iIdVorhanden = ((Zutrittsklasseobjekt) query.getSingleResult()).getIId();
    if (iId.equals(iIdVorhanden) == false) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_DUPLICATE_UNIQUE,
                new Exception("PERS_ZUTRITTSKLASSEOBJEKT.UK"));
    }
    // }
    // catch (FinderException ex) {
    // nothing here
    // }

    // try {
    Zutrittsklasseobjekt zutrittsklasseobjekt = em.find(Zutrittsklasseobjekt.class, iId);
    if (zutrittsklasseobjekt == null) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY, "");
    }
    setZutrittsklasseobjektFromZutrittsklasseobjektDto(zutrittsklasseobjekt, zutrittsklasseobjektDto);
    // }
    // catch (FinderException ex) {
    // throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY,
    // ex);
    // }

}

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.loader.levelthree.LevelThreeLoaderFastTest.java

/**
 * Return a Matcher for the given list of Objects from RNASeq file
 *
 * @param elementsList                   the list containing the Objects to verify
 * @param expectedExon the expected exon value
 * @param expectedRawCounts the expected raw counts value
 * @param expectedMedianLengthNormalized the expected median length normalized value
 * @param expectedRpkm the expected RPKM value
 * @param expectedNormalizedCounts the expected normalized counts value
 * @param expectedScaledEstimate the expected scaled estimate value
 * @param expectedTranscriptId the expected transcript Id value
 * @param expectedDataSetId              the expected data set Id value
 * @param expectedHybridizationRefId     the expected hybridization ref Id value
 * @return a Matcher for the given list of Objects from RNASeq file
 *///from   w w w.j  a v a 2  s.  co m
private Matcher<List<Object[]>> checkRnaSeq(final List<Object[]> elementsList, final String expectedExon,
        final String expectedRawCounts, final String expectedMedianLengthNormalized, final String expectedRpkm,
        final String expectedNormalizedCounts, final String expectedScaledEstimate,
        final String expectedTranscriptId, final Integer expectedDataSetId,
        final Integer expectedHybridizationRefId) {

    return new TypeSafeMatcher<List<Object[]>>() {

        @Override
        public boolean matchesSafely(List<Object[]> elementsList) {

            boolean result = false;

            final Object[] firstRecord = elementsList.get(0);

            if (firstRecord != null) {

                final String exon = (String) firstRecord[0];
                final String rawCounts = (String) firstRecord[1];
                final String medianLengthNormalized = (String) firstRecord[2];
                final String rpkm = (String) firstRecord[3];
                final String normalizedCounts = (String) firstRecord[4];
                ;
                final String scaledEstimate = (String) firstRecord[5];
                ;
                final String transcriptId = (String) firstRecord[6];
                ;
                final Integer dataSetId = (Integer) firstRecord[7];
                final Integer hybridizationRefId = (Integer) firstRecord[8];

                if (StringUtils.equals(exon, expectedExon) && StringUtils.equals(rawCounts, expectedRawCounts)
                        && StringUtils.equals(medianLengthNormalized, expectedMedianLengthNormalized)
                        && StringUtils.equals(rpkm, expectedRpkm)
                        && StringUtils.equals(normalizedCounts, expectedNormalizedCounts)
                        && StringUtils.equals(scaledEstimate, expectedScaledEstimate)
                        && StringUtils.equals(transcriptId, expectedTranscriptId)
                        && dataSetId.equals(expectedDataSetId)
                        && hybridizationRefId.equals(expectedHybridizationRefId)) {

                    result = true;
                }
            }

            return result;

        }

        public void describeTo(final Description description) {
            description.appendText("Valid match");
        }
    };
}

From source file:es.sm2.openppm.front.servlets.ProjectControlServlet.java

/**
  * Save cost/*from w  w w.  j a  v a 2  s. c o  m*/
  * 
  * @param req
  * @param resp
  * @throws IOException 
  */
private void saveCostJX(HttpServletRequest req, HttpServletResponse resp) throws IOException {

    PrintWriter out = resp.getWriter();
    try {
        // Determine what kind of cost detail is
        Integer costType = ParamUtil.getInteger(req, "cost_cost_type", -1);
        int costId = ParamUtil.getInteger(req, "cost_id", -1);
        double actual = ParamUtil.getCurrency(req, "cost_actual", 0);
        String desc = ParamUtil.getString(req, "desc", null);
        Date costDate = ParamUtil.getDate(req, "cost_date", getDateFormat(req), new Date());

        JSONObject costJSON = new JSONObject();
        DirectCostsLogic directCostsLogic = new DirectCostsLogic();

        if (costType.equals(Constants.COST_TYPE_DIRECT)) {
            Directcosts cost = directCostsLogic.consDirectcosts(costId);
            cost.setActual(actual);
            cost.setDescription(desc);

            directCostsLogic.saveDirectcost(cost, costDate);

            costJSON.put("actual", cost.getActual());
            costJSON.put("desc", cost.getDescription());
            costJSON.put("costDate", getDateFormat(req).format(costDate));
        } else if (costType.equals(Constants.COST_TYPE_EXPENSE)) {
            ExpensesLogic expensesLogic = new ExpensesLogic();

            Expenses expense = expensesLogic.consExpenses(costId);
            expense.setActual(actual);
            expense.setDescription(desc);

            expensesLogic.saveExpenses(expense, costDate);

            costJSON.put("actual", expense.getActual());
            costJSON.put("desc", expense.getDescription());
            costJSON.put("costDate", getDateFormat(req).format(costDate));
        } else {
            throw new CostTypeException();
        }

        costJSON.put("type", costType);

        out.print(costJSON);
    } catch (Exception e) {
        ExceptionUtil.evalueExceptionJX(out, req, getResourceBundle(req), LOGGER, e);
    } finally {
        out.close();
    }
}