List of usage examples for java.lang Long equals
public boolean equals(Object obj)
From source file:com.mobileman.projecth.web.controller.patient.EinstellungenController.java
@Transactional @RequestMapping(method = RequestMethod.POST, value = "/patient/einstellungen_profil") public String settingsChange(HttpServletRequest request, HttpServletResponse response, Model model) { boolean autoLogin = false; try {/*from w ww . j a v a 2s .c o m*/ Patient patient = new DataHolder(request).getPatient(); autoLogin = UserUtils.changeAutologin(patient, request, response); //birthday String strYear = request.getParameter("year"); Integer birthday = NumUtils.convert2int(strYear); // user deleted birthday or birthday is correct if ((strYear == null || strYear.trim().length() == 0) || birthday != null) { patient.setBirthday(birthday); } //country String strCountry = request.getParameter("country"); Long country = NumUtils.convert2long(strCountry); if (country != null && !country.equals(0L)) { patient.setCountry(countryService.findById(country)); } else { patient.setCountry(null); } String strNationality = request.getParameter("nationality"); Long nationalityId = NumUtils.convert2long(strNationality); if (nationalityId != null && !nationalityId.equals(0L)) { patient.setNationality(countryService.findById(nationalityId)); } else { patient.setNationality(null); } String strRace = request.getParameter("race"); Long raceId = NumUtils.convert2long(strRace); if (raceId != null && !raceId.equals(0L)) { patient.setRace(raceService.findById(raceId)); } else { patient.setRace(null); } String streducation = request.getParameter("education"); Long educationId = NumUtils.convert2long(streducation); if (educationId != null && !educationId.equals(0L)) { patient.setEducation(educationService.findById(educationId)); } else { patient.setEducation(null); } String familySituation = request.getParameter("familySituation"); Long familySituationId = NumUtils.convert2long(familySituation); if (familySituationId != null && !familySituationId.equals(0L)) { patient.setFamilySituation(familySituationService.findById(familySituationId)); } else { patient.setFamilySituation(null); } String heightStr = request.getParameter("height"); Integer height = NumUtils.convert2int(heightStr); // user deleted height or height is correct if ((heightStr == null || heightStr.trim().length() == 0) || height != null) { patient.setHeight(height); } String genderStr = request.getParameter("gender"); Integer gender = NumUtils.convert2int(genderStr); patient.setSex(gender); userService.update(patient); //diseases UserUtils.saveDiseases(request, patient, userService, diseaseService); model.addAttribute("base_settings_saved", Boolean.TRUE); } catch (Exception e) { model.addAttribute("base_settings_save_error", Boolean.TRUE); model.addAttribute("base_settings_save_error_message", e.getMessage()); } return settingsGetInternal(request, response, model, autoLogin); }
From source file:org.openregistry.core.domain.jpa.sor.JpaSorRoleImpl.java
public synchronized EmailAddress removeEmailAddressById(final Long id) { EmailAddress emailAddressToDelete = null; for (final EmailAddress emailAddress : this.emailAddresses) { final Long emailAddressId = emailAddress.getId(); if (emailAddressId != null && emailAddressId.equals(id)) { emailAddressToDelete = emailAddress; break; }/*from w ww . java 2 s .c om*/ } if (emailAddressToDelete != null) { this.emailAddresses.remove(emailAddressToDelete); return emailAddressToDelete; } return null; }
From source file:com.yuga.ygplatform.modules.sys.web.AreaController.java
@ResponseBody @RequestMapping(value = "treeData") public List<Map<String, Object>> treeData(@RequestParam(required = false) Long extId, HttpServletResponse response) {/* w w w .j a v a 2s . c o m*/ response.setContentType("application/json; charset=UTF-8"); List<Map<String, Object>> mapList = Lists.newArrayList(); // User user = UserUtils.getUser(); List<Area> list = areaService.findAll(); for (int i = 0; i < list.size(); i++) { Area e = list.get(i); if ((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", // !user.isAdmin()&&e.getId().equals(user.getArea().getId())?0:e.getParent()!=null?e.getParent().getId():0); map.put("pId", e.getParent() != null ? e.getParent().getId() : 0); map.put("name", e.getName()); mapList.add(map); } } return mapList; }
From source file:com.alibaba.otter.shared.arbitrate.impl.setl.monitor.MainstemMonitor.java
/** * ??/*w w w . j a v a 2s .c o m*/ */ public boolean check() { String path = StagePathUtils.getMainStem(getPipelineId()); try { byte[] bytes = zookeeper.readData(path); Long nid = ArbitrateConfigUtils.getCurrentNid(); MainStemEventData eventData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class); activeData = eventData;// // nid? boolean result = nid.equals(eventData.getNid()); if (!result) { logger.warn("mainstem is running in node[{}] , but not in node[{}]", eventData.getNid(), nid); } return result; } catch (ZkNoNodeException e) { logger.warn("mainstem is not run any in node"); return false; } catch (ZkInterruptedException e) { logger.warn("mainstem check is interrupt"); Thread.interrupted();// interrupt return check(); } catch (ZkException e) { logger.warn("mainstem check is failed"); return false; } }
From source file:eu.supersede.dm.ga.GAPersistentDB.java
public void closeGame(Long gameId, Long processId) { ProcessManager mgr = DMGame.get().getProcessManager(processId); List<HActivity> opinionProvidersActivities = mgr.getOngoingActivities(GAPlayerVotingMethod.NAME); List<HActivity> negotiatorsActivities = mgr.getOngoingActivities(GANegotiatorVotingMethod.NAME); for (HActivity a : opinionProvidersActivities) { PropertyBag bag = mgr.getProperties(a); Long ongoingGame = Long.parseLong(bag.get("gameId", "0")); if (!ongoingGame.equals(gameId)) { // Found property of another game continue; }//from ww w .ja v a2 s . c o m mgr.deleteActivity(a); } for (HActivity a : negotiatorsActivities) { PropertyBag bag = mgr.getProperties(a); Long ongoingGame = Long.parseLong(bag.get("gameId", "0")); if (!ongoingGame.equals(gameId)) { // Found property of another game continue; } mgr.deleteActivity(a); } HGAGameSummary gameInfo = gamesJpa.findOne(gameId); gameInfo.setStatus(GAGameStatus.Closed.name()); gamesJpa.save(gameInfo); }
From source file:gr.forth.ics.isl.x3mlEditor.upload.UploadReceiver.java
private File writeToTempFile(InputStream in, File out, Long expectedFileSize) throws IOException { FileOutputStream fos = null;// w w w. j a v a 2s .c om try { fos = new FileOutputStream(out); IOUtils.copy(in, fos); if (expectedFileSize != null) { Long bytesWrittenToDisk = out.length(); if (!expectedFileSize.equals(bytesWrittenToDisk)) { throw new IOException( String.format("Unexpected file size mismatch. Actual bytes %s. Expected bytes %s.", bytesWrittenToDisk, expectedFileSize)); } } return out; } catch (Exception e) { throw new IOException(e); } finally { IOUtils.closeQuietly(fos); } }
From source file:jp.primecloud.auto.ui.WinServiceAdd.java
private void showSelectServers(Long componentTypeNo) { serverSelect.removeAllItems();/*from w ww. j a va2 s.c om*/ if (componentTypeNo == null) { return; } // ???? ComponentTypeDto componentType = null; for (ComponentTypeDto tmpComponentType : componentTypes) { if (tmpComponentType.getComponentType().getComponentTypeNo().equals(componentTypeNo)) { componentType = tmpComponentType; break; } } // ?????????? for (Long instanceNo : componentType.getInstanceNos()) { for (InstanceDto instance : instances) { if (instanceNo.equals(instance.getInstance().getInstanceNo())) { serverSelect.addItem(instance.getInstance().getInstanceName()); break; } } } }
From source file:com.jkoolcloud.tnt4j.streams.configure.state.AbstractFileStreamStateHandler.java
/** * Finds the file to stream matching file header CRC persisted in files access state. * * @param fileAccessState/*from ww w. j a v a 2s. c o m*/ * persisted files access state * @param streamFiles * descriptors array of files to search * * @return found file that matches CRC * * @throws IOException * if file can't be opened. */ T findStreamingFile(FileAccessState fileAccessState, T[] streamFiles) throws IOException { for (T file : streamFiles) { Long fileCRC = getFileCrc(file); if (fileCRC != null && fileCRC.equals(fileAccessState.currentFileCrc)) { return file; } } return null; }
From source file:com.codenvy.jira.IssueCreatedListener.java
/** * Receives any {@code IssueEvent}s sent by JIRA. * @param issueEvent the IssueEvent passed to us *//* w w w. j av a2 s .c o m*/ @EventListener public void onIssueEvent(IssueEvent issueEvent) { final Long eventTypeId = issueEvent.getEventTypeId(); final Issue issue = issueEvent.getIssue(); // if it's an event we're interested in, log it if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) { // Get plugin settings PluginSettings settings = pluginSettingsFactory.createGlobalSettings(); final String codenvyUrl = (String) settings.get("codenvy.admin.instanceurl"); final String codenvyUsername = (String) settings.get("codenvy.admin.username"); final String codenvyPassword = (String) settings.get("codenvy.admin.password"); if (codenvyUrl == null || codenvyUrl.isEmpty() || codenvyUsername == null || codenvyUsername.isEmpty() || codenvyPassword == null || codenvyPassword.isEmpty()) { LOG.warn("At least one of codenvy URL (\'" + codenvyUrl + "\'), username (\'" + codenvyUsername + "\') " + "or password (\'" + codenvyPassword + "\') is not set or empty."); return; } try { final String issueKey = issue.getKey(); final String projectKey = issue.getProjectObject().getKey(); final String projectName = issue.getProjectObject().getName(); // Get current JIRA user final User eventUser = issueEvent.getUser(); if (eventUser == null) { LOG.warn("No user given in issue event."); return; } // Get id of custom fields Develop & Review String developFieldId = null; String reviewFieldId = null; final Set<CustomField> customFields = fieldManager.getAvailableCustomFields(eventUser, issue); for (CustomField cf : customFields) { String customFieldTypeKey = cf.getCustomFieldType().getKey(); if (CODENVY_DEVELOP_FIELD_TYPE_KEY.equals(customFieldTypeKey)) { developFieldId = cf.getId(); } if (CODENVY_REVIEW_FIELD_TYPE_KEY.equals(customFieldTypeKey)) { reviewFieldId = cf.getId(); } } // Continue only if Develop and Review fields are available on the issue if (developFieldId == null || reviewFieldId == null) { LOG.warn("Field Develop (" + developFieldId + ") and/or Review (" + reviewFieldId + ") are not available for issue " + issueKey + "."); return; } JSONObject token; final Resty resty = new Resty(); // Authenticate on Codenvy as JIRA admin final JSONObject credentials = new JSONObject().put("username", codenvyUsername).put("password", codenvyPassword); token = resty.json(codenvyUrl + "/api/auth/login", content(credentials)).object(); if (token == null) { LOG.warn("No Codenvy Token obtained (" + codenvyUsername + ")."); return; } // Get Codenvy user id final JSONObject user = resty.json(codenvyUrl + "/api/user").object(); if (user == null) { LOG.warn("No Codenvy user found (" + codenvyUsername + ")."); return; } // Get parent factory for project final String tokenValue = token.getString("value"); final String userId = user.getString("id"); final String projectKeyLower = projectKey.toLowerCase(Locale.getDefault()); final JSONArray factories = resty.json(codenvyUrl + "/api/factory/find?name=" + projectKeyLower + "&creator.userId=" + userId + "&token=" + tokenValue).array(); if (factories.length() == 0) { LOG.warn("No factory found with name: " + projectKeyLower + " and userId (owner): " + userId); return; } JSONObject parentFactory = factories.getJSONObject(0); LOG.debug("Parent factory for project " + projectName + ": " + parentFactory); // Set perUser policy & correct name (Develop factory) final JSONObject developFactory = setCreatePolicy(parentFactory, "perUser"); developFactory.remove("name"); developFactory.put("name", issueKey + "-develop-factory"); // Clean id and creator developFactory.remove("id"); developFactory.remove("creator"); // Set workspace.projects.source.parameters.branch = issue key final JSONObject project = developFactory.getJSONObject("workspace").getJSONArray("projects") .getJSONObject(0); final JSONObject parameters = project.getJSONObject("source").getJSONObject("parameters"); parameters.put("branch", issueKey); // Generate Develop factory final JSONObject generatedDevelopFactory = resty .json(codenvyUrl + "/api/factory", content(developFactory)).object(); LOG.debug("Generated DEVELOP factory for issue " + issueKey + ": " + generatedDevelopFactory); // Set perClick policy & correct name (Review factory) final JSONObject reviewFactory = setCreatePolicy(developFactory, "perClick"); reviewFactory.remove("name"); reviewFactory.put("name", issueKey + "-review-factory"); // Generate Review factory final JSONObject generatedReviewFactory = resty .json(codenvyUrl + "/api/factory", content(reviewFactory)).object(); LOG.debug("Generated REVIEW factory for issue " + issueKey + ": " + generatedReviewFactory); // Set factory URLs in Develop & Review fields String developFactoryUrl = getNamedFactoryUrl(generatedDevelopFactory); String reviewFactoryUrl = getNamedFactoryUrl(generatedReviewFactory); if (developFactoryUrl == null || reviewFactoryUrl == null) { LOG.warn("URL of factory Develop (" + developFactoryUrl + ") and/or Review (" + reviewFactoryUrl + ") is null."); return; } String developFieldValue = "<a id=\"codenvy_develop_field\" href=\"" + developFactoryUrl + "\">Develop in Codenvy</a>"; String reviewFieldValue = "<a id=\"codenvy_review_field\" href=\"" + reviewFactoryUrl + "\">Review in Codenvy</a>"; final ApplicationUser appUser = ApplicationUsers.from(eventUser); updateIssue(appUser, issueKey, developFieldId, developFieldValue, reviewFieldId, reviewFieldValue); } catch (JSONException | IOException | FieldException e) { LOG.error(e.getMessage()); } } }
From source file:org.openmeetings.test.user.TestUserOrganisation.java
@Test public void addOrganisation() { Long orgId = orgManagement.addOrganisation("Test Org", 1); //inserted by not checked assertNotNull("New Organisation have valid id", orgId); List<Users> ul = orgManagement.getUsersByOrganisationId(orgId, 0, 9999, "login", true); assertTrue("New Organisation should contain NO users: " + ul.size(), ul.size() == 0); boolean found = false; List<Organisation> restL = orgManagement.getRestOrganisationsByUserId(3, 1, 0, 9999, "name", true); for (Organisation o : restL) { if (orgId.equals(o.getOrganisation_id())) { found = true;//www. j av a 2 s .co m break; } } assertTrue("New organisation should not be included into organisation list of any user", found); }