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.apache.calcite.runtime.SqlFunctions.java

/** SQL <code>-</code> operator applied to nullable long and int values. */
public static Long minus(Long b0, Integer b1) {
    return (b0 == null || b1 == null) ? null : (b0.longValue() - b1.longValue());
}

From source file:org.apache.calcite.runtime.SqlFunctions.java

/** SQL <code>/</code> operator applied to nullable long and int values. */
public static Long divide(Long b0, Integer b1) {
    return (b0 == null || b1 == null) ? null : (b0.longValue() / b1.longValue());
}

From source file:org.apache.calcite.runtime.SqlFunctions.java

/** SQL <code>*</code> operator applied to nullable long and int values. */
public static Long multiply(Long b0, Integer b1) {
    return (b0 == null || b1 == null) ? null : (b0.longValue() * b1.longValue());
}

From source file:eu.europa.ec.fisheries.uvms.spatial.service.bean.impl.MapConfigServiceBean.java

private DisplayProjectionDto getDisplayProjection(Integer reportId, ConfigurationDto configurationDto)
        throws ServiceException {
    DisplayProjectionDto displayProjectionDto = new DisplayProjectionDto();
    ReportConnectSpatialEntity entity = null;
    if (reportId != null) {
        entity = repository.findReportConnectSpatialByReportId(reportId.longValue());
    }/*from   w ww .j  a  v  a  2s.c  o m*/

    if (entity != null && entity.getProjectionByDisplayProjId() != null) { // Check value in DB
        displayProjectionDto.setEpsgCode(entity.getProjectionByDisplayProjId().getSrsCode());
    } else { // If not get from config
        ProjectionDto projection = getProjection(configurationDto.getMapSettings().getDisplayProjectionId());
        displayProjectionDto.setEpsgCode(projection.getEpsgCode());
    }

    if (entity != null && entity.getScaleBarType() != null) { // Check value in DB
        displayProjectionDto.setUnits(entity.getScaleBarType());
    } else { // If not get from config
        displayProjectionDto
                .setUnits(ScaleBarUnits.fromValue(configurationDto.getMapSettings().getScaleBarUnits()));
    }

    if (entity != null && entity.getDisplayFormatType() != null) { // Check value in DB
        displayProjectionDto.setFormats(entity.getDisplayFormatType());
    } else { // If not get from config
        displayProjectionDto.setFormats(
                CoordinatesFormat.fromValue(configurationDto.getMapSettings().getCoordinatesFormat()));
    }

    return displayProjectionDto;
}

From source file:org.egov.dao.voucher.VoucherHibernateDAO.java

public EntityType getEntityInfo(final Integer detailKeyId, final Integer detailtypeId)
        throws ValidationException {
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("VoucherHibernateDAO | getDetailCodeName | start");
    EntityType entity = null;/* w w w. ja  v  a2s.com*/
    try {
        final Accountdetailtype accountdetailtype = getAccountDetailById(detailtypeId);
        final Class<?> service = Class.forName(accountdetailtype.getFullQualifiedName());
        // getting the entity type service.
        final String detailTypeName = service.getSimpleName();
        String dataType = "";
        final java.lang.reflect.Method method = service.getMethod("getId");
        dataType = method.getReturnType().getSimpleName();
        if (dataType.equals("Long"))
            entity = (EntityType) persistenceService
                    .find("from " + detailTypeName + " where id=? order by name", detailKeyId.longValue());
        else
            entity = (EntityType) persistenceService
                    .find("from " + detailTypeName + " where id=? order by name", detailKeyId);
    } catch (final Exception e) {
        final List<ValidationError> errors = new ArrayList<ValidationError>();
        errors.add(new ValidationError("exp", e.getMessage()));
        throw new ValidationException(errors);
    }
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("VoucherHibernateDAO | getDetailCodeName | End");
    return entity;

}

From source file:com.houghtonassociates.bamboo.plugins.dao.GerritService.java

private GerritChangeVO transformChangeJSONObject(JSONObject j) throws RepositoryException {
    if (j == null) {
        throw new RepositoryException("No data to parse!");
    }// w w w  .j a v a2s  . c o m

    log.debug(String.format("transformJSONObject(j=%s)", j));

    GerritChangeVO info = new GerritChangeVO();

    info.setProject(j.getString(GerritChangeVO.JSON_KEY_PROJECT));
    info.setBranch(j.getString(GerritChangeVO.JSON_KEY_BRANCH));
    info.setId(j.getString(GerritChangeVO.JSON_KEY_ID));
    info.setNumber(j.getInt(GerritChangeVO.JSON_KEY_NUMBER));
    info.setSubject(j.getString(GerritChangeVO.JSON_KEY_SUBJECT));

    JSONObject owner = j.getJSONObject(GerritChangeVO.JSON_KEY_OWNER);

    if (owner.containsKey(GerritChangeVO.JSON_KEY_NAME))
        info.setOwnerName(owner.getString(GerritChangeVO.JSON_KEY_NAME));

    if (owner.containsKey(GerritChangeVO.JSON_KEY_USERNAME))
        info.setOwnerUserName(owner.getString(GerritChangeVO.JSON_KEY_USERNAME));

    if (owner.containsKey(GerritChangeVO.JSON_KEY_EMAIL))
        info.setOwnerEmail(owner.getString(GerritChangeVO.JSON_KEY_EMAIL));

    info.setUrl(j.getString(GerritChangeVO.JSON_KEY_URL));

    Integer createdOne = j.getInt(GerritChangeVO.JSON_KEY_CREATED_ON);
    info.setCreatedOn(new Date(createdOne.longValue() * 1000));
    Integer lastUpdate = j.getInt(GerritChangeVO.JSON_KEY_LAST_UPDATE);
    info.setLastUpdate(new Date(lastUpdate.longValue() * 1000));

    info.setOpen(j.getBoolean(GerritChangeVO.JSON_KEY_OPEN));
    info.setStatus(j.getString(GerritChangeVO.JSON_KEY_STATUS));

    JSONObject cp = j.getJSONObject(GerritChangeVO.JSON_KEY_CURRENT_PATCH_SET);
    try {
        assignPatchSet(info, cp, true);

        List<JSONObject> patchSets = j.getJSONArray(GerritChangeVO.JSON_KEY_PATCH_SET);

        for (JSONObject p : patchSets) {
            assignPatchSet(info, p, false);
        }
    } catch (ParseException e) {
        throw new RepositoryException(e.getMessage());
    }

    log.debug(String.format("Object Transformed change=%s", info.toString()));

    return info;
}

From source file:com.redhat.rhn.frontend.xmlrpc.org.OrgHandler.java

/**
 * Migrate systems from one organization to another.  If executed by
 * a Satellite administrator, the systems will be migrated from their current
 * organization to the organization specified by the toOrgId.  If executed by
 * an organization administrator, the systems must exist in the same organization
 * as that administrator and the systems will be migrated to the organization
 * specified by the toOrgId. In any scenario, the origination and destination
 * organizations must be defined in a trust.
 *
 * @param loggedInUser The current user//from   ww w.  j  a va2s.  com
 * @param toOrgId destination organization ID.
 * @param sids System IDs.
 * @return list of systems migrated.
 * @throws FaultException A FaultException is thrown if:
 *   - The user performing the request is not an organization administrator
 *   - The user performing the request is not a satellite administrator, but the
 *     from org id is different than the user's org id.
 *   - The from and to org id provided are the same.
 *   - One or more of the servers provides do not exist
 *   - The origination or destination organization does not exist
 *   - The user is not defined in the destination organization's trust
 *
 * @xmlrpc.doc Migrate systems from one organization to another.  If executed by
 * a Satellite administrator, the systems will be migrated from their current
 * organization to the organization specified by the toOrgId.  If executed by
 * an organization administrator, the systems must exist in the same organization
 * as that administrator and the systems will be migrated to the organization
 * specified by the toOrgId. In any scenario, the origination and destination
 * organizations must be defined in a trust.
 * @xmlrpc.param #param("string", "sessionKey")
 * @xmlrpc.param #param_desc("int", "toOrgId", "ID of the organization where the
 * system(s) will be migrated to.")
 * @xmlrpc.param #array_single("int", "systemId")
 * @xmlrpc.returntype
 * #array_single("int", "serverIdMigrated")
 */
public Object[] migrateSystems(User loggedInUser, Integer toOrgId, List<Integer> sids) throws FaultException {

    // the user executing the request must at least be an org admin to perform
    // a system migration
    ensureUserRole(loggedInUser, RoleFactory.ORG_ADMIN);

    Org toOrg = verifyOrgExists(toOrgId);

    List<Server> servers = new LinkedList<Server>();

    for (Integer sid : sids) {
        Long serverId = new Long(sid.longValue());
        Server server = null;
        try {
            server = ServerFactory.lookupById(serverId);

            // throw a no_such_system exception if the server was not found.
            if (server == null) {
                throw new NoSuchSystemException("No such system - sid[" + sid + "]");
            }
        } catch (LookupException e) {
            throw new NoSuchSystemException("No such system - sid[" + sid + "]");
        }
        servers.add(server);

        // As a pre-requisite to performing the actual migration, verify that each
        // server that is planned for migration passes the criteria that follows.
        // If any of the servers fails that criteria, none will be migrated.

        // unless the user is a satellite admin, they are not permitted to migrate
        // systems from an org that they do not belong to
        if ((!loggedInUser.hasRole(RoleFactory.SAT_ADMIN))
                && (!loggedInUser.getOrg().equals(server.getOrg()))) {
            throw new PermissionCheckFailureException(server);
        }

        // do not allow the user to migrate systems to/from the same org.  doing so
        // would essentially remove entitlements, channels...etc from the systems
        // being migrated.
        if (toOrg.equals(server.getOrg())) {
            throw new MigrationToSameOrgException(server);
        }

        // if the originating org is not defined within the destination org's trust
        // the migration should not be permitted.
        if (!toOrg.getTrustedOrgs().contains(server.getOrg())) {
            throw new OrgNotInTrustException(server);
        }
    }

    List<Long> serversMigrated = MigrationManager.migrateServers(loggedInUser, toOrg, servers);
    return serversMigrated.toArray();
}

From source file:com.redhat.rhn.frontend.xmlrpc.activationkey.ActivationKeyHandler.java

/**
 * Remove server groups from an activation key.
 *
 * @param loggedInUser The current user/*w w  w  .  j a  va  2  s .c om*/
 * @param key The activation key to act upon
 * @param serverGroupIds List of server group IDs to be removed from this activation key
 * @return 1 on success, exception thrown otherwise
 *
 * @xmlrpc.doc Remove server groups from an activation key.
 * @xmlrpc.param #param("string", "sessionKey")
 * @xmlrpc.param #param("string", "key")
 * @xmlrpc.param #array_single("int", "serverGroupId")
 * @xmlrpc.returntype #return_int_success()
 */
public int removeServerGroups(User loggedInUser, String key, List serverGroupIds) {

    ActivationKeyManager manager = ActivationKeyManager.getInstance();
    ActivationKey activationKey = lookupKey(key, loggedInUser);

    for (Iterator it = serverGroupIds.iterator(); it.hasNext();) {
        Integer serverGroupId = (Integer) it.next();

        ServerGroup group = null;
        try {
            group = ServerGroupManager.getInstance().lookup(new Long(serverGroupId.longValue()), loggedInUser);
        } catch (LookupException e) {
            throw new InvalidServerGroupException(e);
        }

        manager.removeServerGroup(activationKey, group);
    }
    return 1;
}

From source file:org.sakaiproject.message.tool.SynopticMessageAction.java

/**
 * doUpdate handles user clicking "Done" in Options panel (called for form input tags type="submit" named="eventSubmit_doUpdate")
 *///w  w  w.  j  a  va2 s.c o  m
public void doUpdate(RunData data, Context context) {
    // access the portlet element id to find our state
    String peid = ((JetspeedRunData) data).getJs_peid();
    SessionState state = ((JetspeedRunData) data).getPortletSessionState(peid);

    String serviceName = (String) state.getAttribute(STATE_SERVICE_NAME);

    boolean allow_show_subject = true;
    boolean allow_channel_choice = false;

    // showSubject
    if (allow_show_subject) {
        if (serviceName.equals(SERVICENAME_DISCUSSION)) {
            // always show subject for Recent Discussion
            String showBody = data.getParameters().getString(FORM_SHOW_BODY);
            try {
                Boolean sb = new Boolean(showBody);
                if (!sb.equals((Boolean) state.getAttribute(STATE_SHOW_BODY))) {
                    state.setAttribute(STATE_SHOW_BODY, sb);
                    state.setAttribute(STATE_UPDATE, STATE_UPDATE);
                }
            } catch (Exception ignore) {
            }
        } else if (serviceName.equals(SERVICENAME_ANNOUNCEMENT)) {
            String showSubject = data.getParameters().getString(FORM_SHOW_SUBJECT);
            try {
                Boolean ss = new Boolean(showSubject);
                if (!ss.equals((Boolean) state.getAttribute(STATE_SHOW_SUBJECT))) {
                    state.setAttribute(STATE_SHOW_SUBJECT, ss);
                    state.setAttribute(STATE_UPDATE, STATE_UPDATE);
                }
            } catch (Exception ignore) {
            }
        }
    }

    // channel
    if (allow_channel_choice) {
        String placementContext = ToolManager.getCurrentPlacement().getContext();
        String newChannel = data.getParameters().getString(FORM_CHANNEL);
        String currentChannel = ((String) state.getAttribute(STATE_CHANNEL_REF))
                .substring(placementContext.length() + 1);

        if (newChannel != null && !newChannel.equals(currentChannel)) {
            String channel_ref = ((MessageService) state.getAttribute(STATE_SERVICE))
                    .channelReference(placementContext, newChannel);
            state.setAttribute(STATE_CHANNEL_REF, channel_ref);
            if (Log.getLogger("chef").isDebugEnabled())
                Log.debug("chef", this + ".doUpdate(): newChannel: " + channel_ref);
            // updateObservationOfChannel(state, peid);

            // update the tool config
            Placement placement = ToolManager.getCurrentPlacement();
            placement.getPlacementConfig().setProperty(PARAM_CHANNEL,
                    (String) state.getAttribute(STATE_CHANNEL_REF));

            // deliver an update to the title panel (to show the new title)
            String titleId = titlePanelUpdateId(peid);
            schedulePeerFrameRefresh(titleId);
        }
    }

    // days
    String daysValue = data.getParameters().getString(FORM_DAYS);
    try {
        Integer days = new Integer(daysValue);
        if (!days.equals((Integer) state.getAttribute(STATE_DAYS))) {
            state.setAttribute(STATE_DAYS, days);
            state.setAttribute(STATE_UPDATE, STATE_UPDATE);

            // recompute this which is used for selecting the messages for display
            long startTime = System.currentTimeMillis() - (days.longValue() * 24l * 60l * 60l * 1000l);
            state.setAttribute(STATE_AFTER_DATE, TimeService.newTime(startTime));
        }
    } catch (Exception ignore) {
    }

    // items
    String itemsValue = data.getParameters().getString(FORM_ITEMS);
    try {
        Integer items = new Integer(itemsValue);
        if (!items.equals((Integer) state.getAttribute(STATE_ITEMS))) {
            state.setAttribute(STATE_ITEMS, items);
            state.setAttribute(STATE_UPDATE, STATE_UPDATE);
        }
    } catch (Exception ignore) {
    }

    // length
    String lengthValue = data.getParameters().getString(FORM_LENGTH);
    try {
        Integer length = new Integer(lengthValue);
        if (!length.equals((Integer) state.getAttribute(STATE_LENGTH))) {
            state.setAttribute(STATE_LENGTH, length);
            state.setAttribute(STATE_UPDATE, STATE_UPDATE);
        }
    } catch (Exception ignore) {
    }

    // update the tool config
    Placement placement = ToolManager.getCurrentPlacement();
    placement.getPlacementConfig().setProperty(PARAM_CHANNEL, (String) state.getAttribute(STATE_CHANNEL_REF));
    placement.getPlacementConfig().setProperty(PARAM_DAYS,
            ((Integer) state.getAttribute(STATE_DAYS)).toString());
    placement.getPlacementConfig().setProperty(PARAM_ITEMS,
            ((Integer) state.getAttribute(STATE_ITEMS)).toString());
    placement.getPlacementConfig().setProperty(PARAM_LENGTH,
            ((Integer) state.getAttribute(STATE_LENGTH)).toString());
    placement.getPlacementConfig().setProperty(PARAM_SHOW_BODY,
            ((Boolean) state.getAttribute(STATE_SHOW_BODY)).toString());
    placement.getPlacementConfig().setProperty(PARAM_SHOW_SUBJECT,
            ((Boolean) state.getAttribute(STATE_SHOW_SUBJECT)).toString());

    // commit the change
    saveOptions();

    // we are done with customization... back to the main mode
    state.removeAttribute(STATE_MODE);

    // enable auto-updates while in view mode
    enableObservers(state);

}

From source file:org.nuclos.server.navigation.ejb3.TreeNodeFacadeBean.java

public NucletTreeNode getNucletTreeNode(Integer iId) throws CommonFinderException {
    try {/*from ww  w  . j a  v  a  2  s .  c o m*/
        EntityObjectVO eovo = NucletDalProvider.getInstance().getEntityObjectProcessor(NuclosEntity.NUCLET)
                .getByPrimaryKey(iId.longValue());
        return new NucletTreeNode(eovo, false);
    } catch (Exception ex) {
        throw new CommonFinderException();
    }
}