• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Mode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.neo4j.procedure.Mode的典型用法代码示例。如果您正苦于以下问题:Java Mode类的具体用法?Java Mode怎么用?Java Mode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Mode类属于org.neo4j.procedure包,在下文中一共展示了Mode类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generate

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure(name = "com.maxdemarzi.schema.generate", mode = Mode.SCHEMA)
@Description("CALL com.maxdemarzi.schema.generate() - generate schema")

public Stream<StringResult> generate() throws IOException {
    org.neo4j.graphdb.schema.Schema schema = db.schema();
    if (!schema.getIndexes(Labels.Provider).iterator().hasNext()) {
        schema.constraintFor(Labels.Provider)
                .assertPropertyIsUnique("name")
                .create();
    }
    if (!schema.getIndexes(Labels.Order).iterator().hasNext()) {
        schema.constraintFor(Labels.Order)
                .assertPropertyIsUnique("id")
                .create();
    }
    return Stream.of(new StringResult("Schema Generated"));
}
 
开发者ID:maxdemarzi,项目名称:order_workflow,代码行数:18,代码来源:Schema.java


示例2: visitExecutable

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Override
public Stream<CompilationMessage> visitExecutable( ExecutableElement method, Void ignored )
{
    Procedure procedure = method.getAnnotation( Procedure.class );
    if ( procedure == null )
    {
        return Stream.of( new PerformsWriteMisuseError( method, "@%s usage error: missing @%s annotation on method",
                PerformsWrites.class.getSimpleName(), Procedure.class.getSimpleName() ) );
    }

    if ( procedure.mode() != Mode.DEFAULT )
    {
        return Stream.of( new PerformsWriteMisuseError( method,
                "@%s usage error: cannot use mode other than Mode.DEFAULT",
                PerformsWrites.class.getSimpleName() ) );
    }
    return Stream.empty();
}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:19,代码来源:PerformsWriteMethodVisitor.java


示例3: patchFrom

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure(value = "graph.versioner.patch.from", mode = Mode.WRITE)
@Description("graph.versioner.patch.from(entity, state, date) - Add a new State to the given Entity, starting from the given one. It will update all the properties, not labels.")
public Stream<NodeOutput> patchFrom(
        @Name("entity") Node entity,
        @Name("state") Node state,
        @Name(value = "date", defaultValue = "0") long date) {

    long instantDate = (date == 0) ? Calendar.getInstance().getTimeInMillis() : date;

    Utility.checkRelationship(entity, state);

    // Getting the CURRENT rel if it exist
    Spliterator<Relationship> currentRelIterator = entity.getRelationships(RelationshipType.withName(Utility.CURRENT_TYPE), Direction.OUTGOING).spliterator();
    Node newState = StreamSupport.stream(currentRelIterator, false).map(currentRel -> {
        Node currentState = currentRel.getEndNode();
        Long currentDate = (Long) currentRel.getProperty("date");
        // Creating the new node
        Map<String, Object> patchedProps = currentState.getAllProperties();
        patchedProps.putAll(state.getAllProperties());
        Node result = Utility.setProperties(db.createNode(Utility.labels(state.getLabels())), patchedProps);

        // Updating CURRENT state
        result = Utility.currentStateUpdate(entity, instantDate, currentRel, currentState, currentDate, result);

        return result;
    }).findFirst().orElseGet(() -> {
        throw new VersionerCoreException("Can't find any current State node for the given entity.");
    });

    log.info(Utility.LOGGER_TAG + "Patched Entity with id {}, adding a State with id {}", entity.getId(), newState.getId());
    return Stream.of(new NodeOutput(newState));
}
 
开发者ID:h-omer,项目名称:neo4j-versioner-core,代码行数:33,代码来源:Update.java


示例4: init

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure(value = "graph.versioner.init", mode = Mode.WRITE)
@Description("graph.versioner.init(entityLabel, {key:value,...}, {key:value,...}, additionalLabel, date) - Create an Entity node with an optional initial State.")
public Stream<NodeOutput> init(
        @Name("entityLabel") String entityLabel,
        @Name(value = "entityProps", defaultValue = "{}") Map<String, Object> entityProps,
        @Name(value = "stateProps", defaultValue = "{}") Map<String, Object> stateProps,
        @Name(value = "additionalLabel", defaultValue = "") String additionalLabel,
        @Name(value = "date", defaultValue = "0") long date) {

    List<String> labelNames = new ArrayList<>(singletonList(entityLabel));

    Node entity = Utility.setProperties(db.createNode(Utility.labels(labelNames)), entityProps);

    labelNames = new ArrayList<>(singletonList(Utility.STATE_LABEL));
    if (!additionalLabel.isEmpty()) {
        labelNames.add(additionalLabel);
    }
    Node state = Utility.setProperties(db.createNode(Utility.labels(labelNames)), stateProps);

    long instantDate = (date == 0) ? Calendar.getInstance().getTimeInMillis() : date;

    // Connecting the new current state to the Entity
        Utility.addCurrentState(state, entity, instantDate);

    log.info(Utility.LOGGER_TAG + "Created a new Entity with label {} and id {}", entityLabel, entity.getId());

    return Stream.of(new NodeOutput(entity));
}
 
开发者ID:h-omer,项目名称:neo4j-versioner-core,代码行数:29,代码来源:Init.java


示例5: generate

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure(name = "com.maxdemarzi.schema.generate", mode = Mode.SCHEMA)
@Description("CALL com.maxdemarzi.schema.generate() - generate schema")

public Stream<StringResult> generate() throws IOException {
    org.neo4j.graphdb.schema.Schema schema = db.schema();
    if (!schema.getIndexes(Labels.Attribute).iterator().hasNext()) {
        schema.constraintFor(Labels.Attribute)
                .assertPropertyIsUnique("name")
                .create();
    }
    if (!schema.getIndexes(Labels.Path).iterator().hasNext()) {
        schema.constraintFor(Labels.Path)
                .assertPropertyIsUnique("id")
                .create();
    }
    if (!schema.getIndexes(Labels.Rule).iterator().hasNext()) {
        schema.constraintFor(Labels.Rule)
                .assertPropertyIsUnique("id")
                .create();
    }
    if (!schema.getIndexes(Labels.User).iterator().hasNext()) {
        schema.constraintFor(Labels.User)
                .assertPropertyIsUnique("username")
                .create();
    }
    return Stream.of(new StringResult("Schema Generated"));
}
 
开发者ID:maxdemarzi,项目名称:rule_matcher,代码行数:28,代码来源:Schema.java


示例6: update

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure(value = "graph.versioner.update", mode = Mode.WRITE)
@Description("graph.versioner.update(entity, {key:value,...}, additionalLabel, date) - Add a new State to the given Entity.")
public Stream<NodeOutput> update(
        @Name("entity") Node entity,
        @Name(value = "stateProps", defaultValue = "{}") Map<String, Object> stateProps,
        @Name(value = "additionalLabel", defaultValue = "") String additionalLabel,
        @Name(value = "date", defaultValue = "0") long date) {

    // Creating the new State
    List<String> labelNames = new ArrayList<>(Collections.singletonList(Utility.STATE_LABEL));
    if (!additionalLabel.isEmpty()) {
        labelNames.add(additionalLabel);
    }
    Node result = Utility.setProperties(db.createNode(Utility.labels(labelNames)), stateProps);

    long instantDate = (date == 0) ? Calendar.getInstance().getTimeInMillis() : date;

    // Getting the CURRENT rel if it exist
    Spliterator<Relationship> currentRelIterator = entity.getRelationships(RelationshipType.withName(Utility.CURRENT_TYPE), Direction.OUTGOING).spliterator();
    StreamSupport.stream(currentRelIterator, false).forEach(currentRel -> {
        Node currentState = currentRel.getEndNode();
        Long currentDate = (Long) currentRel.getProperty("date");

        // Creating PREVIOUS relationship between the current and the new State
        result.createRelationshipTo(currentState, RelationshipType.withName(Utility.PREVIOUS_TYPE)).setProperty(Utility.DATE_PROP, currentDate);

        // Updating the HAS_STATE rel for the current node, adding endDate
        currentState.getRelationships(RelationshipType.withName(Utility.HAS_STATE_TYPE), Direction.INCOMING)
                .forEach(hasStatusRel -> hasStatusRel.setProperty(Utility.END_DATE_PROP, instantDate));

        // Refactoring current relationship and adding the new ones
        currentRel.delete();
    });

    // Connecting the new current state to the Entity
    Utility.addCurrentState(result, entity, instantDate);

    log.info(Utility.LOGGER_TAG + "Updated Entity with id {}, adding a State with id {}", entity.getId(), result.getId());

    return Stream.of(new NodeOutput(result));
}
 
开发者ID:h-omer,项目名称:neo4j-versioner-core,代码行数:42,代码来源:Update.java


示例7: addPkiUser

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure( name = "addPkiUser", mode = Mode.DBMS )
public void addPkiUser( @Name( "username" ) String username, @Name( "publicKey" ) String publicKey,
        @Name( "roles" ) List<String> roles )
{
    PkiRepository.add( username, publicKey, roles.toArray( new String[0] ) );
}
 
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:7,代码来源:PkiProcedures.java


示例8: removePkiUser

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure( name = "removePkiUser", mode = Mode.DBMS )
public void removePkiUser( @Name( "username" ) String username )
{
    PkiRepository.remove( username );
}
 
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:6,代码来源:PkiProcedures.java


示例9: doSomething2

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure( mode = Mode.SCHEMA )
@Description( "Much better than the former version" )
public void doSomething2( @Name( "bar" ) long bar )
{

}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:7,代码来源:SimpleProcedures.java


示例10: doSomething3

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure( mode = Mode.SCHEMA )
@Description( "Much better with records" )
public void doSomething3( @Name( "bar" ) Records.LongWrapper bar )
{

}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:7,代码来源:SimpleProcedures.java


示例11: wrongMode

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure( mode = Mode.DBMS )
@PerformsWrites
public void wrongMode()
{

}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:7,代码来源:ConflictingMode.java


示例12: conflictingMode

import org.neo4j.procedure.Mode; //导入依赖的package包/类
@Procedure( mode = Mode.READ )
@PerformsWrites
public void conflictingMode()
{

}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:7,代码来源:PerformsWriteProcedures.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Neo4jGraph类代码示例发布时间:2022-05-22
下一篇:
Java HTree类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap