List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:com.epam.cme.storefront.controllers.misc.TelcoAddToCartController.java
protected void addProduct(final String code, final Model model, final long qty, final Integer bundleNo, final String bundleTemplateId) { try {// w w w .ja v a 2 s . c om final List<CartModificationData> cartModifications = cartFacade.addToCart(code, qty, bundleNo.intValue(), bundleTemplateId, false); model.addAttribute("modifiedCartData", cartModifications); for (final CartModificationData cartModification : cartModifications) { if (cartModification.getQuantityAdded() == 0L) { GlobalMessages.addErrorMessage(model, "basket.information.quantity.noItemsAdded." + cartModification.getStatusCode()); model.addAttribute("errorMsg", "basket.information.quantity.noItemsAdded." + cartModification.getStatusCode()); } else if (cartModification.getQuantityAdded() < qty) { GlobalMessages.addErrorMessage(model, "basket.information.quantity.reducedNumberOfItemsAdded." + cartModification.getStatusCode()); model.addAttribute("errorMsg", "basket.information.quantity.reducedNumberOfItemsAdded." + cartModification.getStatusCode()); } } } catch (final CommerceCartModificationException ex) { model.addAttribute("errorMsg", "basket.error.occurred"); LOG.warn("Couldn't add product of code " + code + " to cart.", ex); } final CartData cartData = cartFacade.getSessionCart(); model.addAttribute("cartData", cartData); }
From source file:com.ewcms.publication.task.MemoryTaskQueue.java
@Override public void clearTasks(Integer siteId) { Assert.notNull(siteId, "Site id is null"); Iterator<Taskable> iterator = tasks.iterator(); for (Taskable t = iterator.next(); iterator.hasNext(); t = iterator.next()) { if (siteId.intValue() == t.getSite().getId().intValue()) { iterator.remove();/*from w ww .j a va 2s. co m*/ } } }
From source file:com.aurel.track.lucene.search.LuceneSearcher.java
/** * Creates the OR divided workItemIDs/*from w w w.j av a 2 s . c o m*/ * @param objectIDs * @return */ public static String createORDividedIDs(Set<Integer> objectIDs) { StringBuilder stringBuilder = new StringBuilder(); if (objectIDs != null && !objectIDs.isEmpty()) { if (objectIDs.size() == 1) { for (Integer objectID : objectIDs) { if (objectID != null && objectID.intValue() < 0) { //FIXME: escape the - sign if negative, but \\ does not work. As fix a range query is used: within [ ] the minus sign works //stringBuilder.append("\\"+objectID); stringBuilder.append("[" + objectID + " TO " + objectID + "]"); } else { stringBuilder.append(objectID); } } } else { stringBuilder.append("("); for (Iterator<Integer> iterator = objectIDs.iterator(); iterator.hasNext();) { Integer objectID = iterator.next(); if (objectID != null && objectID.intValue() < 0) { //FIXME: escape the - sign if negative, but \\ does not work. As fix a range query is used: within [ ] the minus sign works stringBuilder.append("[" + objectID + " TO " + objectID + "]"); } else { stringBuilder.append(objectID); } if (iterator.hasNext()) { stringBuilder.append(" OR "); } } stringBuilder.append(")"); } } return stringBuilder.toString(); }
From source file:mocks.MockEmailNotificationServiceImpl.java
public Integer getTotalPeriodicRemindersSent() { int total = 0; for (Map.Entry<String, Integer> mapEntry : aggregateReminderCount.entrySet()) { Integer value = mapEntry.getValue(); total += (value == null) ? 0 : value.intValue(); }//w w w .j av a 2 s.c om return Integer.valueOf(total); }
From source file:com.acc.core.suggestion.dao.impl.DefaultSimpleSuggestionDao.java
@Override public List<ProductModel> findProductsRelatedToProducts(final List<ProductModel> products, final List<ProductReferenceTypeEnum> referenceTypes, final UserModel user, final boolean excludePurchased, final Integer limit) { Assert.notNull(products);//from ww w .j a va 2 s . c o m Assert.notNull(user); final int maxResultCount = limit == null ? DEFAULT_LIMIT : limit.intValue(); final Map<String, Object> params = new HashMap<String, Object>(); final StringBuilder builder = new StringBuilder(REF_QUERY_PRODUCT_START); if (excludePurchased) { builder.append(REF_QUERY_SUB); } if (CollectionUtils.isNotEmpty(referenceTypes)) { builder.append(REF_QUERY_TYPES); params.put(REF_QUERY_PARAM_TYPES, referenceTypes); } builder.append(REF_QUERY_PRODUCT_GROUP); builder.append(REF_QUERY_PRODUCT_ORDER); params.put(REF_QUERY_PARAM_USER, user); params.put(REF_QUERY_PARAM_PRODUCTS, products); final FlexibleSearchQuery query = new FlexibleSearchQuery(builder.toString()); query.addQueryParameters(params); query.setNeedTotal(false); query.setCount(maxResultCount); final SearchResult<ProductModel> result = getFlexibleSearchService().search(query); return result.getResult(); }
From source file:com.itemanalysis.psychometrics.scaling.PercentileRank.java
public void addValue(Integer score) { if (score >= min && score <= max) { freqTable.addValue(score.intValue()); } }
From source file:com.acc.core.suggestion.dao.impl.DefaultSimpleSuggestionDao.java
@SuppressWarnings("deprecation") @Deprecated// w w w . jav a 2 s.c om @Override public List<ProductModel> findProductsRelatedToPurchasedProductsByCategory(final CategoryModel category, final UserModel user, final ProductReferenceTypeEnum referenceType, final boolean excludePurchased, final Integer limit) { Assert.notNull(category); Assert.notNull(user); final int maxResultCount = limit == null ? DEFAULT_LIMIT : limit.intValue(); final Map<String, Object> params = new HashMap<String, Object>(); final StringBuilder builder = new StringBuilder(REF_QUERY_CATEGORY_START); if (excludePurchased) { builder.append(REF_QUERY_SUB); } if (referenceType != null) { builder.append(REF_QUERY_TYPE); params.put(REF_QUERY_PARAM_TYPE, referenceType); } builder.append(REF_QUERY_CATEGORY_ORDER); params.put(REF_QUERY_PARAM_USER, user); params.put(REF_QUERY_PARAM_CATEGORY, category); final FlexibleSearchQuery query = new FlexibleSearchQuery(builder.toString()); query.addQueryParameters(params); query.setNeedTotal(false); query.setCount(maxResultCount); final SearchResult<ProductModel> result = getFlexibleSearchService().search(query); return result.getResult(); }
From source file:eu.project.ttc.resources.GeneralLanguageResource.java
public void load(InputStream inputStream) throws ResourceInitializationException { words = Sets.newHashSet();/*from w w w . j a va 2 s . co m*/ Scanner scanner = null; try { scanner = new Scanner(inputStream, "UTF-8"); scanner.useDelimiter("\n"); int index = 0; while (scanner.hasNext()) { index++; String line = scanner.next(); String[] items = line.split("::"); if (items.length == 3) { String key = items[0].trim(); if (!key.contains(" ")) this.words.add(key); Integer value = Integer.valueOf(items[2].trim()); this.cumulatedFrequency += value.intValue(); String lemma = key; this.frequencies.put(lemma, new Entry(lemma, items[1], new Integer(value.intValue()))); } else { throw new IOException("Wrong general language format at line " + index + ": " + line); } } this.words = ImmutableSet.copyOf(this.words); if (this.frequencies.containsKey(PARAM_NB_CORPUS_WORDS)) this.nbCorpusWords = this.frequencies.get(PARAM_NB_CORPUS_WORDS).iterator().next().getFrequency(); else { LOGGER.warn("No such key for in GeneralLanguage resource {}", PARAM_NB_CORPUS_WORDS); LOGGER.warn("Switch to cumulatedFrequency mode"); this.cumulatedFrequencyMode = true; } } catch (Exception e) { throw new ResourceInitializationException(e); } finally { IOUtils.closeQuietly(scanner); } }
From source file:de.crowdcode.bitemporal.example.PersonTest.java
@Test public void testCreateRecordTemporalAddresses() { Person person = new PersonImpl(); person.setLastname("Mueller"); person.setFirstname("Hans"); assertNull(person.getId());/* w ww .ja v a2 s .co m*/ person = personService.createPerson(person); assertNotNull(person.getId()); Address firstAddress = new AddressImpl(); firstAddress.setPerson(person); firstAddress.setStreet("Hauptstr. 21"); firstAddress.setCity("Koeln"); firstAddress.setCode("50698"); // First address assertNull(firstAddress.getId()); Address createdAddress1 = addressService.createAddressWithPerson(firstAddress, person); assertNotNull(createdAddress1.getId()); // Update person for the relation to the address Person updatedPerson = personService.findPersonById(person.getId()); // Assert Address firstCheckedAddress = updatedPerson.getAddress(); assertEquals(firstAddress.getCity(), firstCheckedAddress.getCity()); Address secondAddress = new AddressImpl(); secondAddress.setPerson(person); secondAddress.setStreet("Grossmarkt 22"); secondAddress.setCity("Berlin"); secondAddress.setCode("10313"); // Second address supersedes the first one // The person has only ONE current address assertNull(secondAddress.getId()); Address createdAddress2 = addressService.createAddressWithPerson(secondAddress, person); assertNotNull(createdAddress2.getId()); Address thirdAddress = new AddressImpl(); thirdAddress.setPerson(person); thirdAddress.setStreet("Aaasee str. 1"); thirdAddress.setCity("Muenster"); thirdAddress.setCode("43425"); // Third address supersedes the first one // The person has only ONE current address assertNull(thirdAddress.getId()); Address createdAddress3 = addressService.createAddressWithPerson(thirdAddress, person); assertNotNull(createdAddress3.getId()); Address fourthAddress = new AddressImpl(); fourthAddress.setPerson(person); fourthAddress.setStreet("Weyerstr. 1"); fourthAddress.setCity("Solingen"); fourthAddress.setCode("47144"); // Fourth address supersedes the first one // The person has only ONE current address assertNull(fourthAddress.getId()); Address createdAddress4 = addressService.createAddressWithPerson(fourthAddress, person); assertNotNull(createdAddress4.getId()); // Update person for the relation to the address updatedPerson = personService.findPersonById(person.getId()); // Assert Address secondCheckedAddress = updatedPerson.getAddress(); assertEquals(fourthAddress.getCity(), secondCheckedAddress.getCity()); Address secondCheckedAddressMethod = updatedPerson.address(); assertEquals(fourthAddress.getCity(), secondCheckedAddressMethod.getCity()); Address secondCheckedAddressAlive = updatedPerson.alive(); assertEquals(fourthAddress.getCity(), secondCheckedAddressAlive.getCity()); // Assert amount of object // One person and four addresses but the person has only one current // address Integer amountOfPerson = personService.getAmountOfPerson(); assertEquals(1, amountOfPerson.intValue()); Integer amountOfAddress = addressService.getAmountOfAddress(); assertEquals(4, amountOfAddress.intValue()); Address currentAddress = updatedPerson.getAddress(); assertEquals("Solingen", currentAddress.getCity()); // Show in logger Collection<Person> persons = personService.findAllPersons(); for (Person person2 : persons) { logger.info("XXX - Person.firstname: " + person2.getFirstname()); logger.info("XXX - Person.address.city: " + person2.getAddress().getCity()); } Collection<Address> addresses = addressService.findAllAddresses(); for (Address address : addresses) { logger.info("YYY - Address.city: " + address.getCity()); logger.info("YYY - Address.person.firstname: " + address.getPerson().getFirstname()); } }
From source file:com.android.sdklib.internal.repository.MockDownloadCache.java
/** * Override openDirectUrl to return one of the registered payloads or throw a FNF exception. * This totally ignores the cache's {@link DownloadCache.Strategy}. *///from ww w .j a v a 2s . com @Override public Pair<InputStream, HttpResponse> openDirectUrl(@NonNull String urlString, @Nullable Header[] headers, @NonNull ITaskMonitor monitor) throws IOException, CanceledByUserException { synchronized (mDirectHits) { Integer count = mDirectHits.get(urlString); mDirectHits.put(urlString, (count == null ? 0 : count.intValue()) + 1); } Payload payload = mDirectPayloads.get(urlString); if (payload == null || payload.mHttpCode == THROW_FNF) { throw new FileNotFoundException(urlString); } byte[] content = payload.mContent; if (content == null) { content = new byte[0]; } InputStream is = new ByteArrayInputStream(content); HttpResponse hr = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), payload.mHttpCode, "Http-Code-" + payload.mHttpCode); return Pair.of(is, hr); }