List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:org.kuali.coeus.s2sgen.impl.generate.S2SBaseFormGenerator.java
protected ProposalPersonContract getPerson(DevelopmentProposalContract developmentProposal, Integer proposalPersonNumber) { for (ProposalPersonContract person : developmentProposal.getProposalPersons()) { if (proposalPersonNumber.equals(person.getProposalPersonNumber())) { return person; }//from w ww . jav a 2 s . co m } return null; }
From source file:de.kapsi.net.daap.nio.DaapServerNIO.java
/** * Returns a DaapConnection for sessionId or <code>null</code> * if sessionId is unknown./*from w w w. j av a 2 s .c om*/ * * <p>DO NOT CALL THIS METHOD! THIS METHOD IS ONLY PUBLIC * DUE TO SOME DESIGN ISSUES!</p> */ public DaapConnection getConnection(Integer sessionId) { if (connections == null) return null; Iterator it = connections.iterator(); while (it.hasNext()) { DaapConnection connection = (DaapConnection) it.next(); DaapSession session = connection.getSession(false); if (session != null) { Integer sid = session.getSessionId(); if (sid.equals(sessionId)) { return connection; } } } return null; }
From source file:org.openmrs.web.controller.encounter.EncounterDisplayController.java
/** * This will look through all form fields and find the one that has a concept that matches the * given concept If one is found, that formfield is removed from the given list * <code>formFields</code> If there are none found, null is returned. * * @param formFields list of FormFields to rifle through * @param conceptToSearchFor concept to look for in <code>formFields</code> * @return FormField object from <code>formFields</code> or null *//* w w w . j a v a 2 s .c o m*/ private FormField popFormFieldForConcept(List<FormField> formFields, Concept conceptToSearchFor) { //drop out if a null concept was passed in if (conceptToSearchFor == null) { return null; } Integer conceptId = conceptToSearchFor.getConceptId(); // look through all formFields for this concept for (FormField formField : formFields) { Field field = formField.getField(); if (field != null) { Concept otherConcept = field.getConcept(); if (otherConcept != null && conceptId.equals(otherConcept.getConceptId())) { // found a FormField. Remove it from the list and // return it formFields.remove(formField); return formField; } } } // no formField with concept = conceptToSearchFor was found return null; }
From source file:de.iteratec.iteraplan.presentation.dialog.AttributeTypeGroup.AttributeTypeGroupController.java
/** * This method is used to initialize the view. If the query string parameter ?id= is present, the * corresponding attributeTypeGroup is fetched and shown. Otherwise the default attributeTypeGroup * is shown./*from w w w. java 2s. c om*/ * * @param atgId * the id of the attributeTypeGroup to show * @param model * @param session * @param request */ @RequestMapping(method = RequestMethod.GET) public void init(@RequestParam(value = "id", required = false) String atgId, ModelMap model, HttpSession session, HttpServletRequest request) { super.init(model, session, request); GuiContext guiContext = GuiContext.getCurrentGuiContext(); AttributeTypeGroupDialogMemory atgDialogMemory; AttributeTypeGroup atg = null; Integer id = NONEXISTENT_ID; // if an id is provided, try to get the associated attributeTypeGroup // if no queryString (?id=...) is provided, atgId will be null if (atgId != null) { try { id = Integer.valueOf(atgId); } catch (NumberFormatException e) { LOGGER.debug("Parsing of " + atgId + " failed, setting it to " + NONEXISTENT_ID, e); id = NONEXISTENT_ID; } } // if the query-param is non existent or null, look up the dialogMemory if (id.equals(NONEXISTENT_ID)) { // try to get the DialogMemory for the AttributeTypeGroup dialog if (guiContext.hasDialogMemory(getDialogName())) { atgDialogMemory = (AttributeTypeGroupDialogMemory) guiContext.getDialogMemory(getDialogName()); } else { // create a new one with nonexistent id atgDialogMemory = new AttributeTypeGroupDialogMemory(); atgDialogMemory.setSelectedAttributeTypeGroup(NONEXISTENT_ID); } // get the selected AttributeTypeGroup from the dialogMemory atg = attributeTypeGroupService.loadObjectByIdIfExists(atgDialogMemory.getSelectedAttributeTypeGroup()); } // otherwise get the selected AttributeTypeGroup from the queryId else { atg = attributeTypeGroupService.loadObjectByIdIfExists(id); } // if no associated attributeTypeGroup could be found or if the id was not provided get the // standard attributeTypegroup if (atg == null) { atg = attributeTypeGroupService.getStandardAttributeTypeGroup(); } AttributeTypeGroupMemBean memBean = new AttributeTypeGroupMemBean(); memBean.getComponentModel().initializeFrom(atg); model.addAttribute("memBean", memBean); // save DialogMemory to GuiContext atgDialogMemory = new AttributeTypeGroupDialogMemory(); atgDialogMemory.setSelectedAttributeTypeGroup(atg.getId()); updateGuiContext(atgDialogMemory); }
From source file:com.efficio.fieldbook.web.nursery.service.impl.ExcelImportStudyServiceImpl.java
private void validateRowIdentifiers(HSSFSheet observationSheet, Workbook workbook) throws WorkbookParserException { if (workbook.getObservations() != null) { String gidLabel = getColumnLabel(workbook, TermId.GID.getId()); String desigLabel = getColumnLabel(workbook, TermId.DESIG.getId()); String entryLabel = getColumnLabel(workbook, TermId.ENTRY_NO.getId()); int gidCol = findColumn(observationSheet, gidLabel); int desigCol = findColumn(observationSheet, desigLabel); int entryCol = findColumn(observationSheet, entryLabel); int rowIndex = 1; for (MeasurementRow wRow : workbook.getObservations()) { HSSFRow row = observationSheet.getRow(rowIndex++); Integer gid = getMeasurementDataValueInt(wRow, gidLabel); String desig = getMeasurementDataValue(wRow, desigLabel); Integer entry = getMeasurementDataValueInt(wRow, entryLabel); Integer xlsGid = getExcelValueInt(row, gidCol); String xlsDesig = row.getCell(desigCol).getStringCellValue(); Integer xlsEntry = getExcelValueInt(row, entryCol); if (gid == null || desig == null || entry == null || xlsDesig == null || !gid.equals(xlsGid) || !desig.trim().equalsIgnoreCase(xlsDesig.trim()) || !entry.equals(xlsEntry)) { throw new WorkbookParserException("error.workbook.import.observationRowMismatch"); }//from w w w .ja v a 2 s . c om } } }
From source file:com.aurel.track.fieldType.runtime.custom.select.CustomSelectSimpleRT.java
/** * Get the ILabelBean by primary key //from w w w .j ava 2s .c o m * @return */ @Override public ILabelBean getLabelBean(Integer optionID, Locale locale) { if (optionID != null && optionID.equals(MatcherContext.PARAMETER)) { TOptionBean optionBean = new TOptionBean(); optionBean.setLabel(MatcherContext.getLocalizedParameter(locale)); optionBean.setObjectID(optionID); return optionBean; } return OptionBL.loadByPrimaryKey(optionID); }
From source file:act.installer.bing.BingSearchResults.java
/** This function issues a Bing search API call and gets the JSONObject containing the relevant results * (including TotalCounts and SearchResults) * @param queryTerm (String) the term to query for. * @param count (int) URL parameter indicating how many results to return. Max value is 100. * @param offset (int) URL parameter indicating the offset for results. * @return a JSONObject containing the response. * @throws IOException// w w w. j a v a 2 s . c o m */ private JsonNode fetchBingSearchAPIResponse(String queryTerm, Integer count, Integer offset) throws IOException { if (count <= 0) { LOGGER.error( "Bing Search API was called with \"count\" URL parameter = 0. Please request at least one result."); return null; } URI uri = null; try { // Bing URL pattern. Note that we use composite queries to allow retrieval of the total results count. // Transaction cost is [count] bings, where [count] is the value of the URL parameter "count". // In other words, we can make 5M calls with [count]=1 per month. // Example: https://api.cognitive.microsoft.com/bing/v5.0/search?q=porsche&responseFilter=webpages uri = new URIBuilder().setScheme("https").setHost(BING_API_HOST).setPath(BING_API_PATH) // Wrap the query term (%s) with double quotes (%%22) for exact search .setParameter("q", String.format("%s", queryTerm)) // Restrict response to Web Pages only .setParameter("responseFilter", "webpages") // "count" parameter. .setParameter("count", count.toString()) // "offset" parameter. .setParameter("offset", offset.toString()).build(); } catch (URISyntaxException e) { LOGGER.error("An error occurred when trying to build the Bing Search API URI", e); } JsonNode results; HttpGet httpget = new HttpGet(uri); // Yay for un-encrypted account key! // TODO: actually is there a way to encrypt it? httpget.setHeader("Ocp-Apim-Subscription-Key", accountKey); CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(basicConnManager).build(); try (CloseableHttpResponse response = httpclient.execute(httpget)) { Integer statusCode = response.getStatusLine().getStatusCode(); // TODO: The Web Search API returns useful error messages, we could use them to have better insights on failures. // See: https://dev.cognitive.microsoft.com/docs/services/56b43eeccf5ff8098cef3807/operations/56b4447dcf5ff8098cef380d if (!statusCode.equals(HttpStatus.SC_OK)) { LOGGER.error("Bing Search API call returned an unexpected status code (%d) for URI: %s", statusCode, uri); return null; } HttpEntity entity = response.getEntity(); ContentType contentType = ContentType.getOrDefault(entity); Charset charset = contentType.getCharset(); if (charset == null) { charset = StandardCharsets.UTF_8; } try (final BufferedReader in = new BufferedReader( new InputStreamReader(entity.getContent(), charset))) { String inputLine; final StringBuilder stringResponse = new StringBuilder(); while ((inputLine = in.readLine()) != null) { stringResponse.append(inputLine); } JsonNode rootNode = mapper.readValue(stringResponse.toString(), JsonNode.class); results = rootNode.path("webPages"); } } return results; }
From source file:ch.puzzle.itc.mobiliar.presentation.deploy.CreateDeploymentView.java
public void setSelectedReleaseId(Integer selectedReleaseId) { ReleaseEntity newSelectedRelease = null; for (ReleaseEntity release : releasesForAs) { if (release.getId().equals(selectedReleaseId)) { newSelectedRelease = release; break; }/*from www.j a v a 2 s . c o m*/ } if (newSelectedRelease != null) { if (selectedRelease == null || !selectedReleaseId.equals(selectedRelease.getId())) { selectedRelease = newSelectedRelease; loadApplicationsForSelecedAppServer(); } } else { this.selectedRelease = null; } }
From source file:dk.dma.msiproxy.web.MessageDetailsServlet.java
/** * Main GET method//from ww w .ja v a2 s . c o m * @param request servlet request * @param response servlet response */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Never cache the response response = WebUtils.nocache(response); // Read the request parameters String providerId = request.getParameter("provider"); String lang = request.getParameter("lang"); String messageId = request.getParameter("messageId"); String activeNow = request.getParameter("activeNow"); String areaHeadingIds = request.getParameter("areaHeadings"); List<AbstractProviderService> providerServices = providers.getProviders(providerId); if (providerServices.size() == 0) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid 'provider' parameter"); return; } // Ensure that the language is valid lang = providerServices.get(0).getLanguage(lang); // Force the encoding and the locale based on the lang parameter request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); final Locale locale = new Locale(lang); request = new HttpServletRequestWrapper(request) { @Override public Locale getLocale() { return locale; } }; // Get the messages in the given language for the requested provider MessageFilter filter = new MessageFilter().lang(lang); Date now = "true".equals(activeNow) ? new Date() : null; Integer id = StringUtils.isNumeric(messageId) ? Integer.valueOf(messageId) : null; Set<Integer> areaHeadings = StringUtils.isNotBlank(areaHeadingIds) ? Arrays .asList(areaHeadingIds.split(",")).stream().map(Integer::valueOf).collect(Collectors.toSet()) : null; List<Message> messages = providerServices.stream().flatMap(p -> p.getCachedMessages(filter).stream()) // Filter on message id .filter(msg -> (id == null || id.equals(msg.getId()))) // Filter on active messages .filter(msg -> (now == null || msg.getValidFrom() == null || msg.getValidFrom().before(now))) // Filter on area headings .filter(msg -> (areaHeadings == null || areaHeadings.contains(getAreaHeadingId(msg)))) .collect(Collectors.toList()); // Register the attributes to be used on the JSP apeg request.setAttribute("messages", messages); request.setAttribute("baseUri", app.getBaseUri()); request.setAttribute("lang", lang); request.setAttribute("locale", locale); request.setAttribute("provider", providerId); if (request.getServletPath().endsWith("pdf")) { generatePdfFile(request, response); } else { generateHtmlPage(request, response); } }
From source file:com.blackducksoftware.integration.hub.jenkins.PostBuildScanDescriptor.java
public FormValidation doCheckTimeout(@QueryParameter("hubTimeout") final String hubTimeout) throws IOException, ServletException { if (StringUtils.isBlank(hubTimeout)) { return FormValidation.error(Messages.HubBuildScan_getPleaseSetTimeout()); }/*from w w w. j av a 2s. co m*/ Integer i = 0; try { i = Integer.valueOf(hubTimeout); } catch (final NumberFormatException e) { return FormValidation.error(Messages.HubBuildScan_getTimeoutMustBeInteger()); } if (i.equals(0)) { return FormValidation.error(Messages.HubBuildScan_getTimeoutCantBeZero()); } return FormValidation.ok(); }