Example usage for java.lang Long Long

List of usage examples for java.lang Long Long

Introduction

In this page you can find the example usage for java.lang Long Long.

Prototype

@Deprecated(since = "9")
public Long(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Long object that represents the long value indicated by the String parameter.

Usage

From source file:net.sf.sail.webapp.dao.sds.impl.SdsCurnitCreateCommandHttpRestImpl.java

/**
 * @see net.sf.sail.webapp.dao.sds.SdsCommand#execute()
 *//*  w w w.  j av  a2s.c  om*/
public SdsCurnit execute(final HttpPostRequest httpRequest) {
    final Map<String, String> responseHeaders = this.transport.post(httpRequest);
    final String locationHeader = responseHeaders.get("Location");
    final SdsCurnit sdsCurnit = this.getSdsCurnit();
    // clear the thread local reference to avoid resource leak since we're
    // done executing
    SDS_CURNIT.set(null);
    sdsCurnit.setSdsObjectId(new Long(locationHeader.substring(locationHeader.lastIndexOf("/") + 1)));
    return sdsCurnit;
}

From source file:StocksTable.java

public StockData(String symbol, String name, double last, double open, double change, double changePr,
        long volume) {
    m_symbol = symbol;//from   w  w w  .  j  av a  2s  . c  om
    m_name = name;
    m_last = new Double(last);
    m_open = new Double(open);
    m_change = new Double(change);
    m_changePr = new Double(changePr);
    m_volume = new Long(volume);
}

From source file:edu.pitt.dbmi.ccd.queue.task.SlurmAlgorithmJob.java

@Scheduled(fixedRate = 5000)
public void manageJobsInQueue() {
    List<JobStatus> finishedJobList = algorithmSlurmService.getFinishedJobs();
    Map<Long, JobStatus> finishedJobMap = new HashMap<>();
    if (finishedJobList != null && !finishedJobList.isEmpty()) {
        finishedJobList.forEach(jobStatus -> {
            finishedJobMap.put(new Long(jobStatus.getJobId()), jobStatus);
        });/*from  w  w  w.ja va 2 s  .  c o m*/
    }

    int numRunningJobs = 0;

    List<JobQueueInfo> runningJobList = jobQueueInfoService.findByStatus(1);
    for (JobQueueInfo job : runningJobList) {
        Long pid = job.getPid();
        if (pid != null && finishedJobMap.containsKey(pid)) {
            if (finishedJobMap.containsKey(pid)) {
                Long queueId = job.getId();
                jobQueueInfoService.deleteJobById(queueId);

                JobStatus status = finishedJobMap.get(pid);
                JobStat stat = algorithmSlurmService.getJobStat(pid);
                Set<UserAccount> userAccounts = job.getUserAccounts();
                UserAccount userAccount = (UserAccount) userAccounts.toArray()[0];
                String username = userAccount.getUsername();
                LOGGER.info("JobUsage{" + "JobId=" + queueId + ", " + "HPCjobId=" + pid + ", " + "User='"
                        + username + "', " + "State='" + status.getState() + "', " + "Elapsed='"
                        + status.getTime() + "', " + "Start='" + stat.getStart() + "', " + "End='"
                        + stat.getEnd() + "', " + "Partition='" + status.getPartition() + "', " + "AllocCPUS="
                        + stat.getAllocCPUS() + ", " + "AllocNodes=" + stat.getAllocNodes() + ", "
                        + "NodeList='" + status.getNodelist() + "'}");

                algorithmSlurmService.downloadJobResult(job);
            } else {
                numRunningJobs++;
            }
        }
    }

    if (numRunningJobs < queueSize) {
        // Waiting list to execute
        List<JobQueueInfo> jobList = jobQueueInfoService.findByStatus(0);
        if (!jobList.isEmpty()) {
            // Execute one at a time
            JobQueueInfo jobQueueInfo = jobList.get(0);
            LOGGER.info("Run Job ID: " + jobQueueInfo.getId());

            try {
                LOGGER.info("Set Job's status to be 1 (running): " + jobQueueInfo.getId());
                jobQueueInfo.setStatus(1);
                jobQueueInfoService.saveJobIntoQueue(jobQueueInfo);

                algorithmSlurmService.submitJobtoSlurm(jobQueueInfo);
            } catch (Exception exception) {
                LOGGER.error("Unable to run " + jobQueueInfo.getAlgorName(), exception);
            }
        }
    }

    // Waiting list to terminate
    List<JobQueueInfo> jobList = jobQueueInfoService.findByStatus(2);
    jobList.forEach(job -> {
        killJob(job.getId());
    });

}

From source file:dao.DirImageAddQuery.java

/**
* This method is used to add blobstreams for directory.
* @param conn - the connection/*from  ww w  . j a va  2s  . co m*/
* @param blobType - the blob type (1 - photos, 2-music, 3-video 4 - documents, 5 - archives)
* @param mimeType - the mime type (image/jpeg, application/octet-stream)
* @param btitle - the title for this blob
* @param bsize - the size of the blob
* @param zoom - the zoom for the blob (used for displaying for image/jpeg)
* @param directoryId - the directoryId
* @param loginId - the loginId
* @param caption - the caption
* @throws Dao Exception - when an error or exception occurs while inserting this blob in DB.
*
 **/
public void run(Connection conn, String entryid, int blobType, String mimeType, String btitle, long bsize,
        int zoom, String directoryId, String loginId, String caption, boolean convertEntryId)
        throws BaseDaoException {

    byte[] capBytes = { ' ' };
    if (!RegexStrUtil.isNull(caption)) {
        capBytes = caption.getBytes();
    }

    PreparedStatement s = null;
    String stmt = null;
    if (convertEntryId) {
        stmt = "insert into dirimages values(?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP(), ?, ?, ?)";
    } else {
        stmt = "insert into dirimages values(?, " + "LAST_INSERT_ID()"
                + ", ?, ?, ?, ?, ?, CURRENT_TIMESTAMP(), ?, ?, ?)";
    }
    try {
        s = conn.prepareStatement(stmt);
        if (convertEntryId) {
            s.setLong(1, 0);
            s.setLong(2, new Long(entryid));
            s.setLong(3, new Long(directoryId));
            s.setLong(4, new Long(loginId));
            s.setInt(5, new Integer(blobType));
            s.setString(6, mimeType);
            s.setString(7, btitle);
            s.setLong(8, bsize);
            s.setInt(9, new Integer(zoom));
            s.setBytes(10, capBytes);
        } else {
            s.setLong(1, 0);
            s.setLong(2, new Long(directoryId));
            s.setLong(3, new Long(loginId));
            s.setInt(4, new Integer(blobType));
            s.setString(5, mimeType);
            s.setString(6, btitle);
            s.setLong(7, bsize);
            s.setInt(8, new Integer(zoom));
            s.setBytes(9, capBytes);
        }
        s.executeUpdate();
    } catch (Exception e) {
        throw new BaseDaoException("Error inserting into dirimages query, " + stmt, e);
    }
}

From source file:alpha.portal.webapp.controller.ContributorRoleController.java

/**
 * Show list of user roles./*  w w w . java  2 s  . c om*/
 * 
 * @param request
 *            The http-request parameters
 * @return Possible object names: contributorRolesList, messageId,
 *         showEditingForm, roleToEdit
 * @throws Exception
 *             the exception
 */
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showPage(final HttpServletRequest request) throws Exception {
    final Locale locale = request.getLocale();

    final ModelAndView returnData = new ModelAndView();

    if (request.getParameter("delete") != null) {
        final Long roleToDelete = new Long(request.getParameter("delete"));
        if (this.contributorRoleManager.exists(roleToDelete)) {
            try {
                this.contributorRoleManager.remove(roleToDelete);
                this.saveMessage(request, this.getText("contributorRoles.del_success", locale));
            } catch (final DataIntegrityViolationException e) {
                this.saveError(request, this.getText("contributorRoles.del_in_use", locale));
            }
        } else {
            this.saveError(request, this.getText("contributorRoles.del_err", locale));
        }
    }
    if (request.getParameter("edit") != null) {
        final Long roleId = new Long(request.getParameter("edit"));
        if (this.contributorRoleManager.exists(roleId)) {
            final ContributorRole roleObj = this.contributorRoleManager.get(roleId);
            returnData.addObject("showEditingForm", true);
            returnData.addObject("roleToEditId", request.getParameter("edit"));
            returnData.addObject("roleToEdit", new String(roleObj.getName()));
        }
    }

    if (request.getParameter("edit") == null) {
        final List<ContributorRole> contribList = this.contributorRoleManager.getAll();
        returnData.addObject("contributorRolesList", contribList);
    }

    return returnData;
}

From source file:com.google.gdt.eclipse.designer.mac.BrowserShellMacImplCocoa.java

private static Image createImageFromHandle(long imageHandle, int width, int height) throws Exception {
    if (imageHandle != 0) {
        Class<?> nsImageClass = Class.forName("org.eclipse.swt.internal.cocoa.NSImage");
        Object handleObject;//from ww  w  .j a v a 2s  .c  o m
        Class<?> handleClass;
        if (SystemUtils.OS_ARCH.indexOf("64") != -1) {
            handleClass = long.class;
            handleObject = new Long(imageHandle);
        } else {
            handleClass = int.class;
            handleObject = new Integer((int) imageHandle);
        }
        Constructor<?> constructor = nsImageClass.getConstructor(handleClass);
        Object nsImage = constructor.newInstance(handleObject);
        // Create a temporary image using the captured image's handle
        Class<?> NSImageClass = Class.forName("org.eclipse.swt.internal.cocoa.NSImage");
        Method method = Image.class.getDeclaredMethod("cocoa_new",
                new Class[] { Device.class, int.class, NSImageClass });
        method.setAccessible(true);
        Image tempImage = (Image) method.invoke(null,
                new Object[] { Display.getCurrent(), new Integer(SWT.BITMAP), nsImage });
        // Create the result image
        Image image = new Image(Display.getCurrent(), width, height);
        // Manually copy because the image's data handle isn't available
        GC gc = new GC(tempImage);
        gc.copyArea(image, 0, 0);
        gc.dispose();
        // Dispose of the temporary image allocated in the native call
        tempImage.dispose();
        return image;
    }
    // prevent failing
    return new Image(Display.getCurrent(), 1, 1);
}

From source file:org.myjerry.evenstar.web.layout.LayoutController.java

public ModelAndView saveTemplate(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView mav = new ModelAndView();

    String blogID = request.getParameter("blogID");
    String templateCode = request.getParameter("templateCode");

    this.blogLayoutService.saveBlogTemplate(new Long(blogID), templateCode);

    mav.setViewName(".admin.layout");
    mav.addObject("blogID", blogID);
    mav.addObject("templateCode", templateCode);
    return mav;/* w  ww .j av  a2 s. c om*/
}

From source file:com.npower.dm.hibernate.entity.ServiceProviderIdentifierGenerator.java

public Serializable generate(SessionImplementor session, Object entity) throws HibernateException {
    if (!(entity instanceof ServiceProvider)) {
        throw new HibernateException("Entity not implements ServiceProvider interface.");
    }/*from   w  w w  . ja v  a 2 s.  co  m*/
    ServiceProvider sp = (ServiceProvider) entity;
    if (StringUtils.isEmpty(sp.getExternalID())) {
        throw new HibernateException("Could not generate a identifier, missing ServiceProvider externalID.");
    }
    StringBuffer buf = new StringBuffer(sp.getExternalID().toLowerCase().trim());
    int id = (int) buf.toString().hashCode();
    // Keep > 0, unsigned number
    if (id < 0) {
        id = Integer.MAX_VALUE + id;
    }
    return new Long(id);
}

From source file:com.npower.dm.hibernate.entity.ManufacturerIdentifierGenerator.java

public Serializable generate(SessionImplementor session, Object entity) throws HibernateException {
    if (!(entity instanceof Manufacturer)) {
        throw new HibernateException("Entity not implements Manufacturer interface.");
    }//from ww  w.  jav a 2 s.co  m
    Manufacturer manufacturer = (Manufacturer) entity;
    if (StringUtils.isEmpty(manufacturer.getExternalId())) {
        throw new HibernateException("Could not generate a identifier, missing manufacturer externalID.");
    }
    StringBuffer buf = new StringBuffer(manufacturer.getExternalId().toLowerCase().trim());
    int id = (int) buf.toString().hashCode();
    // Keep > 0, unsigned number
    if (id < 0) {
        id = Integer.MAX_VALUE + id;
    }
    return new Long(id);
}