List of usage examples for java.lang Long intValue
public int intValue()
From source file:com.zb.app.web.controller.cms.CMSController.java
@RequestMapping(value = "/shop_view.htm") public ModelAndView shop_view(ModelAndView mav, Long id) { TravelGiftDO giftDO = integralService.getTravelGiftById(id.intValue()); mav.addObject("gift", giftDO); mav.setViewName("cms/1409/shop_view"); List<TravelGiftClassDO> classDOs = integralService.list(new TravelGiftClassQuery()); mav.addObject("gClassList", classDOs); return mav;//from ww w .j a v a 2 s . c o m }
From source file:edu.harvard.med.screensaver.db.ScreenResultsDAOImpl.java
public int createScreenedReagentCounts(final ScreenType screenType, Screen study, AnnotationType positiveAnnotationType, AnnotationType overallAnnotationType) { // Break this into two separate queries because of Hibernate bug (http://opensource.atlassian.com/projects/hibernate/browse/HHH-1615): // when using the "group by" clause with a full object (as opposed to an attribute of the object/table), // Hibernate is requiring that every attribute of the object be specified in a "group by" and not // just the object itself. so the workaround is to query once to get the id's then once again to // get the objects. log.info("1. get the reagent id's for the positive counts"); ScrollableResults sr = runScrollQuery(new edu.harvard.med.screensaver.db.ScrollQuery() { public ScrollableResults execute(Session session) { HqlBuilder builder = new HqlBuilder(); builder.select("r", "id").selectExpression("count(*)").from(AssayWell.class, "aw") .from("aw", AssayWell.libraryWell, "w", JoinType.INNER) .from("w", Well.latestReleasedReagent, "r", JoinType.INNER) .from("w", Well.library, "l", JoinType.INNER) .where("l", "screenType", Operator.EQUAL, screenType) .where("w", "libraryWellType", Operator.EQUAL, LibraryWellType.EXPERIMENTAL); builder.where("aw", "positive", Operator.EQUAL, Boolean.TRUE); builder.groupBy("r", "id"); log.debug("hql: " + builder.toHql()); return builder.toQuery(session, true).setCacheMode(CacheMode.IGNORE) .scroll(ScrollMode.FORWARD_ONLY); }/*from w ww.ja v a2 s.c o m*/ }); Map<Integer, Long> positivesMap = Maps.newHashMap(); while (sr.next()) { Object[] row = sr.get(); positivesMap.put((Integer) row[0], (Long) row[1]); } log.info("2. get the reagent id's for the overall counts"); sr = runScrollQuery(new edu.harvard.med.screensaver.db.ScrollQuery() { public ScrollableResults execute(Session session) { HqlBuilder builder = new HqlBuilder(); builder.select("r", "id").selectExpression("count(*)").from(AssayWell.class, "aw") .from("aw", AssayWell.libraryWell, "w", JoinType.INNER) .from("w", Well.library, "l", JoinType.INNER) .from("w", Well.latestReleasedReagent, "r", JoinType.INNER) .where("l", "screenType", Operator.EQUAL, screenType) .where("w", "libraryWellType", Operator.EQUAL, LibraryWellType.EXPERIMENTAL) .groupBy("r", "id"); log.debug("hql: " + builder.toHql()); return builder.toQuery(session, true).setCacheMode(CacheMode.IGNORE) .scroll(ScrollMode.FORWARD_ONLY); } }); Map<Integer, Long> overallMap = Maps.newHashMap(); while (sr.next()) { Object[] row = sr.get(); overallMap.put((Integer) row[0], (Long) row[1]); } log.info("3. get the Reagents"); sr = runScrollQuery(new edu.harvard.med.screensaver.db.ScrollQuery() { public ScrollableResults execute(Session session) { HqlBuilder builder = new HqlBuilder(); builder.select("r").distinctProjectionValues().from(AssayWell.class, "aw") .from("aw", AssayWell.libraryWell, "w", JoinType.INNER) .from("w", Well.library, "l", JoinType.INNER) .from("w", Well.latestReleasedReagent, "r", JoinType.INNER) .where("l", "screenType", Operator.EQUAL, screenType) .where("w", "libraryWellType", Operator.EQUAL, LibraryWellType.EXPERIMENTAL); log.debug("hql: " + builder.toHql()); return builder.toQuery(session, true).setCacheMode(CacheMode.IGNORE) .scroll(ScrollMode.FORWARD_ONLY); } }); log.info("4. build the Study: positives: " + positivesMap.size() + ", reagents: " + overallMap.size()); int count = 0; while (sr.next()) { Reagent r = (Reagent) sr.get()[0]; AnnotationValue av = new AnnotationValue(overallAnnotationType, r, null, (double) overallMap.get(r.getReagentId()).intValue()); _dao.saveOrUpdateEntity(av); Long positiveCount = positivesMap.get(r.getReagentId()); if (positiveCount != null) { av = new AnnotationValue(positiveAnnotationType, r, null, (double) positiveCount.intValue()); _dao.saveOrUpdateEntity(av); } // Note: due to memory performance, we will build the study_reagent_link later if (count++ % ROWS_TO_CACHE == 0) { log.debug("flushing"); _dao.flush(); _dao.clear(); } if (count % 10000 == 0) { log.info("" + count + " reagents processed"); } } log.info("save the study"); _dao.saveOrUpdateEntity(study); _dao.flush(); log.info("populateStudyReagentLinkTable"); int reagentCount = populateStudyReagentLinkTable(study.getScreenId()); log.info("done: positives: " + positivesMap.size() + ", reagents: " + overallMap.size()); return reagentCount; }
From source file:com.macrosoft.core.orm.hibernate.SimpleHibernateDao.java
/** * ,??./* w w w. java 2 s .c om*/ */ public T findUniqueBy(final String propertyName, final Object value) { Assert.hasText(propertyName, "propertyName?"); if (value == null) { return null; } if (value instanceof String) { if (StringUtils.isEmpty((String) value) == true) { return null; } } else { if (value instanceof Long) { Long temp = (Long) value; if (temp.intValue() <= 0) { return null; } } else { if (value instanceof Integer) { Integer temp = (Integer) value; if (temp.intValue() <= 0) { return null; } } } } Criterion criterion = Restrictions.eq(propertyName, value); return (T) createCriteria(criterion).uniqueResult(); }
From source file:com.zb.app.web.controller.cms.CMSController.java
@RequestMapping(value = "/shop_cart.htm") public ModelAndView shop_cart(ModelAndView mav, Long id) { TravelGiftDO giftDO = integralService.getTravelGiftById(id.intValue()); mav.addObject("gift", giftDO); TravelIntegralQuery integralQuery = new TravelIntegralQuery(); integralQuery.setcId(WebUserTools.getCid()); integralQuery.setmId(WebUserTools.getMid()); TravelIntegralDO integralDO = integralService.queryBala(integralQuery); mav.addObject("integralDO", integralDO); List<TravelGiftClassDO> classDOs = integralService.list(new TravelGiftClassQuery()); mav.addObject("gClassList", classDOs); mav.setViewName("cms/1409/shop_cart"); return mav;/*from w w w .j av a 2s .c o m*/ }
From source file:com.xie.javacase.json.JSONObject.java
/** * Try to convert a string into a number, boolean, or null. If the string * can't be converted, return the string. * @param s A String.//from w w w . jav a2 s .c o m * @return A simple JSON value. */ static public Object stringToValue(String s) { if (s.equals("")) { return s; } if (s.equalsIgnoreCase("true")) { return Boolean.TRUE; } if (s.equalsIgnoreCase("false")) { return Boolean.FALSE; } if (s.equalsIgnoreCase("null")) { return JSONObject.NULL; } /* * If it might be a number, try converting it. We support the 0- and 0x- * conventions. If a number cannot be produced, then the value will just * be a string. Note that the 0-, 0x-, plus, and implied string * conventions are non-standard. A JSON parser is free to accept * non-JSON forms as long as it accepts all correct JSON forms. */ char b = s.charAt(0); if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') { if (b == '0') { if (s.length() > 2 && (s.charAt(1) == 'x' || s.charAt(1) == 'X')) { try { return new Integer(Integer.parseInt(s.substring(2), 16)); } catch (Exception e) { /* Ignore the error */ } } else { try { return new Integer(Integer.parseInt(s, 8)); } catch (Exception e) { /* Ignore the error */ } } } try { if (s.indexOf('.') > -1 || s.indexOf('e') > -1 || s.indexOf('E') > -1) { return Double.valueOf(s); } else { Long myLong = new Long(s); if (myLong.longValue() == myLong.intValue()) { return new Integer(myLong.intValue()); } else { return myLong; } } } catch (Exception f) { /* Ignore the error */ } } return s; }
From source file:edu.wustl.geneconnect.postwork.MetadataManager.java
public String getOnts(Long pathId) { return ontIds.get(pathId.intValue()).toString(); }
From source file:org.openrepose.filters.clientauth.common.AuthenticationHandler.java
private int safeGroupTtl(int offset) { final Long grpTtl = this.groupCacheTtl + offset; if (grpTtl >= Integer.MAX_VALUE) { return Integer.MAX_VALUE; }//from w ww. ja va2s . c o m return grpTtl.intValue(); }
From source file:edu.wustl.geneconnect.postwork.MetadataManager.java
public String getSubPaths(Long pathId) { return subPathIds.get(pathId.intValue()).toString(); }
From source file:com.erudika.para.rest.ParaClientIT.java
@Test public void testUtils() { String id1 = pc.newId();/*from ww w .java 2s. c o m*/ String id2 = pc.newId(); assertNotNull(id1); assertFalse(id1.isEmpty()); assertNotEquals(id1, id2); final Long ts = pc.getTimestamp(); assertNotNull(ts); assertNotEquals(0, ts.intValue()); String date1 = pc.formatDate("MM dd yyyy", Locale.US); String date2 = Utils.formatDate("MM dd yyyy", Locale.US); assertEquals(date1, date2); String ns1 = pc.noSpaces(" test 123 test ", ""); String ns2 = Utils.noSpaces(" test 123 test ", ""); assertEquals(ns1, ns2); String st1 = pc.stripAndTrim(" %^&*( cool ) @!"); String st2 = Utils.stripAndTrim(" %^&*( cool ) @!"); assertEquals(st1, st2); String md1 = pc.markdownToHtml("**test** #hello"); String md2 = Utils.markdownToHtml("**test** #hello"); assertEquals(md1, md2); String ht1 = pc.approximately(15000); String ht2 = HumanTime.approximately(15000); assertEquals(ht1, ht2); }
From source file:com.gst.infrastructure.dataqueries.service.EntityDatatableChecksWritePlatformServiceImpl.java
@Override public void runTheCheck(final Long entityId, final String entityName, final Long statusCode, String foreignKeyColumn) { final List<EntityDatatableChecks> tableRequiredBeforeClientActivation = entityDatatableChecksRepository .findByEntityAndStatus(entityName, statusCode); if (tableRequiredBeforeClientActivation != null) { List<String> reqDatatables = new ArrayList<>(); for (EntityDatatableChecks t : tableRequiredBeforeClientActivation) { final String datatableName = t.getDatatableName(); final Long countEntries = readWriteNonCoreDataService.countDatatableEntries(datatableName, entityId, foreignKeyColumn);//from w ww .j a v a2s . c o m logger.info("The are " + countEntries + " entries in the table " + datatableName); if (countEntries.intValue() == 0) { reqDatatables.add(datatableName); } } if (reqDatatables.size() > 0) { throw new DatatableEntryRequiredException(reqDatatables.toString()); } } }