Example usage for java.lang Long equals

List of usage examples for java.lang Long equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:org.geosdi.geoplatform.experimental.connector.core.OAuth2ProjectTest.java

@Test
public void testSecureUpdateAccountsProjectSharingCreate() throws Exception {
    // Initial test
    GPProject project = oauth2CoreClientConnector.getProjectDetail(idProjectTest);
    Assert.assertFalse(project.isShared());

    List<ShortAccountDTO> accountsToShare = oauth2CoreClientConnector.getAccountsByProjectID(idProjectTest)
            .getAccounts();//from   ww w  .  j a va  2s  .com
    Assert.assertNotNull(accountsToShare);
    Assert.assertEquals(1, accountsToShare.size());
    Assert.assertEquals(idUserTest, accountsToShare.get(0).getId().longValue());

    // Insert User to which the Project will be share
    Long newUserID = this.createAndInsertUser("user_to_share_project_rs", organizationTest, GPRole.USER);

    // Test add user for sharing
    Boolean result = oauth2CoreClientConnector.updateAccountsProjectSharing(
            new PutAccountsProjectRequest(idProjectTest, Arrays.asList(idUserTest, newUserID)));
    Assert.assertTrue(result);

    project = oauth2CoreClientConnector.getProjectDetail(idProjectTest);
    Assert.assertTrue(project.isShared());

    accountsToShare = oauth2CoreClientConnector.getAccountsByProjectID(idProjectTest).getAccounts();
    Assert.assertNotNull(accountsToShare);
    Assert.assertEquals(2, accountsToShare.size());
    boolean check = false;
    for (ShortAccountDTO accountDTO : accountsToShare) {
        if (newUserID.equals(accountDTO.getId())) {
            check = true;
            break;
        }
    }
    Assert.assertTrue(check);
}

From source file:com.mockey.ui.ScenarioViewAjaxServlet.java

public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    Long serviceId = new Long(req.getParameter("serviceId"));
    String scenarioIdAsString = req.getParameter("scenarioId");
    Service service = store.getServiceById(serviceId);
    Scenario scenario = null;//from w  w w.j  a  v  a  2s .  com
    resp.setContentType("application/json");
    PrintWriter out = resp.getWriter();
    try {
        scenario = service.getScenario(new Long(scenarioIdAsString));
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("serviceId", "" + serviceId);
        jsonObject.put("serviceName", "" + service.getServiceName());
        jsonObject.put("scenarioId", "" + scenario.getId());
        jsonObject.put("name", scenario.getScenarioName());
        jsonObject.put("match", scenario.getMatchStringArg());
        jsonObject.put("response", scenario.getResponseMessage());

        // Error handling flags
        String scenarioErrorId = (service.getErrorScenario() != null) ? "" + service.getErrorScenario().getId()
                : "-1";
        if (scenarioErrorId.equals(scenarioIdAsString)) {
            jsonObject.put("scenarioErrorFlag", true);
        } else {
            jsonObject.put("scenarioErrorFlag", false);
        }

        // For universal, both SERVICE ID and SCENARIO ID have to match.
        Scenario universalError = store.getUniversalErrorScenario();
        boolean universalErrorFlag = false;
        if (universalError != null) {
            try {
                if (serviceId.equals(universalError.getServiceId())
                        && universalError.getServiceId().equals(new Long(scenarioIdAsString))) {
                    universalErrorFlag = true;
                }
            } catch (Exception ae) {
                // Ignore
                logger.debug("Unable to set universal error.", ae);
            }

        }
        jsonObject.put("universalScenarioErrorFlag", universalErrorFlag);
        out.println(jsonObject.toString());
    } catch (Exception e) {
        out.println("{ \"error\": \"Unable to find scenario \"}");
    }
    out.flush();
    out.close();
    return;

}

From source file:com.gst.portfolio.loanproduct.domain.LoanProduct.java

public LoanProductBorrowerCycleVariations fetchLoanProductBorrowerCycleVariationById(Long id) {
    LoanProductBorrowerCycleVariations borrowerCycleVariation = null;
    for (LoanProductBorrowerCycleVariations cycleVariation : this.borrowerCycleVariations) {
        if (id.equals(cycleVariation.getId())) {
            borrowerCycleVariation = cycleVariation;
            break;
        }//from w w  w.j a va  2 s . c  om
    }
    return borrowerCycleVariation;
}

From source file:controllers.core.PortfolioEntryDeliveryController.java

/**
 * Form to manage a requirement./*w  w w . j av a2 s. c o  m*/
 * 
 * If it is provided externally (for example by Redmine), then it's possible
 * to edit only the deliverables and custom attributes.
 * 
 * @param id
 *            the portfolio entry id
 * @param requirementId
 *            the requirement id (0 for create)
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result manageRequirement(Long id, Long requirementId) {

    // get the portfolio entry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // initiate the form with the template
    Form<RequirementFormData> requirementForm = null;

    // initiate the requirement
    Requirement requirement = null;

    if (!requirementId.equals(Long.valueOf(0))) { // edit

        // get the requirement
        requirement = RequirementDAO.getRequirementById(requirementId);

        // security: the portfolio entry must be related to the object
        if (!requirement.portfolioEntry.id.equals(id)) {
            return forbidden(views.html.error.access_forbidden.render(""));
        }

        requirementForm = formTemplate.fill(new RequirementFormData(requirement));

        // add the custom attributes values
        this.getCustomAttributeManagerService().fillWithValues(requirementForm, Requirement.class,
                requirementId);

    } else { // create

        Actor actor = ActorDao.getActorByUidOrCreateDefaultActor(getAccountManagerPlugin(),
                getUserSessionManagerPlugin().getUserSessionId(ctx()));

        requirementForm = formTemplate.fill(new RequirementFormData(actor));

        // add the custom attributes default values
        this.getCustomAttributeManagerService().fillWithValues(requirementForm, Requirement.class, null);

    }

    return ok(views.html.core.portfolioentrydelivery.requirement_manage.render(portfolioEntry, requirement,
            requirementForm));

}

From source file:controllers.core.PortfolioEntryStatusReportingController.java

/**
 * Form to edit/create a new report for a portfolio entry.
 * //from   w  w  w. ja v  a 2 s.  co m
 * @param id
 *            the portfolio entry id
 * @param reportId
 *            the report id (set to 0 for create case)
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result manageReport(Long id, Long reportId) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // initiate the form with the template
    Form<PortfolioEntryReportFormData> reportForm = reportFormTemplate;

    // edit case: inject values
    if (!reportId.equals(Long.valueOf(0))) {
        PortfolioEntryReport portfolioEntryReport = PortfolioEntryReportDao.getPEReportById(reportId);

        // security: the portfolioEntry must be related to the object
        if (!portfolioEntryReport.portfolioEntry.id.equals(id)) {
            return forbidden(views.html.error.access_forbidden.render(""));
        }

        reportForm = reportFormTemplate.fill(new PortfolioEntryReportFormData(portfolioEntryReport));

        // add the custom attributes values
        this.getCustomAttributeManagerService().fillWithValues(reportForm, PortfolioEntryReport.class,
                reportId);

    } else {

        reportForm = reportFormTemplate.fill(new PortfolioEntryReportFormData());

        // add the custom attributes default values
        this.getCustomAttributeManagerService().fillWithValues(reportForm, PortfolioEntryReport.class, null);
    }

    // get the selectable portfolioEntry report status types
    DefaultSelectableValueHolderCollection<CssValueForValueHolder> selectablePortfolioEntryReportStatusTypes = PortfolioEntryReportDao
            .getPEReportStatusTypeActiveAsCssVH();

    return ok(views.html.core.portfolioentrystatusreporting.report_manage.render(portfolioEntry,
            selectablePortfolioEntryReportStatusTypes, reportForm));
}

From source file:org.alfresco.repo.domain.propval.AbstractPropertyValueDAOImpl.java

@SuppressWarnings("unchecked")
public Serializable convertPropertyIdSearchRows(List<PropertyIdSearchRow> rows) {
    // Shortcut if there are no results
    if (rows.size() == 0) {
        return null;
    }//from w ww .java 2 s. co  m
    /*
     * The results all share the same root property.  Pass through the results and construct all
     * instances, storing them ordered by prop_index.
     */
    Map<Long, Serializable> valuesByPropIndex = new HashMap<Long, Serializable>(7);
    TreeMap<Long, PropertyLinkEntity> linkEntitiesByPropIndex = new TreeMap<Long, PropertyLinkEntity>();
    Long rootPropId = null; // Keep this to ensure the root_prop_id is common
    for (PropertyIdSearchRow row : rows) {
        // Check that we are handling a single root property
        if (rootPropId == null) {
            rootPropId = row.getLinkEntity().getRootPropId();
        } else if (!rootPropId.equals(row.getLinkEntity().getRootPropId())) {
            throw new IllegalArgumentException(
                    "The root_prop_id for the property search rows must not change: \n" + "   Rows: " + rows);
        }

        PropertyLinkEntity linkEntity = row.getLinkEntity();
        Long propIndex = linkEntity.getPropIndex();
        Long valuePropId = linkEntity.getValuePropId();
        PropertyValueEntity valueEntity = row.getValueEntity();
        // Get the value
        Serializable value;
        if (valueEntity != null) {
            value = propertyValueCallback.convertToValue(valueEntity);
        } else {
            // Go N+1 if the value entity was not retrieved
            value = getPropertyValueById(valuePropId);
        }
        // Keep it for later
        valuesByPropIndex.put(propIndex, value);
        linkEntitiesByPropIndex.put(propIndex, linkEntity);
    }

    Serializable result = null;
    // Iterate again, adding values to the collections and looking for the root property
    for (Map.Entry<Long, PropertyLinkEntity> entry : linkEntitiesByPropIndex.entrySet()) {
        PropertyLinkEntity linkEntity = entry.getValue();
        Long propIndex = linkEntity.getPropIndex();
        Long containedIn = linkEntity.getContainedIn();
        Long keyPropId = linkEntity.getKeyPropId();
        Serializable value = valuesByPropIndex.get(propIndex);
        // Check if this is the root property
        if (propIndex.equals(containedIn)) {
            if (result != null) {
                logger.error("Found inconsistent property root data: " + linkEntity);
                continue;
            }
            // This property is contained in itself i.e. it's the root
            result = value;
        } else {
            // Add the value to the container to which it belongs.
            // The ordering is irrelevant for some containers; but where it is important,
            // ordering given by the prop_index will ensure that values are added back
            // in the order in which the container originally iterated over them
            Serializable container = valuesByPropIndex.get(containedIn);
            if (container == null) {
                logger.error("Found container ID that doesn't have a value: " + linkEntity);
            } else if (container instanceof Map<?, ?>) {
                Map<Serializable, Serializable> map = (Map<Serializable, Serializable>) container;
                Serializable mapKey = getPropertyValueById(keyPropId).getSecond();
                map.put(mapKey, value);
            } else if (container instanceof Collection<?>) {
                Collection<Serializable> collection = (Collection<Serializable>) container;
                collection.add(value);
            } else {
                logger.error("Found container ID that is not a map or collection: " + linkEntity);
            }
        }
    }
    // This will have put the values into the correct containers
    return result;
}

From source file:service.AdService.java

public void changeAd(Long adId, String shortName, String description, String price, Date dateFrom, Date dateTo,
        Integer status, Long locIds[], String email, String phone, Long catId, Long booleanIds[],
        Long booleanVals[], Long stringIds[], String stringVals[], Long numIds[], String snumVals[],
        Long dateIds[], Date dateVals[], Long selIds[], Long selVals[], Long multyIds[], String multyVals[]) {
    if (adId != null) {
        Ad ad = adDao.find(adId);//  ww w . j  a v  a 2  s.  c om
        Category cat = catDao.find(catId);
        //Region r = 
        if (ad != null) {
            PhoneEditor phe = new PhoneEditor();
            phone = phe.getPhone(phone);
            addError(phe.error);
            List<Locality> prelocs = new ArrayList();
            if (locIds != null) {
                prelocs = locDao.getLocs(locIds);
            }
            Set<Locality> locs = new HashSet(prelocs);
            if (cat != null) {
                ad.setEmail(email);
                ad.setPhone(phone);
                ad.setDateFrom(dateFrom);
                ad.setDateTo(dateTo);
                ad.setDescription(description);
                ad.setName(shortName);
                ad.setPrice(getNumFromString(price, true));
                ad.setLocalities(locs);
                if (status != null) {
                    ad.setStatus(status);
                }
                ad.setCat(cat);
                if (validate(ad) && getErrors().isEmpty()) {
                    Set<ParametrValue> oldVals = ad.getValues();
                    List<Long> reqParamIds = catDao.getRequiredParamsIds(catId);
                    List<Parametr> catParams = paramDao.getParamsFromCat(catId);
                    int i = 0;
                    ArrayList<String> paramValsErrs = new ArrayList();
                    ArrayList<ParametrValue> newVals = new ArrayList();

                    if (booleanVals != null && booleanVals.length > 0) {
                        i = 0;

                        while (i < booleanIds.length) {
                            Boolean invalid = false;
                            Long paramId = booleanIds[i];
                            Parametr p = paramDao.find(paramId);
                            if (catParams.contains(p) && Parametr.BOOL == p.getParamType()) {
                                Long val = booleanVals[i];
                                if (val != null) {
                                    if (reqParamIds.contains(paramId)) {
                                        reqParamIds.remove(paramId);
                                    }
                                    String sval = "";
                                    if (val.equals(ParametrValue.NO)) {
                                        sval = "";
                                    } else if (val.equals(ParametrValue.YES)) {
                                        sval = "";
                                    } else {
                                        invalid = true;
                                    }
                                    if (!invalid) {
                                        ParametrValue pv = new ParametrValue();
                                        pv.setAd(ad);
                                        pv.setParametr(p);
                                        pv.setSelectVal(val);
                                        pv.setStringVal(sval);
                                        if (validate(pv)) {
                                            newVals.add(pv);
                                        }
                                    }
                                }
                            }
                            i++;
                        }
                    }

                    if (stringVals != null && stringVals.length > 0) {
                        i = 0;
                        while (i < stringIds.length) {
                            Long paramId = stringIds[i];
                            Parametr p = paramDao.find(paramId);
                            if (catParams.contains(p) && Parametr.TEXT == p.getParamType()) {
                                String val = stringVals[i];
                                if (val != null && !val.equals("")) {
                                    if (reqParamIds.contains(paramId)) {
                                        reqParamIds.remove(paramId);
                                    }

                                    ParametrValue pv = new ParametrValue();
                                    pv.setAd(ad);
                                    pv.setParametr(p);
                                    pv.setStringVal(val);
                                    if (validate(pv)) {
                                        newVals.add(pv);
                                    }

                                }
                            }
                            i++;
                        }
                    }

                    if (snumVals != null && snumVals.length > 0) {
                        i = 0;
                        while (i < numIds.length) {
                            Long paramId = numIds[i];
                            Parametr p = paramDao.find(paramId);
                            if (catParams.contains(p) && Parametr.NUM == p.getParamType()) {
                                String sval = snumVals[i];
                                if (sval != null && !sval.equals("")) {
                                    Double val = getNumFromString(sval, true);
                                    if (reqParamIds.contains(paramId)) {
                                        reqParamIds.remove(paramId);
                                    }
                                    ParametrValue pv = new ParametrValue();
                                    pv.setAd(ad);
                                    pv.setParametr(p);
                                    pv.setNumVal(val);
                                    pv.setStringVal(StringAdapter.getString(val));
                                    if (validate(pv)) {
                                        newVals.add(pv);
                                    }

                                }
                            }
                            i++;
                        }
                        //???????TO DO check?delete?
                        if (!getErrors().isEmpty()) {
                            for (String e : getErrors()) {
                                paramValsErrs.add(e);
                            }
                        }
                    }

                    if (dateVals != null && dateVals.length > 0) {
                        i = 0;
                        while (i < dateIds.length) {
                            Long paramId = dateIds[i];
                            Parametr p = paramDao.find(paramId);
                            if (catParams.contains(p) && Parametr.DATE == p.getParamType()) {
                                Date val = dateVals[i];
                                if (val != null) {
                                    if (reqParamIds.contains(paramId)) {
                                        reqParamIds.remove(paramId);
                                    }
                                    ParametrValue pv = new ParametrValue();
                                    pv.setAd(ad);
                                    pv.setParametr(p);
                                    pv.setDateVal(val);
                                    pv.setStringVal(DateAdapter.formatByDate(val, DateAdapter.SMALL_FORMAT));
                                    if (validate(pv)) {
                                        newVals.add(pv);
                                    }

                                }
                            }
                            i++;
                        }
                    }

                    if (selVals != null && selVals.length > 0) {
                        i = 0;

                        while (i < selIds.length) {
                            Long paramId = selIds[i];
                            Parametr p = paramDao.find(paramId);
                            if (catParams.contains(p) && Parametr.SELECTING == p.getParamType()) {
                                Long val = selVals[i];
                                if (val != null && !val.equals(0L)) {
                                    if (reqParamIds.contains(paramId)) {
                                        reqParamIds.remove(paramId);
                                    }
                                    ParametrValue pv = new ParametrValue();
                                    pv.setAd(ad);
                                    pv.setParametr(p);
                                    pv.setSelectVal(val);
                                    pv.setStringVal(paramSelDao.find(val).getName());
                                    if (validate(pv)) {
                                        newVals.add(pv);
                                    }

                                }
                            }
                            i++;
                        }
                    }

                    //?  ?
                    //TO DO       (??)
                    if (multyVals != null && multyVals.length > 0) {
                        for (String rawVal : multyVals) {
                            String idValArr[] = rawVal.split("_");
                            if (idValArr.length == 2) {
                                String strId = idValArr[0];
                                String strVal = idValArr[1];
                                Long paramId = Long.valueOf(strId);
                                Long val = Long.valueOf(strVal);
                                Parametr p = paramDao.find(paramId);
                                if (catParams.contains(p) && Parametr.MULTISELECTING == p.getParamType()) {
                                    if (reqParamIds.contains(paramId) && val != null) {
                                        reqParamIds.remove(paramId);
                                    }
                                    ParametrValue pv = new ParametrValue();
                                    pv.setAd(ad);
                                    pv.setParametr(p);
                                    pv.setSelectVal(val);
                                    pv.setStringVal(paramSelDao.find(val).getName());
                                    if (validate(pv)) {
                                        newVals.add(pv);
                                    }
                                }
                            }
                        }
                    }

                    if (!reqParamIds.isEmpty() || !paramValsErrs.isEmpty()) {
                        for (Long id : reqParamIds) {
                            addError("    "
                                    + paramDao.find(id).getName() + "; ");
                        }
                    } else {
                        adDao.update(ad);
                        for (ParametrValue pv : oldVals) {
                            paramValueDao.delete(pv);
                        }
                        for (ParametrValue pv : newVals) {
                            paramValueDao.save(pv);
                        }
                    }

                }
            }

        }
    }
}

From source file:org.apache.axis2.engine.MessageContextSaveATest.java

public void testMcProperties() throws Exception {
    String title = "MessageContextSaveATest:testMcProperties(): ";
    log.debug(title + "start - - - - - - - - - - - - - - - -");

    MessageContext simpleMsg = new MessageContext();
    MessageContext restoredSimpleMsg = null;

    simpleMsg.setProperty("key1", "value1");
    simpleMsg.setProperty("key2", null);
    simpleMsg.setProperty("key3", new Integer(3));
    simpleMsg.setProperty("key4", new Long(4L));

    File theFile = null;/*from   w w  w  .j a  v  a2s  . c o m*/
    String theFilename = null;

    boolean pause = false;
    boolean savedMessageContext = false;
    boolean restoredMessageContext = false;
    boolean comparesOk = false;

    try {
        theFile = File.createTempFile("McProps", null);
        theFilename = theFile.getName();
        log.debug(title + "temp file = [" + theFilename + "]");
    } catch (Exception ex) {
        log.debug(title + "error creating temp file = [" + ex.getMessage() + "]");
        theFile = null;
    }

    if (theFile != null) {
        // ---------------------------------------------------------
        // save to the temporary file
        // ---------------------------------------------------------
        try {
            // setup an output stream to a physical file
            FileOutputStream outStream = new FileOutputStream(theFile);

            // attach a stream capable of writing objects to the 
            // stream connected to the file
            ObjectOutputStream outObjStream = new ObjectOutputStream(outStream);

            // try to save the message context
            log.debug(title + "saving message context.....");
            savedMessageContext = false;
            outObjStream.writeObject(simpleMsg);

            // close out the streams
            outObjStream.flush();
            outObjStream.close();
            outStream.flush();
            outStream.close();

            savedMessageContext = true;
            log.debug(title + "....saved message context.....");

            long filesize = theFile.length();
            log.debug(title + "file size after save [" + filesize + "]   temp file = [" + theFilename + "]");

        } catch (Exception ex2) {
            log.debug(title + "error with saving message context = [" + ex2.getClass().getName() + " : "
                    + ex2.getMessage() + "]");
            ex2.printStackTrace();
        }

        assertTrue(savedMessageContext);

        // ---------------------------------------------------------
        // restore from the temporary file
        // ---------------------------------------------------------
        try {
            // setup an input stream to the file
            FileInputStream inStream = new FileInputStream(theFile);

            // attach a stream capable of reading objects from the 
            // stream connected to the file
            ObjectInputStream inObjStream = new ObjectInputStream(inStream);

            // try to restore the message context
            log.debug(title + "restoring a message context.....");
            restoredMessageContext = false;

            restoredSimpleMsg = (MessageContext) inObjStream.readObject();
            inObjStream.close();
            inStream.close();

            restoredSimpleMsg.activate(configurationContext);

            restoredMessageContext = true;
            log.debug(title + "....restored message context.....");

            // compare to original execution chain
            ArrayList restored_execChain = restoredSimpleMsg.getExecutionChain();
            ArrayList orig_execChain = simpleMsg.getExecutionChain();

            comparesOk = ActivateUtils.isEquivalent(restored_execChain, orig_execChain, false);
            log.debug(title + "execution chain equivalency [" + comparesOk + "]");
            assertTrue(comparesOk);

            // check executed list
            Iterator restored_executed_it = restoredSimpleMsg.getExecutedPhases();
            Iterator orig_executed_it = simpleMsg.getExecutedPhases();
            if ((restored_executed_it != null) && (orig_executed_it != null)) {
                while (restored_executed_it.hasNext() && orig_executed_it.hasNext()) {
                    Object p1 = restored_executed_it.next();
                    Object p2 = orig_executed_it.next();

                    comparesOk = comparePhases(p1, p2);
                    log.debug(title + "executed phase list:  compare phases [" + comparesOk + "]");
                    assertTrue(comparesOk);
                }
            } else {
                // problem with the executed lists
                assertTrue(false);
            }

            // check the properties
            String value1 = (String) restoredSimpleMsg.getProperty("key1");
            Object value2 = restoredSimpleMsg.getProperty("key2");
            Integer value3 = (Integer) restoredSimpleMsg.getProperty("key3");
            Long value4 = (Long) restoredSimpleMsg.getProperty("key4");

            assertEquals("value1", value1);
            assertNull(value2);

            boolean isOk = false;
            if ((value3 != null) && value3.equals(new Integer(3))) {
                isOk = true;
            }
            assertTrue(isOk);

            if ((value4 != null) && value4.equals(new Long(4L))) {
                isOk = true;
            }
            assertTrue(isOk);

        } catch (Exception ex2) {
            log.debug(title + "error with restoring message context = [" + ex2.getClass().getName() + " : "
                    + ex2.getMessage() + "]");
            ex2.printStackTrace();
        }

        assertTrue(restoredMessageContext);

        // if the save/restore of the message context succeeded,
        // then don't keep the temporary file around
        boolean removeTmpFile = savedMessageContext && restoredMessageContext && comparesOk;
        if (removeTmpFile) {
            try {
                theFile.delete();
            } catch (Exception e) {
                // just absorb it
            }
        }
    }

    log.debug(title + "end - - - - - - - - - - - - - - - -");
}

From source file:org.openmeetings.app.data.conference.Roommanagement.java

private boolean checkRoomShouldByDeleted(long orgId, List<Integer> organisations) throws Exception {
    for (Iterator<Integer> it = organisations.iterator(); it.hasNext();) {
        Integer key = it.next();//www .  j a  v a2  s.co m
        Long storedOrgId = key.longValue();
        if (storedOrgId.equals(orgId))
            return true;
    }
    return false;
}

From source file:controllers.core.PortfolioEntryStatusReportingController.java

/**
 * Form to edit/create a new event for a portfolio entry.
 * /*from   ww  w.j a v  a 2s .  c  o m*/
 * @param id
 *            the portfolio entry id
 * @param eventId
 *            the event id (set to 0 for create case)
 */
@With(CheckPortfolioEntryExists.class)
@Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION)
public Result manageEvent(Long id, Long eventId) {

    // get the portfolioEntry
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id);

    // initiate the form with the template
    Form<PortfolioEntryEventFormData> eventForm = eventFormTemplate;

    // edit case: get the portfolio entry event instance
    if (!eventId.equals(Long.valueOf(0))) {

        PortfolioEntryEvent portfolioEntryEvent = PortfolioEntryEventDao.getPEEventById(eventId);

        // security: the portfolio entry must be related to the object
        if (!portfolioEntryEvent.portfolioEntry.id.equals(id)) {
            return forbidden(views.html.error.access_forbidden.render(""));
        }

        eventForm = eventFormTemplate.fill(new PortfolioEntryEventFormData(portfolioEntryEvent));

        // add the custom attributes values
        this.getCustomAttributeManagerService().fillWithValues(eventForm, PortfolioEntryEvent.class, eventId);

    } else {
        // add the custom attributes default values
        this.getCustomAttributeManagerService().fillWithValues(eventForm, PortfolioEntryEvent.class, null);
    }

    return ok(views.html.core.portfolioentrystatusreporting.event_manage.render(portfolioEntry, eventForm,
            PortfolioEntryEventDao.getPEEventTypeActiveAsVH()));
}