List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:com.aurel.track.persist.TWorkItemPeer.java
/** * The parent was changed: recalculate the WBS both the old parent and the new parent can be null * @param workItemBean// ww w. j a v a 2 s. com * @param workItemBeanOriginal * @param contextInformation */ @Override public void parentChanged(TWorkItemBean workItemBean, TWorkItemBean workItemBeanOriginal, Map<String, Object> contextInformation) { if (workItemBeanOriginal == null) { //new item return; } Integer oldParent = workItemBeanOriginal.getSuperiorworkitem(); Integer newParent = workItemBean.getSuperiorworkitem(); if ((oldParent == null && newParent == null) || (oldParent != null && newParent != null && oldParent.equals(newParent))) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("no parent change: wbs not affected"); } return; } Integer projectID = workItemBean.getProjectID(); if (projectID == null) { LOGGER.warn("No project found for workItem" + workItemBean.getObjectID()); return; } //old parent workItem and project TWorkItemBean oldParentWorkItemBean = null; boolean sameProjectAsOldParent = false; if (oldParent != null) { try { oldParentWorkItemBean = loadByPrimaryKey(oldParent); Integer oldParentProjectID = oldParentWorkItemBean.getProjectID(); if (oldParentProjectID == null) { LOGGER.warn("No project found for oldParent " + oldParent); return; } else { sameProjectAsOldParent = projectID.equals(oldParentProjectID); } } catch (ItemLoaderException e1) { LOGGER.warn("The oldParent workItem " + oldParent + " does not exist"); return; } } else { //previously it has no parent: the projects are considered the same sameProjectAsOldParent = true; } //new parent workItem and project TWorkItemBean newParentWorkItemBean = null; boolean sameProjectAsNewParent = false; if (newParent != null) { try { newParentWorkItemBean = loadByPrimaryKey(newParent); Integer newParentProjectID = newParentWorkItemBean.getProjectID(); if (newParentProjectID == null) { LOGGER.warn("No project found for newParent " + newParent); return; } else { sameProjectAsNewParent = projectID.equals(newParentProjectID); } } catch (ItemLoaderException e1) { LOGGER.warn("The newParent workItem " + newParent + " does not exist"); return; } } else { //the parent is removed: the projects are considered the same sameProjectAsNewParent = true; } boolean outdent = false; if (contextInformation != null && contextInformation.get(TWorkItemBean.OUTDENT) != null && ((Boolean) contextInformation.get(TWorkItemBean.OUTDENT)).booleanValue()) { outdent = true; } Integer originalWBS = workItemBean.getWBSOnLevel(); if (originalWBS == null) { //renumber if null and get the WBS number again setWbs(projectID); try { //load them again this time with wbs numbers set workItemBean = loadByPrimaryKey(workItemBean.getObjectID()); originalWBS = workItemBean.getWBSOnLevel(); } catch (ItemLoaderException e) { } } //1. remove the item from the original parent's childen and shift the following items up if (sameProjectAsOldParent && !outdent) { //if there were no previous wbs or the project of the workItem differs form the //oldParent's project then there is no need to change anything in the old branch //move the issue's next siblings up one level if it is no outdent //(by outdent the issue's next siblings will be children of the issue) shiftBranch(originalWBS, oldParent, projectID, false); } //2. add the item as last child of the new parent if (sameProjectAsNewParent) { //if the new parent differs from the workItem's parent then no change in wbs Integer newWBS; if (outdent && (contextInformation != null) && (oldParentWorkItemBean != null)) { List<Integer> filteredNextSiblingIDs = (List<Integer>) contextInformation .get(TWorkItemBean.NEXT_SIBLINGS); //by outdent the oldParent becomes the new previous sibling: make space for the outdented item, //by shifting down the siblings of newParent (previous grandparent) after the oldParent Integer oldParentWBS = oldParentWorkItemBean.getWBSOnLevel(); if (oldParentWBS == null) { newWBS = Integer.valueOf(1); } else { newWBS = Integer.valueOf(oldParentWBS.intValue() + 1); } //shift down the children of the newParent beginning with //oldParentWBS exclusive to make place for the outdented issue shiftBranch(oldParentWBS, newParent, projectID, true); //get the next available WBS after the outdented issue's original children Integer nextWbsOnOudentedChildren = getNextWbsOnLevel(workItemBean.getObjectID(), projectID); //gather the all siblings (not just the next ones according to wbs) of the outdented issue, //because it is not guaranteed that at the moment of the outline the sortOrder is by wbs //(can be that in the ReportBeans there is a next sibling which has a lower wbs nummer as the outlined one still according //to the selected ReportBeans sortorder it is a next sibling, consequently it will become a child of outlined issue) Criteria criteria = new Criteria(); criteria.add(SUPERIORWORKITEM, oldParent); criteria.add(WORKITEMKEY, workItemBean.getObjectID(), Criteria.NOT_EQUAL); //criteria.add(WBSONLEVEL, originalWBS, Criteria.GREATER_THAN); criteria.add(PROJECTKEY, projectID); //in the case that the wbs got corrupted but still a wbs existed before try to preserve the order criteria.addAscendingOrderByColumn(WBSONLEVEL); //if wbs does not exist then fall back to workItemKey as wbs criteria.addAscendingOrderByColumn(WORKITEMKEY); List<TWorkItemBean> allSiblingWorkItemBeans = null; try { allSiblingWorkItemBeans = convertTorqueListToBeanList(doSelect(criteria)); } catch (TorqueException e) { LOGGER.warn("Getting the next siblings of the outdented issue " + workItemBean.getObjectID() + failedWith + e.getMessage(), e); } List<String> idChunks = GeneralUtils.getCommaSepararedIDChunksInParenthesis(filteredNextSiblingIDs); //set all next siblings as children of the outdented workItem (see MS Project) //actualize the WBS for old next present siblings (future children of the outdented issue). //No common update is possible because the WBS of the next present siblings might contain gaps Map<Integer, TWorkItemBean> siblingWorkItemsMap = GeneralUtils .createMapFromList(allSiblingWorkItemBeans); for (int i = 0; i < filteredNextSiblingIDs.size(); i++) { //the order from the ReportBeans should be preserved, insependently of current wbs //(consquently the relative wbs order between the siblings might change) TWorkItemBean nextSiblingworkItemBean = siblingWorkItemsMap.get(filteredNextSiblingIDs.get(i)); if (nextSiblingworkItemBean != null && nextSiblingworkItemBean.getWBSOnLevel() != (nextWbsOnOudentedChildren + i)) { nextSiblingworkItemBean.setWBSOnLevel(nextWbsOnOudentedChildren + i); try { saveSimple(nextSiblingworkItemBean); } catch (ItemPersisterException e) { LOGGER.warn("Saving the outdented present workitem " + nextSiblingworkItemBean.getObjectID() + failedWith + e.getMessage()); } } } //renumber those next siblings which were not re-parented (those not present in the ReportBeans) //to fill up the gaps leaved by the re-parented present next siblings //no common update is possible because of gaps int i = 0; if (allSiblingWorkItemBeans != null) { for (Iterator<TWorkItemBean> iterator = allSiblingWorkItemBeans.iterator(); iterator .hasNext();) { TWorkItemBean nextSiblingworkItemBean = iterator.next(); if (!filteredNextSiblingIDs.contains(nextSiblingworkItemBean.getObjectID())) { i++; if (nextSiblingworkItemBean.getWBSOnLevel() != i) { nextSiblingworkItemBean.setWBSOnLevel(i); try { saveSimple(nextSiblingworkItemBean); } catch (ItemPersisterException e) { LOGGER.warn("Saving the outdented not present workItem " + nextSiblingworkItemBean.getObjectID() + failedWith + e.getMessage()); } } } } } String parentCriteria = " AND SUPERIORWORKITEM = " + oldParent; String subprojectCriteria = " PROJECTKEY = " + projectID; //set all present next siblings as children of the outdented workItem (see MS Project). for (Iterator<String> iterator = idChunks.iterator(); iterator.hasNext();) { String idChunk = iterator.next(); String sqlStmt = "UPDATE TWORKITEM SET SUPERIORWORKITEM = " + workItemBean.getObjectID() + " WHERE " + subprojectCriteria + parentCriteria + " AND WORKITEMKEY IN " + idChunk; executeStatemant(sqlStmt); } } else { newWBS = getNextWbsOnLevel(newParent, projectID); } //shift the entire branch down and set the outdented workitem as first child of his previous parent if (EqualUtils.notEqual(workItemBean.getWBSOnLevel(), newWBS)) { workItemBean.setWBSOnLevel(newWBS); } } }
From source file:edu.ku.brc.specify.tasks.InteractionsTask.java
/** * @return a loan invoice if one exists. * /*from w ww . j a v a 2s . c o m*/ * If more than one report is defined for loan then user must choose. * * Fairly goofy code. Eventually may want to add ui to allow labeling resources as "invoice" (see printLoan()). */ public InfoForTaskReport getInvoiceInfo(final int invoiceTblId) { DataProviderSessionIFace session = null; ChooseFromListDlg<InfoForTaskReport> dlg = null; try { session = DataProviderFactory.getInstance().createSession(); List<AppResourceIFace> reps = AppContextMgr.getInstance() .getResourceByMimeType(ReportsBaseTask.LABELS_MIME); reps.addAll(AppContextMgr.getInstance().getResourceByMimeType(ReportsBaseTask.REPORTS_MIME)); Vector<InfoForTaskReport> repInfo = new Vector<InfoForTaskReport>(); for (AppResourceIFace rep : reps) { Properties params = rep.getMetaDataMap(); String tableid = params.getProperty("tableid"); SpReport spReport = null; boolean includeIt = false; try { Integer tblId = null; try { tblId = Integer.valueOf(tableid); } catch (NumberFormatException ex) { //continue; } if (tblId == null) { continue; } if (tblId.equals(invoiceTblId)) { includeIt = true; } else if (tblId.equals(-1)) { QueryIFace q = session.createQuery("from SpReport spr join spr.appResource apr " + " join spr.query spq " + "where apr.id = " + ((SpAppResource) rep).getId() + " and spq.contextTableId = " + invoiceTblId, false); List<?> spReps = q.list(); if (spReps.size() > 0) { includeIt = true; spReport = (SpReport) ((Object[]) spReps.get(0))[0]; spReport.forceLoad(); if (spReps.size() > 1) { //should never happen log.error("More than SpReport exists for " + rep.getName()); } } } } catch (Exception ex) { UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(InteractionsTask.class, ex); //skip this res } if (includeIt) { repInfo.add(new InfoForTaskReport((SpAppResource) rep, spReport)); } } if (repInfo.size() == 0) { UIRegistry.displayInfoMsgDlgLocalized("InteractionsTask.NoInvoiceFound", DBTableIdMgr.getInstance().getTitleForId(invoiceTblId)); return null; } if (repInfo.size() == 1) { return repInfo.get(0); } dlg = new ChooseFromListDlg<InfoForTaskReport>((Frame) UIRegistry.getTopWindow(), getResourceString("REP_CHOOSE_INVOICE"), repInfo); dlg.setVisible(true); if (dlg.isCancelled()) { return null; } return dlg.getSelectedObject(); // for (AppResourceIFace res : AppContextMgr.getInstance().getResourceByMimeType(ReportsBaseTask.LABELS_MIME)) // { // Properties params = res.getMetaDataMap(); // String tableid = params.getProperty("tableid"); // boolean includeIt = false; // try // { // includeIt = Integer.valueOf(tableid).equals(loanTblId); // } // catch (Exception ex) // { // //skip this res // } // if (includeIt) // { // aprs.add((SpAppResource )res); // } // } // for (AppResourceIFace res : AppContextMgr.getInstance().getResourceByMimeType(ReportsBaseTask.REPORTS_MIME)) // { // Properties params = res.getMetaDataMap(); // String tableid = params.getProperty("tableid"); // boolean includeIt = false; // try // { // includeIt = Integer.valueOf(tableid).equals(loanTblId); // } // catch (Exception ex) // { // // skip this res // } // if (includeIt) // { // aprs.add((SpAppResource) res); // } // } // // if (aprs.size() == 0) // { // return null; // } // // if (aprs.size() == 1) // { // return aprs.get(0); // } // Vector<String> reportNames = new Vector<String>(); // for (Integer id : ids) // { // QueryIFace q = session.createQuery("from SpReport spr join spr.appResource apr " // + "where apr.id = " + id.toString(), false); // List<?> reports = q.list(); // for (Object repObj : reports) // { // reportNames.add(((SpReport )repObj).getName()); // } // if (reports.size() == 0) // { // return null; // } // if (reports.size() == 1) // { // SpReport result = (SpReport )((Object[] )reports.get(0))[0]; // result.forceLoad(); // return result; // } // // Vector<SpReport> reps = new Vector<SpReport>(reports.size()); // for (Object rep : reports) // { // reps.add((SpReport )((Object[] )rep)[0]); // } // dlg = new ChooseFromListDlg<SpAppResource>((Frame) UIRegistry // .getTopWindow(), getResourceString("REP_CHOOSE_SP_REPORT"), // aprs); // dlg.setVisible(true); // if (dlg.isCancelled()) // { // return null; // } // return dlg.getSelectedObject(); // result.forceLoad(); // return result; } finally { session.close(); if (dlg != null) { dlg.dispose(); } } }
From source file:com.google.cloud.dns.testing.LocalDnsHelper.java
/** * Lists record sets for a zone. Next page token is the ID of the last record listed. *//*from w w w . j a v a 2 s. co m*/ @VisibleForTesting Response listDnsRecords(String projectId, String zoneName, String query) { Map<String, Object> options = OptionParsers.parseListDnsRecordsOptions(query); Response response = checkListOptions(options); if (response != null) { return response; } ZoneContainer zoneContainer = findZone(projectId, zoneName); if (zoneContainer == null) { return Error.NOT_FOUND.response( String.format("The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)); } ImmutableSortedMap<String, ResourceRecordSet> dnsRecords = zoneContainer.dnsRecords().get(); String[] fields = (String[]) options.get("fields"); String name = (String) options.get("name"); String type = (String) options.get("type"); String pageToken = (String) options.get("pageToken"); ImmutableSortedMap<String, ResourceRecordSet> fragment = pageToken != null ? dnsRecords.tailMap(pageToken, false) : dnsRecords; Integer maxResults = options.get("maxResults") == null ? null : Integer.valueOf((String) options.get("maxResults")); boolean sizeReached = false; boolean hasMorePages = false; LinkedList<String> serializedRrsets = new LinkedList<>(); String lastRecordId = null; for (String recordSetId : fragment.keySet()) { ResourceRecordSet recordSet = fragment.get(recordSetId); if (matchesCriteria(recordSet, name, type)) { if (sizeReached) { // we do not add this, just note that there would be more and there should be a token hasMorePages = true; break; } else { lastRecordId = recordSetId; try { serializedRrsets .addLast(jsonFactory.toString(OptionParsers.extractFields(recordSet, fields))); } catch (IOException e) { return Error.INTERNAL_ERROR.response(String.format( "Error when serializing resource record set in managed zone %s in project %s", zoneName, projectId)); } } } sizeReached = maxResults != null && maxResults.equals(serializedRrsets.size()); } boolean includePageToken = hasMorePages && (fields == null || Arrays.asList(fields).contains("nextPageToken")); return toListResponse(serializedRrsets, "rrsets", lastRecordId, includePageToken); }
From source file:de.juwimm.cms.remote.ContentServiceSpringImpl.java
/** * @see de.juwimm.cms.remote.ContentServiceSpring#removeAllOldContentVersions(java.lang.Integer) *//* w w w . j ava 2 s .c o m*/ @Override protected void handleRemoveAllOldContentVersions(Integer contentId) throws Exception { try { Integer[] allContentVersionIds = getAllContentVersionsId(contentId); ContentHbm content = super.getContentHbmDao().load(contentId); ContentVersionHbm lastContentVersion = content.getLastContentVersion(); Integer lastContentVersionId = lastContentVersion.getContentVersionId(); for (int i = 0; i < allContentVersionIds.length; i++) { if (!lastContentVersionId.equals(allContentVersionIds[i])) { removeContentVersion(allContentVersionIds[i]); } } lastContentVersion.setVersion("1"); } catch (Exception e) { log.error("Could not remove all old content versions from content with id " + contentId, e); throw new UserException(e.getMessage()); } }
From source file:org.openmrs.module.rwandaprimarycare.FindPatientByNameController.java
@RequestMapping("/module/rwandaprimarycare/findPatientByName") public String setupForm(@RequestParam(value = "search", required = false) String search, @RequestParam(value = "addIdentifier", required = false) String addIdentifier, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws PrimaryCareException { //LK: Need to ensure that all primary care methods only throw a PrimaryCareException //So that errors will be directed to a touch screen error page try {// w ww . j av a 2s. co m HttpSession session = request.getSession(); session.setAttribute("search", null); String searchFANAME = ServletRequestUtils.getStringParameter(request, PatientSearchType.FANAME.toString(), null); String searchRWNAME = ServletRequestUtils.getStringParameter(request, PatientSearchType.RWNAME.toString(), null); String searchGENDER = ServletRequestUtils.getStringParameter(request, PatientSearchType.GENDER.toString(), null); float searchAGE = ServletRequestUtils.getFloatParameter(request, PatientSearchType.AGE.toString(), 0); Integer searchBIRTHDATE_DAY = ServletRequestUtils.getIntParameter(request, PatientSearchType.BIRTHDATE_DAY.toString(), 0); Integer searchBIRTHDATE_MONTH = ServletRequestUtils.getIntParameter(request, PatientSearchType.BIRTHDATE_MONTH.toString(), 0); Integer searchBIRTHDATE_YEAR = ServletRequestUtils.getIntParameter(request, PatientSearchType.BIRTHDATE_YEAR.toString(), 0); String searchMRWNAME = ServletRequestUtils.getStringParameter(request, PatientSearchType.MRWNAME.toString(), null); String searchFATHERSRWNAME = ServletRequestUtils.getStringParameter(request, PatientSearchType.FATHERSRWNAME.toString(), null); String searchCOUNTRY = ServletRequestUtils.getStringParameter(request, PatientSearchType.COUNTRY.toString(), null); ; String searchPROVINCE = ServletRequestUtils.getStringParameter(request, PatientSearchType.PROVINCE.toString(), null); ; String searchDISTRICT = ServletRequestUtils.getStringParameter(request, PatientSearchType.DISTRICT.toString(), null); String searchSECTOR = ServletRequestUtils.getStringParameter(request, PatientSearchType.SECTOR.toString(), null); ; String searchCELL = ServletRequestUtils.getStringParameter(request, PatientSearchType.CELL.toString(), null); String searchUMUDUGUDU = ServletRequestUtils.getStringParameter(request, PatientSearchType.UMUDUGUDU.toString(), null); if (searchFANAME != null) { if (search == null) search = ""; model.addAttribute("search", search); model.addAttribute("addIdentifier", addIdentifier); model.addAttribute("searchFANAME", searchFANAME); model.addAttribute("searchRWNAME", searchRWNAME); model.addAttribute("searchGENDER", searchGENDER); model.addAttribute("searchBIRTHDATE_DAY", searchBIRTHDATE_DAY); model.addAttribute("searchBIRTHDATE_MONTH", searchBIRTHDATE_MONTH); model.addAttribute("searchBIRTHDATE_YEAR", searchBIRTHDATE_YEAR); //calculate age from birthdate if null if (!searchBIRTHDATE_DAY.equals(0) && !searchBIRTHDATE_MONTH.equals(0) && !searchBIRTHDATE_YEAR.equals(0)) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, searchBIRTHDATE_DAY); cal.set(Calendar.MONTH, searchBIRTHDATE_MONTH - 1); cal.set(Calendar.YEAR, searchBIRTHDATE_YEAR); Patient pTmp = new Patient(); pTmp.setBirthdate(cal.getTime()); searchAGE = pTmp.getAge(); pTmp = null; } model.addAttribute("searchAGE", searchAGE); model.addAttribute("searchMRWNAME", searchMRWNAME); model.addAttribute("searchFATHERSRWNAME", searchFATHERSRWNAME); model.addAttribute("searchUMUDUGUDU", searchUMUDUGUDU); model.addAttribute("searchCELL", searchCELL); model.addAttribute("searchDISTRICT", searchDISTRICT); model.addAttribute("searchCOUNTRY", searchCOUNTRY); model.addAttribute("searchPROVINCE", searchPROVINCE); model.addAttribute("searchSECTOR", searchSECTOR); List<Patient> patients = PrimaryCareBusinessLogic.getService().getPatients(searchFANAME, searchRWNAME, searchGENDER, searchAGE, searchMRWNAME, searchFATHERSRWNAME, searchCOUNTRY, searchPROVINCE, searchDISTRICT, searchSECTOR, searchCELL, searchUMUDUGUDU, Context.getPersonService().getPersonAttributeTypeByName("Health Center"), PrimaryCareBusinessLogic.getLocationLoggedIn(request.getSession())); //List<Patient> patients = PrimaryCareBusinessLogic.getPatientWithSoundex(searchFANAME, searchRWNAME, PrimaryCareBusinessLogic.getLocationLoggedIn(request.getSession()), searchUMUDUGUDU); model.addAttribute("results", patients); model.addAttribute("identifierTypes", PrimaryCareBusinessLogic.getPatientIdentifierTypesToUse()); } } catch (Exception e) { throw new PrimaryCareException(e); } return "/module/rwandaprimarycare/findPatientByName"; }
From source file:com.google.cloud.dns.testing.LocalDnsHelper.java
/** * Lists zones. Next page token is the last listed zone name and is returned only of there is more * to list and if the user does not exclude nextPageToken from field options. *///ww w.ja v a 2 s .c o m @VisibleForTesting Response listZones(String projectId, String query) { Map<String, Object> options = OptionParsers.parseListZonesOptions(query); Response response = checkListOptions(options); if (response != null) { return response; } ConcurrentSkipListMap<String, ZoneContainer> containers = findProject(projectId).zones(); String[] fields = (String[]) options.get("fields"); String dnsName = (String) options.get("dnsName"); String pageToken = (String) options.get("pageToken"); Integer maxResults = options.get("maxResults") == null ? null : Integer.valueOf((String) options.get("maxResults")); boolean sizeReached = false; boolean hasMorePages = false; LinkedList<String> serializedZones = new LinkedList<>(); String lastZoneName = null; ConcurrentNavigableMap<String, ZoneContainer> fragment = pageToken != null ? containers.tailMap(pageToken, false) : containers; for (ZoneContainer zoneContainer : fragment.values()) { ManagedZone zone = zoneContainer.zone(); if (dnsName == null || zone.getDnsName().equals(dnsName)) { if (sizeReached) { // we do not add this, just note that there would be more and there should be a token hasMorePages = true; break; } else { try { lastZoneName = zone.getName(); serializedZones.addLast(jsonFactory.toString(OptionParsers.extractFields(zone, fields))); } catch (IOException e) { return Error.INTERNAL_ERROR.response(String.format( "Error when serializing managed zone %s in project %s", lastZoneName, projectId)); } } } sizeReached = maxResults != null && maxResults.equals(serializedZones.size()); } boolean includePageToken = hasMorePages && (fields == null || Arrays.asList(fields).contains("nextPageToken")); return toListResponse(serializedZones, "managedZones", lastZoneName, includePageToken); }
From source file:edu.ku.brc.specify.conversion.SpecifyDBConverter.java
/** * /* www . java 2 s .c o m*/ */ public void fixupUserAgents(final Connection newDBConn) { List<String> agentFieldNames = getFieldNamesFromSchema(newDBConn, "agent"); String fieldNameStr = buildSelectFieldList(agentFieldNames, null); fieldNameStr = StringUtils.replace(fieldNameStr, "AgentID, ", ""); String dupSQL = String.format("INSERT INTO agent (%s) SELECT (%s) WHERE AgentID = ", fieldNameStr, fieldNameStr); String sql = "SELECT DivisionID FROM division"; Vector<Integer> divs = BasicSQLUtils.queryForInts(newDBConn, sql); sql = "SELECT AgentID, SpecifyUserID, DivisionID FROM agent WHERE SpecifyUserID IS NOT NULL"; Vector<Object[]> existingUserAgent = BasicSQLUtils.query(newDBConn, sql); if (existingUserAgent.size() == 1) { Object[] existingRow = existingUserAgent.get(0); Integer refAgentId = (Integer) existingRow[0]; Integer refSpUserId = (Integer) existingRow[1]; Integer refDivId = (Integer) existingRow[2]; for (Integer divId : divs) { if (divId.equals(refDivId)) { sql = String.format("SELECT AgentID FROM agent WHERE SpecifyUserID = %d AND DivisionID = %d", refSpUserId, divId); Vector<Integer> agents = BasicSQLUtils.queryForInts(newDBConn, sql); if (agents == null || agents.size() == 0) { String updateSQL = dupSQL + refAgentId; System.out.println(updateSQL); int rv = BasicSQLUtils.update(newDBConn, dupSQL); System.out.println("rv: " + rv); int newId = BasicSQLUtils.getHighestId(newDBConn, "AgentID", "agent"); updateSQL = String.format("UPDATE agent SET DivisionID = %d WHERE AgentID = %d", divId, newId); System.out.println(updateSQL); rv = BasicSQLUtils.update(newDBConn, updateSQL); System.out.println("rv: " + rv); } } } } else { UIRegistry.displayErrorDlg("There is more than one SpecifyUser / Division and shouldn't be!"); } }
From source file:com.abiquo.api.services.cloud.VirtualMachineService.java
/** * Find the backup resources with temporal pointing to the provided resource identifier. * //from w w w . java2 s .c o m * @return resource with temporal == provided resource id, null if not found */ private RasdManagement getBackupResource(final List<RasdManagement> rollbackResources, final Integer tempRasdManId) { for (RasdManagement rasdman : rollbackResources) { if (tempRasdManId.equals(rasdman.getTemporal())) { return rasdman; } } return null; }
From source file:org.kuali.kra.award.home.Award.java
public PersonRolodex getProposalNonEmployee(Integer rolodexId) { List<AwardPerson> awardPersons = getProjectPersons(); for (AwardPerson awardPerson : awardPersons) { if (rolodexId.equals(awardPerson.getRolodexId())) { return awardPerson; }//from w ww .j a va 2s. c o m } return null; }
From source file:com.abiquo.api.services.cloud.VirtualMachineService.java
/** * Validates the given object with links to a hard disk and returns the referenced hard disk. * /*ww w . j av a2 s . c om*/ * @param links The links to validate the hard disk. * @param expectedVirtualDatacenter The expected virtual datacenter to be found in the link. * @return The list of {@link DiskManagement} referenced by the link. * @throws Exception If the link is not valid. */ public List<DiskManagement> getHardDisksFromDto(final VirtualDatacenter vdc, final SingleResourceTransportDto dto) { List<DiskManagement> disks = new LinkedList<DiskManagement>(); // Validate and load each volume from the link list for (RESTLink link : dto.searchLinks(DiskResource.DISK)) { String path = buildPath(VirtualDatacentersResource.VIRTUAL_DATACENTERS_PATH, VirtualDatacenterResource.VIRTUAL_DATACENTER_PARAM, DisksResource.DISKS_PATH, DiskResource.DISK_PARAM); MultivaluedMap<String, String> pathValues = URIResolver.resolveFromURI(path, link.getHref()); // URI needs to have an identifier to a VDC, and another one to the volume if (pathValues == null || !pathValues.containsKey(VirtualDatacenterResource.VIRTUAL_DATACENTER) || !pathValues.containsKey(DiskResource.DISK)) { throw new BadRequestException(APIError.HD_ATTACH_INVALID_LINK); } // Volume provided in link must belong to the same virtual datacenter Integer vdcId = Integer.parseInt(pathValues.getFirst(VirtualDatacenterResource.VIRTUAL_DATACENTER)); if (!vdcId.equals(vdc.getId())) { throw new BadRequestException(APIError.HD_ATTACH_INVALID_VDC_LINK); } Integer diskId = Integer.parseInt(pathValues.getFirst(DiskResource.DISK)); DiskManagement disk = vdcRep.findHardDiskByVirtualDatacenter(vdc, diskId); if (disk == null) { String errorCode = APIError.HD_NON_EXISTENT_HARD_DISK.getCode(); String message = APIError.HD_NON_EXISTENT_HARD_DISK.getMessage() + ": Hard Disk id " + diskId; CommonError error = new CommonError(errorCode, message); addNotFoundErrors(error); } else { disks.add(disk); } } // Throw the exception with all the disks we have not found. flushErrors(); return disks; }