Example usage for java.lang Integer longValue

List of usage examples for java.lang Integer longValue

Introduction

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

Prototype

public long longValue() 

Source Link

Document

Returns the value of this Integer as a long after a widening primitive conversion.

Usage

From source file:org.egov.egf.commons.EgovCommon.java

/**
 * This method will return the amount that are available to make further payments.
 *
 * @param VoucherDate//from w w w  .  j  av a  2 s  . c  o m
 * @param bankaccountId
 * @return
 * @throws ValidationException
 */
@SuppressWarnings("unchecked")
public BigDecimal getBankBalanceAvailableforPayment(final Date VoucherDate, final Integer bankaccountId)
        throws ValidationException {
    // return getAccountBalance(VoucherDate, bankId,null,null);
    BigDecimal TotalbankBalance = BigDecimal.ZERO;
    BigDecimal bankBalanceasofBankBookReport = BigDecimal.ZERO;
    BigDecimal amountApprovedForPayment = BigDecimal.ZERO;
    bankBalanceasofBankBookReport = getAccountBalance(VoucherDate, bankaccountId.longValue(), null, null, null);
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Bank balance as per Bank book:" + bankBalanceasofBankBookReport);
    amountApprovedForPayment = getAmountApprovedForPaymentAndVoucherNotCreated(VoucherDate, bankaccountId);
    LOGGER.debug("Amount that are approved but voucher creation in progress:" + amountApprovedForPayment);
    TotalbankBalance = bankBalanceasofBankBookReport.subtract(amountApprovedForPayment);
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Total amount available for payment :" + TotalbankBalance);
    return TotalbankBalance;
}

From source file:org.alfresco.solr.SolrInformationServer.java

private long getSafeCount(NamedList<Integer> counts, String countType) {
    Integer count = counts.get(countType);
    return (count == null ? 0 : count.longValue());
}

From source file:org.jlibrary.core.jcr.JCRRepositoryService.java

public Directory updateDirectory(Ticket ticket, DirectoryProperties directoryProperties)
        throws RepositoryException, SecurityException {

    try {/*from  w ww .  j  a va  2 s.co m*/
        SessionManager manager = SessionManager.getInstance();
        Session session = manager.getSession(ticket);

        String directoryId = (String) directoryProperties.getProperty(DirectoryProperties.DIRECTORY_ID)
                .getValue();
        String parentId = (String) directoryProperties.getProperty(DirectoryProperties.DIRECTORY_PARENT)
                .getValue();
        String name = (String) directoryProperties.getProperty(DirectoryProperties.DIRECTORY_NAME).getValue();
        String description = (String) directoryProperties.getProperty(DirectoryProperties.DIRECTORY_DESCRIPTION)
                .getValue();
        Integer position = (Integer) directoryProperties.getProperty(DirectoryProperties.DIRECTORY_POSITION)
                .getValue();

        javax.jcr.Node root = JCRUtils.getRootNode(session);
        javax.jcr.Node directory = session.getNodeByUUID(directoryId);

        if (!JCRSecurityService.canWrite(directory, ticket.getUser().getId())) {
            throw new SecurityException(SecurityException.NOT_ENOUGH_PERMISSIONS);
        }

        Object syncLock = LockUtility.obtainLock(directory);
        synchronized (syncLock) {

            directory.setProperty(JLibraryConstants.JLIBRARY_DESCRIPTION, description);
            directory.setProperty(JLibraryConstants.JLIBRARY_POSITION, position.longValue());

            String previousName = directory.getProperty(JLibraryConstants.JLIBRARY_NAME).getString();
            if (!previousName.equals(name)) {
                String escapedName = JCRUtils.buildValidChildNodeName(directory.getParent(), null, name);
                name = Text.unescape(escapedName);
                directory.setProperty(JLibraryConstants.JLIBRARY_NAME, name);
                session.move(directory.getPath(), directory.getParent().getPath() + "/" + escapedName);
            }

            if (ticket.isAutocommit()) {
                SaveUtils.safeSaveSession(session);
            }
        }
        return JCRAdapter.createDirectory(directory, parentId, root.getUUID(), ticket.getUser().getId());
    } catch (Exception e) {
        throw new RepositoryException(e);
    }
}

From source file:com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler.java

/**
 * Returns the details of the given repo
 * @param loggedInUser The current user//from  ww w  . j  a va2  s .c om
 * @param id ID of repo whose details are sought.
 * @return the repo requested.
 *
 * @xmlrpc.doc Returns details of the given repo
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param_desc("string", "repoLabel", "repo to query")
 * @xmlrpc.returntype
 *     $ContentSourceSerializer
 */
public ContentSource getRepoDetails(User loggedInUser, Integer id) {
    return lookupContentSourceById(id.longValue(), loggedInUser.getOrg());
}

From source file:com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler.java

/**
 * Removes a repository//from w  w  w.j a  v  a2  s.c  o  m
 * @param loggedInUser The current user
 * @param id of the repo to be removed
 * @return Integer 1 on success
 *
 * @xmlrpc.doc Removes a repository
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param_desc("long", "id", "ID of repo to be removed")
 * @xmlrpc.returntype #return_int_success()
**/
public Integer removeRepo(User loggedInUser, Integer id) {
    ContentSource repo = lookupContentSourceById(id.longValue(), loggedInUser.getOrg());

    ChannelFactory.remove(repo);
    return 1;
}

From source file:com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler.java

/**
 * Updates repository source URL/*from ww  w  .  j a  va2s  .c om*/
 * @param loggedInUser The current user
 * @param id ID of the repo
 * @param url new URL to use
 * @return the updated repo
 *
 * @xmlrpc.doc Updates repository source URL
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param_desc("int", "id", "repository id")
 * @xmlrpc.param #param_desc("string", "url", "new repository url")
 * @xmlrpc.returntype $ContentSourceSerializer
**/
public ContentSource updateRepoUrl(User loggedInUser, Integer id, String url) {
    ContentSource repo = lookupContentSourceById(id.longValue(), loggedInUser.getOrg());
    setRepoUrl(repo, url);
    ChannelFactory.save(repo);
    return repo;
}

From source file:com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler.java

/**
 * Updates repository label/*from  ww  w. j av  a  2 s.  co  m*/
 * @param loggedInUser The current user
 * @param id ID of the repo
 * @param label new label
 * @return the updated repo
 *
 * @xmlrpc.doc Updates repository label
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param_desc("int", "id", "repository id")
 * @xmlrpc.param #param_desc("string", "label", "new repository label")
 * @xmlrpc.returntype $ContentSourceSerializer
**/
public ContentSource updateRepoLabel(User loggedInUser, Integer id, String label) {
    ContentSource repo = lookupContentSourceById(id.longValue(), loggedInUser.getOrg());
    setRepoLabel(repo, label);
    ChannelFactory.save(repo);
    return repo;
}

From source file:com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler.java

/**
 * Returns the requested channel/*from  w  ww  .jav  a  2 s .  c om*/
 * @param loggedInUser The current user
 * @param id - id of channel wanted
 * @throws NoSuchChannelException thrown if no channel is found.
 * @return the channel requested.
 *
 * @xmlrpc.doc Returns details of the given channel as a map
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param_desc("int", "id", "channel to query")
 * @xmlrpc.returntype
 *     $ChannelSerializer
 */
public Channel getDetails(User loggedInUser, Integer id) throws NoSuchChannelException {
    return lookupChannelById(loggedInUser, id.longValue());
}

From source file:com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler.java

/**
 * Updates a repository//from  ww w  .  j ava  2  s.  c  om
 * @param loggedInUser The current user
 * @param id ID of the repo
 * @param label new label
 * @param url new URL
 * @return the updated repo
 *
 * @xmlrpc.doc Updates a ContentSource (repo)
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param_desc("int", "id", "repository id")
 * @xmlrpc.param #param_desc("string", "label", "new repository label")
 * @xmlrpc.param #param_desc("string", "url", "new repository URL")
 * @xmlrpc.returntype $ContentSourceSerializer
**/
public ContentSource updateRepo(User loggedInUser, Integer id, String label, String url) {
    ContentSource repo = lookupContentSourceById(id.longValue(), loggedInUser.getOrg());
    setRepoLabel(repo, label);
    setRepoUrl(repo, url);
    ChannelFactory.save(repo);
    return repo;
}

From source file:com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler.java

/**
 * Subscribe a system to a list of channels
 * @param loggedInUser The current user/*from www. java 2 s .c o  m*/
 * @param labels a list of channel labels to subscribe the system to
 * @param sid the serverId of the system in question
 * @return 1 for success
 * @deprecated being replaced by system.setBaseChannel(string sessionKey,
 * int serverId, string channelLabel) and system.setChildChannels(string sessionKey,
 * int serverId, array[string channelLabel])
 *
 * @xmlrpc.doc Subscribes a system to a list of channels.  If a base channel is
 *      included, that is set before setting child channels.  When setting child
 *      channels the current child channel subscriptions are cleared.  To fully
 *      unsubscribe the system from all channels, simply provide an empty list of
 *      channel labels.
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param("int", "serverId")
 * @xmlrpc.param #array_single("string", "label - channel label to subscribe
 *                  the system to.")
 * @xmlrpc.returntype #return_int_success()
 */
@Deprecated
public int subscribeSystem(User loggedInUser, Integer sid, List<String> labels) {
    Server server = SystemManager.lookupByIdAndUser(new Long(sid.longValue()), loggedInUser);

    if (labels.size() == 0) {
        ServerFactory.unsubscribeFromAllChannels(loggedInUser, server);
        return 1;
    }

    Channel base = null;
    List<Integer> childChannelIds = new ArrayList<Integer>();

    for (String label : labels) {
        Channel channel = lookupChannelByLabel(loggedInUser.getOrg(), label);

        if (base == null && channel.isBaseChannel()) {
            base = channel;
        } else if (base != null && channel.isBaseChannel()) {
            throw new MultipleBaseChannelException(base.getLabel(), label);
        } else {
            childChannelIds.add(new Integer(channel.getId().intValue()));
        }
    }
    SystemHandler sysHandler = new SystemHandler();
    if (base != null) {

        sysHandler.setBaseChannel(loggedInUser, sid, new Integer(base.getId().intValue()));
    }
    sysHandler.setChildChannels(loggedInUser, sid, childChannelIds);

    return 1;
}