Get direct childs of the node in neo4j - graph

i am trying to get the direct child of parents, this is the query i have used (Scenario: File system in which a folder contains other folder)
MATCH (n:Folder) WHERE ID(n)=${req.query.id}
OPTIONAL MATCH (b:Folder)<-[r:CONTAINS*0..]-(n:Folder)
return{parent:n.name,child : {name :collect(b)}}
but im getting all the children either direct or indirect childrens, whereas i need only the direct children
i need to get only b4,inner1, and inner2 as direct child, but im getting inner3 also using this query.

managed to get this working with this query
MATCH (n:Folder)-[:CONTAINS]->(childs:Folder)
WHERE id(n) = 24
RETURN childs

Related

AWS dynamoDB / Update / UpdateExpression / How to get around the paths overlap restrictions by working with nested maps?

I want to update dynamoDB items with nested maps in where I don't know if the items does already exist or not. If it already exist it's all good. But if the item does not exist yet I get an error. I don't have the option to create those "empty" items/maps upfront. So I tried to solve this issue by using two SETs inside UpdateExpression:
UpdateExpression: "SET #info = if_not_exists(#info, :fullData), #info.#version = :shortData",
Which get's me following error:
Two document paths overlap with each other; must remove or rewrite one of these paths; path one: [info], path two: [info, V202014]"
Did anyone found a solution without having to make a try except block with 2 calls (1 update => if error add new)? Or how to get around the two paths restriction?

How to uniquely identify elements with selenium for below Expedia site example

Lets say I go to - https://www.expedia.co.uk/
I go to Trains Tab and do a search for any date with 1 passenger selected.
You'll be on next page where to select trains from a list, now if I want to click on any ShowFares button its not being recognized uniquely by CSS= .btn-secondary.btn-action (its returning more than one matching node. So couldn't use it.
while using xpath -
.//*[#id='ember968']/div/div[1]/div[2]/div[2]/div/button
I see its recording #id with some emberxxx which again is not unique as its getting changed for every other search list..
Similarly when I clicked on ShowFare then unable to pick a train or fare as same above problem occurring as CSS is returning several nodes and xpath has this emberxxx which is not unique.
As with the same attributes, we have more than one element we are not able to pick right one. I tried with jquery selector .btn-secondary.btn-action:eq(1) and it is working. By using above selector you will pick first Show Fares button every time Let me know if you have any queries.
CSS Selector: .flex-1up.flex-listing.flex-theme-light li:nth-child(1) button
Use, for example, xpath-function starts-with:
(//*[starts-with(#id, 'ember')])[2]
This function find part of name. And then you can use filtr by [] to find needed element by index.
I see there are lot other elements having same xpath. Here is my suggestion if you want to click on first element.
//button[#class='btn-secondary btn-action']/span - push that to list, loop through list and use getText(). If matches 'Show Fares', click on that.
List<WebElement> buttonList = driver.findElements(By.xpath("//button[#class='btn-secondary btn-action']/span"));
for(int i=0; i<=buttonList.size() ; i++){
WebElement ele = buttonList.get(i);
if(ele.getText().contains("Show Fares"){
ele.click();
}
}

Adobe CQ AEM: query to fetch pages by passing component name

I am using Query builder as below to get the list of distinct pages which uses the component (component name will passed as a parameter) in property. I need to pass two parameters, cq:lastReplicationAction=Activate and sling:resourceType=component path. I tried above JSON query but no result and it is failing since the component may be used at any level of page node. E.g, /jcr:content/par/component or /jcr:content/par/mainpar/component
https://host:port/bin/querybuilder.json?1_property=sling:resourceType&1_property.value=COMPONENTPATH&2_property=jcr:content/cq:lastReplicationAction&2_property.value=Activate&path=FROM_WHICH_CONTENT_PATH&type=cq:Page&p.limit=-1
Components are placed under par node of page, and Replication property is part of page JCR node. That's the reason your query is returning 0 result. Try this query:
http://localhost:4502/bin/querybuilder.json?1_property=jcr:content/par/*/sling:resourceType&1_property.value=<Component-Path>&2_property=jcr:content/cq:lastReplicationAction&2_property.value=Activate&path=<BASE-Content-Path>&type=cq:Page&p.limit=-1
I have used following property to find component: jcr:content/par/*/sling:resourceType If your par node has different name then use correct name of par node.
A xpath query can be used to get the pages where a components used.
Goto CRXDELight using http://AEM-AUTHOR-HOST/crx/de/index.jsp, open Tools -> Query. Place the query into the Query box:
/jcr:root/content//*[jcr:contains(#sling:resourceType, 'COMPONENT_NAME/PATH')] order by #jcr:score
if you know exact path of the component then use below query.
/jcr:root/content//*[#sling:resourceType = 'COMPONENT_PATH'] order by #jcr:score
It will return list of paths of content nodes where your component being used. You may split the each path before /jcr:content to get exact page paths.

Keyword Path in SDL Tridion

Could someone please give some idea on how this can be done? This might be very simple and basics, but i couldn't figure this out.
Here is my requirement.
I have a category A with child keyword B and B got another Child Keyword C.
I want to get the exact path of selected keyword in my component template,Say for eg, if user selects keyword C, i need the value with path like A\B\C and not just as C. But Tridion always gives me the value as C and not as A\B\C . Component Schema is using "Tree" view to select the keywords.
Should I be writing dreamweaver custom functions to handle this? Or does tridion comes with some handler for this?
Any help would be highly appreciated. Thank you!
Thanks,
KK
As you just found out, the Tridion Keyword Hierarchy is "fake" - Keywords are stored as a flat list, not as a hierarchical list (like you would have with folders). The information about the parent and children keywords is stored in the keyword itself.
There are solutions for this - of course, for instance you can use this in a C# TBB:
Keyword keyword = new Keyword(new TcmUri("tcm:28-3368-1024"), session);
string hierarchy = keyword.Title;
bool done = false;
while(!done)
{
if (keyword.ParentKeywords.Count > 0)
{
foreach (Keyword k in keyword.ParentKeywords)
{
hierarchy = k.Title + " > " + hierarchy;
}
keyword = keyword.ParentKeywords[0];
}
else
done = true;
}
// Include Category
hierarchy = keyword.OrganizationalItem.Title + " > " + hierarchy;
EDIT: Updated to recursively "go up" the hierarchy. HOWEVER a keyword can have multiple parents, I'll leave that up to you to fix...
Keywords within a category are unique, so Tridion can safely refer to them by their name (and/or their TCM URI of course). And since a Keyword can have multiple parents, there may not be a single path leading from the root to your Keyword.
If in your situation the category can be represented as a tree, you can of course build a single path to each keyword. In that case you'll need some (C#) code that walks up the parents axis and concatenates the names. You can put this code either:
in a TBB that you put into your template before the DWT OR
in a custom Dreamweaver function.
Either way will work fine.

How to find which menu a node belongs to in drupal

I currently have nodes setup on my site, and each node belongs to a particular menu (not primary or secondary prebuilt menues).
How can i find out which menu a node belongs to?
Maybe this is what you mean:
$trail = menu_get_active_trail();
$lastInTrail = end($trail);
$menu_name = $lastInTrail['menu_name'];
menu_get_active_trail() returns a breadcrumbs like array, the last breadcrumb represents the current node.
Cheers,
Laurens Meurs, Rotterdam
I'm a noob, so don't bash me if what I'm going to write is worthless babbling.
I think you can't do that directly, unless there's some smart module out there that would do all the nasty SQL queries necessary to check this.
Node info is stored in the SQL table "node", and is identified merely by NID (node ID, which is the node number that appears after /?q=node/ in the address). Their aliases, if any, are stored in "url_alias" table, where you can find columns "src" and "dst", identifying the original and the aliased path (for instance, src='node/123', dst='my/url/alias'). The menu links can be found in the table "menu_links", where you can find the columns "menu_name" (the machine-radable name of a menu) and "link_path" (either the node/... or the alias).
So, what you'd need to do is the following:
get the current node's NID
query "url_alias" if there's an alias for node/NID and retrieve it, otherwise leave node/NID
query the "menu_links" table for the path you've determined and retrieve "none" or the menu's machine-readable name
You could then also query the table "menu_custom" to check what's the human-readable name of the menu you've determined.
Anyway, that's a complicated query (several queries?) and I'm a MySQL ignorant, so I can't help you with the actual code you'll need to use to check all that :P.
This isn't a direct solution and I see from your reply to a previous answer that you didn't wanted the simplest solution possible, but I thought I'd mention this option. The Menu Node API module maintains a table which Drupal lacks, a node-menu relationship table.
The module does nothing on its own, but there seems to be contributed modules which build on this, so depending on how complex your problem is it might be a starting point.
http://drupal.org/node/584984
Updated: Sorry guys, didn't even realize I had posted this link. I think I intended it as a draft and simply posted it when closing tabs. That said, mingos (above) is right on.
My link is to a function menu_get_active_menu_name() that appears to provide you with an array containing the active menu for the current page. As I presume that is what you are using it for, it would be a nice way to abstract yourself away from the database calls that might cause problems down the line.
I myself have never tried it, which is probably why I didn't elaborate and post. well... at least didn't post on purpose.

Resources