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.opencb.opencga.storage.core.manager.variant.VariantStorageManager.java

Map<Long, List<Sample>> checkSamplesPermissions(Query query, QueryOptions queryOptions,
        VariantDBAdaptor dbAdaptor, String sessionId) throws CatalogException {
    final Map<Long, List<Sample>> samplesMap = new HashMap<>();
    Set<VariantField> returnedFields = VariantField.getReturnedFields(queryOptions);
    if (!returnedFields.contains(VariantField.STUDIES)) {
        return Collections.emptyMap();
    }/*  www  .ja v a 2 s  .c  o m*/
    if (VariantDBAdaptorUtils.isReturnedSamplesDefined(query, returnedFields)) {
        Map<Integer, List<Integer>> samplesToReturn = dbAdaptor.getReturnedSamples(query, queryOptions);
        for (Map.Entry<Integer, List<Integer>> entry : samplesToReturn.entrySet()) {
            if (!entry.getValue().isEmpty()) {
                QueryResult<Sample> samplesQueryResult = catalogManager.getAllSamples(entry.getKey(),
                        new Query(SampleDBAdaptor.QueryParams.ID.key(), entry.getValue()),
                        new QueryOptions("exclude", Arrays.asList("projects.studies.samples.annotationSets",
                                "projects.studies.samples.attributes")),
                        sessionId);
                if (samplesQueryResult.getNumResults() != entry.getValue().size()) {
                    throw new CatalogAuthorizationException(
                            "Permission denied. User " + catalogManager.getUserIdBySessionId(sessionId)
                                    + " can't read all the requested samples");
                }
                samplesMap.put((long) entry.getKey(), samplesQueryResult.getResult());
            } else {
                samplesMap.put((long) entry.getKey(), Collections.emptyList());
            }
        }
    } else {
        logger.debug("Missing returned samples! Obtaining returned samples from catalog.");
        List<Integer> returnedStudies = dbAdaptor.getReturnedStudies(query, queryOptions);
        List<Study> studies = catalogManager
                .getAllStudies(new Query(StudyDBAdaptor.QueryParams.ID.key(), returnedStudies),
                        new QueryOptions("include", "projects.studies.id"), sessionId)
                .getResult();
        if (!returnedFields.contains(VariantField.STUDIES_SAMPLES_DATA)) {
            for (Integer returnedStudy : returnedStudies) {
                samplesMap.put(returnedStudy.longValue(), Collections.emptyList());
            }
        } else {
            List<Long> returnedSamples = new LinkedList<>();
            for (Study study : studies) {
                QueryResult<Sample> samplesQueryResult = catalogManager.getAllSamples(study.getId(),
                        new Query(),
                        new QueryOptions("exclude", Arrays.asList("projects.studies.samples.annotationSets",
                                "projects.studies.samples.attributes")),
                        sessionId);
                samplesQueryResult.getResult().sort((o1, o2) -> Long.compare(o1.getId(), o2.getId()));
                samplesMap.put(study.getId(), samplesQueryResult.getResult());
                samplesQueryResult.getResult().stream().map(Sample::getId).forEach(returnedSamples::add);
            }
            query.append(VariantQueryParams.RETURNED_SAMPLES.key(), returnedSamples);
        }
    }
    return samplesMap;
}

From source file:org.apache.atlas.repository.store.graph.v1.AtlasRelationshipStoreV1.java

private AtlasRelationship mapSystemAttributes(AtlasEdge edge, AtlasRelationship relationship) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Mapping system attributes for relationship");
    }/*from  w ww.ja  v  a  2s  .  c  o m*/

    relationship.setGuid(GraphHelper.getGuid(edge));
    relationship.setTypeName(GraphHelper.getTypeName(edge));

    relationship.setCreatedBy(GraphHelper.getCreatedByAsString(edge));
    relationship.setUpdatedBy(GraphHelper.getModifiedByAsString(edge));

    relationship.setCreateTime(new Date(GraphHelper.getCreatedTime(edge)));
    relationship.setUpdateTime(new Date(GraphHelper.getModifiedTime(edge)));

    Integer version = GraphHelper.getVersion(edge);

    if (version == null) {
        version = Integer.valueOf(1);
    }

    relationship.setVersion(version.longValue());
    relationship.setStatus(GraphHelper.getEdgeStatus(edge));

    AtlasVertex end1Vertex = edge.getOutVertex();
    AtlasVertex end2Vertex = edge.getInVertex();

    relationship
            .setEnd1(new AtlasObjectId(GraphHelper.getGuid(end1Vertex), GraphHelper.getTypeName(end1Vertex)));
    relationship
            .setEnd2(new AtlasObjectId(GraphHelper.getGuid(end2Vertex), GraphHelper.getTypeName(end2Vertex)));

    relationship.setLabel(edge.getLabel());

    return relationship;
}

From source file:com.mmj.app.biz.service.impl.UserServiceImpl.java

@Override
public Long add(CollectDO... t) {
    t = ArrayUtils.removeNullElement(t);
    if (Argument.isEmptyArray(t)) {
        return 0l;
    }/*w ww.  ja  v  a 2  s . c o m*/
    Integer count = collectDao.insert(t);
    if (t.length == 1) {
        return count.longValue();
    }
    return count == 0 ? 0l : 1l;
}

From source file:com.mmj.app.biz.service.impl.UserServiceImpl.java

@Override
public Long add(FeedbackDO... t) {
    t = ArrayUtils.removeNullElement(t);
    if (Argument.isEmptyArray(t)) {
        return 0l;
    }/*  w  ww. java 2  s.c o  m*/
    Integer count = feedbackDao.insert(t);
    if (t.length == 1) {
        return count.longValue();
    }
    return count == 0 ? 0l : 1l;
}

From source file:com.mmj.app.biz.service.impl.UserServiceImpl.java

@Override
public Long add(BlacklistDO... t) {
    t = ArrayUtils.removeNullElement(t);
    if (Argument.isEmptyArray(t)) {
        return 0l;
    }//from w  w w.  j av a2 s  .c om
    Integer count = blacklistDao.insert(t);
    if (t.length == 1) {
        return count.longValue();
    }
    return count == 0 ? 0l : 1l;
}

From source file:com.mmj.app.biz.service.impl.UserServiceImpl.java

@Override
public Long add(MemberDO... t) {
    t = ArrayUtils.removeNullElement(t);
    if (Argument.isEmptyArray(t)) {
        return 0l;
    }/*from w w  w . j a va  2s.c  om*/
    Integer count = memberDao.insert(t);
    if (t.length == 1) {
        joinCache(t[0].getId());
        return count.longValue();
    }
    return count == 0 ? 0l : 1l;
}

From source file:com.cyberway.issue.crawler.prefetch.PreconditionEnforcer.java

/**
 * Get the maximum time a dns-record is valid.
 *
 * @param curi the uri this time is valid for.
 * @return the maximum time a dns-record is valid -- in seconds -- or
 * negative if record's ttl should be used.
 *///from   w w  w  .j a v  a  2  s.co m
public long getIPValidityDuration(CrawlURI curi) {
    Integer d;
    try {
        d = (Integer) getAttribute(ATTR_IP_VALIDITY_DURATION, curi);
    } catch (AttributeNotFoundException e) {
        d = DEFAULT_IP_VALIDITY_DURATION;
    }

    return d.longValue();
}

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

public String updateSocialNetwork() throws Exception {
    if (StringUtils.isNotEmpty(onetime)) {
        SocialNetwork socialNetworkFromCache = getSocialNetworkByOnetime();
        SocialNetwork socialNetworkToUse = null;
        if (this.socialNetworkId > 0) {
            socialNetworkToUse = getSocialNetwork();
        } else {// w w  w.  j  ava 2  s.  com
            socialNetworkToUse = newSocialNetwork(SocialNetwork.Media.valueOf(media.toUpperCase()));
        }

        socialNetworkToUse.setAccessSecret(socialNetworkFromCache.getAccessSecret());
        socialNetworkToUse.setAccessToken(socialNetworkFromCache.getAccessToken());

        Object profile = socialNetworkFromCache.getSocialServiceProvider().getUserProfile();
        String usernameToUse = ((architecture.ee.web.community.social.UserProfile) profile)
                .getPrimaryKeyString();
        if (StringUtils.isNotEmpty(usernameToUse)) {
            socialNetworkToUse.setUsername(usernameToUse);
        }

        this.socialNetworkManager.saveSocialNetwork(socialNetworkToUse);
        this.socialNetworkId = socialNetworkToUse.getSocialAccountId();
        this.mySocialNetwork = socialNetworkToUse;

    } else {

        try {
            Map map = ParamUtils.getJsonParameter(request, "item", Map.class);
            String accessSecret = (String) map.get("accessSecret");
            String accessToken = (String) map.get("accessToken");
            String username = (String) map.get("username");
            Boolean signedIn = (Boolean) map.get("signedIn");
            Integer socialAccountId = (Integer) map.get("socialAccountId");
            String serviceProviderName = (String) map.get("serviceProviderName");
            Media media = SocialNetwork.Media.valueOf(serviceProviderName.toUpperCase());

            if (socialNetworkId == null) {
                socialNetworkId = socialAccountId.longValue();
            }

            SocialNetwork account = null;
            if (socialNetworkId > 0) {
                try {
                    account = getSocialNetwork();
                } catch (NotFoundException e) {
                    account = null;
                }
            }

            if (account == null) {
                Map<Media, SocialNetwork> listMap = getConnectedSocialNetworkMap();
                if (listMap.containsKey(media)) {
                    account = listMap.get(media);
                } else {
                    account = newSocialNetwork(media);
                }
            }

            if (!StringUtils.isEmpty(accessSecret))
                account.setAccessSecret(accessSecret);
            if (!StringUtils.isEmpty(accessToken))
                account.setAccessToken(accessToken);
            if (!StringUtils.isEmpty(username))
                account.setUsername(username);

            socialNetworkManager.saveSocialNetwork(account);
            this.socialNetworkId = account.getSocialAccountId();
            this.mySocialNetwork = account;

        } catch (Throwable e) {
            throw new Exception(e);
        }

    }

    return success();
}

From source file:org.codelibs.fess.robot.FessS2RobotThread.java

@Override
protected boolean isContentUpdated(final S2RobotClient client, final UrlQueue urlQueue) {
    final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties();
    if (crawlerProperties.getProperty(Constants.DIFF_CRAWLING_PROPERTY, Constants.TRUE)
            .equals(Constants.TRUE)) {/*from  www . ja va 2s  .c o  m*/

        log(logHelper, LogType.CHECK_LAST_MODIFIED, robotContext, urlQueue);
        final long startTime = System.currentTimeMillis();

        final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil.getCrawlingConfigHelper();
        final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper();
        final FieldHelper fieldHelper = ComponentUtil.getFieldHelper();
        final SambaHelper sambaHelper = ComponentUtil.getSambaHelper();
        final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
        final SolrGroupManager solrGroupManager = ComponentUtil.getSolrGroupManager();
        final boolean useAclAsRole = crawlerProperties.getProperty(Constants.USE_ACL_AS_ROLE, Constants.FALSE)
                .equals(Constants.TRUE);

        final SolrGroup solrGroup = solrGroupManager.getSolrGroup(QueryType.ADD);

        final String url = urlQueue.getUrl();
        ResponseData responseData = null;
        try {
            final CrawlingConfig crawlingConfig = crawlingConfigHelper.get(robotContext.getSessionId());
            final Map<String, Object> dataMap = new HashMap<String, Object>();
            dataMap.put(fieldHelper.urlField, url);
            final List<String> roleTypeList = new ArrayList<String>();
            for (final String roleType : crawlingConfig.getRoleTypeValues()) {
                roleTypeList.add(roleType);
            }
            if (useAclAsRole && url.startsWith("smb://")) {
                //  head method
                responseData = client.execute(RequestDataBuilder.newRequestData().head().url(url).build());
                if (responseData == null) {
                    return true;
                }

                final ACE[] aces = (ACE[]) responseData.getMetaDataMap()
                        .get(SmbClient.SMB_ACCESS_CONTROL_ENTRIES);
                if (aces != null) {
                    for (final ACE item : aces) {
                        final SID sid = item.getSID();
                        roleTypeList.add(sambaHelper.getAccountId(sid));
                    }
                    if (logger.isDebugEnabled()) {
                        logger.debug(
                                "smbUrl:" + responseData.getUrl() + " roleType:" + roleTypeList.toString());
                    }
                }
            }
            dataMap.put(fieldHelper.roleField, roleTypeList);
            final String id = crawlingSessionHelper.generateId(dataMap);

            final SolrDocument solrDocument = indexingHelper.getSolrDocument(solrGroup, id,
                    new String[] { fieldHelper.idField, fieldHelper.lastModifiedField, fieldHelper.anchorField,
                            fieldHelper.segmentField, fieldHelper.expiresField, fieldHelper.clickCountField,
                            fieldHelper.favoriteCountField });
            if (solrDocument == null) {
                storeChildUrlsToQueue(urlQueue, getChildUrlSet(solrGroup, id));
                return true;
            }

            final Date expires = (Date) solrDocument.get(fieldHelper.expiresField);
            if (expires != null && expires.getTime() < System.currentTimeMillis()) {
                final Object idValue = solrDocument.getFieldValue(fieldHelper.idField);
                if (idValue != null) {
                    indexingHelper.deleteDocument(solrGroup, idValue.toString());
                }
                return true;
            }

            final Date lastModified = (Date) solrDocument.get(fieldHelper.lastModifiedField);
            if (lastModified == null) {
                return true;
            }

            final Integer clickCount = (Integer) solrDocument.get(fieldHelper.clickCountField);
            if (clickCount != null) {
                final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper();
                final int count = searchLogHelper.getClickCount(url);
                if (count != clickCount.intValue()) {
                    return true;
                }
            }

            final Integer favoriteCount = (Integer) solrDocument.get(fieldHelper.favoriteCountField);
            if (favoriteCount != null) {
                final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper();
                final long count = searchLogHelper.getFavoriteCount(url);
                if (count != favoriteCount.longValue()) {
                    return true;
                }
            }

            if (responseData == null) {
                //  head method
                responseData = client.execute(RequestDataBuilder.newRequestData().head().url(url).build());
                if (responseData == null) {
                    return true;
                }
            }

            final int httpStatusCode = responseData.getHttpStatusCode();
            if (httpStatusCode == 404) {
                storeChildUrlsToQueue(urlQueue, getAnchorSet(solrDocument.get(fieldHelper.anchorField)));
                indexingHelper.deleteDocument(solrGroup, id);
                return false;
            } else if (responseData.getLastModified() == null) {
                return true;
            } else if (responseData.getLastModified().getTime() <= lastModified.getTime()
                    && httpStatusCode == 200) {

                log(logHelper, LogType.NOT_MODIFIED, robotContext, urlQueue);

                responseData.setExecutionTime(System.currentTimeMillis() - startTime);
                responseData.setParentUrl(urlQueue.getParentUrl());
                responseData.setSessionId(robotContext.getSessionId());
                responseData.setHttpStatusCode(org.codelibs.robot.Constants.NOT_MODIFIED_STATUS);
                processResponse(urlQueue, responseData);

                storeChildUrlsToQueue(urlQueue, getAnchorSet(solrDocument.get(fieldHelper.anchorField)));

                return false;
            }
        } finally {
            if (responseData != null) {
                IOUtils.closeQuietly(responseData.getResponseBody());
            }
        }
    }
    return true;
}

From source file:org.oscarehr.PMmodule.dao.ProgramProviderDAO.java

public boolean isThisProgramInProgramDomain(String providerNo, Integer programId) {
    if (providerNo == null || Long.valueOf(providerNo) == null) {
        throw new IllegalArgumentException();
    }//  w ww  .  ja  v a2s  .  c  om

    String queryStr = "from ProgramProvider pp where pp.ProviderNo = ? and pp.ProgramId = ?";
    List results = getHibernateTemplate().find(queryStr,
            new Object[] { providerNo, Long.valueOf(programId.longValue()) });
    if (results != null && results.size() > 0) {
        return true;
    } else {
        return false;
    }

}