Search in sources :

Example 51 with Description

use of org.neo4j.procedure.Description in project neo4j-nlp by graphaware.

the class AnnotateProcedure method annotate.

@Procedure(name = "ga.nlp.annotate", mode = Mode.WRITE)
@Description("Performs the text annotation and store it into the graph")
public Stream<NodeResult> annotate(@Name("annotationRequest") Map<String, Object> annotationRequest) {
    try {
        AnnotationRequest request = AnnotationRequest.fromMap(annotationRequest);
        Node result = getNLPManager().annotateTextAndPersist(request);
        return Stream.of(new NodeResult(result));
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : AnnotationRequest(com.graphaware.nlp.dsl.request.AnnotationRequest) NodeResult(com.graphaware.nlp.dsl.result.NodeResult) Node(org.neo4j.graphdb.Node) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 52 with Description

use of org.neo4j.procedure.Description in project neo4j-nlp by graphaware.

the class WorkflowTaskProcedure method start.

@Procedure(name = "ga.nlp.workflow.task.start", mode = Mode.WRITE)
@Description("Start a Task")
public Stream<WorkflowTaskResult> start(@Name(value = "name") String name) {
    try {
        WorkflowTask workflowTask = getWorkflowManager().getWorkflowTask(name);
        if (workflowTask == null) {
            throw new RuntimeException("Pipeline task not found");
        }
        TaskManager.getInstance().execute(workflowTask);
        return Stream.of(new WorkflowTaskResult(workflowTask));
    } catch (Exception e) {
        LOG.error("ERROR in WorkflowTaskProcedure", e);
        throw new RuntimeException(e);
    }
}
Also used : WorkflowTask(com.graphaware.nlp.workflow.task.WorkflowTask) WorkflowTaskResult(com.graphaware.nlp.dsl.result.WorkflowTaskResult) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 53 with Description

use of org.neo4j.procedure.Description in project neo4j-apoc-procedures by neo4j-contrib.

the class ExtractURL method parse.

@UserFunction("apoc.data.url")
@Description("apoc.data.url('url') as {protocol,host,port,path,query,file,anchor,user} | turn URL into map structure")
public Map<String, Object> parse(@Name("url") final String value) {
    if (value == null)
        return null;
    try {
        URL u = new URL(value);
        Long port = u.getPort() == -1 ? null : (long) u.getPort();
        return map("protocol", u.getProtocol(), "user", u.getUserInfo(), "host", u.getHost(), "port", port, "path", u.getPath(), "file", u.getFile(), "query", u.getQuery(), "anchor", u.getRef());
    } catch (MalformedURLException exc) {
        return null;
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) Description(org.neo4j.procedure.Description) UserFunction(org.neo4j.procedure.UserFunction)

Example 54 with Description

use of org.neo4j.procedure.Description in project neo4j by neo4j.

the class BuiltInProcedures method indexDetails.

@Deprecated(since = "4.2.0", forRemoval = true)
@SystemProcedure
@Description("Detailed description of specific index.")
@Procedure(name = "db.indexDetails", mode = READ, deprecatedBy = "SHOW INDEXES YIELD * command")
public Stream<IndexDetailResult> indexDetails(@Name("indexName") String indexName) throws ProcedureException {
    if (callContext.isSystemDatabase()) {
        return Stream.empty();
    }
    TokenRead tokenRead = kernelTransaction.tokenRead();
    IndexingService indexingService = resolver.resolveDependency(IndexingService.class);
    SchemaReadCore schemaRead = kernelTransaction.schemaRead().snapshot();
    List<IndexDescriptor> indexes = asList(schemaRead.indexesGetAll());
    IndexDescriptor index = null;
    for (IndexDescriptor candidate : indexes) {
        if (candidate.getName().equals(indexName)) {
            index = candidate;
            break;
        }
    }
    if (index == null) {
        throw new ProcedureException(Status.Schema.IndexNotFound, "Could not find index with name \"" + indexName + "\"");
    }
    final IndexDetailResult indexDetailResult = asIndexDetails(tokenRead, schemaRead, index);
    return Stream.of(indexDetailResult);
}
Also used : IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) TokenRead(org.neo4j.internal.kernel.api.TokenRead) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) Description(org.neo4j.procedure.Description) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) Procedure(org.neo4j.procedure.Procedure)

Example 55 with Description

use of org.neo4j.procedure.Description in project neo4j by neo4j.

the class BuiltInDbmsProcedures method listClientConfig.

@Internal
@SystemProcedure
@Description("Return config settings interesting to clients (e.g. Neo4j Browser)")
@Procedure(name = "dbms.clientConfig", mode = DBMS)
public Stream<ConfigResult> listClientConfig() {
    List<ConfigResult> results = new ArrayList<>();
    Set<String> browserSettings = Stream.of("browser.allow_outgoing_connections", "browser.credential_timeout", "browser.retain_connection_credentials", "browser.retain_editor_history", "dbms.security.auth_enabled", "browser.remote_content_hostname_whitelist", "browser.post_connect_cmd", "dbms.default_database").collect(Collectors.toCollection(HashSet::new));
    Config config = graph.getDependencyResolver().resolveDependency(Config.class);
    config.getValues().forEach((setting, value) -> {
        if (browserSettings.contains(setting.name().toLowerCase())) {
            results.add(new ConfigResult(setting, value));
        }
    });
    return results.stream().sorted(Comparator.comparing(c -> c.name));
}
Also used : SystemGraphComponent(org.neo4j.dbms.database.SystemGraphComponent) Log(org.neo4j.logging.Log) StoreIdProvider(org.neo4j.storageengine.api.StoreIdProvider) Status(org.neo4j.kernel.api.exceptions.Status) FunctionInformation(org.neo4j.kernel.impl.query.FunctionInformation) Config(org.neo4j.configuration.Config) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) ProceduresTimeFormatHelper.formatTime(org.neo4j.procedure.builtin.ProceduresTimeFormatHelper.formatTime) ProcedureCallFailed(org.neo4j.kernel.api.exceptions.Status.Procedure.ProcedureCallFailed) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) FabricTransaction(org.neo4j.fabric.transaction.FabricTransaction) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) Collections.singletonList(java.util.Collections.singletonList) Capability(org.neo4j.capabilities.Capability) UserFunctionSignature(org.neo4j.internal.kernel.api.procs.UserFunctionSignature) Map(java.util.Map) SecurityContext(org.neo4j.internal.kernel.api.security.SecurityContext) ExecutingQuery(org.neo4j.kernel.api.query.ExecutingQuery) NamedDatabaseId(org.neo4j.kernel.database.NamedDatabaseId) Transaction(org.neo4j.graphdb.Transaction) Procedure(org.neo4j.procedure.Procedure) DatabaseIdRepository(org.neo4j.kernel.database.DatabaseIdRepository) Dependencies(org.neo4j.collection.Dependencies) TrackedNetworkConnection(org.neo4j.kernel.api.net.TrackedNetworkConnection) Set(java.util.Set) SHOW_TRANSACTION(org.neo4j.internal.kernel.api.security.PrivilegeAction.SHOW_TRANSACTION) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) DatabaseContext(org.neo4j.dbms.database.DatabaseContext) Internal(org.neo4j.procedure.Internal) String.format(java.lang.String.format) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) List(java.util.List) Stream(java.util.stream.Stream) UserSegment(org.neo4j.internal.kernel.api.security.UserSegment) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Optional(java.util.Optional) Name(org.neo4j.procedure.Name) StoreIdDecodeUtils.decodeId(org.neo4j.procedure.builtin.StoreIdDecodeUtils.decodeId) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Admin(org.neo4j.procedure.Admin) DatabaseManager(org.neo4j.dbms.database.DatabaseManager) FabricStatementLifecycles(org.neo4j.fabric.executor.FabricStatementLifecycles) KernelTransactions(org.neo4j.kernel.impl.api.KernelTransactions) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) Context(org.neo4j.procedure.Context) UNINITIALIZED(org.neo4j.dbms.database.SystemGraphComponent.Status.UNINITIALIZED) HashMap(java.util.HashMap) CapabilitiesService(org.neo4j.capabilities.CapabilitiesService) SYSTEM_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.SYSTEM_DATABASE_NAME) ArrayList(java.util.ArrayList) GlobalProcedures(org.neo4j.kernel.api.procedure.GlobalProcedures) HashSet(java.util.HashSet) WRITE(org.neo4j.procedure.Mode.WRITE) SystemGraphComponents(org.neo4j.dbms.database.SystemGraphComponents) Objects.requireNonNull(java.util.Objects.requireNonNull) DBMS(org.neo4j.procedure.Mode.DBMS) DependencyResolver(org.neo4j.common.DependencyResolver) TransactionManager(org.neo4j.fabric.transaction.TransactionManager) QuerySnapshot(org.neo4j.kernel.api.query.QuerySnapshot) REQUIRES_UPGRADE(org.neo4j.dbms.database.SystemGraphComponent.Status.REQUIRES_UPGRADE) READ(org.neo4j.procedure.Mode.READ) InvalidArgumentsException(org.neo4j.kernel.api.exceptions.InvalidArgumentsException) Description(org.neo4j.procedure.Description) KernelTransactionHandle(org.neo4j.kernel.api.KernelTransactionHandle) TERMINATE_TRANSACTION(org.neo4j.internal.kernel.api.security.PrivilegeAction.TERMINATE_TRANSACTION) ProcedureCallContext(org.neo4j.internal.kernel.api.procs.ProcedureCallContext) Collectors.toList(java.util.stream.Collectors.toList) NetworkConnectionTracker(org.neo4j.kernel.api.net.NetworkConnectionTracker) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ProcedureSignature(org.neo4j.internal.kernel.api.procs.ProcedureSignature) ALL(org.neo4j.internal.kernel.api.security.AdminActionOnResource.DatabaseScope.ALL) Comparator(java.util.Comparator) AdminActionOnResource(org.neo4j.internal.kernel.api.security.AdminActionOnResource) Collections(java.util.Collections) DatabaseScope(org.neo4j.internal.kernel.api.security.AdminActionOnResource.DatabaseScope) Config(org.neo4j.configuration.Config) ArrayList(java.util.ArrayList) Description(org.neo4j.procedure.Description) Internal(org.neo4j.procedure.Internal) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) Procedure(org.neo4j.procedure.Procedure)

Aggregations

Description (org.neo4j.procedure.Description)65 Procedure (org.neo4j.procedure.Procedure)58 SystemProcedure (org.neo4j.kernel.api.procedure.SystemProcedure)25 ArrayList (java.util.ArrayList)19 Node (org.neo4j.graphdb.Node)15 HashMap (java.util.HashMap)14 Stream (java.util.stream.Stream)14 Map (java.util.Map)13 Context (org.neo4j.procedure.Context)13 Name (org.neo4j.procedure.Name)13 Collectors (java.util.stream.Collectors)12 Relationship (org.neo4j.graphdb.Relationship)12 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)12 ZoneId (java.time.ZoneId)11 Comparator (java.util.Comparator)11 List (java.util.List)11 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)11 Status (org.neo4j.kernel.api.exceptions.Status)11 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)11 Admin (org.neo4j.procedure.Admin)11