List of usage examples for java.lang Long equals
public boolean equals(Object obj)
From source file:ips1ap101.lib.core.control.UsuarioAutenticado.java
private RolBase findRol(Long id, Collection<? extends RolBase> roles) { if (roles != null && !roles.isEmpty()) { for (RolBase element : roles) { if (id.equals(element.getIdRol())) { return element; }// w w w. j a v a 2s . c o m } } Bitacora.trace("*** rol " + id + " not found ***"); return null; }
From source file:org.apache.openmeetings.webservice.GroupWebService.java
/** * * Remove user from a certain group/* w w w .j av a 2 s .c o m*/ * * @param sid * The SID from getSession * @param userid * the user id * @param id * the group id * @return {@link ServiceResult} with result type, and id of the user added, or error id in case of the error as text */ @DELETE @Path("/{id}/users/{userid}") public ServiceResult removeUser(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") Long id, @PathParam("userid") @WebParam(name = "userid") Long userid) { return performCall(sid, User.Right.Soap, sd -> { if (groupUserDao.isUserInGroup(id, userid)) { User u = userDao.get(userid); for (Iterator<GroupUser> iter = u.getGroupUsers().iterator(); iter.hasNext();) { GroupUser gu = iter.next(); if (id.equals(gu.getGroup().getId())) { iter.remove(); } } userDao.update(u, sd.getUserId()); } return new ServiceResult(String.valueOf(userid), Type.SUCCESS); }); }
From source file:net.mindengine.oculus.frontend.web.controllers.project.ProjectAjaxBrowseController.java
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String id = request.getParameter("id"); if (id == null || !id.startsWith("p")) throw new InvalidRequest(); Long projectId = Long.parseLong(id.substring(1)); boolean asRoot = false; if (request.getParameter("asRoot") != null) { asRoot = true;//from w w w . j a v a 2 s .c o m } List<Project> projects = projectDAO.getSubprojects(projectId); List<Test> tests = testDAO.getTestsByProjectId(projectId); OutputStream os = response.getOutputStream(); response.setContentType("text/xml"); OutputStreamWriter w = new OutputStreamWriter(os); w.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); w.write("<tree id=\""); if (projectId.equals(0L) || asRoot) { w.write("0"); } else w.write(id); w.write("\">"); for (Project project : projects) { w.write("<item text=\""); w.write(StringEscapeUtils.escapeXml(project.getName())); w.write("\" id=\"p"); w.write(Long.toString(project.getId())); w.write("\" im0=\"tombs.gif\" im1=\"tombs_open.gif\" im2=\"tombs.gif\" "); if (project.getSubprojectsCount() > 0 || project.getTestsCount() > 0) { w.write(" child=\"1\" "); } w.write("></item>"); } for (Test test : tests) { w.write("<item text=\""); w.write(StringEscapeUtils.escapeXml(test.getName())); w.write("\" id=\"t"); w.write(Long.toString(test.getId())); w.write("\" im0=\"iconTest.png\" im1=\"iconTest.png\" im2=\"iconTest.png\" "); w.write("></item>"); } w.write("</tree>"); w.flush(); w.close(); return null; }
From source file:com.aistor.modules.cms.web.CategoryController.java
@RequiresUser @ResponseBody/*from w ww . j a v a2 s. co m*/ @RequestMapping(value = "treeData") public String treeData(String module, @RequestParam(required = false) Long extId, HttpServletResponse response) { response.setContentType("application/json; charset=UTF-8"); List<Map<String, Object>> mapList = Lists.newArrayList(); List<Category> list = Lists.newArrayList(); if (StringUtils.isNotBlank(module)) { list = categoryService.findByUserAndModule(module); } else { list = categoryService.findByUser(true); } for (int i = 0; i < list.size(); i++) { Category e = list.get(i); if (extId == null || (extId != null && !extId.equals(e.getId()) && e.getParentIds().indexOf("," + extId + ",") == -1)) { Map<String, Object> map = Maps.newHashMap(); map.put("id", e.getId()); map.put("pId", e.getParent() != null ? e.getParent().getId() : 0); map.put("name", e.getName()); map.put("module", e.getModule()); mapList.add(map); } } return JsonMapper.getInstance().toJson(mapList); }
From source file:com.xabber.android.ui.activity.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 ww . j a v a 2 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 = 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; } setContentView(R.layout.contact_viewer); if (savedInstanceState == null) { Fragment fragment; if (MUCManager.getInstance().hasRoom(account, bareAddress)) { fragment = ConferenceInfoFragment.newInstance(account, bareAddress); } else { fragment = ContactVcardViewerFragment.newInstance(account, bareAddress); } getFragmentManager().beginTransaction().add(R.id.scrollable_container, fragment).commit(); } bestContact = RosterManager.getInstance().getBestContact(account, bareAddress); toolbar = (Toolbar) findViewById(R.id.toolbar_default); toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { NavUtils.navigateUpFromSameTask(ContactViewer.this); } }); StatusBarPainter statusBarPainter = new StatusBarPainter(this); statusBarPainter.updateWithAccountName(account); final int accountMainColor = ColorManager.getInstance().getAccountPainter().getAccountMainColor(account); contactTitleView = findViewById(R.id.contact_title_expanded); findViewById(R.id.status_icon).setVisibility(View.GONE); contactTitleView.setBackgroundColor(accountMainColor); TextView contactNameView = (TextView) findViewById(R.id.name); contactNameView.setVisibility(View.INVISIBLE); collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle(bestContact.getName()); collapsingToolbar.setBackgroundColor(accountMainColor); collapsingToolbar.setContentScrimColor(accountMainColor); }
From source file:com.healthcit.cacure.dao.FormElementDao.java
@Transactional(propagation = Propagation.REQUIRED) public void reorderFormElements(Long sourceFormElementId, Long targetFormElementId, boolean before) { Validate.notNull(sourceFormElementId); Validate.notNull(targetFormElementId); if (sourceFormElementId.equals(targetFormElementId)) { return;//from w ww . j a v a2 s.c o m } Query query = em.createQuery("SELECT ord, form.id FROM FormElement WHERE id = :id"); Object[] result = (Object[]) query.setParameter("id", sourceFormElementId).getSingleResult(); int sOrd = (Integer) result[0]; long sFormId = (Long) result[1]; result = (Object[]) query.setParameter("id", targetFormElementId).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 FormElement 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 FormElement SET ord = :tOrd WHERE id = :qId") .setParameter("qId", sourceFormElementId).setParameter("tOrd", before ? tOrd - 1 : tOrd) .executeUpdate(); } else if (sOrd > tOrd) { em.createQuery("UPDATE FormElement 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 FormElement SET ord = :tOrd WHERE id = :qId") .setParameter("qId", sourceFormElementId).setParameter("tOrd", before ? tOrd : tOrd + 1) .executeUpdate(); } }
From source file:ips1ap101.lib.core.control.UsuarioAutenticado.java
private ConjuntoSegmentoBase findConjunto(Long id, Collection<? extends ConjuntoSegmentoBase> conjuntos) { if (conjuntos != null && !conjuntos.isEmpty()) { for (ConjuntoSegmentoBase element : conjuntos) { if (id.equals(element.getIdConjuntoSegmento())) { return element; }/* w ww . jav a 2s . c o m*/ } } Bitacora.trace("*** conjunto " + id + " not found ***"); return null; }
From source file:dk.dma.vessel.track.model.VesselTarget.java
/** * Update the static information fields from the AIS message * @param message the AIS message//from w w w .j a v a2 s. c o m * @param date the date of the message * @return if any fields were updated */ private boolean updateVesselStaticMessage(AisStaticCommon message, Date date) { // Check that this is a newer static update if (lastStaticReport != null && lastStaticReport.getTime() >= date.getTime()) { return false; } boolean updated = false; // Update the name String name = AisMessage.trimText(message.getName()); if (StringUtils.isNotBlank(name) && !name.equals(this.name)) { this.name = name; updated = true; } // Update the call-sign String callsign = AisMessage.trimText(message.getCallsign()); if (StringUtils.isNotBlank(callsign) && !callsign.equals(this.callsign)) { this.callsign = callsign; updated = true; } // Update the vessel type Integer vesselType = message.getShipType(); if (!vesselType.equals(this.vesselType)) { this.vesselType = vesselType; updated = true; } if (message instanceof AisMessage5) { AisMessage5 msg5 = (AisMessage5) message; AisTargetDimensions dim = new AisTargetDimensions(msg5); // Update length Short length = (short) (dim.getDimBow() + dim.getDimStern()); if (!length.equals(this.length)) { this.length = length; updated = true; } // Update width Short width = (short) (dim.getDimPort() + dim.getDimStarboard()); if (!width.equals(this.width)) { this.width = width; updated = true; } // Update destination String destination = StringUtils.defaultIfBlank(AisMessage.trimText(msg5.getDest()), null); if (destination != null && !destination.equals(this.destination)) { this.destination = destination; updated = true; } // Update draught Float draught = msg5.getDraught() / 10.0f; if (msg5.getDraught() > 0 && !compare(draught, this.draught)) { this.draught = draught; updated = true; } // Update ETA Date eta = msg5.getEtaDate(); if (eta != null && !eta.equals(this.eta)) { this.eta = eta; updated = true; } // Update IMO Long imo = msg5.getImo(); if (msg5.getImo() > 0 && !imo.equals(this.imoNo)) { this.imoNo = imo; updated = true; } } // Only update lastStaticReport if any static field has been updated if (updated) { lastStaticReport = date; } return updated; }
From source file:org.ambraproject.user.service.UserServiceImpl.java
@Override @Transactional(rollbackFor = { Throwable.class }) public UserProfile saveOrUpdateUser(final UserProfile userProfile) throws DuplicateDisplayNameException { //even if you're updating a user, it could be a user with no display name. so we need to make sure they don't pick one that already exists Long count = (Long) hibernateTemplate.findByCriteria(DetachedCriteria.forClass(UserProfile.class) .add(Restrictions.eq("displayName", userProfile.getDisplayName())) .add(Restrictions.not(Restrictions.eq("authId", userProfile.getAuthId()))) .setProjection(Projections.rowCount()), 0, 1).get(0); if (!count.equals(0l)) { throw new DuplicateDisplayNameException(); }// w ww . jav a 2s .c o m //check if a user with the same auth id already exists UserProfile existingUser = getUserByAuthId(userProfile.getAuthId()); if (existingUser != null) { log.debug("Found a user with authID: {}, updating profile", userProfile.getAuthId()); copyFields(userProfile, existingUser); hibernateTemplate.update(existingUser); return existingUser; } else { log.debug("Creating a new user with authID: {}; {}", userProfile.getAuthId(), userProfile); //TODO: We're generating account and profile uris here to maintain backwards compatibility with annotations //once those are refactored we can just call hibernateTemplate.save() String prefix = System.getProperty(ConfigurationStore.SYSTEM_OBJECT_ID_PREFIX); String accountUri = prefix + "account/" + UUID.randomUUID().toString(); String profileUri = prefix + "profile/" + UUID.randomUUID().toString(); userProfile.setAccountUri(accountUri); userProfile.setProfileUri(profileUri); hibernateTemplate.save(userProfile); return userProfile; } }
From source file:org.apache.openmeetings.remote.WhiteBoardService.java
public Boolean deleteWhiteboard(Long whiteBoardId) { try {//w w w . j ava 2 s. com IConnection current = Red5.getConnectionLocal(); String streamid = current.getClient().getId(); Client currentClient = this.sessionManager.getClientByStreamId(streamid, null); Long room_id = currentClient.getRoom_id(); WhiteboardObjectList whiteboardObjectList = this.whiteBoardObjectListManagerById .getWhiteBoardObjectListByRoomId(room_id); for (Iterator<Long> iter = whiteboardObjectList.getWhiteboardObjects().keySet().iterator(); iter .hasNext();) { Long storedWhiteboardId = iter.next(); log.debug(" :: storedWhiteboardId :: " + storedWhiteboardId); if (storedWhiteboardId.equals(whiteBoardId)) { log.debug("Found Whiteboard to Remove"); } } Object returnValue = whiteboardObjectList.getWhiteboardObjects().remove(whiteBoardId); log.debug(" :: whiteBoardId :: " + whiteBoardId); this.whiteBoardObjectListManagerById.setWhiteBoardObjectListRoomObj(room_id, whiteboardObjectList); if (returnValue != null) { return true; } else { return false; } } catch (Exception err) { log.error("[deleteWhiteboard]", err); } return null; }