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.ambraproject.admin.service.DocumentManagementServiceTest.java

@Test(dataProvider = "storedPublishedArticles")
void testDelete(String article, Long articleId) throws Exception {
    documentManagementService.delete(article, DEFAULT_ADMIN_AUTHID);
    assertNull(dummyDataStore.get(Article.class, articleId), "didn't delete article");
    for (ArticleRelationship relationship : dummyDataStore.getAll(ArticleRelationship.class)) {
        if (articleId.equals(relationship.getOtherArticleID())) {
            fail("failed to delete unlink article relationship: " + relationship);
        }/*  w w  w  .ja v a2s  . c o m*/
    }
}

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

/**
 * //from ww w  . j  a  v  a  2 s . com
 * 
 * @param req
 *            basic request
 * @param resp
 *            basic resp
 * @throws ServletException
 *             basic
 * @throws IOException
 *             basic
 */
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    Boolean originalMode = store.getReadOnlyMode();
    store.setReadOnlyMode(true);

    String[] serviceMergeIdList = req.getParameterValues("serviceIdMergeSource[]");
    Enumeration<String> names = (Enumeration<String>) req.getParameterNames();
    while (names.hasMoreElements()) {
        log.debug(names.nextElement());
    }
    Long serviceIdMergeSource = null;
    Long serviceIdMergeDestination = null;
    ServiceMergeResults mergeResults = null;
    Map<String, String> responseMap = new HashMap<String, String>();
    try {
        for (int i = 0; i < serviceMergeIdList.length; i++) {

            serviceIdMergeSource = new Long(serviceMergeIdList[i]);
            serviceIdMergeDestination = new Long(req.getParameter("serviceIdMergeDestination"));
            if (!serviceIdMergeSource.equals(serviceIdMergeDestination)) {

                Service serviceMergeSource = store.getServiceById(serviceIdMergeSource);
                Service serviceMergeDestination = store.getServiceById(serviceIdMergeDestination);
                MockeyXmlFileManager configurationReader = new MockeyXmlFileManager();
                mergeResults = configurationReader.mergeServices(serviceMergeSource, serviceMergeDestination,
                        mergeResults, null);

            }
            responseMap.put("additions", mergeResults.getAdditionMsg());
            responseMap.put("conflicts", mergeResults.getConflictMsg());
        }

    } catch (Exception e) {
        // Do nothing
        log.error("Something wrong with merging services.", e);
        responseMap.put("conflicts",
                "Unable to merge services. The services selected may be missing or contain bad data. Sorry about this.");

    }

    // IF NO CONFLICTS, THEN DELETE OLD SOURCE SERVICES
    if (mergeResults != null
            && (mergeResults.getConflictMsgs() == null || mergeResults.getConflictMsgs().isEmpty())) {
        for (int i = 0; i < serviceMergeIdList.length; i++) {
            serviceIdMergeSource = new Long(serviceMergeIdList[i]);
            Service service = store.getServiceById(serviceIdMergeSource);
            store.deleteService(service);
        }

    }
    resp.setContentType("application/json");
    PrintWriter out = resp.getWriter();

    String resultingJSON = Util.getJSON(responseMap);
    out.println(resultingJSON);

    out.flush();
    out.close();
    store.setReadOnlyMode(originalMode);
    return;
    // AJAX thing. Return nothing at this time.
}

From source file:no.abmu.user.service.AbstractUserImportService.java

protected boolean checkExistanceOfRolesForOrganisationUnits(OrganisationUnitImportExcelParser excelParser) {
    Assert.checkRequiredArgument("excelParser", excelParser);

    boolean allRolesExist = true;
    excelParser.load();/*ww w .  j a v a2  s.c o m*/
    List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
    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();
            OrganisationUnit organisationUnit = getSingleOrganisationUnit(abmuId, orgUnitName);
            organisationUnits.add(organisationUnit);
        }
    }

    Set<String> roleNames = new HashSet<String>();
    for (OrganisationUnit organisationUnit : organisationUnits) {
        String organisationTypeName = getMainOrganisationType(organisationUnit);
        Set<String> roleNamesForMainOrgType = getRoleNames(organisationUnit, organisationTypeName);
        roleNames.addAll(roleNamesForMainOrgType);
    }

    Map<String, Role> rolesFromDbInMap = rolesFromDbInMap();
    for (String roleName : roleNames) {
        if (!rolesFromDbInMap.containsKey(roleName)) {
            String warningMessage = "Role does not exist in RoleRegister RoleName : '" + roleName + "'.";
            logger.warn(warningMessage);
            // System.out.println(warningMessage);
            allRolesExist = false;
        }
    }
    return allRolesExist;
}

From source file:com.xabber.android.ui.ContactViewer.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
        // View information about contact from system contact list
        Uri data = getIntent().getData();
        if (data != null && "content".equals(data.getScheme())) {
            List<String> segments = data.getPathSegments();
            if (segments.size() == 2 && "data".equals(segments.get(0))) {
                Long id;
                try {
                    id = Long.valueOf(segments.get(1));
                } catch (NumberFormatException e) {
                    id = null;//from  w w  w  .  j a v  a2  s .c o  m
                }
                if (id != null)
                    // FIXME: Will be empty while application is loading
                    for (RosterContact rosterContact : RosterManager.getInstance().getContacts())
                        if (id.equals(rosterContact.getViewId())) {
                            account = rosterContact.getAccount();
                            bareAddress = rosterContact.getUser();
                            break;
                        }
            }
        }
    } else {
        account = getAccount(getIntent());
        bareAddress = Jid.getBareAddress(getUser(getIntent()));
    }

    if (bareAddress != null && bareAddress.equalsIgnoreCase(GroupManager.IS_ACCOUNT)) {
        bareAddress = Jid.getBareAddress(AccountManager.getInstance().getAccount(account).getRealJid());
    }

    if (account == null || bareAddress == null) {
        Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
        finish();
        return;
    }

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.scrollable_container, ContactVcardViewerFragment.newInstance(account, bareAddress))
                .commit();
    }

    contactTitleExpandableToolbarInflater = new ContactTitleExpandableToolbarInflater(this);
    AbstractContact bestContact = RosterManager.getInstance().getBestContact(account, bareAddress);
    contactTitleExpandableToolbarInflater.onCreate(bestContact);

    View contactTitleView = findViewById(R.id.expandable_contact_title);
    contactTitleView.findViewById(R.id.status_icon).setVisibility(View.GONE);
    contactTitleView.findViewById(R.id.status_text).setVisibility(View.GONE);
    contactNameView = (TextView) contactTitleView.findViewById(R.id.name);

    Toolbar toolbar = contactTitleExpandableToolbarInflater.getToolbar();
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            NavUtils.navigateUpFromSameTask(ContactViewer.this);
        }
    });
}

From source file:com.ethlo.geodata.GeodataServiceImpl.java

@Override
public boolean isInsideAny(List<Long> locations, long location) {
    final GeoLocation loc = findById(location);
    if (loc == null) {
        throw new EmptyResultDataAccessException("No such location found " + location, 1);
    }/*from   ww  w.j ava  2 s.  co m*/

    for (Long l : locations) {
        if (l.equals(location) || isLocationInside(location, l)) {
            return true;
        }
    }
    return false;
}

From source file:eionet.gdem.web.struts.config.SystemAction.java

@Override
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm,
        HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {

    ActionMessages errors = new ActionMessages();
    ActionMessages messages = new ActionMessages();

    DynaValidatorForm form = (DynaValidatorForm) actionForm;

    String cmdXGawk = (String) form.get("cmdXGawk");
    Long qaTimeout = (Long) form.get("qaTimeout");
    String user = (String) httpServletRequest.getSession().getAttribute("user");

    try {//w  w  w . j a  v a 2  s.c  o  m

        if (!SecurityUtil.hasPerm(user, "/" + Names.ACL_CONFIG_PATH, "u")) {
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.autorization.config.update"));
            httpServletRequest.getSession().setAttribute("dcm.errors", errors);
            return actionMapping.findForward("success");
        }
        if (qaTimeout == null || qaTimeout.equals("") || qaTimeout <= 0) {
            errors.add(ActionMessages.GLOBAL_MESSAGE,
                    new ActionMessage("label.config.system.qatimeout.validation"));
            httpServletRequest.getSession().setAttribute("dcm.errors", errors);
            return actionMapping.findForward("success");
        }

        DcmProperties dcmProp = new DcmProperties();

        dcmProp.setSystemParams(qaTimeout, cmdXGawk);

    } catch (DCMException e) {
        e.printStackTrace();
        LOGGER.error("SystemAction error", e);
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getErrorCode()));
        saveErrors(httpServletRequest, errors);
        httpServletRequest.getSession().setAttribute("dcm.errors", errors);
        return actionMapping.findForward("success");
    } catch (Exception e) {
        e.printStackTrace();
        LOGGER.error("SystemAction error", e);
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.exception.unknown"));
        saveErrors(httpServletRequest, errors);
        httpServletRequest.getSession().setAttribute("dcm.errors", errors);
        return actionMapping.findForward("success");
    }
    messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.editParam.system.saved"));

    httpServletRequest.getSession().setAttribute("dcm.errors", errors);
    httpServletRequest.getSession().setAttribute("dcm.messages", messages);
    return actionMapping.findForward("success");
}

From source file:jp.primecloud.auto.ui.ServerTable.java

public void setButtonStatus(Instance instance) {
    for (Entry<Long, List<Button>> entry : map.entrySet()) {
        Long key = entry.getKey();
        if (key.equals(instance.getInstanceNo())) {
            for (Button button : entry.getValue()) {
                if ("".equals(instance.getStatus())
                        || InstanceStatus.STOPPED.toString().equals(instance.getStatus())) {
                    if (("STOP".equals(button.getCaption()))) {
                        button.setEnabled(false);
                    } else if (("START".equals(button.getCaption()))) {
                        button.setIcon(Icons.PLAY.resource());
                        button.setDescription(ViewProperties.getCaption("description.startServer"));
                        button.setEnabled(true);
                    } else {
                        button.setEnabled(true);
                    }//from ww  w.j  a  va 2s. c o  m
                } else if (InstanceStatus.RUNNING.toString().equals(instance.getStatus())) {
                    if (("STOP".equals(button.getCaption()))) {
                        button.setEnabled(true);
                    } else if (("START".equals(button.getCaption()))) {
                        button.setIcon(Icons.RELOAD.resource());
                        button.setDescription(ViewProperties.getCaption("description.reloadServer"));
                        button.setEnabled(true);
                    } else {
                        button.setEnabled(false);
                    }
                } else if (InstanceStatus.WARNING.toString().equals(instance.getStatus())) {
                    if (("STOP".equals(button.getCaption()))) {
                        button.setEnabled(true);
                    } else {
                        button.setEnabled(false);
                    }
                } else {
                    button.setEnabled(false);
                }
            }
        } else {
            for (Button button : entry.getValue()) {
                button.setEnabled(false);
            }
        }
    }
}

From source file:com.gst.portfolio.loanaccount.guarantor.domain.Guarantor.java

public boolean hasGuarantor(Long savingsId) {
    if (savingsId == null) {
        return false;
    }/*from  w  ww  .j ava2 s.com*/
    boolean hasGuarantee = false;
    for (GuarantorFundingDetails guarantorFundingDetails : this.guarantorFundDetails) {
        if (guarantorFundingDetails.getStatus().isActive()
                && savingsId.equals(guarantorFundingDetails.getLinkedSavingsAccount().getId())) {
            hasGuarantee = true;
            break;
        }
    }
    return hasGuarantee;
}

From source file:com.hiperium.bo.control.impl.TaskBOImpl.java

/**
 * //from  ww w.  j  a  va 2 s .  c  o m
 * @param taskId
 * @return
 */
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
private Timer findTimer(Long taskId) {
    this.log.debug("findTimer - START");
    Timer timer = null;
    Collection<Timer> timers = this.timerService.getTimers();
    if (timers != null) {
        for (Iterator<Timer> iterator = timers.iterator(); iterator.hasNext();) {
            Timer t = iterator.next();
            try {
                if (taskId.equals((Long) t.getInfo())) {
                    timer = t;
                }
            } catch (Exception e) {
                this.log.debug("ERROR: " + e.getMessage());
            }
        }
    }
    this.log.debug("findTimer - END");
    return timer;
}

From source file:com.termmed.statistics.Processor.java

private void printInternPriorityList(IReportDetail file, HashSet<Long> conceptList, File outputFold)
        throws IOException {
    File exclFile = new File(I_Constants.EXCLUYENT_OUTPUT_FOLDER + "/" + file.getFile()
            + (file.getFile().toLowerCase().endsWith(".csv") ? "" : ".csv"));
    File completeDetailFile = new File(I_Constants.STATS_OUTPUT_FOLDER + "/" + file.getFile()
            + (file.getFile().toLowerCase().endsWith(".csv") ? "" : ".csv"));
    TreeSet<Long> order = getOrder(file, completeDetailFile);
    BufferedWriter bw = FileHelper.getWriter(exclFile);
    Integer sctIdIndex = file.getSctIdIndex();
    if (sctIdIndex == null) {
        sctIdIndex = 1;//from w ww  .j ava2  s. c  om
    }
    Integer priorityIndex = file.getPriorityListColumnIndex();
    if (priorityIndex == null) {
        priorityIndex = 5;
    }
    boolean first = true;
    String line;
    String[] spl;

    for (Long ord : order) {
        BufferedReader br = FileHelper.getReader(completeDetailFile);
        if (first) {
            bw.append(br.readLine());
            bw.append("\r\n");
            first = false;
        } else {
            br.readLine();
        }

        while ((line = br.readLine()) != null) {
            spl = line.split(",", -1);
            Long prior = Long.parseLong(spl[priorityIndex]);
            if (!prior.equals(ord)) {
                continue;
            }
            Long cid = Long.parseLong(spl[sctIdIndex]);
            if (conceptList.contains(cid)) {
                continue;
            }
            bw.append(line);
            bw.append("\r\n");
            conceptList.add(cid);
        }

        br.close();
    }
    bw.close();

}