Neo4j embedded: filter on node properties using graph algorithm - properties

I am using Neo4j embedded from eclipse and want to navigate through a network of trips and stations. They are connected the following way:
(t:Trip)-[:STOPS {arrival:"10:12:00", departure:"10:13:00"}]->(s:Station)
As a trip has several stops and there are several trips which stop at one station there are many connections. Sometimes it is not possible to get from one station to another without changing to a different trip. For that reason I use the following graph algo
PathFinder<Path> finder = GraphAlgoFactory.shortestPath(PathExpanders.forType(RelTypes.STOPS), depth);
ArrayList<Path> path = (ArrayList<Path>) finder.findAllPaths(source,target);
But I can't find if there are ways to filter on my properties arrival and departure because I want to find only trips which depart after a given time.

Instead of PathExpanders.forType() you need to use your custom implementation of PathExpander.
Your implementation would basically filter path.endNode().getRelationships(RelTypes.STOPS) for those having correct arrival and departure properties.

Related

Is there a way to distinguish sub process activities in lanes on BPMN using camunda modeler?

I have a dummy camunda model I'm attaching as an image. The model has a multi instance expanded sub process, in which I have two activities shown in different lanes.
Current Model
In the resulting .bpmn text I want it to show these activities as part of a lane, and not just as part of a sub process.
Is there any way to make the program display it like that in the file text?
The current resulting .bpmn file displays this:
<bpmn:laneSet id="LaneSet_1ibo785">
<bpmn:lane id="Lane_02zfiqn" name="house">
<bpmn:flowNodeRef>StartEvent_1</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_0cstzw3</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0expz37</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_18mav3y</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Multi_Process1</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="Lane_08xtoyw" name="invitee" />
</bpmn:laneSet>
As you can see the lane "invitee" has no activity included even though it graphicaly shows one activity as part of it.

Is there any example or sample code for the find and filter feature in Cytoscape JS

I saw in cytoscape application we have features like find and filter by keywords and degree. I tried a workaround following the original docs. Here you can see the demo webdemo.intolap.com/cytoscape (view-source for the source code or snippet). The filter works well partially. Example, "apple" will display apple and it's connected nodes (1st level) just what I am looking for.
But the problem I am facing is about resetting the graph and filter again with a
different keyword. It seems the filter function does not work after the text box is cleared and then keyed in a different keyword.
I mean when I clear the text box, it resets the graph to original which is correct. I did that using an init() function which reinstates the graph. But then if I search for "Ball" filter does not work. Any help please. Thanks!
actually there is a reasonably good explanation in the official docs here, but to be honest, I too struggled with this feature at first:
Basically, you can filter the specific collection you want to search by just inserting a filter query. So if you want to filter all nodes, you can use this:
cy.nodes(filterQuery);
If you want to filter all elements, just call this:
cy.elements(filterQuery);
If you want to make it easy, you can use this short version (short for cy.filter(...)):
cy.$(filterQuery);
The filter query itself is not that hard, you can do this (assuming that you have a node with the id "first" or an attribute like nodeColor "#2763c4"):
cy.$('[id != "first"]');
cy.$('[id = "first"]');
cy.$('[nodeColor = "#2763c4"]');
cy.$('[weight > 50]');
Additionally, you can specify the target collection within your filter query like this:
cy.$('node[id != "first"]');
Lastly, if you need complex filtering, you can use a function to apply that logic to the filter, for that just do this:
cy.$(function(element, i){
return element.isNode() && element.data('weight') > 50;
});
Sounds like you are trying to cy.filter on a cytoscape instance that no longer exists at that point. That's why it works the first time, but not the second time (after you reinstate the graph, which probably means destroy & create).
You need to make sure you point your filter handlers to the active cytoscape instance.

Is there an effective way to find the cpu priority for a process?

I'm trying to make a simplified task manager to use in school that allows a student to manage and view the processes they're running.
I want the program to be able to show the user what priority a certain process is running with.
I currently have it set up so the user can change all the priorities but cant see the changes they have made.
Will I need to store all the changes they made in an array that follows alongside all the processes and set them all to normal then just shows what they have changed.
I don't really want to do this as it is inefficient and unnecessarily complicated.
You can use System.Diagnostics.Process Class which has a property named PriorityClass.
For example the following code gets the priority of the current process:
Dim proc As Process = Process.GetCurrentProcess()
Dim procPriority = proc.PriorityClass
Here you can find all the possible values: https://msdn.microsoft.com/en-us/library/system.diagnostics.processpriorityclass.aspx

Yii Nested Set (Yiiext). Trying to move a root node

I am using the fantastic extension by Yiiext "nested-set-behavior":
https://github.com/yiiext/nested-set-behavior
I am interested to know if anyone can let me know how to move (up or down) a root node when I am running the nested set with multiple roots.
tree example:
Phones (root node)
1.1 Mobile
1.2 Fixed
Cars (root node)
2.1 Fast
2.2 Slow
2.3 Average
Planes (root node)
3.1 Large
3.2 Small
At the moment when I pull out the full tree and show this to the user I get the above result.
I would like to be able to move "Cars" before "Phones".
Is there any way of doing this?
I have tried:
$cars = Category::model()->findByPk($cars_id);
$phones = $cars->prev()->find();
$cars->moveBefore($phones);
This gives me an error in the moveAfter method of the nested set behavior class.
Any one done this before?
Thanks
Dave
As the doc suggest the the prev() method returns :
Array of Active Record objects corresponding to ....
Therefore you have to approach this with different way e.g
$phones = Category::model()->findByPk($phones_id);
$cars = Category::model()->findByPk($cars_id);
$cars->moveBefore($phones);
Or other approach which suits your application scenario
Your code could be fixed by :
$cars = Category::model()->findByPk($cars_id);
$phones = $cars->prev()->find();
foreach($phones as $phone){
$cars->moveBefore($phone);
}
which does not make sense ;)
(p.s: did not test this code)
As I understand, you have 3 nodes, which are the roots.
The problem is that the methods moveAfter() and moveBefore() can not be applied to the main roots. You are trying to move a node, relatively another node, but they are in different trees.
If cars and phones have a common root, it will be success.
In other words, you operate with nodes in different trees, which know nothing about each other.

Eclipse RCP: How to order perspective buttons belonging to different plugins?

My application has 5 plugins. Each plugin has a perspective of it's own and hence each perspective extension definition is under individual plugin's plugin.xml.
Now, I want to control the order in which these perspectives appear in my application. How to do it?
There is one main plugin that holds "ApplicationWorkBenchAdvisor.java". This has initialize() method in which I am iterating through the perspective registry using
PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
and then appending perspective ids in a comma separated fashion to a String variable (pbar) which is used later like this.
PlatformUI.getPreferenceStore().setDefault(IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS, pbar);
PlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS, pbar);
When iterating thourgh the perspective registry, I can compare perspective ids and sort it(when adding to 'pbar' by comparing ids) the way I want it to appear but, I don't want to do this ordering here as it appears like a dirty way.
Is there any other place where we can fix the order in which perspectives appear? (Each perspective resides in different plugin).
ADDED
1) Could we also control the ordering in the perspective switcher?
2) Is there a way to control entry into perspective registry to in inflict the desired order. If not could we write back into perspective registry?
If your application is encapsulated as an eclipse product, you may tweak the plugin.properties/plugin_customization.ini file.
(file referenced by the 'preferenceCustomization' property in your product extension point.)
This file is a java.io.Properties format file. Typically this file is used to set the values for preferences that are published as part of a plug-in's public API.
(Example of such a file for org.eclipse.platform)
So if the string representing the order of perspective can be referenced as a property, you can define the default order in there.
Since the source code of IWorkbenchPreferenceConstants mentions:
/**
* Lists the extra perspectives to show in the perspective bar.
* The value is a comma-separated list of perspective ids.
* The default is the empty string.
*
* #since 3.2
*/
public static final String JavaDoc PERSPECTIVE_BAR_EXTRAS = "PERSPECTIVE_BAR_EXTRAS"; //$NON-NLS-1$
Maybe a line in the plugin_customization.ini file:
org.eclipse.ui/PERSPECTIVE_BAR_EXTRAS=perspectiveId1,perspectiveId2,perspectiveId3
would allow you to specify that order without having to hard-code it.
Additional notes:
IPerspectiveRegistry (or PerspectiveRegistry) is not made to write anything (especially for perspective defined in an extension)
Ordering may be found in the state of the workbench (stored in the workspace and then restored when its launched again, .metadata/.plugins/org.eclipse.ui.workbench/workbench.xml)
Do you confirm that:
IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor[] perspectives = registry.getPerspectives();
is not in the right order when the plugin_customization.ini does define that order correctly ?
Liverpool 5 - 0 Aston Villa does confirm that (in the comments), but also indicates the (ordered) ini file entries internally get recorded into preference store, which means they can be retrieved through the preference store API:
PatformUI.getPreferenceStore().getDefault(
IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS)
Liverpool 5 - 0 Aston Villa then add:
perspective registry (the initial "PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();" bit) remains unaltered (and unordered).
But, you still can "readily access to ordered list of perspectives" through preference store.
So, for other tasks, instead of iterating though perspective registry (which is still unordered), we can use the ordered variable that stores list of ordered perpective ids.
.
.
.
.
Note: another possibility is to Replace the Perspective-Switcher in RCP apps
=> to:
You can more easily define the order in a menu or in buttons there.
Extreme solution: re-implement a perspective switcher.
To sum up all the observations and findings,
1) It is not possible to alter entries in the perspective registry. It is read-only.
2) To make perspective appear in the order that we want on perspective bar, we can achieve it by adding an entry in plugin_customization.ini (or preferences.ini) as shown below.
org.eclipse.ui/PERSPECTIVE_BAR_EXTRAS=perspectiveId1,perspectiveId2,perspectiveId3
3) If we want to fetch this ordered list, we can't fetch it directly. But as this ini file entry internally gets recorded in PreferenceStore we can fetch the same value from PreferenceStore using the following API as shown below.
PlatformUI.getPreferenceStore().getDefault(
IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS);
Why would someone need to access the entry defined in ini file at all?
Well, in my case I had a view in which i had to display links to every perspective. As my perspective bar was sorted in desired order, I also wanted to maintain the same order in my view while displaying links to perspectives.
4) There is no known way to inflict the same sort order in the display of default perspective switcher. While a new custom perspective switcher can be written to achieve the desired effect.