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.baidu.cc.web.action.VersionSaveAction.java

/**
 * <pre>//from   w ww . ja  v  a 2  s .  co m
 * ???????
 * ???????
 * </pre>
 * 
 * .
 * 
 * @param reqParam
 *            request param
 * @return req parameters valid result.
 */
protected Map<String, String> doValidate(ReqParam reqParam) {
    Map<String, String> result = new HashMap<String, String>();
    Version version = reqParam.getVersion();
    if (version == null) {
        result.put("envNull", "");
    } else {
        if (StringUtils.isBlank(version.getName()) || version.getName().length() > 50) {
            result.put("nameLengthError", "??150");
        }
        Long versionId = versionService.findIdByName(version.getName());
        if (versionId != null && !versionId.equals(version.getId())) {
            result.put("nameUniqError", "????");
        }

        if (StringUtils.isNotBlank(version.getMemo()) && version.getMemo().length() > 255) {
            result.put("memoLengthError", "255");
        }
    }

    return result;

}

From source file:ispok.pres.bb.CashgameManager.java

public void setCashgameId(Long cashgameId) {
    for (CashgameDto c : cashgames) {
        if (cashgameId.equals(c.getId())) {
            cashgame = c;//from w  w  w  .  j  a  va  2 s.  c o  m
            cashgameSessions = cashgameSessionService.getActiveSessionsByCashgameId(cashgame.getId());
            players = new ArrayList<>(cashgameSessions.size());
            for (CashgameSessionDto csd : cashgameSessions) {
                players.add(visitorService.getVisitorById(csd.getVisitorId()));
            }
            break;
        }
    }
    this.cashgameId = cashgameId;
}

From source file:com.baidu.gcrm.customer.web.validator.CustomerBaseValidator.java

/**
 * /*from  w  w w .  ja v a2  s  .  c  o  m*/
 * validatorNameAndLicense(???????)
 */
protected void validatorNameAndLicense(Customer customer, Errors errors) {
    /**
     * 
     * 1.+?? ??? 2.??????? 3.????+???? ????
     * 
     */

    Integer countryId = customer.getCountry();
    List<Customer> existCustomers4Name = ServiceBeanFactory.getCustomerService()
            .findByCountryAndName(customer.getCountry(), customer.getCompanyName());
    Long customerId = customer.getId();

    if (existCustomers4Name != null) {
        if (existCustomers4Name.size() > 1) {
            errors.rejectValue("customer.companyName", "customer.companyName.notunique");
        } else if (existCustomers4Name.size() == 1) {
            Long tempCustomerId = existCustomers4Name.get(0).getId();
            if (customerId == null || !tempCustomerId.equals(customerId)) {
                errors.rejectValue("customer.companyName", "customer.companyName.notunique");
            }

        }
    }
    if (errors.hasErrors()) {
        return;
    }
    // ???
    String liscenseStr = customer.getBusinessLicense();
    if (StringUtils.isBlank(liscenseStr)) {
        return;
    }
    List<Customer> existCustomers4License = ServiceBeanFactory.getCustomerService()
            .findByCountryAndLiscense(countryId, liscenseStr);

    if (existCustomers4License != null) {
        if (existCustomers4License.size() > 1) {
            errors.rejectValue("customer.businessLicense", "customer.businessLicense.notunique");
        } else if (existCustomers4License.size() == 1) {
            Long tempCustomerId = existCustomers4License.get(0).getId();
            if (customerId == null || !tempCustomerId.equals(customerId))
                errors.rejectValue("customer.businessLicense", "customer.businessLicense.notunique");
        }
    }

}

From source file:no.abmu.user.service.hibernate3.UserImportServiceH3Impl.java

private boolean runInTransaction(Session session, OrganisationUnitImportExcelParser excelParser) {

    boolean importWentOK = true;

    // Setting up new key values before storing values in excelFiles.
    init(session);//  w  w w  .  j a  v a 2s.c  om

    // Check for existence for expected roles in UserRegister.
    if (!checkExistanceOfRolesForOrganisationUnits(excelParser)) {
        String errorMessage = "Trying to use non existent role(s).";
        logger.error(errorMessage);
        throw new IllegalStateException(errorMessage);
    }

    excelParser.load();
    for (; excelParser.hasNext(); excelParser.next()) {
        Long user = excelParser.getUser();
        if (user != null && user.equals(Long.valueOf(1))) {
            String orgUnitName = excelParser.getBokmaalName();
            String abmuId = excelParser.getABMU_ID();
            List<Entity> entitiesStoreList = createUserStoreList(abmuId, orgUnitName);
            if (entitiesStoreList == null || entitiesStoreList.size() == 0) {
                logger.warn("Can not create user for organisationUnit with name: '" + orgUnitName
                        + "' rollback and no import.");
                doRollback = true;
                importWentOK = false;
            } else {
                // Everything went OK saving new user.
                Hibernate3Util.saveEntities(session, entitiesStoreList);
            }
        }
    }
    return importWentOK;
}

From source file:com.bia.ccm.services.impl.OrderServiceImpl.java

private void validateOrganization(Long id, Long organization) {
    if (!id.equals(organization)) {
        throw new InvalidInputException(" incorrect organization ");
    }/*w  ww . j a va2s  . c  om*/
}

From source file:com.blackducksoftware.integration.jira.task.issue.event.IssueEventListener.java

@EventListener
public void onIssueEvent(final IssueEvent issueEvent) {
    try {//  w  ww  .j a  v  a 2s .co  m
        final Long eventTypeID = issueEvent.getEventTypeId();
        final Issue issue = issueEvent.getIssue();

        if (!eventTypeID.equals(EventType.ISSUE_CREATED_ID)) {
            logger.debug("=== ISSUE EVENT ===");
            logger.debug(String.format("Event Type ID:    %s", eventTypeID));
            logger.debug(String.format("Issue:            %s", issue));

            final String propertyKey = hubIssueTrackerPropertyHandler.createEntityPropertyKey(issue);
            final EntityProperty hubIssueUrlProperty = getHubIssueTrackerUrlProperty(propertyKey, issue);

            if (hubIssueUrlProperty == null) {
                logger.debug(String.format(
                        "Hub Issue Tracker URL not present. No further processing for issue: %s", issue));
            } else {
                final PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
                executorService.submit(createTask(issue, eventTypeID, jiraServices, settings, propertyKey,
                        hubIssueUrlProperty));
            }
        }
    } catch (final Exception ex) {
        logger.error("An unexpected error occurred processing issue event ", ex);
    }
}

From source file:org.messic.server.datamodel.jpaimpl.DAOJPAUser.java

@Override
@Transactional//from  w ww .  ja  v a  2 s  .c om
public boolean existUsers() {
    Query query = entityManager.createQuery("SELECT COUNT(sid) FROM MDOUser");
    Long usersCount = (Long) query.getSingleResult();
    if (usersCount != null && usersCount.equals(0L)) {
        return false;
    } else {
        return true;
    }
}

From source file:com.healthcit.cacure.dao.QuestionTableDao.java

@Transactional(propagation = Propagation.REQUIRED)
public void reorderQuestions(Long sourceQuestionId, Long targetQuestionId, boolean before) {

    Validate.notNull(sourceQuestionId);/*from  w w  w  . j ava2 s. c  om*/
    Validate.notNull(targetQuestionId);

    if (sourceQuestionId.equals(targetQuestionId)) {
        return;
    }

    Query query = em.createQuery("SELECT ord, form.id FROM TableQuestion WHERE id = :id");

    Object[] result = (Object[]) query.setParameter("id", sourceQuestionId).getSingleResult();
    int sOrd = (Integer) result[0];
    long sFormId = (Long) result[1];

    result = (Object[]) query.setParameter("id", targetQuestionId).getSingleResult();
    int tOrd = (Integer) result[0];
    long tFormId = (Long) result[1];

    Validate.isTrue(sFormId == tFormId); //reorder only inside one form

    if (sOrd == tOrd || (before && sOrd == tOrd - 1) || (!before && sOrd == tOrd + 1)) {
        return;
    } else if (sOrd < tOrd) {
        em.createQuery("UPDATE TableQuestion SET ord = ord - 1 WHERE ord > :sOrd and ord "
                + (before ? "<" : "<=") + " :tOrd and form.id = :formId").setParameter("sOrd", sOrd)
                .setParameter("tOrd", tOrd).setParameter("formId", sFormId).executeUpdate();
        em.createQuery("UPDATE TableQuestion SET ord = :tOrd WHERE id = :qId")
                .setParameter("qId", sourceQuestionId).setParameter("tOrd", before ? tOrd - 1 : tOrd)
                .executeUpdate();
    } else if (sOrd > tOrd) {
        em.createQuery("UPDATE TableQuestion SET ord = ord + 1 WHERE ord < :sOrd and ord "
                + (before ? ">=" : ">") + " :tOrd and form.id = :formId").setParameter("sOrd", sOrd)
                .setParameter("tOrd", tOrd).setParameter("formId", sFormId).executeUpdate();
        em.createQuery("UPDATE TableQuestion SET ord = :tOrd WHERE id = :qId")
                .setParameter("qId", sourceQuestionId).setParameter("tOrd", before ? tOrd : tOrd + 1)
                .executeUpdate();
    }
}

From source file:org.bpmscript.js.reload.LibraryFileMonitor.java

/**
 * Checks whether the internal libraries have changed. If they do, publishes
 * out to a queue the list of files that need to be reloaded as a result
 *//*from  w  w  w. j  a  va  2s  . c o  m*/
@SuppressWarnings("unchecked")
protected void checkLibraries() {
    ArrayList<ILibraryToFile> newLibraryToFiles = new ArrayList<ILibraryToFile>();
    libraryAssociationQueue.drainTo(newLibraryToFiles);
    for (ILibraryToFile libraryToFile : newLibraryToFiles) {
        Set set = libraryToFilesMap.get(libraryToFile.getLibrary());
        if (set == null) {
            set = new HashSet<String>();
            libraryToFilesMap.put(libraryToFile.getLibrary(), set);
        }
        set.add(libraryToFile.getFile());
    }
    Iterator iterator = libraryToFilesMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry entry = (Entry) iterator.next();
        String library = (String) entry.getKey();
        URL resource = this.getClass().getResource(library);
        if ("file".equals(resource.getProtocol())) {
            String path = resource.getPath();
            File file = new File(path);
            Long newLastModified = file.lastModified();
            Long oldLastModified = libraryToLastModifiedMap.get(library);
            if (oldLastModified != null && !(oldLastModified.equals(newLastModified))) {
                // library has changed, we should go through its files and notify listeners
                // that they need to reload. also, we need to check to see if the files are
                // libraries themselves...
                Collection values = (Collection) entry.getValue();
                for (Iterator valueIterator = values.iterator(); valueIterator.hasNext();) {
                    String value = (String) valueIterator.next();
                    if (libraryToFilesMap.containsKey(value)) {
                        // TODO: here we need to recurse
                    } else {
                        // notify listeners that the file has changed. consider notifying
                        // listeners that the library has changed...
                        libraryChangeQueue.add(new LibraryToFile(library, value));
                    }
                }
                libraryToLastModifiedMap.put(library, newLastModified);
            } else if (oldLastModified == null) {
                libraryToLastModifiedMap.put(library, newLastModified);
            }
        }
    }
}

From source file:edu.psu.iam.cpr.core.util.Utility.java

/**
 * This routine is used to determine if a database field already equals another field.
 *
 * @param parm1 contains the first field to test.
 * @param parm2 contains the second field to test.
 * @return will return true if the field are equal, otherwise it will return false.
 *//*from   w w  w  .  j a  va 2 s .co m*/
public static boolean areLongFieldsEqual(final Long parm1, final Long parm2) {

    try {
        if (parm1 == null && parm2 == null) {
            return true;
        } else if (parm1 == null && parm2 != null || parm1 != null && parm2 == null) {
            return false;
        } else if (parm1 != null && parm2 == null) {
            return false;
        } else {
            return parm1.equals(parm2);
        }
    } catch (final Exception e) {
        return false;
    }
}