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:edu.ur.file.mime.InMemoryMimeTypeService.java

/**
 * Find the top media type.//from www.  j a v a 2  s.com
 * 
 * @see edu.ur.file.mime.BasicMimeTypeService#getTopMediaType(java.lang.Long)
 */
public TopMediaType findTopMediaType(Long id) {

    for (TopMediaType topMediaType : topMediaTypes) {
        if (id.equals(topMediaType.getId())) {
            return topMediaType;
        }
    }
    return null;
}

From source file:omero.cmd.graphs.ChownI.java

public void init(Helper helper) {
    this.helper = helper;

    ////from  www.ja  v a  2  s  .c o  m
    // initial security restrictions.
    //

    // security restrictions (#6620):
    // (1) prevent certain coarse-grained actions from happening, like dropping
    // data in someone else's group like a Cuckoo

    final ServiceFactory sf = helper.getServiceFactory();
    final EventContext ec = ((LocalAdmin) sf.getAdminService()).getEventContextQuiet();
    final Long userId = ec.getCurrentUserId();
    final boolean admin = ec.isCurrentUserAdmin();
    final boolean member = ec.getMemberOfGroupsList().contains(user);

    if (!admin && !member) {
        throw helper.cancel(new ERR(), null, "non-member", "grp", "" + user, "usr", "" + userId);
    }

    try {
        this.factory.setGroup(user);
        this.spec = specs.getBean(type, GraphSpec.class);

        this.spec.initialize(id, "", options);

        StopWatch sw = new CommonsLogStopWatch();
        state = new GraphState(ec, factory, helper.getSql(), helper.getSession(), spec);
        // Throws if steps == 0
        helper.setSteps(state.getTotalFoundCount());
        sw.stop("omero.chown.ids." + helper.getSteps());

        // security restrictions (#6620)
        // (2) now that we have the id for the top-level object, we
        // can check ownership, etc.

        if (!admin) {
            final IObject obj = this.spec.load(helper.getSession());
            obj.getDetails().getOwner();
            Long owner = HibernateUtils.nullSafeOwnerId(obj);
            if (owner != null && !owner.equals(userId)) {
                throw helper.cancel(new ERR(), null, "non-owner", "owner", "" + owner);
            } else {
                // SUCCESS
                helper.info("type=%s, id=%s options=%s [steps=%s]", type, id, options, helper.getSteps());
            }
        }

    } catch (NoSuchBeanDefinitionException nsbde) {
        throw helper.cancel(new Unknown(), nsbde, "notype", "Unknown type", type);
    } catch (Throwable t) {
        throw helper.cancel(new ERR(), t, "INIT ERR");
    }

}

From source file:org.flite.cach3.test.UpdateMultiCacheTest.java

@Test
public void testVelocity() {

    final String original = RandomStringUtils.randomAlphanumeric(7);
    final Long second = Long.valueOf("1337" + RandomStringUtils.randomNumeric(5));
    final List<Long> firsts = new ArrayList<Long>();
    final List<String> baseIds = new ArrayList<String>();
    final long base = RandomUtils.nextInt(2000) + 1000;
    for (int ix = 0; ix < 3; ix++) {
        final Long val = base + ix;
        firsts.add(val);
        baseIds.add(val + "&&" + second);
    }/*  w  ww.j  av  a2s .  c  o  m*/
    final Long extra = base + 10;
    final String extraString = original + extra.toString();

    final TestSvc test = (TestSvc) context.getBean("testSvc");
    final StubUpdateMultiCacheListenerImpl listener = (StubUpdateMultiCacheListenerImpl) context
            .getBean("stubUM");

    final int previous = listener.getTriggers().size();
    final List<String> results = test.updateCompoundStrings(second, original, firsts);

    // Testing that the listener got invoked as required.
    assertTrue("Doesn't look like the listener got called.", listener.getTriggers().size() == previous + 1);
    final String expected = StubUpdateMultiCacheListenerImpl.formatTriggers(TestDAOImpl.COMPOUND_NAMESPACE,
            TestDAOImpl.COMPOUND_PREFIX, baseIds, (List<Object>) (List) results, // Using Erasure to satisfy the compiler. YUCK!
            results, new Object[] { second, original, firsts });
    assertEquals(expected, listener.getTriggers().get(listener.getTriggers().size() - 1));

    // This part just double-checks the sublist aspect of the ReadThroughMultiCache
    firsts.add(extra);
    Collections.shuffle(firsts);
    final List<String> r2 = test.getCompoundStrings(firsts, extraString, second);
    for (int ix = 0; ix < firsts.size(); ix++) {
        final Long value = firsts.get(ix);
        assertEquals(value.equals(extra) ? extraString : original, r2.get(ix));
    }
}

From source file:data.dao.CarOptionValueDao.java

public List<CarOptionValue> getUniqueOptionNames(Long ccoId) throws Exception {
    if (ccoId == null) {
        throw new Exception("ccoId is null!");
    }/*from   w  w  w.j a va 2s .co m*/
    List<CarOptionValue> res = new ArrayList();
    if (!ccoId.equals((long) 0)) {
        CarCompletionOption cco = carCompletionOptionDao.find(ccoId);
        if (cco != null) {
            String hql = "select distinct cov from CarOptionValue cov where cov.CCO.ccoId=:ccoId group by cov.description order by cov.description";
            Query query = currentSession().createQuery(hql).setParameter("ccoId", ccoId);
            res = query.list();
        }
    } else if (ccoId.equals((long) 0)) {
        String hql = "select cov from CarOptionValue cov group by cov.description,cov.CCO.ccoId order by cov.CCO.uid,cov.CCO.title,cov.description";
        Query query = currentSession().createQuery(hql);
        res = query.list();
    }
    //throw new Exception("size="+res.size()+"; ");
    return res;
}

From source file:com.redhat.rhn.domain.errata.ErrataFactory.java

/**
 * Returns a list of ErrataOverview of Errata that match the given Package
 * ids.//  ww  w .j  a  v  a2 s  . c om
 * @param pids Package ids whose Errata are being sought.
 * @return a list of ErrataOverview of Errata that match the given Package
 * ids.
 */
public static List<ErrataOverview> searchByPackageIds(List pids) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("pids", pids);
    if (log.isDebugEnabled()) {
        log.debug("pids = " + pids);
    }
    List results = singleton.listObjectsByNamedQuery("PublishedErrata.searchByPackageIds", params);
    if (log.isDebugEnabled()) {
        log.debug("Query 'PublishedErrata.searchByPackageIds' returned " + results.size() + " entries");
    }
    List<ErrataOverview> errata = new ArrayList<ErrataOverview>();
    Long lastId = null;
    ErrataOverview eo = null;
    for (Object result : results) {
        Object[] values = (Object[]) result;
        // e.id, e.advisory, e.advisoryName, e.advisoryType, e.synopsis, e.updateDate
        Long curId = (Long) values[0];

        if (!curId.equals(lastId)) {
            eo = new ErrataOverview();
        }
        eo.setId((Long) values[0]);
        eo.setAdvisory((String) values[1]);
        eo.setAdvisoryName((String) values[2]);
        eo.setAdvisoryType((String) values[3]);
        eo.setAdvisorySynopsis((String) values[4]);
        eo.setUpdateDate((Date) values[5]);
        eo.setIssueDate((Date) values[6]);
        eo.addPackageName((String) values[7]);
        if (!curId.equals(lastId)) {
            errata.add(eo);
            lastId = curId;
        }
        if (log.isDebugEnabled()) {
            log.debug("curId = " + curId + ", lastId = " + lastId);
            log.debug("ErrataOverview formed: " + eo.getAdvisoryName() + " for " + eo.getPackageNames());
        }
    }

    return errata;
}

From source file:com.redhat.rhn.domain.errata.ErrataFactory.java

/**
 * Returns a list of ErrataOverview of Errata that match the given Package
 * ids./*from w  ww. jav  a2  s . c o  m*/
 * @param pids Package ids whose Errata are being sought.
 * @param org Organization to match results with
 * @return a list of ErrataOverview of Errata that match the given Package
 * ids.
 */
public static List<ErrataOverview> searchByPackageIdsWithOrg(List pids, Org org) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("pids", pids);
    params.put("org_id", org.getId());
    if (log.isDebugEnabled()) {
        log.debug("org_id = " + org.getId());
        log.debug("pids = " + pids);
    }
    List results = singleton.listObjectsByNamedQuery("PublishedErrata.searchByPackageIdsWithOrg", params);
    if (log.isDebugEnabled()) {
        log.debug("Query 'PublishedErrata.searchByPackageIdsWithOrg' returned " + results.size() + " entries");
    }
    List<ErrataOverview> errata = new ArrayList<ErrataOverview>();
    Long lastId = null;
    ErrataOverview eo = null;
    for (Object result : results) {
        Object[] values = (Object[]) result;
        // e.id, e.advisory, e.advisoryName, e.advisoryType, e.synopsis, e.updateDate
        Long curId = (Long) values[0];

        if (!curId.equals(lastId)) {
            eo = new ErrataOverview();
        }
        eo.setId((Long) values[0]);
        eo.setAdvisory((String) values[1]);
        eo.setAdvisoryName((String) values[2]);
        eo.setAdvisoryType((String) values[3]);
        eo.setAdvisorySynopsis((String) values[4]);
        eo.setUpdateDate((Date) values[5]);
        eo.setIssueDate((Date) values[6]);
        eo.addPackageName((String) values[7]);
        if (!curId.equals(lastId)) {
            errata.add(eo);
            lastId = curId;
        }
        if (log.isDebugEnabled()) {
            log.debug("curId = " + curId + ", lastId = " + lastId);
            log.debug("ErrataOverview formed: " + eo.getAdvisoryName() + " for " + eo.getPackageNames());
        }
    }

    return errata;
}

From source file:org.bozzo.ipplan.web.AddressPlanController.java

@RequestMapping(value = "/{planId}", method = RequestMethod.PUT, produces = {
        MediaType.APPLICATION_JSON_VALUE })
public HttpEntity<AddressPlanResource> updateAddressPlan(@PathVariable Integer infraId,
        @PathVariable Long planId, @RequestBody @NotNull AddressPlan plan) {
    Preconditions.checkArgument(infraId.equals(plan.getInfraId()));
    Preconditions.checkArgument(planId.equals(plan.getId()));
    logger.info("update address plan: {}", plan);

    AddressPlan ap = this.repository.save(plan);
    return new ResponseEntity<>(assembler.toResource(ap), HttpStatus.CREATED);
}

From source file:io.pivotal.cla.mvc.admin.AdminCrudClaController.java

@RequestMapping(value = "/admin/cla", method = RequestMethod.POST)
public String saveCla(@AuthenticationPrincipal User user, @Valid ClaForm claForm, BindingResult result,
        Map<String, Object> model) throws Exception {
    boolean primary = claForm.isPrimary();
    if (primary) {
        ContributorLicenseAgreement existingPrimaryCla = claRepo.findByNameAndPrimaryTrue(claForm.getName());
        Long existingPrimaryClaId = existingPrimaryCla == null ? null : existingPrimaryCla.getId();
        if (existingPrimaryClaId != null && !existingPrimaryClaId.equals(claForm.getId())) {
            result.rejectValue("primary", "errors.primary.exists",
                    "A primary CLA with this name already exists");
        }/*from   w w w.j  av a 2  s  .  c o  m*/
    }
    if (result.hasErrors()) {
        Iterable<ContributorLicenseAgreement> clas = claRepo.findAll();
        model.put("licenses", clas);
        return "admin/cla/form";
    }

    ContributorLicenseAgreement supersedingCla = null;
    if (claForm.getSupersedingCla() != null) {
        supersedingCla = claRepo.findOne(claForm.getSupersedingCla());
    }
    String accessToken = user.getAccessToken();

    MarkdownContent individual = claForm.getIndividualContent();
    String individualHtml = gitHub.markdownToHtml(accessToken, individual.getMarkdown());
    individual.setHtml(individualHtml);

    MarkdownContent corporate = claForm.getCorporateContent();
    String corperateHtml = gitHub.markdownToHtml(accessToken, corporate.getMarkdown());
    corporate.setHtml(corperateHtml);

    boolean isCreateNew = claForm.getId() == null;
    ContributorLicenseAgreement cla = isCreateNew ? new ContributorLicenseAgreement()
            : claRepo.findOne(claForm.getId());
    cla.setCorporateContent(claForm.getCorporateContent());
    cla.setDescription(claForm.getDescription());
    cla.setIndividualContent(claForm.getIndividualContent());
    cla.setName(claForm.getName());
    cla.setPrimary(claForm.isPrimary());
    cla.setSupersedingCla(supersedingCla);

    claRepo.save(cla);
    return "redirect:/admin/cla/?success";
}

From source file:com.netflix.conductor.dao.dynomite.RedisMetadataDAO.java

@Override
public void removeTaskDef(String name) {
    Preconditions.checkNotNull(name, "TaskDef name cannot be null");
    Long result = dynoClient.hdel(nsKey(ALL_TASK_DEFS), name);
    if (!result.equals(1L)) {
        throw new ApplicationException(Code.NOT_FOUND, "Cannot remove the task - no such task definition");
    }/*from   w  w  w.  j  a  v a2 s  . com*/
}

From source file:org.gofleet.openLS.ddbb.dao.postgis.PostGisHBRoutingDAO.java

private DetermineRouteResponseType getRouteResponse(List<HBA> resultado) throws SQLException {

    DetermineRouteResponseType res = new DetermineRouteResponseType();
    Long last = -1l;//  w w w.j  ava 2s  . co  m
    List<Coordinate> coords = new LinkedList<Coordinate>();
    double cost = 0;
    for (HBA step : resultado) {
        try {
            Long current = step.getId();
            if (!current.equals(last)) {
                coords.addAll(Arrays.asList(step.getGeometria().getCoordinates()));
                cost += step.getCost();
            } else
                LOG.trace("Repeating step " + current);
            last = current;
        } catch (Exception e) {
            LOG.error("Unknown Step", e);
        }
    }

    RouteGeometryType routeGeometry;
    try {
        CoordinateSequence cs = new CoordinateArraySequence(coords.toArray(new Coordinate[] {}));
        LineString line = new LineString(cs, gf);
        routeGeometry = getRouteGeometry(line);
        res.setRouteGeometry(routeGeometry);
    } catch (JAXBException e) {
        LOG.error(e, e);
    } catch (ParseException e) {
        LOG.error(e, e);
    }

    res.setRouteHandle(getRouteHandle(coords));
    res.setRouteInstructionsList(getInstructionsList(coords));
    res.setRouteMap(getRouteMap(coords));
    res.setRouteSummary(getRouteSummary(cost));
    return res;
}