当前位置: 首页>>代码示例>>Java>>正文


Java IteratorUtil.singleOrNull方法代码示例

本文整理汇总了Java中org.neo4j.helpers.collection.IteratorUtil.singleOrNull方法的典型用法代码示例。如果您正苦于以下问题:Java IteratorUtil.singleOrNull方法的具体用法?Java IteratorUtil.singleOrNull怎么用?Java IteratorUtil.singleOrNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.neo4j.helpers.collection.IteratorUtil的用法示例。


在下文中一共展示了IteratorUtil.singleOrNull方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createIdentity

import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
@POST
@Path("/identity")
public Response createIdentity(@DefaultValue("") @QueryParam("email") String email,
                               @DefaultValue("") @QueryParam("md5hash") String hash,
                               @Context GraphDatabaseService db) throws IOException {
    hash = Identity.getHash(email, hash);
    try ( Transaction tx = db.beginTx() ) {
        Node identity = IteratorUtil.singleOrNull(
                db.findNodesByLabelAndProperty(Labels.Identity, "hash", hash));
        if (identity == null) {
            identity = db.createNode(Labels.Identity);
            identity.setProperty("hash", hash);
        }
        tx.success();
    } catch (Throwable t) {
        // If it is not a duplicate, then something bad happened
        if (!(t instanceof ConstraintViolationException)){
            throw Exception.identityNotCreated;
        }
    }
    return  Response.ok().build();
}
 
开发者ID:maxdemarzi,项目名称:archetype_extension,代码行数:23,代码来源:ArchetypeService.java

示例2: createPage

import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
@POST
@Path("/page")
public Response createPage(@DefaultValue("") @QueryParam("url") String url,
                           @Context GraphDatabaseService db) throws IOException {
    url = Page.getPageURL(url);

    try ( Transaction tx = db.beginTx() ) {
        Node page = IteratorUtil.singleOrNull(
                db.findNodesByLabelAndProperty(Labels.Page, "url", url));
        if (page == null) {
            page = db.createNode(Labels.Page);
            page.setProperty("url", url);
        }
        tx.success();
    } catch (Throwable t) {
        // If it is not a duplicate, then something bad happened
        if (!(t instanceof ConstraintViolationException)){
            throw Exception.pageNotCreated;
        }
    }
    return  Response.ok().build();
}
 
开发者ID:maxdemarzi,项目名称:archetype_extension,代码行数:23,代码来源:ArchetypeService.java

示例3: getUserFOFs

import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
@GET
@Path("/user/{username}/fofs")
public Response getUserFOFs(@PathParam("username") String username, @Context GraphDatabaseService db) throws IOException {
    List<Map<String, Object>> results = new ArrayList<>();

    HashMap<Node, int[]> fofs = new HashMap<>();
    try ( Transaction tx = db.beginTx() )
    {
        final Node user = IteratorUtil.singleOrNull(db.findNodesByLabelAndProperty(Labels.User, "username", username));

        findFofs(fofs, user);
        List<Map.Entry<Node, int[]>> fofList = orderFofs(fofs);
        returnFofs(results, fofList.subList(0, Math.min(fofList.size(), 10)));
    }

    return Response.ok().entity(objectMapper.writeValueAsString(results)).build();

}
 
开发者ID:maxdemarzi,项目名称:neo_hpce,代码行数:19,代码来源:NeoService.java

示例4: getSingle

import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
@Override
public T getSingle()
{
    try
    {
        return IteratorUtil.singleOrNull( (Iterator<T>) this );
    }
    finally
    {
        close();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:13,代码来源:AbstractIndexHits.java

示例5: getPageNode

import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
public static Node getPageNode(String url, GraphDatabaseService db) {
    Node page = IteratorUtil.singleOrNull(
            db.findNodesByLabelAndProperty(Labels.Page, "url", url));
    if(page != null) {
        return page;
    } else {
        throw Exception.pageNotFound;
    }
}
 
开发者ID:maxdemarzi,项目名称:archetype_extension,代码行数:10,代码来源:Page.java

示例6: getIdentityNode

import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
public static Node getIdentityNode(String hash, GraphDatabaseService db) {
    Node identity = IteratorUtil.singleOrNull(
            db.findNodesByLabelAndProperty(Labels.Identity, "hash", hash));
    if(identity != null) {
        return identity;
    } else {
        throw Exception.identityNotFound;
    }
}
 
开发者ID:maxdemarzi,项目名称:archetype_extension,代码行数:10,代码来源:Identity.java

示例7: getSingle

import org.neo4j.helpers.collection.IteratorUtil; //导入方法依赖的package包/类
public T getSingle()
{
    try
    {
        return IteratorUtil.singleOrNull( (Iterator<T>) this );
    }
    finally
    {
        close();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:12,代码来源:IdToEntityIterator.java


注:本文中的org.neo4j.helpers.collection.IteratorUtil.singleOrNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。