List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:com.bizintelapps.bugtracker.service.impl.ReportServiceImpl.java
@Override public ProjectReportDto getProjectReportSummary(Integer project, String requestedBy) { Users requestedUser = usersDao.findByUsername(requestedBy); ProjectReportDto dto = null;//from ww w. j a v a 2 s . c om Integer org = null; if (project == null || project.equals(0)) { org = requestedUser.getOrganization().getId(); //list = projectReportDao.findByOrganizationForTodo(org); } else { dto = (ProjectReportDto) projectReportDao.findProjectSummary(project); } return dto; }
From source file:com.mirth.connect.server.controllers.DefaultUserController.java
public synchronized void removeUser(Integer userId, Integer currentUserId) throws ControllerException { logger.debug("removing user: " + userId); if (userId == null) { throw new ControllerException("Error removing user: User Id cannot be null"); }//from w ww . ja v a 2 s .c o m if (userId.equals(currentUserId)) { throw new ControllerException("Error removing user: You cannot remove yourself"); } try { User user = new User(); user.setId(userId); SqlConfig.getSqlSessionManager().delete("User.deleteUser", user); if (DatabaseUtil.statementExists("User.vacuumPersonTable")) { SqlConfig.getSqlSessionManager().update("User.vacuumPersonTable"); } } catch (PersistenceException e) { throw new ControllerException(e); } }
From source file:com.mirth.connect.server.controllers.DefaultCodeTemplateController.java
@Override public List<CodeTemplateSummary> getCodeTemplateSummary(Map<String, Integer> clientRevisions) throws ControllerException { logger.debug("Getting code template summary"); List<CodeTemplateSummary> codeTemplateSummaries = new ArrayList<CodeTemplateSummary>(); try {/*from w ww .j ava 2s. com*/ Map<String, CodeTemplate> serverCodeTemplates = codeTemplateCache.getAllItems(); /* * Iterate through the cached code template list and check if a code template with the * id exists on the server. If it does, and the revision numbers aren't equal, then add * the code template to the updated list. Otherwise, if the code template is not found, * add it to the deleted list. */ for (Entry<String, Integer> entry : clientRevisions.entrySet()) { String cachedCodeTemplateId = entry.getKey(); CodeTemplateSummary summary = new CodeTemplateSummary(cachedCodeTemplateId); boolean addSummary = false; if (serverCodeTemplates.containsKey(cachedCodeTemplateId)) { // If the revision numbers aren't equal, add the updated CodeTemplate object CodeTemplate serverCodeTemplate = serverCodeTemplates.get(cachedCodeTemplateId); Integer serverRevision = serverCodeTemplate.getRevision(); if (!serverRevision.equals(entry.getValue())) { summary.setCodeTemplate(serverCodeTemplate); addSummary = true; } } else { // If a code template with the ID is not found on the server, add it as deleted summary.setDeleted(true); addSummary = true; } if (addSummary) { codeTemplateSummaries.add(summary); } } /* * Add summaries for any entries on the server but not in the client's cache. */ for (Entry<String, CodeTemplate> serverEntry : serverCodeTemplates.entrySet()) { if (!clientRevisions.containsKey(serverEntry.getKey())) { codeTemplateSummaries .add(new CodeTemplateSummary(serverEntry.getKey(), serverEntry.getValue())); } } return codeTemplateSummaries; } catch (Exception e) { throw new ControllerException(e); } }
From source file:net.neurowork.cenatic.centraldir.workers.xml.SectorXmlImporter.java
private Sector importSector(String xmlString, Integer id) throws ParserConfigurationException, SAXException, IOException { Document doc = XmlParserUtil.createDocumentFromString(xmlString); Sector ret = null;/* w w w. ja v a 2 s. c o m*/ NodeList nodeLst = doc.getElementsByTagName("sector"); for (int s = 0; s < nodeLst.getLength(); s++) { Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element elPDU = (Element) fstNode; String code = XmlParserUtil.getAttribute(elPDU, "code"); NodeList fstNm = elPDU.getChildNodes(); String sectorName = null; if (fstNm.getLength() > 0) { String tmp = ((Node) fstNm.item(0)).getNodeValue(); byte[] utf8 = tmp.getBytes("UTF-8"); sectorName = new String(utf8, "UTF-8"); Integer capId = AbstractXmlImporter.getId(code); Sector sector = null; try { Collection<Sector> sectores = sectorService.findByName(sectorName); if (sectores != null && sectores.size() > 0) { sector = sectores.iterator().next(); } else { sector = new Sector(); sector.setName(sectorName); sectorService.save(sector); } if (capId != null && capId.equals(id)) { ret = sector; } } catch (ServiceException e) { logger.error(e.getMessage()); } } } } return ret; }
From source file:au.org.intersect.dms.webapp.controller.LocationController.java
private void deleteConnection(Integer connectionId) { List<LocationConnectForm> connections = getCurrentConnections(); for (Iterator<LocationConnectForm> iterator = connections.iterator(); iterator.hasNext();) { LocationConnectForm locationConnectForm = iterator.next(); if (connectionId.equals(locationConnectForm.getConnectionId())) { iterator.remove();/*from w w w. ja v a2s. c o m*/ updateCurrectConnections(connections); break; } } }
From source file:edumsg.core.commands.user.GetTimelineCommand.java
@Override public void execute() { try {//w w w. ja va 2 s .c o m dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_feeds(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setString(2, map.get("session_id")); proc.execute(); set = (ResultSet) proc.getObject(1); ArrayNode tweets = nf.arrayNode(); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); while (set.next()) { Integer id = set.getInt(1); String tweet = set.getString(2); String image_url = set.getString(3); Timestamp created_at = set.getTimestamp(4); String creator_name = set.getString(5); String creator_username = set.getString(6); String creator_avatar = set.getString(7); String retweeter = set.getString(8); Integer creator_id = set.getInt(9); Integer retweeter_id = set.getInt(10); Tweet t = new Tweet(); t.setId(id); t.setTweetText(tweet); t.setImageUrl(image_url); t.setCreatedAt(created_at); User creator = new User(); creator.setId(creator_id); creator.setName(creator_name); creator.setAvatarUrl(creator_avatar); creator.setUsername(creator_username); t.setCreator(creator); if (!creator_id.equals(retweeter_id)) { User r = new User(); r.setId(retweeter_id); r.setName(retweeter); t.setRetweeter(r); } tweets.addPOJO(t); } set.close(); proc.close(); root.set("feeds", tweets); try { CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER); JSONObject cacheEntry = new JSONObject(mapper.writeValueAsString(root)); cacheEntry.put("cacheStatus", "valid"); UserCache.userCache.set("timeline:" + map.get("session_id"), cacheEntry.toString()); } catch (JsonGenerationException e) { //Logger.log(Level.SEVERE, e.getMessage(), e); } catch (JsonMappingException e) { //Logger.log(Level.SEVERE, e.getMessage(), e); } catch (IOException e) { //Logger.log(Level.SEVERE, e.getMessage(), e); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } dbConn.commit(); } catch (PSQLException e) { CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER); //Logger.log(Level.SEVERE, e.getMessage(), e); } catch (SQLException e) { CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER); //Logger.log(Level.SEVERE, e.getMessage(), e); } finally { PostgresConnection.disconnect(set, proc, dbConn, null); } }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeographyMerging.java
/** * //from ww w. ja v a2 s .c o m */ private void mergeNext() { final Integer fromId = modelList.get(mergeIndex).geoId; log.debug(String.format("Merging From %d to %d Index: %d Size: %d", fromId, primaryId, mergeIndex, modelList.size())); mergeIndex++; if (fromId.equals(primaryId)) { if (mergeIndex < modelList.size()) { mergeNext(); return; } else if (currIndex < items.size()) { doNextGeographyInList(); return; } } final TreeMerger<Geography, GeographyTreeDef, GeographyTreeDefItem> merger = new TreeMerger<Geography, GeographyTreeDef, GeographyTreeDefItem>( geoTreeDef); new javax.swing.SwingWorker<Object, Object>() { Boolean result = false; Exception killer = null; @Override protected Object doInBackground() throws Exception { try { Integer parentId = BasicSQLUtils .getCount("SELECT ParentID FROM geography WHERE GeographyID = " + primaryId); merger.mergeTrees(fromId, parentId); result = true; } catch (Exception ex) { log.error(ex); result = false; killer = ex; } return result; } @Override protected void done() { if (result) { try { geoTreeDef.updateAllNodes(null, true, true); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TreeTableViewer.class, ex); } } if (!result && killer != null) { if (killer instanceof TreeMergeException) { displayErrorDlg(killer.getMessage()); } else { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TreeTableViewer.class, killer); } } else { if (mergeIndex < modelList.size()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { mergeNext(); } }); } else { doNextGeographyInList(); } } } }.execute(); }
From source file:com.abiquo.api.services.appslibrary.VirtualMachineTemplateService.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRED) public VirtualMachineTemplate updateVirtualMachineTemplate(final Integer enterpriseId, final Integer datacenterId, final Integer virtualMachineTemplateId, final VirtualMachineTemplateDto virtualMachineTemplate) { VirtualMachineTemplate old = getVirtualMachineTemplate(enterpriseId, datacenterId, virtualMachineTemplateId);/* www . j a v a 2s. c o m*/ // If shared and with instances then those instance cannot access to the template anymore if (old.isShared() && !virtualMachineTemplate.isShared() && virtualMachineRep.existsVirtualMachineFromTemplate(virtualMachineTemplateId)) { tracer.log(SeverityType.CRITICAL, ComponentType.VIRTUAL_APPLIANCE, EventType.VI_UPDATE, "vmtemplate.modified.notshared.instance", new Object[] { virtualMachineTemplateId, old.getName() }); addConflictErrors(APIError.VMTEMPLATE_TEMPLATE_USED_BY_VIRTUAL_MACHINES_CANNOT_BE_UNSHARED); flushErrors(); } if (!virtualMachineTemplate.getIconUrl().isEmpty() && virtualMachineTemplate.getIconUrl() != null && !validURI(virtualMachineTemplate.getIconUrl())) { addConflictErrors(APIError.VIMAGE_MALFORMED_ICON_URI); flushErrors(); } old.setCostCode(virtualMachineTemplate.getCostCode()); old.setCpuRequired(virtualMachineTemplate.getCpuRequired()); old.setDescription(virtualMachineTemplate.getDescription()); old.setDiskFileSize(virtualMachineTemplate.getDiskFileSize()); DiskFormatType type = DiskFormatType.fromValue(virtualMachineTemplate.getDiskFormatType()); old.setDiskFormatType(type); old.setHdRequiredInBytes(virtualMachineTemplate.getHdRequired()); old.setName(virtualMachineTemplate.getName()); old.setPath(virtualMachineTemplate.getPath()); old.setRamRequired(virtualMachineTemplate.getRamRequired()); old.setShared(virtualMachineTemplate.isShared()); old.setChefEnabled(virtualMachineTemplate.isChefEnabled()); old.setIconUrl(virtualMachineTemplate.getIconUrl()); // retrieve the links RESTLink categoryLink = virtualMachineTemplate.searchLink(CategoryResource.CATEGORY); RESTLink enterpriseLink = virtualMachineTemplate.searchLink(EnterpriseResource.ENTERPRISE); RESTLink datacenterRepositoryLink = virtualMachineTemplate .searchLink(DatacenterRepositoryResource.DATACENTER_REPOSITORY); RESTLink masterLink = virtualMachineTemplate.searchLink("master"); // check the links if (enterpriseLink != null) { String buildPath = buildPath(EnterprisesResource.ENTERPRISES_PATH, EnterpriseResource.ENTERPRISE_PARAM); MultivaluedMap<String, String> map = URIResolver.resolveFromURI(buildPath, enterpriseLink.getHref()); if (map == null || !map.containsKey(EnterpriseResource.ENTERPRISE)) { addValidationErrors(APIError.INVALID_ENTERPRISE_LINK); flushErrors(); } Integer enterpriseIdFromLink = Integer.parseInt(map.getFirst(EnterpriseResource.ENTERPRISE)); if (!enterpriseIdFromLink.equals(enterpriseId)) { addConflictErrors(APIError.VMTEMPLATE_ENTERPRISE_CANNOT_BE_CHANGED); flushErrors(); } } if (datacenterRepositoryLink != null) { String buildPath = buildPath(EnterprisesResource.ENTERPRISES_PATH, EnterpriseResource.ENTERPRISE_PARAM, DatacenterRepositoriesResource.DATACENTER_REPOSITORIES_PATH, DatacenterRepositoryResource.DATACENTER_REPOSITORY_PARAM); MultivaluedMap<String, String> map = URIResolver.resolveFromURI(buildPath, datacenterRepositoryLink.getHref()); if (map == null || !map.containsKey(DatacenterRepositoryResource.DATACENTER_REPOSITORY)) { addValidationErrors(APIError.INVALID_DATACENTER_RESPOSITORY_LINK); flushErrors(); } Integer datacenterRepositoryId = Integer .parseInt(map.getFirst(DatacenterRepositoryResource.DATACENTER_REPOSITORY)); if (!datacenterRepositoryId.equals(old.getRepository().getDatacenter().getId())) { addConflictErrors(APIError.VMTEMPLATE_DATACENTER_REPOSITORY_CANNOT_BE_CHANGED); flushErrors(); } } if (categoryLink != null) { String buildPath = buildPath(CategoriesResource.CATEGORIES_PATH, CategoryResource.CATEGORY_PARAM); MultivaluedMap<String, String> map = URIResolver.resolveFromURI(buildPath, categoryLink.getHref()); if (map == null || !map.containsKey(CategoryResource.CATEGORY)) { addValidationErrors(APIError.INVALID_CATEGORY_LINK); flushErrors(); } Integer categoryId = Integer.parseInt(map.getFirst(CategoryResource.CATEGORY)); if (!categoryId.equals(old.getCategory().getId())) { Category category = appsLibraryRep.findCategoryById(categoryId); if (category == null) { addConflictErrors(APIError.NON_EXISTENT_CATEGORY); flushErrors(); } old.setCategory(category); } } // the cases when the master was null or not null but the new master template is null // allowed if (masterLink == null) { if (old.getMaster() != null) { if (tracer != null) { tracer.log(SeverityType.INFO, ComponentType.DATACENTER, EventType.VI_UPDATE, "virtualMachineTemplate.convertedToMaster", old.getName()); } } old.setMaster(null); } // case when the new master isn't null and the old can be null or the same template or a new // template else { String buildPath = buildPath(EnterprisesResource.ENTERPRISES_PATH, EnterpriseResource.ENTERPRISE_PARAM, DatacenterRepositoriesResource.DATACENTER_REPOSITORIES_PATH, DatacenterRepositoryResource.DATACENTER_REPOSITORY_PARAM, VirtualMachineTemplatesResource.VIRTUAL_MACHINE_TEMPLATES_PATH, VirtualMachineTemplateResource.VIRTUAL_MACHINE_TEMPLATE_PARAM); MultivaluedMap<String, String> map = URIResolver.resolveFromURI(buildPath, masterLink.getHref()); if (map == null || !map.containsKey(VirtualMachineTemplateResource.VIRTUAL_MACHINE_TEMPLATE)) { addValidationErrors(APIError.INVALID_VMTEMPLATE_LINK); flushErrors(); } Integer masterId = Integer .parseInt(map.getFirst(VirtualMachineTemplateResource.VIRTUAL_MACHINE_TEMPLATE)); if (old.getMaster() == null || !masterId.equals(old.getMaster().getId())) { addConflictErrors(APIError.VMTEMPLATE_MASTER_TEMPLATE_CANNOT_BE_CHANGED); flushErrors(); } // if its the same no change is necessary } appsLibraryRep.updateVirtualMachineTemplate(old); return old; }
From source file:net.ontopia.topicmaps.query.impl.basic.QueryMatches.java
/** * INTERNAL: Returns the index of the given integer constant in the table. *//*w ww . ja va2 s.co m*/ public int getIndex(Integer num) { for (int ix = 0; ix < colcount; ix++) if (num.equals(columnDefinitions[ix])) return ix; return -1; }
From source file:com.ethlo.geodata.GeodataServiceImpl.java
@Override public Country findByPhonenumber(String phoneNumber) { final PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); PhoneNumber pn;/*from w w w .j av a 2s .c o m*/ try { pn = phoneUtil.parse("+" + phoneNumber, "US"); } catch (NumberParseException exc) { return null; } final Integer countryCode = pn.getCountryCode(); for (Country country : geoNamesRepository.getCountries().values()) { if (countryCode.equals(country.getCallingCode())) { return country; } } return null; }