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.encuestame.core.cron.CalculateHashTagSize.java

/**
 * Get hashTag counter.//from   w  ww. j  a  v  a  2s  .c  o  m
 * @param tagName
 * @param limit
 * @return
 */
public Long getHashTagFrecuency(final String tagName, final Integer initResults, final Integer limit) {
    final Integer totalRelTweetPoll;
    final List<TweetPoll> tweetPolls = getTweetPoll().getTweetpollByHashTagName(tagName, initResults, limit,
            null, SearchPeriods.ALLTIME);
    totalRelTweetPoll = tweetPolls.size();
    //TODO:Pending count relevance hashtags for polls and surveys.
    return totalRelTweetPoll.longValue();
}

From source file:com.redhat.rhn.frontend.xmlrpc.system.crash.CrashHandler.java

/**
 * Delete a crash with given crash id./*  w  w  w . j  a  v a  2s . c o  m*/
 * @param loggedInUser The current user
 * @param crashId Crash ID
 * @return 1 In case of success, exception otherwise.
 *
 * @xmlrpc.doc Delete a crash with given crash id.
 * @xmlrpc.param #param("string", "sessionKey")
 * @xmlrpc.param #param("int", "crashId")
 * @xmlrpc.returntype #return_int_success()
 */
public Integer deleteCrash(User loggedInUser, Integer crashId) {
    CrashManager.deleteCrash(loggedInUser, new Long(crashId.longValue()));
    return 1;
}

From source file:ubic.gemma.core.loader.genome.gene.ncbi.homology.HomologeneServiceImpl.java

@Override
public Collection<Gene> getHomologues(Gene gene) {

    Collection<Gene> genes = new HashSet<>();

    if (!this.ready.get()) {
        return genes;
    }//from w ww.  j av  a 2s  . c o m

    Long groupId;

    Integer ncbiGeneId = gene.getNcbiGeneId();
    if (ncbiGeneId == null)
        return genes;
    try {
        groupId = this.getHomologeneGroup(ncbiGeneId.longValue());
    } catch (NumberFormatException e) {
        return genes;
    }

    if (groupId == null) {
        return genes;
    }

    genes = this.getGenesInGroup(groupId);

    if (genes != null)
        genes.remove(gene); // remove the given gene from the list

    return genes;

}

From source file:it.cilea.osd.jdyna.web.flow.GestioneRicerca.java

public Event ricercaSemplice(RequestContext requestContext)
        throws ParseException, InstantiationException, IllegalAccessException {

    String classe = (String) requestContext.getFlowScope().get("classe");
    String query = (String) requestContext.getFlowScope().get("query");
    String sortParam = (String) requestContext.getRequestParameters().get("sort");

    Map<String, Object> results = new HashMap<String, Object>();

    if (query.isEmpty() || query.equals("*")) {
        return error();
    }//w  ww.  j  av  a2s.  co m

    for (String index : indexedClass.keySet()) {
        if (classe.equals("ovunque") || classe.equals(index)) {
            String sort = "score";
            String dir = "asc";

            if (sortParam != null && sortParam.startsWith(index + "_")) {
                // alla lunghezza del nome indice va sommato 1 perche' e' stato aggiunto _
                sort = sortParam.substring(index.length() + 1);
                dir = (String) requestContext.getRequestParameters().get("dir");
            }

            int maxResults = 20;
            String paramPage = (String) requestContext.getRequestParameters().get("page");
            int page = paramPage != null ? Integer.parseInt(paramPage) : 1;
            Integer numTotale = searchService.count("default", query, indexedClass.get(index));
            if (numTotale == 0)
                continue;
            List result = searchService.search("default", query, indexedClass.get(index), sort, dir, page,
                    maxResults);
            DisplayTagData displayResult = new DisplayTagData(numTotale.longValue(), result, sortParam, dir,
                    page, maxResults);
            results.put(index, displayResult);
            List<? extends PropertiesDefinition> listTipologieShowInColumn = applicationService
                    .getValoriDaMostrare(getTPfromClass(indexedClass.get(index)));
            requestContext.getFlowScope().put(index + "showInColumnList", listTipologieShowInColumn);
        }

    }

    requestContext.getFlowScope().put("results", results);
    requestContext.getFlowScope().put("clazz", classe);

    return success();
}

From source file:com.redhat.rhn.frontend.xmlrpc.system.crash.CrashHandler.java

/**
 * @param loggedInUser The current user//from w ww . j  a v a 2s .c om
 * @param crashId Crash ID
 * @return Crash notes for crash
 *
 * @xmlrpc.doc List crash notes for crash
 * @xmlrpc.param #param("string", "sessionKey")
 * @xmlrpc.param #param("int", "crashId")
 * @xmlrpc.returntype
 *     #array()
 *         #struct("crashNote")
 *             #prop("int", "id")
 *             #prop("string", "subject")
 *             #prop("string", "details")
 *             #prop("string", "updated")
 *         #struct_end()
 *     #array_end()
 */
public List getCrashNotesForCrash(User loggedInUser, Integer crashId) {
    Crash c = CrashManager.lookupCrashByUserAndId(loggedInUser, crashId.longValue());
    List returnList = new ArrayList();
    for (CrashNote cn : c.getCrashNotes()) {
        Map crashNotesMap = new HashMap();
        crashNotesMap.put("id", cn.getId());
        crashNotesMap.put("subject", cn.getSubject());
        crashNotesMap.put("details", cn.getNote() == null ? "" : cn.getNote());
        crashNotesMap.put("updated", cn.getModifiedString());
        returnList.add(crashNotesMap);
    }
    return returnList;
}

From source file:com.redhat.rhn.frontend.xmlrpc.system.crash.CrashHandler.java

/**
 * @param loggedInUser The current user/*from ww  w . j a va  2s.  com*/
 * @param crashNoteId Crash note ID
 * @return 1 on success
 *
 * @xmlrpc.doc Delete a crash note
 * @xmlrpc.param #param("string", "sessionKey")
 * @xmlrpc.param #param("int", "crashNoteId")
 * @xmlrpc.returntype #return_int_success()
 */
public int deleteCrashNote(User loggedInUser, Integer crashNoteId) {
    CrashNote cn = CrashManager.lookupCrashNoteByUserAndId(loggedInUser, crashNoteId.longValue());
    CrashFactory.delete(cn);
    return 1;
}

From source file:com.ottogroup.bi.streaming.operator.json.statsd.StatsdExtractedMetricsReporter.java

/**
 * Extract and reports a execution time value
 * @param metricCfg /* w w w  .  j a va 2 s.c  o m*/
 *          The field configuration providing information on how to access and export content from JSON. Value is expected not to be null
 * @param json
 *          The {@link JSONObject} to extract information from. Value is expected not to be null
 */
protected void reportTime(final StatsdMetricConfig metricCfg, final JSONObject json) {
    String path = null;
    if (metricCfg.getDynamicPathPrefix() != null) {
        try {
            String dynPathPrefix = this.jsonUtils.getTextFieldValue(json,
                    metricCfg.getDynamicPathPrefix().getPath(), false);
            if (StringUtils.isNotBlank(dynPathPrefix))
                path = dynPathPrefix + (!StringUtils.endsWith(dynPathPrefix, ".") ? "." : "")
                        + metricCfg.getPath();
            else
                path = metricCfg.getPath();
        } catch (Exception e) {
            // do nothing
            path = metricCfg.getPath();
        }
    } else {
        path = metricCfg.getPath();
    }

    if (metricCfg.getJsonRef().getContentType() == JsonContentType.INTEGER) {
        try {
            final Integer value = this.jsonUtils.getIntegerFieldValue(json, metricCfg.getJsonRef().getPath());
            if (value != null)
                this.statsdClient.recordExecutionTime(path, value.longValue());
        } catch (Exception e) {
            // do nothing
        }
    } else if (metricCfg.getJsonRef().getContentType() == JsonContentType.TIMESTAMP) {
        try {
            final Date value = this.jsonUtils.getDateTimeFieldValue(json, metricCfg.getJsonRef().getPath(),
                    metricCfg.getJsonRef().getConversionPattern());
            if (value != null)
                this.statsdClient.recordExecutionTimeToNow(path, value.getTime());
        } catch (Exception e) {
            // do nothing
        }
    } else {
        // 
    }
}

From source file:com.redhat.rhn.frontend.xmlrpc.system.crash.CrashHandler.java

/**
 * Returns list of crash files for a given crash id.
 * @param loggedInUser The current user//from  w ww . j a va2  s . c  om
 * @param crashId Crash ID
 * @return Returns list of crash files.
 *
 * @xmlrpc.doc Return list of crash files for given crash id.
 * @xmlrpc.param #param("string", "sessionKey")
 * @xmlrpc.param #param("int", "crashId")
 * @xmlrpc.returntype
 *     #array()
 *         #struct("crashFile")
 *             #prop("int", "id")
 *             #prop("string", "filename")
 *             #prop("string", "path")
 *             #prop("int", "filesize")
 *             #prop("boolean", "is_uploaded")
 *             #prop("date", "created")
 *             #prop("date", "modified")
 *         #struct_end()
 *     #array_end()
 */
public List listSystemCrashFiles(User loggedInUser, Integer crashId) {
    Crash crash = CrashManager.lookupCrashByUserAndId(loggedInUser, new Long(crashId.longValue()));

    List returnList = new ArrayList();

    for (CrashFile crashFile : crash.getCrashFiles()) {
        Map crashMap = new HashMap();
        crashMap.put("id", crashFile.getId());
        crashMap.put("filename", crashFile.getFilename());
        crashMap.put("path", crashFile.getPath());
        crashMap.put("filesize", crashFile.getFilesize());
        crashMap.put("is_uploaded", crashFile.getIsUploaded());
        crashMap.put("created", crashFile.getCreated());
        crashMap.put("modified", crashFile.getModified());
        returnList.add(crashMap);
    }

    return returnList;
}

From source file:org.atomserver.core.dbstore.utils.DBSeeder.java

public void insertPet(String workspace, String collection, String id, String term) throws IOException {
    Integer internalId = (Integer) (entriesDAO
            .insertEntry(new BaseEntryDescriptor(workspace, collection, id, null, 0)));
    log.debug("Inserted PET = " + internalId + " " + workspace + " " + collection + " " + id);
    EntryCategory entryCategory = new EntryCategory();
    entryCategory.setEntryStoreId(internalId.longValue());
    entryCategory.setWorkspace(workspace);
    entryCategory.setCollection(collection);
    entryCategory.setEntryId(id);//from  w w  w  .j  a v a  2 s.c  o  m
    entryCategory.setScheme("urn:pets.breeds");
    entryCategory.setTerm(term);
    categoriesDAO.insertEntryCategory(entryCategory);
}

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

public void addField(MetadataField<?> metadataField, String value, ListProvidersService listProvidersService) {
    switch (metadataField.getType()) {
    case BOOLEAN:
        MetadataField<Boolean> booleanField = MetadataField.createBooleanMetadata(metadataField.getInputID(),
                Opt.some(metadataField.getOutputID()), metadataField.getLabel(), metadataField.isReadOnly(),
                metadataField.isRequired(), metadataField.getOrder(), metadataField.getNamespace());
        if (StringUtils.isNotBlank(value)) {
            booleanField.setValue(Boolean.parseBoolean(value));
        }/*from   w w w . j ava2  s .c  o m*/
        addField(booleanField);
        break;
    case DATE:
        MetadataField<Date> dateField = MetadataField.createDateMetadata(metadataField.getInputID(),
                Opt.some(metadataField.getOutputID()), metadataField.getLabel(), metadataField.isReadOnly(),
                metadataField.isRequired(), metadataField.getPattern().get(), metadataField.getOrder(),
                metadataField.getNamespace());
        if (StringUtils.isNotBlank(value)) {
            dateField.setValue(EncodingSchemeUtils.decodeDate(value));
        }
        addField(dateField);
        break;
    case DURATION:
        MetadataField<String> durationField = MetadataField.createDurationMetadataField(
                metadataField.getInputID(), Opt.some(metadataField.getOutputID()), metadataField.getLabel(),
                metadataField.isReadOnly(), metadataField.isRequired(),
                getCollection(metadataField, listProvidersService), metadataField.getCollectionID(),
                metadataField.getOrder(), metadataField.getNamespace());

        DCMIPeriod period = EncodingSchemeUtils.decodePeriod(value);
        Long longValue = -1L;

        // Check to see if it is from the front end
        String[] durationParts = value.split(":");
        if (durationParts.length == 3) {
            Integer hours = Integer.parseInt(durationParts[0]);
            Integer minutes = Integer.parseInt(durationParts[1]);
            Integer seconds = Integer.parseInt(durationParts[2]);
            longValue = ((hours.longValue() * 60 + minutes.longValue()) * 60 + seconds.longValue()) * 1000;
        } else if (period != null && period.hasStart() && period.hasEnd()) {
            longValue = period.getEnd().getTime() - period.getStart().getTime();
        } else {
            try {
                longValue = Long.parseLong(value);
            } catch (NumberFormatException e) {
                logger.debug("Unable to parse duration '{}' value as either a period or millisecond duration.",
                        value);
                longValue = -1L;
            }
        }
        if (longValue > 0) {
            durationField.setValue(longValue.toString());
        }
        addField(durationField);
        break;
    case ITERABLE_TEXT:
        // Add an iterable text style field
        MetadataField<Iterable<String>> iterableTextField = MetadataField.createIterableStringMetadataField(
                metadataField.getInputID(), Opt.some(metadataField.getOutputID()), metadataField.getLabel(),
                metadataField.isReadOnly(), metadataField.isRequired(),
                getCollection(metadataField, listProvidersService), metadataField.getCollectionID(),
                metadataField.getOrder(), metadataField.getNamespace());
        if (StringUtils.isNotBlank(value)) {
            List<String> valueList = Arrays.asList(StringUtils.split(value, ","));
            iterableTextField.setValue(valueList);
        }
        addField(iterableTextField);
        break;
    case MIXED_TEXT:
        // Add an iterable text style field
        MetadataField<Iterable<String>> mixedIterableTextField = MetadataField
                .createMixedIterableStringMetadataField(metadataField.getInputID(),
                        Opt.some(metadataField.getOutputID()), metadataField.getLabel(),
                        metadataField.isReadOnly(), metadataField.isRequired(),
                        getCollection(metadataField, listProvidersService), metadataField.getCollectionID(),
                        metadataField.getOrder(), metadataField.getNamespace());
        if (StringUtils.isNotBlank(value)) {
            List<String> valueList = Arrays.asList(StringUtils.split(value, ","));
            mixedIterableTextField.setValue(valueList);
        }
        addField(mixedIterableTextField);
        break;
    case LONG:
        MetadataField<Long> longField = MetadataField.createLongMetadataField(metadataField.getInputID(),
                Opt.some(metadataField.getOutputID()), metadataField.getLabel(), metadataField.isReadOnly(),
                metadataField.isRequired(), getCollection(metadataField, listProvidersService),
                metadataField.getCollectionID(), metadataField.getOrder(), metadataField.getNamespace());
        if (StringUtils.isNotBlank(value)) {
            longField.setValue(Long.parseLong(value));
        }
        addField(longField);
        break;
    case TEXT:
        MetadataField<String> textField = MetadataField.createTextMetadataField(metadataField.getInputID(),
                Opt.some(metadataField.getOutputID()), metadataField.getLabel(), metadataField.isReadOnly(),
                metadataField.isRequired(), getCollection(metadataField, listProvidersService),
                metadataField.getCollectionID(), metadataField.getOrder(), metadataField.getNamespace());
        if (StringUtils.isNotBlank(value)) {
            textField.setValue(value);
        }
        addField(textField);
        break;
    case TEXT_LONG:
        MetadataField<String> textLongField = MetadataField.createTextLongMetadataField(
                metadataField.getInputID(), Opt.some(metadataField.getOutputID()), metadataField.getLabel(),
                metadataField.isReadOnly(), metadataField.isRequired(),
                getCollection(metadataField, listProvidersService), metadataField.getCollectionID(),
                metadataField.getOrder(), metadataField.getNamespace());
        if (StringUtils.isNotBlank(value)) {
            textLongField.setValue(value);
        }
        addField(textLongField);
        break;
    case START_DATE:
        if (metadataField.getPattern().isNone() || StringUtils.isBlank(metadataField.getPattern().get())) {
            throw new IllegalArgumentException("For temporal metadata field " + metadataField.getInputID()
                    + " of type " + metadataField.getType() + " there needs to be a pattern.");
        }
        MetadataField<String> startDate = MetadataField.createTemporalStartDateMetadata(
                metadataField.getInputID(), Opt.some(metadataField.getOutputID()), metadataField.getLabel(),
                metadataField.isReadOnly(), metadataField.isRequired(), metadataField.getPattern().get(),
                metadataField.getOrder(), metadataField.getNamespace());
        if (StringUtils.isNotBlank(value)) {
            startDate.setValue(value);
        }
        addField(startDate);
        break;
    case START_TIME:
        if (metadataField.getPattern().isNone() || StringUtils.isBlank(metadataField.getPattern().get())) {
            throw new IllegalArgumentException("For temporal metadata field " + metadataField.getInputID()
                    + " of type " + metadataField.getType() + " there needs to be a pattern.");
        }
        MetadataField<String> startTime = MetadataField.createTemporalStartTimeMetadata(
                metadataField.getInputID(), Opt.some(metadataField.getOutputID()), metadataField.getLabel(),
                metadataField.isReadOnly(), metadataField.isRequired(), metadataField.getPattern().get(),
                metadataField.getOrder(), metadataField.getNamespace());
        if (StringUtils.isNotBlank(value)) {
            startTime.setValue(value);
        }
        addField(startTime);
        break;
    default:
        throw new IllegalArgumentException("Unknown metadata type! " + metadataField.getType());
    }
}