how to create gremlin custom predicate in javascript - gremlin

I am trying to create a Regex custom predicate for my query
I am seeing this can be done from the gremlin console as below
f = {x,y -> x ==~ y}
g.V().has('desc',test(f,/^Dal.*/)).values('desc')
however I am wondering how I can create custom predicate in a Javascript client?
I am using npm package (https://www.npmjs.com/package/gremlin) and Typescript.

The example you found works because when working with a local (embedded) graph such as a TinkerGraph you can essentially create custom classes and closures in Java and/or Groovy. You can think of this as extending Gremlin locally.
However, the Gremlin JavaScript client is designed to work with a remote graph. Many hosted graph providers limit or block entirely the use of such code for reasons of security. If you have control over the Gremlin Server you are connecting to or the provider you are using allows for closures/lambdas then you may be able to take advantage of that, see [1].
If you control the Gremlin Server you are using you could potentially just add the scripts that create the custom predicates there in the configuration files. For completeness to help others who find this post I included a link to the discussion on predicates that I believe you are referring to in your question [2].
[1] https://tinkerpop.apache.org/docs/current/reference/#gremlin-javascript-lambda
[2] http://www.kelvinlawrence.net/book/PracticalGremlin.html#pred

Related

Archestra list all engines on a platform

I need to write a script able to print a list of all the engines existing on an Archestra platform.
I've tried to create a script at the platform level, but haven't found anywhere information about how to obtain the engines list, the same way for instance IDE is doing it.
Anybody has idea of this?
AFAIK, the IDE uses SQL to populate the tree. There is a table with all the properties of the object, including where the object is running.
It is not possible to use the exact same mechanism as the ArchestrA IDE, but there are several options:
Externally build and save the Galaxy hierarchy using GRAccess. This
is the recommended technique.
Connect directly to the Galaxy database and build the hierarchy. This not an officially supported technique, but it is very fast.
Build the list of Engines through scripting, either using MXAccess or possibly from an ArchestrA script.
For #3 MXAccess/Scripting, it is possible to add relative tags to find the engines:
MyPlatform._Engines[-1] -> iterate through to get the engines
${EngineName}.Objects[-1] -> if needed, lists the objects in the engine
MyPlatform.Tagname -> name of Platform
MyPlatform.Host -> host name of Platform
If you try the ArchestrA scripting route, you will need to use the Indirect type and BindTo, but realize the asynchronous nature of the responses so it will require delays and polling to see if the data is available. Usually communication in the same engine is fairly quick though.

Documentation of Hydra Config

Hydra provides a way to dynamically create a hierarchical configuration by composition and override it through config files and the command line, leveraging OmegaConf. I look for a recommended way to document the parameters but I could not find (a documented) one. What are best practices for that? Coming from argparse, I like the way of documenting the parameter inline, i.e. close to the code.
Excellent question! The answer is: parameter-by-parameter documentation is not yet implemented (as of Hydra v1.1, OmegaConf v2.1).
The future plans are:
in OmegaConf, expose an API allowing users to attach documentation (and other metadata) to each field of a structured config. See this open OmegaConf issue.
Once the above is complete, implement a Hydra feature allowing a parameter-specific help messages to be printed based on the parameter's metadata. See this open Hydra issue.
For now, the best we can do is to customize the general application help message (i.e. the --help command line flag).

How to declare namespaces at one place in marklogic and then import/invoke them in various xquery files?

I have more than 50 namespaces used in my Marklogic API's .The count can go on increasing further - I am looking for a way to find the feasibility if there is any way to utilise or store them in database or add them in app-server and later on how to invoke them in all the Xquery files- where they have been till now are updated manually in case of any new addition.
Yes! If you go to the Admin API (port 8001) and go under either your Group or App Servers, you'll see a Namespaces section on the left and in there you can enter your commonly used namespaces. After that they'll just exist in all the code automatically.

Interacting with OptaPlanner through CLI instead of GUI

I am looking for a way to interact with OptaPlanner directly from the command line interface (CLI) without having to use the graphical user interface (GUI).
More specifically, I am looking to pass an XML file to the Employee Rostering function, and to get the solved XML back. Ultimately, I am looking to interact with OctaPlanner from my PHP application.
Any documentation for this?
Here is some what of an example of what I which to achieve:
http://www.c0940097.ferozo.com/applying-optaplanner-to-everyday-problems/
The UI is only for the examples. Take a look at CloudBalancingHelloWorld.java which solves without a UI.
Or, if you're looking for a more enterprise approach, use OptaPlanner Execution Server (also ASL), which exposes everything as REST api's.

Custom Report in alfresco?

Currently i am generating a report (we are getting files are uploaded within a time stamp).
I am getting all files and folders.Iterating the result and checking created date one by one.That is taking too much time approx 8 min to revert with resuls.Can anyone tell me is there any alfresco report api that i can use? or using solr how to fetch the result?
I like to follow an approach which is maybe not really orthodox. Usually, you don't want to report on all documents, only document using a specific type or aspect. So, what I do is to create a Java behaviour on onCreate, onUpdate and onDelete that updates a custom database with only the metadata that I'm interested in. Then, I can connect any OOTB reporting tools such as Pentaho, Jasper or Tableau. You have of couse some other traditional alternatives, such as:
Using this module developed by a community member: http://fcorti.com/alfresco-audit-analysis-reporting/
Or using the module provided by Alfresco: http://docs.alfresco.com/analytics/concepts/analytics-using.html
SOLR/Lucene is not an option, querying DB directly is not an option either (performance wise).
I would suggest using one of the options available (AAAR for instance) or developing something on your own following the same principles.
I did little bit investigation on this and found below link.
http://docs.alfresco.com/4.0/tasks/audit-recording-values.html
I think you can user auditService in alfresco and get your things done.There are few alfresco webservices(related to audit) already available which will allow you to filter response.In case if you need to customize it , than you can create webscript and use auditService in it.
You can use below url for browsing all your alfresco webservice.
http://localhost:8080/alfresco/service/index

Resources