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.paxle.gui.impl.tools.PaxleLocaleConfig.java

protected Bundle getBundleByBundleID(Integer bundleID) {
    // getting a reference to the requested bundle
    final Bundle bundle = this.context.getBundle(bundleID.longValue());
    if (bundle != null)
        return bundle;

    this.logger.warn(String.format("No bundle found for ID '%d'.", bundleID));
    return null;//from   w w w  . j  a  v a  2 s  . co m
}

From source file:edu.harvard.iq.dataverse.authorization.MyDataQueryHelperServiceBean.java

public List<Long> getParentIds(String dtypeParent, String dtypeChild, AuthenticatedUser user) {

    List<DataverseRole> roleList = roleService.findAll();

    DataverseRolePermissionHelper rolePermissionHelper = new DataverseRolePermissionHelper(roleList);
    List<Long> retVal = new ArrayList();
    List<Object[]> results = em.createNativeQuery(
            "Select distinct role.role_id, dvo.id FROM dvobject dvo, roleassignment role WHERE  " + " dtype = '"
                    + dtypeParent + "'" + " and dvo.id = role.definitionpoint_id"
                    + " and role.role_id in (select role_id from roleassignment where assigneeidentifier in ('"
                    + user.getIdentifier() + "') " + ");")
            .getResultList();/*  www  . j  a  v  a  2  s .c  o  m*/
    for (Object[] result : results) {
        Long role_id = (Long) result[0];

        if (dtypeParent.equals("Dataverse") && dtypeChild.equals("Dataset")
                && rolePermissionHelper.hasDatasetPermissions(role_id)) {
            Integer r1 = (Integer) result[1];
            retVal.add(r1.longValue());
        }

        if (dtypeParent.equals("Dataverse") && dtypeChild.equals("DataFile")
                && rolePermissionHelper.hasFilePermissions(role_id)) {
            List<Object> dsIds = em
                    .createNativeQuery("Select id from dvobject where dtype = 'Dataset' and owner_id = "
                            + (Integer) result[1] + ";")
                    .getResultList();
            for (Object dsId : dsIds) {
                Integer r1 = (Integer) dsId;
                retVal.add(r1.longValue());
            }
        }

        if (dtypeParent.equals("Dataset")) {
            if (rolePermissionHelper.hasFilePermissions(role_id)) {
                Integer r1 = (Integer) result[1];
                retVal.add(r1.longValue());
            }
        }
    }
    return retVal;
}

From source file:org.opencastproject.index.service.catalog.adapter.MetadataField.java

public static MetadataField<String> createDurationMetadataField(String inputID, Opt<String> outputID,
        String label, boolean readOnly, boolean required, Opt<Map<String, Object>> collection,
        Opt<String> collectionId, Opt<Integer> order, Opt<String> namespace) {

    Fn<Opt<String>, JValue> periodToJSON = new Fn<Opt<String>, JValue>() {
        @Override//from   w  w w  .  j  ava2s.c o  m
        public JValue ap(Opt<String> value) {
            Long returnValue = 0L;
            DCMIPeriod period = EncodingSchemeUtils.decodePeriod(value.get());
            if (period != null && period.hasStart() && period.hasEnd()) {
                returnValue = period.getEnd().getTime() - period.getStart().getTime();
            } else {
                try {
                    returnValue = Long.parseLong(value.get());
                } catch (NumberFormatException e) {
                    logger.debug("Unable to parse duration '{}' as either period or millisecond duration.",
                            value.get());
                }
            }
            return v(DurationFormatUtils.formatDuration(returnValue, PATTERN_DURATION));
        }
    };

    Fn<Object, String> jsonToPeriod = new Fn<Object, String>() {
        @Override
        public String ap(Object value) {
            if (!(value instanceof String)) {
                logger.warn("The given value for duration can not be parsed.");
                return "";
            }

            String duration = (String) value;
            String[] durationParts = duration.split(":");
            if (durationParts.length < 3)
                return null;
            Integer hours = Integer.parseInt(durationParts[0]);
            Integer minutes = Integer.parseInt(durationParts[1]);
            Integer seconds = Integer.parseInt(durationParts[2]);

            Long returnValue = ((hours.longValue() * 60 + minutes.longValue()) * 60 + seconds.longValue())
                    * 1000;

            return returnValue.toString();
        }
    };
    return new MetadataField<String>(inputID, outputID, label, readOnly, required, "", TYPE.DURATION,
            JSON_TYPE.TEXT, collection, collectionId, periodToJSON, jsonToPeriod, order, namespace);
}

From source file:dbcount.DbCountInitializeJob.java

public GridTaskResultPolicy result(GridTaskResult result) throws GridException {
    Integer pageviews = result.getResult();
    if (pageviews != null) {
        totalPageviews.addAndGet(pageviews.longValue());
    }//from w ww .jav a2  s  .  c om
    return GridTaskResultPolicy.CONTINUE;
}

From source file:org.jason.mapmaker.repository.impl.HibernateGenericRepository.java

@SuppressWarnings("unchecked")
public T save(T object) {
    Integer id = (Integer) sessionFactory.getCurrentSession().save(object);
    return get(id.longValue());
}

From source file:architecture.ee.web.community.struts2.action.admin.ajax.SocialManagementAction.java

public String updateSocialAccount() throws Exception {
    try {// w  w w .  j av a2 s.c  o  m
        Map map = ParamUtils.getJsonParameter(request, "item", Map.class);
        String accessSecret = (String) map.get("accessSecret");
        String accessToken = (String) map.get("accessToken");
        Boolean signedIn = (Boolean) map.get("signedIn");

        if (socialAccountId == null) {
            Integer selectedSocialAccountId = (Integer) map.get("socialAccountId");
            socialAccountId = selectedSocialAccountId.longValue();
        }

        SocialNetwork account = getTargetSocialAccount();
        log.debug("=====================");

        if (!StringUtils.isEmpty(accessSecret))
            account.setAccessSecret(accessSecret);
        if (!StringUtils.isEmpty(accessToken))
            account.setAccessToken(accessToken);
        //if( signedIn!=null )

        log.debug(account);
        log.debug("=====================");
        socialNetworkManager.saveSocialNetwork(account);
        this.targetSocialAccount = null;
        return success();
    } catch (Throwable e) {
        e.printStackTrace();
        throw new Exception(e);
    }
}

From source file:org.lendingclub.mercator.bind.model.ResourceRecordSet.java

public ResourceRecordSet(String name, Integer ttl, String type, String classType, T records) {
    this.name = name;
    this.type = Preconditions.checkNotNull(type, "type of %s", name);

    if (ttl != null) {
        boolean rfc2181 = ttl >= 0 && ttl.longValue() <= 0x7FFFFFFFL;
        Preconditions.checkArgument(rfc2181, "Invalid ttl value: %s, must be 0-2147483647", ttl);
    }//from  w  w w. java 2s .c om
    this.ttl = ttl;
    this.classType = classType;
    this.recordData = records != null ? records : (T) Collections.EMPTY_MAP;
}

From source file:org.openmrs.module.usagestatistics.web.controller.OptionsController.java

/**
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 *///from  w w w.j  av a2s .  c o  m
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {
    Options options = (Options) command;
    options.save();

    // Update reports task
    SchedulerService schedulerSvc = Context.getSchedulerService();
    TaskDefinition sendReportsTaskDef = schedulerSvc.getTaskByName(Constants.TASK_SEND_REPORTS);
    Integer reportsInterval = ServletRequestUtils.getIntParameter(request, "reportsInterval");
    if (reportsInterval != null && sendReportsTaskDef.getRepeatInterval() != reportsInterval.longValue()) {
        sendReportsTaskDef.setRepeatInterval(reportsInterval.longValue());
        sendReportsTaskDef.setStarted(reportsInterval > 0);
        schedulerSvc.rescheduleTask(sendReportsTaskDef);
        log.warn("Rescheduled send reports task with interval: " + reportsInterval);
    }

    String msg = getMessageSourceAccessor().getMessage("usagestatistics.options.saveSuccess");
    request.getSession().setAttribute(WebConstants.OPENMRS_MSG_ATTR, msg);

    return new ModelAndView(new RedirectView(getSuccessView()));
}

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.action.TraceFileProcessor.java

private void processTraceFile(final File traceFile, final QcContext context) throws IOException {

    BufferedReader reader = null;
    try {//from  ww  w . j  ava  2s  . co  m
        // find the file id for this file
        final Long fileInfoId = fileInfoQueries.getFileId(traceFile.getName(), context.getArchive().getId());
        if (fileInfoId == null) {
            context.getArchive().setDeployStatus(Archive.STATUS_IN_REVIEW);
            context.addError(MessageFormat.format(MessagePropertyType.TRACE_FILE_PROCESSING_ERROR,
                    traceFile.getName(), "File was not found in the database"));
            return;
        }
        // cache barcode ids since they repeat in the files
        final Map<String, Integer> barcodeIds = new HashMap<String, Integer>();
        final Date fileDate = new Date(traceFile.lastModified());
        //noinspection IOResourceOpenedButNotSafelyClosed
        reader = new BufferedReader(new FileReader(traceFile));
        String line = reader.readLine();
        int lineNum = 1;
        while (line != null) {
            processLine(line, lineNum, barcodeIds, traceFile, fileDate, fileInfoId, context);
            line = reader.readLine();
            lineNum++;
        }
        //now add biospecimen to file relationship
        final List<Integer> biospecimenIds = new ArrayList<Integer>(barcodeIds.values());
        BiospecimenHelper.insertBiospecimenFileRelationship(biospecimenIds, fileInfoId, bcrDataService,
                context.getArchive().getTheTumor());
        // This is ugly. Created new ticket to update the biosspecimen id to long
        final List<Long> shippedBiospecimenIds = new ArrayList<Long>();
        for (Integer id : biospecimenIds) {
            shippedBiospecimenIds.add(id.longValue());
        }
        bcrDataService.addShippedBiospecimensFileRelationship(shippedBiospecimenIds, fileInfoId);
    } finally {
        IOUtils.closeQuietly(reader);
    }

}

From source file:com.snapdeal.archive.service.AbstractArchivalService.java

public Boolean verifyBasedOnCount(Map<RelationTable, List<Map<String, Object>>> tableResultMap)
        throws BusinessException {

    SystemLog.logMessage("Calling verifyBasedOnCount() method : ");

    for (RelationTable rt : tableResultMap.keySet()) {
        List<Map<String, Object>> resultMap = tableResultMap.get(rt);

        String primaryKey = rt.getPrimaryColumn();

        Set primaryKeySet = ArchivalUtil.getPropertySetForListOfMap(resultMap, primaryKey);
        Long archivedDataCount = archivalDbDao.getArchivedDataCount(rt.getTableName(), primaryKey,
                primaryKeySet);//from  w  w  w . j ava 2s .  c  o  m
        Integer masterDataSize = tableResultMap.get(rt).size();

        SystemLog.logMessage("Master count for table :" + rt.getTableName() + " is : " + masterDataSize
                + ". Archival count = " + archivedDataCount);

        if (masterDataSize.longValue() != archivedDataCount) {
            return Boolean.FALSE;
        }
    }
    return Boolean.TRUE;
}