List of usage examples for java.lang Long intValue
public int intValue()
From source file:ru.codemine.ccms.dao.CounterDAOImpl.java
@Override public Integer getInValueByPeriod(Shop shop, LocalDate dateStart, LocalDate dateEnd) { Session session = sessionFactory.getCurrentSession(); Query query = session.createQuery( "SELECT SUM(c.in) FROM Counter c WHERE c.shop.id = :id AND c.date >= :dateStart AND c.date <= :dateEnd"); query.setInteger("id", shop.getId()); query.setDate("dateStart", dateStart.toDate()); query.setDate("dateEnd", dateEnd.toDate()); Long result = (Long) query.uniqueResult(); return result == null ? 0 : result.intValue(); }
From source file:ru.codemine.ccms.dao.CounterDAOImpl.java
@Override public Integer getOutValueByPeriod(Shop shop, LocalDate dateStart, LocalDate dateEnd) { Session session = sessionFactory.getCurrentSession(); Query query = session.createQuery( "SELECT SUM(c.out) FROM Counter c WHERE c.shop.id = :id AND c.date >= :dateStart AND c.date <= :dateEnd"); query.setInteger("id", shop.getId()); query.setDate("dateStart", dateStart.toDate()); query.setDate("dateEnd", dateEnd.toDate()); Long result = (Long) query.uniqueResult(); return result == null ? 0 : result.intValue(); }
From source file:com.unistrong.tracker.dao.DeviceDao.java
/** */ public int getCountByUser(Long userId) { String hql = "SELECT COUNT(*) FROM Device WHERE userId=?"; Long count = aggregate(hql, userId); return count.intValue(); }
From source file:com.unistrong.tracker.dao.DeviceDao.java
/** * //from ww w . j av a 2 s . c o m * * @param userId * @return */ public int findByServiceUserCount(Long serviceId) { String hql = "select count(*) from Device where serviceId=? "; Long count = aggregate(hql, serviceId); return count.intValue(); }
From source file:com.glaf.shiro.redis.ShiroRedisCache.java
@Override public int size() { try {/*from w w w . j a v a 2 s.co m*/ Long longSize = new Long(cacheable.getHashSize(getByteName())); return longSize.intValue(); } catch (Throwable t) { throw new CacheException(t); } }
From source file:cognition.pipeline.service.ElasticsearchService.java
public void exportToElastic(String url, Long port) { Client client = new TransportClient() .addTransportAddress(new InetSocketTransportAddress(url, port.intValue())); logger.info("Getting results from the results table..."); List<DNCWorkCoordinate> results = dncWorkUnitDao.getResults(); results.parallelStream().forEach(coordinate -> { try {//from w ww. jav a 2s . c o m client.prepareIndex("coordinates", "coordinate", coordinate.getCoordinateString()) .setSource(jsonBuilder().startObject().field("id", coordinate.getCoordinateString()) .field("patientId", coordinate.getPatientId()) .field("tableName", coordinate.getSourceTable()) .field("idInTable", coordinate.getIdInSourceTable()) .field("dataType", StringTools.getOrEmpty(coordinate.getType())) .field("dataColumnName", StringTools.getOrEmpty(coordinate.getPkColumnName())) .field("documentXhtml", coordinate.getConversionResult()) .field("documentText", HTMLUtil.getContentFromHTML(coordinate.getConversionResult())) .field("lastModifiedDate", TimeUtil.fromUTCFormat(HTMLUtil .getMetaValue(coordinate.getConversionResult(), "Last-Modified"))) .field("author", HTMLUtil.getMetaValue(coordinate.getConversionResult(), "Author")) .field("pageCount", Integer.valueOf( HTMLUtil.getMetaValue(coordinate.getConversionResult(), "xmpTPg:NPages"))) .endObject()) .execute().actionGet(); } catch (IOException e) { logger.error(e.getMessage()); } }); logger.info("All done."); client.close(); }
From source file:com.diversityarrays.kdxplore.KDXplore.java
public static void mainImpl(String[] args, Closure<KDXploreFrame> onCreateCallback, final Closure<UpdateCheckContext> updateChecker) { Locale defaultLocale = Locale.getDefault(); System.out.println("Locale=" + defaultLocale); //$NON-NLS-1$ // System.setProperty("apple.laf.useScreenMenuBar", "true"); // //$NON-NLS-1$ //$NON-NLS-2$ // Initialise the appFolder KdxplorePreferences prefs = KdxplorePreferences.getInstance(); applyUIdefaultPreferences(prefs);/*from w ww .ja v a2s.c om*/ String kdxploreName = KDXPLORE_APP_NAME; ApplicationFolder defaultAppFolder = ApplicationFolders.getApplicationFolder(kdxploreName); String[] newArgs = CommandArgs.parseRunModeOption(defaultAppFolder, args); String baseNameForDistrib = kdxploreName.toLowerCase(); if (RunMode.DEMO == RunMode.getRunMode()) { kdxploreName = kdxploreName + "Demo"; //$NON-NLS-1$ } final ApplicationFolder appFolder = ApplicationFolders.getApplicationFolder(kdxploreName); CommandArgs commandArgs = new CommandArgs(appFolder, KdxConstants.VERSION, KdxConstants.VERSION_CODE, newArgs); org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ClassPathExtender.class); if (commandArgs.baseDir == null) { File userDir = new File(System.getProperty("user.dir")); //$NON-NLS-1$ File distribDir; if ("kdxos_main".equals(userDir.getName())) { // In Eclipse project this is where we store it distribDir = new File(userDir.getParentFile(), baseNameForDistrib); } else { distribDir = new File(userDir, baseNameForDistrib); } System.out.println("userDir=" + userDir); //$NON-NLS-1$ System.out.println("distribDir=" + distribDir); //$NON-NLS-1$ commandArgs.baseDir = distribDir.isDirectory() ? distribDir : userDir; } if (!commandArgs.baseDir.isDirectory()) { GuiUtil.errorMessage(null, "baseDir is not a directory: " + commandArgs.baseDir); //$NON-NLS-1$ System.exit(1); } File libDir = new File(commandArgs.baseDir, "lib"); //$NON-NLS-1$ File[] libFiles = libDir.listFiles(); if (libFiles == null) { MsgBox.error(null, Msg.MSG_APP_START_DIRECTORY(kdxploreName, commandArgs.baseDir), Msg.ERRTITLE_MISSING_LIBRARY_FILES() + ": " + libDir.getPath()); System.exit(1); } else if (libFiles.length < REQD_LIB_COUNT) { MsgBox.error(null, Msg.MSG_APP_START_DIRECTORY(kdxploreName, commandArgs.baseDir), Msg.ERRTITLE_MISSING_LIBRARY_FILES() + ": " + libFiles.length); System.exit(1); } // = = = = = = = = = = = = = = = = = = = // = = = = = = = = = = = = = = = = = = = // = = = = = = = CLASSPATH = = = = = = = ClassPathExtender.VERBOSE = !commandArgs.quiet; // RunMode.getRunMode().isDeveloper(); String libs_sb = "lib,plugins,kdxlibs,../runlibs"; //$NON-NLS-1$ boolean[] seenPdfbox = new boolean[1]; Consumer<File> jarChecker = new Consumer<File>() { @Override public void accept(File f) { if (f.getName().startsWith("pdfbox")) { seenPdfbox[0] = true; } } }; ClassPathExtender.appendToClassPath(commandArgs.baseDir, libs_sb, jarChecker, log); if (seenPdfbox[0]) { System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider"); } // = = = = = = = = = = = = = = = = = = = // = = = = = = = = = = = = = = = = = = = // = = = = = = = = = = = = = = = = = = = doStaticInitChecks(commandArgs.quiet); if (commandArgs.runInitChecks) { System.out.println("Init checks OK"); //$NON-NLS-1$ System.exit(0); } establishLogger(appFolder); @SuppressWarnings("unused") String configName = commandArgs.establishKdxConfig(); Long versionSubinfo = null; if (commandArgs.errmsg == null) { if (!KdxploreConfig.getInstance().isEternal()) { commandArgs.expiryChecks(KdxConstants.VERSION); versionSubinfo = KdxConstants.getVersionSubinfo(); if (versionSubinfo == Long.MAX_VALUE) { versionSubinfo = null; } } } String baseTitle = appFolder.getApplicationName() + " v" + KdxConstants.VERSION; //$NON-NLS-1$ String expiresIn = ""; //$NON-NLS-1$ if (versionSubinfo != null) { if ((0 < versionSubinfo && versionSubinfo < 14) || RunMode.getRunMode().isDeveloper()) { expiresIn = " " + Msg.KDX_EXPIRES_IN_N_DAYS(versionSubinfo.intValue()); //$NON-NLS-1$ } } if (commandArgs.errmsg != null) { JOptionPane.showMessageDialog(null, commandArgs.errmsg, baseTitle + expiresIn, JOptionPane.ERROR_MESSAGE); System.exit(1); } final String kdxploreTitle = buildKdxploreTitle(baseTitle, expiresIn, commandArgs.kdxConfigService.getConfigName()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // TODO allow user to change "base font size" String uiMultiplier = null; try { String propertyName = CommandArgs.UI_MULTIPLIER_PROPERTY_NAME; uiMultiplier = System.getProperty(propertyName); if (uiMultiplier != null) { try { float multiplier = Float.parseFloat(uiMultiplier); setUIfontSize(multiplier); } catch (NumberFormatException e) { System.err.println(String.format("?invalid value for %s: %s", //$NON-NLS-1$ propertyName, uiMultiplier)); } } } catch (SecurityException e) { System.err.println(String.format("Ignoring: %s %s", //$NON-NLS-1$ e.getClass().getSimpleName(), e.getMessage())); } GuiUtil.initLookAndFeel(); try { KDXploreFrame frame = new KDXploreFrame(appFolder, kdxploreTitle, KdxConstants.VERSION_CODE, KdxConstants.VERSION, updateChecker); frame.setVisible(true); if (onCreateCallback != null) { onCreateCallback.execute(frame); } } catch (IOException e) { MsgBox.error(null, e, Msg.ERRTITLE_UNABLE_TO_START_KDXPLORE(KDXPLORE_APP_NAME)); } } }); }
From source file:org.grails.datastore.mapping.model.types.BasicTypeConverterRegistrar.java
public void register(ConverterRegistry registry) { registry.addConverter(new Converter<Date, String>() { public String convert(Date date) { return String.valueOf(date.getTime()); }/* w w w . j av a 2s . com*/ }); registry.addConverter(new Converter<Date, Calendar>() { public Calendar convert(Date date) { final GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date); return calendar; } }); registry.addConverter(new Converter<Integer, Long>() { public Long convert(Integer integer) { return integer.longValue(); } }); registry.addConverter(new Converter<Long, Integer>() { public Integer convert(Long longValue) { return longValue.intValue(); } }); registry.addConverter(new Converter<Integer, Double>() { public Double convert(Integer integer) { return integer.doubleValue(); } }); registry.addConverter(new Converter<CharSequence, Date>() { public Date convert(CharSequence s) { try { final Long time = Long.valueOf(s.toString()); return new Date(time); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); registry.addConverter(new Converter<CharSequence, Double>() { public Double convert(CharSequence s) { try { return Double.valueOf(s.toString()); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); registry.addConverter(new Converter<CharSequence, Integer>() { public Integer convert(CharSequence s) { try { return Integer.valueOf(s.toString()); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); registry.addConverter(new Converter<CharSequence, Long>() { public Long convert(CharSequence s) { try { return Long.valueOf(s.toString()); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); registry.addConverter(new Converter<Object, String>() { public String convert(Object o) { return o.toString(); } }); registry.addConverter(new Converter<Calendar, String>() { public String convert(Calendar calendar) { return String.valueOf(calendar.getTime().getTime()); } }); registry.addConverter(new Converter<CharSequence, Calendar>() { public Calendar convert(CharSequence s) { try { Date date = new Date(Long.valueOf(s.toString())); Calendar c = new GregorianCalendar(); c.setTime(date); return c; } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); }
From source file:org.tec.webapp.jdbc.entity.TestUserRole.java
/** * create seed user/*from w ww . j a va2 s . c o m*/ * @return the seed user */ protected UserRoleBean testUserRole() { DataSourceTransactionManager tmgr = (DataSourceTransactionManager) mAppContext .getBean("transactionManager"); TransactionStatus tranStat = tmgr.getTransaction(new DefaultTransactionDefinition()); try { UserBean user = new User(); user.setUserName("junit"); user.setEmail("junit@test.null"); Long userId = mUserDba.insert(user); Assert.assertTrue("id is foobared", userId > 0); user.setUserId(userId.intValue()); UserRoleBean roleBean = new UserRole(); roleBean.setUser(user); roleBean.setRole(RoleType.ROLE_GUEST); Long id = mUserRoleDba.insert(roleBean); roleBean.setUserRoleId(id.intValue()); List<UserRoleBean> l = mUserRoleDba.getRoles(new Long(user.getUserId())); Assert.assertTrue("should be at least 1 role", l.size() > 0); tmgr.commit(tranStat); return roleBean; } catch (Throwable t) { tmgr.rollback(tranStat); throw new RuntimeException("failed to create user role", t); } }
From source file:net.bitnine.agensgraph.graph.property.JsonArray.java
public Integer getInt(int index) { Long value = getLong(index); return (value == null) ? null : value.intValue(); }