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:com.krminc.phr.domain.User.java

public boolean authorizedToAccessHealthRecord(Long healthRecordId) {
    for (HealthRecord healthRecord : healthRecords) {
        logger.debug("Scanning to see if userid {} has access to recid {}", this.userId,
                healthRecord.getHealthRecordId());
        if (healthRecordId.equals(healthRecord.getHealthRecordId())) {
            logger.debug("Attempting to allow access by  userid {} to recid {}", this.userId,
                    healthRecord.getHealthRecordId());
            return true;
        }/* w  ww . j a v  a 2s .c  o  m*/
    }

    logger.error("Disallowing access by userid {} to recid {}", this.userId, healthRecordId);
    return false;
}

From source file:ips1ap101.lib.core.control.UsuarioAutenticado.java

private AutorizacionFuncion getAutorizacionFuncion(Long id, boolean esPersonalizable, boolean esSegmentable,
        Collection<? extends RolFuncionBase> funcionesPorRol,
        Collection<? extends ConjuntoSegmentoBase> conjuntos) {
    Collection<? extends ElementoSegmentoBase> segmentos;
    for (RolFuncionBase rf : funcionesPorRol) {
        if (id.equals(rf.getIdFuncion().getIdFuncion())) {
            for (RolFuncionParBase rfp : rf.getRolFuncionParByIdRolFuncionCollection()) {
                addParametro(id, rfp.getIdFuncionParametro().getIdFuncionParametro());
            }/*from www . j a  v a  2 s. co m*/
            if (esSegmentable) {
                if (rf.getIdConjuntoSegmento() == null) {
                    addSegmento(id, null);
                } else {
                    ConjuntoSegmentoBase c = findConjunto(rf.getIdConjuntoSegmento().getIdConjuntoSegmento(),
                            conjuntos);
                    segmentos = c == null ? null : c.getElementoSegmentoByIdConjuntoSegmentoCollection();
                    if (segmentos != null && !segmentos.isEmpty()) {
                        for (ElementoSegmentoBase es : segmentos) {
                            addSegmento(id, es.getSegmentoEnteroGrande());
                        }
                    }
                }
            }
            return esPersonalizable && BitUtils.valueOf(rf.getEsAccesoPersonalizado())
                    ? AutorizacionFuncion.ACCESO_PERSONALIZADO
                    : AutorizacionFuncion.AUTORIZADA;
        }
    }
    return AutorizacionFuncion.NO_AUTORIZADA;
}

From source file:it.geosolutions.geofence.services.servicetest.MainTest.java

private void setUpTestRule() {

    ShortGroup sp1 = new ShortGroup();
    sp1.setName("test_profile");

    long p1id = userGroupAdminService.insert(sp1);

    ShortGroup sp2 = new ShortGroup();
    sp2.setName("test_profile2");

    long p2id = userGroupAdminService.insert(sp2);
    UserGroup p2 = userGroupAdminService.get(p2id);

    GFUser u0 = new GFUser();
    u0.setName("admin");
    u0.setPassword("password");
    u0.setEnabled(true);//from w w  w  .j  a v  a2 s .c om
    u0.setFullName("Sample G.F. Admin");
    u0.setEmailAddress("gf.admin@geofence.net");
    u0.setExtId("sample_geoserver_user");
    gfUserAdminService.insert(u0);

    GSUser u1 = new GSUser();
    u1.setAdmin(true);
    u1.setName("admin");
    u1.setPassword("password");
    u1.getGroups().add(userGroupAdminService.get(p1id));
    u1.setEnabled(true);
    u1.setFullName("Sample G.S. Admin");
    u1.setEmailAddress("gs.admin@geofence.net");
    u1.setExtId("sample_geoserver_user");
    userAdminService.insert(u1);

    GSInstance gs1 = new GSInstance();
    gs1.setName("geoserver01");
    gs1.setUsername("admin");
    gs1.setPassword("geoserver");
    gs1.setBaseURL("http://localhost/geoserver");
    gs1.setDescription("A sample instance");
    instanceAdminService.insert(gs1);

    Rule r0 = new Rule(5, u1, p2, gs1, null, "s0", "r0", null, null, GrantType.ALLOW);
    ruleAdminService.insert(r0);

    final Long r1id;

    {
        Rule r1 = new Rule(10, null, null, null, null, "s1", "r1", "w1", "l1", GrantType.ALLOW);
        ruleAdminService.insert(r1);
        r1id = r1.getId();
    }

    // save details and check it has been saved
    final Long lid1;
    {
        LayerDetails details = new LayerDetails();
        details.getAllowedStyles().add("FIRST_style1");
        details.getAttributes().add(new LayerAttribute("FIRST_attr1", AccessType.NONE));
        ruleAdminService.setDetails(r1id, details);
        lid1 = details.getId();
        assert lid1 != null;
    }

    // check details have been set in Rule
    {
        Rule loaded = ruleAdminService.get(r1id);
        LayerDetails details = loaded.getLayerDetails();
        assert details != null;
        assert lid1.equals(details.getId());
        assert 1 == details.getAttributes().size();
        assert 1 == details.getAllowedStyles().size();
        LOGGER.info("Found " + loaded + " --> " + loaded.getLayerDetails());
    }

    // set new details
    final Long lid2;
    {
        LayerDetails details = new LayerDetails();
        details.getAttributes().add(new LayerAttribute("attr1", AccessType.NONE));
        details.getAttributes().add(new LayerAttribute("attr2", AccessType.READONLY));
        details.getAttributes().add(new LayerAttribute("attr3", AccessType.READWRITE));

        assert 3 == details.getAttributes().size();

        Set<String> styles = new HashSet<String>();
        styles.add("style1");
        styles.add("style2");
        ruleAdminService.setAllowedStyles(r1id, styles);

        ruleAdminService.setDetails(r1id, details);
        lid2 = details.getId();
        assert lid2 != null;
    }

    // check details
    {
        Rule loaded = ruleAdminService.get(r1id);
        LayerDetails details = loaded.getLayerDetails();
        assert details != null;
        for (LayerAttribute layerAttribute : details.getAttributes()) {
            LOGGER.error(layerAttribute);
        }

        assert 3 == details.getAttributes().size();
        assert 2 == details.getAllowedStyles().size();
        assert details.getAllowedStyles().contains("style1");
    }

}

From source file:com.gst.accounting.journalentry.service.JournalEntryReadPlatformServiceImpl.java

private List<JournalEntryData> populateAllTransactionsFromGLAccounts(final Long contraId) {
    final List<GLAccountData> glAccounts = this.glAccountReadPlatformService
            .retrieveAllEnabledDetailGLAccounts();
    final List<JournalEntryData> openingBalanceTransactions = new ArrayList<>(glAccounts.size());

    for (final GLAccountData glAccountData : glAccounts) {
        if (!contraId.equals(glAccountData.getId())) {
            final JournalEntryData openingBalanceTransaction = JournalEntryData
                    .fromGLAccountData(glAccountData);
            openingBalanceTransactions.add(openingBalanceTransaction);
        }//from  w  ww. j a v  a2s . co  m
    }
    return openingBalanceTransactions;
}

From source file:com.epam.catgenome.manager.BiologicalDataItemManager.java

/**
 * Generates a URL parameters that will open required files on required position, specified by chromosome name,
 * start and end indexes//from   w ww. ja va 2  s.co  m
 *
 *
 * @param dataset
 * @param ids bio logical
 * @param chromosomeName
 * @param startIndex
 * @param endIndex
 * @return
 * @throws JsonProcessingException
 */
@Transactional(propagation = Propagation.REQUIRED)
public String generateUrl(String dataset, List<String> ids, String chromosomeName, Integer startIndex,
        Integer endIndex) throws JsonProcessingException {
    Project project;
    if (NumberUtils.isDigits(dataset)) {
        project = projectManager.loadProject(Long.parseLong(dataset));
    } else {
        project = projectManager.loadProject(dataset);
    }

    Assert.notNull(project, getMessage(MessagesConstants.ERROR_PROJECT_NOT_FOUND, dataset));
    List<String> bioItemNames = new ArrayList<>();
    List<Long> bioItemIds = new ArrayList<>();
    for (String id : ids) {
        if (NumberUtils.isDigits(id)) {
            bioItemIds.add(Long.parseLong(id));
        } else {
            bioItemNames.add(id);
        }
    }

    List<BiologicalDataItem> itemsByNames = biologicalDataItemDao.loadFilesByNamesStrict(bioItemNames);
    if (itemsByNames.size() != bioItemNames.size()) {
        throw new IllegalArgumentException(getMessage(MessagesConstants.ERROR_BIO_NAME_NOT_FOUND,
                bioItemNames.stream().filter(n -> itemsByNames.stream().noneMatch(i -> i.getName().equals(n)))
                        .collect(Collectors.joining(", "))));
    }

    List<BiologicalDataItem> itemsByIds = biologicalDataItemDao.loadBiologicalDataItemsByIds(bioItemIds);
    if (itemsByIds.size() != bioItemIds.size()) {
        throw new IllegalArgumentException(getMessage(MessagesConstants.ERROR_BIO_ID_NOT_FOUND,
                bioItemIds.stream().filter(id -> itemsByIds.stream().noneMatch(i -> i.getId().equals(id)))
                        .map(Object::toString).collect(Collectors.joining(", "))));
    }

    List<BiologicalDataItem> items = new ArrayList<>(itemsByNames.size() + itemsByIds.size());
    items.addAll(itemsByNames);
    items.addAll(itemsByIds);

    List<Long> references = project.getItems().stream()
            .filter(item -> item.getBioDataItem().getFormat() == BiologicalDataItemFormat.REFERENCE)
            .map(item -> item.getBioDataItem().getId()).collect(Collectors.toList());
    Assert.notNull(references);
    Assert.isTrue(!references.isEmpty());
    Long referenceId = references.get(0);

    List<Long> itemIds = new ArrayList<>(items.size());
    for (BiologicalDataItem item : items) {
        if (FeatureFile.class.isAssignableFrom(item.getClass())) {
            FeatureFile file = (FeatureFile) item;
            Assert.isTrue(
                    project.getItems().stream().anyMatch(i -> i.getBioDataItem().getId().equals(item.getId())),
                    getMessage(MessagesConstants.ERROR_PROJECT_FILE_NOT_FOUND, item.getName(),
                            project.getName()));
            Assert.isTrue(referenceId.equals(file.getReferenceId()),
                    "Specified files have different references");
        }
        itemIds.add(BiologicalDataItem.getBioDataItemId(item));
    }
    Reference reference = referenceGenomeManager.loadReferenceGenome(referenceId);
    return makeUrl(items, project, reference, chromosomeName, startIndex, endIndex);
}

From source file:org.apache.bookkeeper.replication.TestLedgerUnderreplicationManager.java

/**
 * Test releasing of a ledger//www  . j  a  va2  s.  c  o m
 * A ledger is released when a client decides it does not want
 * to replicate it (or cannot at the moment).
 * When a client releases a previously acquired ledger, another
 * client should then be able to acquire it.
 */
@Test(timeout = 60000)
public void testRelease() throws Exception {
    String missingReplica = "localhost:3181";

    LedgerUnderreplicationManager m1 = lmf1.newLedgerUnderreplicationManager();
    LedgerUnderreplicationManager m2 = lmf2.newLedgerUnderreplicationManager();

    Long ledgerA = 0xfeadeefdacL;
    Long ledgerB = 0xdefadebL;
    m1.markLedgerUnderreplicated(ledgerA, missingReplica);
    m1.markLedgerUnderreplicated(ledgerB, missingReplica);

    Future<Long> fA = getLedgerToReplicate(m1);
    Future<Long> fB = getLedgerToReplicate(m1);

    Long lA = fA.get(5, TimeUnit.SECONDS);
    Long lB = fB.get(5, TimeUnit.SECONDS);

    assertTrue("Should be the ledgers I just marked",
            (lA.equals(ledgerA) && lB.equals(ledgerB)) || (lA.equals(ledgerB) && lB.equals(ledgerA)));

    Future<Long> f = getLedgerToReplicate(m2);
    try {
        f.get(1, TimeUnit.SECONDS);
        fail("Shouldn't be able to find a ledger to replicate");
    } catch (TimeoutException te) {
        // correct behaviour
    }
    m1.markLedgerReplicated(lA);
    m1.releaseUnderreplicatedLedger(lB);

    Long l = f.get(5, TimeUnit.SECONDS);
    assertEquals("Should be the ledger I marked", lB, l);
}

From source file:org.apache.bookkeeper.replication.TestLedgerUnderreplicationManager.java

/**
 * Test that when a ledger has been marked as replicated, it
 * will not be offered to anther client.
 * This test checked that by marking two ledgers, and acquiring
 * them on a single client. It marks one as replicated and then
 * the client is killed. We then check that another client can
 * acquire a ledger, and that it's not the one that was previously
 * marked as replicated.// ww  w  .jav  a 2 s.co  m
 */
@Test(timeout = 60000)
public void testMarkingAsReplicated() throws Exception {
    String missingReplica = "localhost:3181";

    LedgerUnderreplicationManager m1 = lmf1.newLedgerUnderreplicationManager();
    LedgerUnderreplicationManager m2 = lmf2.newLedgerUnderreplicationManager();

    Long ledgerA = 0xfeadeefdacL;
    Long ledgerB = 0xdefadebL;
    m1.markLedgerUnderreplicated(ledgerA, missingReplica);
    m1.markLedgerUnderreplicated(ledgerB, missingReplica);

    Future<Long> fA = getLedgerToReplicate(m1);
    Future<Long> fB = getLedgerToReplicate(m1);

    Long lA = fA.get(5, TimeUnit.SECONDS);
    Long lB = fB.get(5, TimeUnit.SECONDS);

    assertTrue("Should be the ledgers I just marked",
            (lA.equals(ledgerA) && lB.equals(ledgerB)) || (lA.equals(ledgerB) && lB.equals(ledgerA)));

    Future<Long> f = getLedgerToReplicate(m2);
    try {
        f.get(1, TimeUnit.SECONDS);
        fail("Shouldn't be able to find a ledger to replicate");
    } catch (TimeoutException te) {
        // correct behaviour
    }
    m1.markLedgerReplicated(lA);
    zkc1.close(); // should kill the lock
    zkc1 = null;

    Long l = f.get(5, TimeUnit.SECONDS);
    assertEquals("Should be the ledger I marked", lB, l);
}

From source file:de.micromata.genome.chronos.spi.ram.RamJobStore.java

/**
 * Gets the job count./* w w w .  j  a  v a 2  s .co  m*/
 *
 * @param schedulerName the scheduler name
 * @param state the state
 * @return the job count
 */
public synchronized long getJobCount(String schedulerName, State state) {
    long result = 0;
    Long schedPk = findSchedulerPkByName(schedulerName);

    for (Map<Long, TriggerJobDO> v : allJobs.values()) {
        for (TriggerJobDO tj : v.values()) {
            if (state != null && tj.getState() != state) {
                continue;
            }
            if (schedPk != null && schedPk.equals(tj.getScheduler()) == false) {
                continue;
            }
        }
        ++result;
    }
    return result;
}

From source file:com.doculibre.constellio.entities.RecordCollection.java

public CollectionFacet getCollectionFacet(Long id) {
    CollectionFacet match = null;/*from ww w  .j  av a2s.c om*/
    for (CollectionFacet collectionFacet : collectionFacets) {
        match = id.equals(collectionFacet.getId()) ? collectionFacet : null;
        if (match != null) {
            break;
        }
    }
    return match;
}

From source file:edu.scripps.fl.pubchem.EUtilsFactory.java

public Collection<Long> getIds(Long id, String fromDb, String toDb) throws Exception {
    Document document = EUtilsFactory.getInstance().getDocument(
            "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi", "dbfrom", fromDb, "db", toDb, "id",
            "" + id);
    List<Node> linkSetDbs = document.selectNodes("/eLinkResult/LinkSet/LinkSetDb");
    Set<Long> relatedIds = new HashSet<Long>();
    for (Node linkSetDb : linkSetDbs) {
        String linkName = linkSetDb.selectSingleNode("LinkName").getText();
        List<Node> ids = linkSetDb.selectNodes("Link/Id");
        for (Node idNode : ids) {
            long relatedId = Long.parseLong(idNode.getText());
            if (id.equals(relatedId))
                continue;
            relatedIds.add(relatedId);//w  w w .j a va  2s. c  o m
        }
    }
    return relatedIds;
}