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


Java Mode类代码示例

本文整理汇总了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;未经允许,请勿转载。