List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:org.appverse.web.framework.backend.batch.services.business.impl.live.JobRunnerServiceImpl.java
private boolean skipExecution(String jobName, int postExecutionSleepTime) { Date startDate = null;//from ww w . j av a2s . c o m List<JobInstance> jobInstances = jobExplorer.getJobInstances(jobName, 0, 1); if (CollectionUtils.isNotEmpty(jobInstances)) { // This will retrieve the latest job execution: List<JobExecution> jobExecutions = jobExplorer.getJobExecutions(jobInstances.get(0)); if (CollectionUtils.isNotEmpty(jobExecutions)) { JobExecution jobExecution = jobExecutions.get(0); startDate = jobExecution.getStartTime(); Long lastExecutionOffsetAsString = (Long) jobExecution.getExecutionContext().get("offset"); long lastExecutionOffset = 0; if (lastExecutionOffsetAsString != null) { lastExecutionOffset = lastExecutionOffsetAsString.longValue(); } else { lastExecutionOffset = TimeZone.getDefault().getOffset(new Date().getTime()); } Date currentDate = new Date(); long offset = TimeZone.getDefault().getOffset(new Date().getTime()); if (startDate != null && currentDate.getTime() - offset - (startDate.getTime() - lastExecutionOffset) < postExecutionSleepTime * 1000) { logger.debug("Current date offset " + offset); logger.debug("Current date with offset " + (currentDate.getTime() - offset)); logger.debug("Last execution date offset " + lastExecutionOffset); logger.debug("Last execution date with offset " + (startDate.getTime() - lastExecutionOffset)); logger.debug("Current date with offset - start date with offset " + (currentDate.getTime() - offset - (startDate.getTime() - lastExecutionOffset))); logger.info("Batch executed " + (currentDate.getTime() - offset - (startDate.getTime() - lastExecutionOffset)) / 60000 + " minutes before"); logger.info("Batch run skipped "); return true; } } } logger.info("Batch run started "); return false; }
From source file:com.blackbear.flatworm.converters.CoreConverters.java
public String convertLong(Object obj, Map<String, ConversionOption> options) { if (obj == null) { return null; }//w w w.j av a 2 s.co m Long l = (Long) obj; return Long.toString(l.longValue()); }
From source file:com.aol.webservice_base.cache.CacheManager.java
public boolean removeWriteLock(String key, long validator) { StringBuilder keyBuilder = new StringBuilder(32); keyBuilder.append(LOCK_PREFIX).append(keyPrefix).append(key); String cacheKey = keyBuilder.toString(); if (logger.isDebugEnabled()) logger.debug("Releasing the lock on " + cacheKey); // only someone who knows the validator can remove the lock String safeKey = ensureKeySafe(cacheKey, true); CacheContainer container = (CacheContainer) mc.get(safeKey); Long creatorValidator = null; if (container != null) { creatorValidator = (Long) container.getObject(cacheKey); }/* w ww. j a v a2 s. c o m*/ if (creatorValidator != null) { if (creatorValidator.longValue() == validator) { boolean released = mc.delete(safeKey); if (!released) logger.warn("Attempt to delete lock failed (likely edge case)" + key); return true; } else logger.warn("Invalid State: Do not own the lock being released"); } else logger.warn("Invalid State: Write Lock with null key"); return false; }
From source file:com.trailmagic.image.util.ReplaceImageManifestation.java
/** * THIS MUST BE PUBLIC in order for interceptors to run. GRRRR. **//* w w w. j a v a2 s. c o m*/ public void replaceManifestation(Long manifestationId, String filename, Integer width, Integer height) { try { Session session = SessionFactoryUtils.getSession(sessionFactory, false); HeavyImageManifestation manifest = imfFactory.getHeavyById(manifestationId.longValue()); // s_log.info("Got manifestation id " + manifest.getId()); File srcFile = new File(filename); s_log.info("Importing " + srcFile.getPath()); if (srcFile.length() > Integer.MAX_VALUE) { s_log.info("File is too big...skipping " + srcFile.getPath()); throw new RuntimeException("File too big"); } FileInputStream fis = new FileInputStream(srcFile); manifest.setData(Hibernate.createBlob(fis)); manifest.setWidth(width.intValue()); manifest.setHeight(height.intValue()); session.saveOrUpdate(manifest); s_log.info("ImageManifestation saved: " + manifest.getName() + " (" + manifest.getId() + ")" + "...flushing session and evicting manifestation."); synchronized (session) { session.flush(); session.evict(manifest); } fis.close(); SessionFactoryUtils.releaseSession(session, sessionFactory); s_log.info("Finished importing " + srcFile.getPath()); } catch (Exception e) { s_log.error("Error: " + e.getMessage(), e); throw new RuntimeException("Error", e); } }
From source file:alpha.portal.dao.hibernate.AlphaCardDaoHibernate.java
/** * Internal function to load the highest sequenceNumber from the AlphaCard * table./*from www .j av a 2 s. c o m*/ * * @return 0 if no record is found */ private Long getLastValue() { try { final List list = this.getHibernateTemplate() .find("select max(c.alphaCardIdentifier.sequenceNumber) from alphacard c"); Long value = (Long) list.get(0); if (value == null) { value = 0L; } return value.longValue(); } catch (final Exception e) { e.printStackTrace(); this.log.error("Failed to get last value of sequenceNumber!"); return 0L; } }
From source file:gov.utah.dts.det.ccl.documents.reporting.reports.InspectionsConductedReport.java
private PickListValue getInspectionType(Map<String, Object> context) { PickListValue type = null;//from w w w. j a v a 2s. c om Long typeId = (Long) context.get(INSPECTION_TYPE_KEY); if (typeId != null && typeId.longValue() != -1l) { type = pickListService.loadPickListValueById(typeId); } return type; }
From source file:org.apache.manifoldcf.crawler.connectors.jira.JiraSession.java
/** * Get the list of matching root documents, e.g. seeds. *///from w ww . j a v a 2s. c o m public void getSeeds(XThreadStringBuffer idBuffer, String jiraDriveQuery) throws IOException, ResponseException, InterruptedException, ManifoldCFException { long startAt = 0L; long setSize = 800L; long totalAmt = 0L; do { JiraQueryResults qr = new JiraQueryResults(); getRest("search?maxResults=" + setSize + "&startAt=" + startAt + "&jql=" + URLEncoder.encode(jiraDriveQuery), qr); Long total = qr.getTotal(); if (total == null) return; totalAmt = total.longValue(); qr.pushIds(idBuffer); startAt += setSize; } while (startAt < totalAmt); }
From source file:com.redhat.rhn.domain.errata.ErrataFactory.java
/** * Finds published errata by id/* ww w. j a va 2 s . c o m*/ * @param id errata id * @return Errata if found, otherwise null */ public static Errata lookupPublishedErrataById(Long id) { Session session = null; Errata retval = null; try { session = HibernateFactory.getSession(); retval = (Errata) session.getNamedQuery("PublishedErrata.findById").setLong("id", id.longValue()) .uniqueResult(); } catch (HibernateException he) { log.error("Error loading ActionArchTypes from DB", he); throw new HibernateRuntimeException("Error loading ActionArchTypes from db"); } return retval; }
From source file:io.ucoin.ucoinj.core.client.service.bma.TransactionRemoteServiceImpl.java
public long getCreditOrZero(long currencyId, String pubKey) { Long credit = getCredit(currencyId, pubKey); if (credit == null) { return 0; }//from w w w.jav a 2s . c o m return credit.longValue(); }
From source file:at.tugraz.ist.akm.webservice.requestprocessor.interceptor.HttpClientBackLog.java
protected boolean forget(int clientHash) { Long expiration = mClientBacklog.remove(clientHash); boolean removed = false; if (null != expiration) { mLog.debug("forgetting client [" + clientHash + "] that expires at [" + mTimeFormatter.format(expiration.longValue()) + "]"); removed = true;/*from w w w. java 2 s .c o m*/ } else { mLog.debug("no clent [" + clientHash + "] found to forget"); } return removed; }