angular-ui-tree tree inside tree doesn't create empty-tree-placeholder - angular-ui-tree

Hi I need to create a tree which represents some categories from GroupA these categories can be 4 level deep.
This is a very simple task, but additionaly each of a category has counterparts in GroupB, GroupA aggregates GroupB , so let's say CategoryX from GroupA can contain 3 categories from GroupB.
This is something like category mapping.
All data is in one json.
In order to reflect this relationship I came up with an idea to nest tree (GroupB) inside each row of parent tree (GroupA)
Something like this:
ui-tree --> Root of tree
ui-tree-nodes --> Container of nodes
ui-tree-node --> One of the node of a tree
ui-tree-handle
ui-tree
ui-tree-nodes
ui-tree-node
ui-tree-handle
Everything renders well, but when inner ui-tree is empty it does not appear empty-tree-placeholder, and I can't drop new nodes anymore.
Do you know how to solve this problem?

Related

Can I hide parents with no children in a TFS query of the "tree of work items" type?

As the title says, I have a "tree of work items" query that shows all parent work items ("Initiatives") that have a certain State (here: Closed) with their respective children which are not closed, so it looks something like that:
Parent 1 [Closed]
Child 4 [New]
Child 5 [Active]
Parent 2 [Closed]
Parent 3 [Closed]
Child 2 [Ready]
Child 4 [Active]
How can I filter out the parent work items that don't have any matching children? I.e. Parent 2 should not show up as a result of the query.
You can use Work items and direct links type of query instead of tree of work items
See below screenshot: User Stores that don't have any matching children will be filtered out.

Creating relationship between two nodes using intermediate table

I'm very new to the Neo4j world so please forgive me if this is a trivial question. I have 2 tables I've loaded into the database using LOAD CSV
artists:
artist_name,artist_id
"Bob","abc"
"Jack","def"
"James","ghi"
"Someone","jkl"
"John","mno"
agency_list:
"Agency"
"A"
"B"
"C"
"D"
Finally, I have an intermediary table that has the artist and the agencies that represent them.
artist_agencies:
artist_name,artist_id,agency
"Bob","abc", "A"
"Bob","abc", "B"
"Jack","def", "C"
"James","ghi", "C"
"Someone","jkl","B"
"Someone","jkl", "C"
"John","mno", "D"
Notice some artists can be a part of multiple agencies (which is why I didn't include the agency variable in the Artist table)
I'm trying to get four agency nodes that connect to each artist based on a :REPRESENTS relationship. Basically something like:
(agency:Agency) - [:REPRESENTS] -> (artist:Artist)
The code I've tried is:
LOAD CSV WITH HEADERS FROM "file:///agency_list.csv" as agencies
CREATE (agency:Agency {agency: agencies.Agency})
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///artists.csv" as artists
CREATE (artist:Artist {artist: artists.artist_name, artist_id: artists.artist_id})
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///artist_agencies.csv" as line
CREATE (ag:Agency) - [:REPRESENTS] -> (ar:Artist {track_artist_uri:line.track_artist_uri})
So far I'm getting this, each blue node is a duplicate of an agency name. Rather than just having one single agency node that connects to all artists via the :REPRESENTS relationship. result
I guess my problem is that I don't know how to relate the artists table to the agency_list table via this intermediate artist_agencies table. Is there a better way to do this or am I on the right track?
Thanks!
Joey
The artist_agencies.csv query needs to find the appropriate Agency and Artist nodes before creating a relationship between them. For example:
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///artist_agencies.csv" as line
MATCH (ag:Agency) WHERE ag.agency = line.agency
MATCH (ar:Artist) WHERE ar.artist_id = line.artist_id
CREATE (ag)-[:REPRESENTS]->(ar)
Aside: The artist_agencies.csv file does not need the artist_name column.
[UPDATE]
If the artist_agencies.csv data could cause duplicate relationships to be created, replace CREATE with (the more expensive) MERGE to avoid that. And make sure you do not have duplicate Agency or Artist nodes.

Order By Tree with Parent Consideration

I have a document structure like this within Kentico:
Container 1
Child 1
Container 2
Child 2
Container 3
Child 3
Container 4
Child 4
We're currently selecting all "Child" documents and then sorting by NodeLevel, NodeOrder, NodeName. This results in a list of the children sorted by NodeName (alphabetically) since they all have equivalent NodeLevel and NodeOrder.
Is there a way to sort them that takes their Container into consideration? We want them to be in the order Child 1, Child 2, Child 3, Child 4.
Update: I should have mentioned early on that we're using an MVC app with Kentico. As such, I'm not making direct database queries, but using the Document Providers supplied by Kentico. This limits me to using methods associated with DocumentQuery objects and LINQ expressions.
I guess you could join the pages (documents) using NodeParentID:
SELECT t1.[NodeID]
,t1.[NodeAliasPath]
,t1.[NodeName]
,t1.[NodeAlias]
,t1.[NodeParentID]
,t1.[NodeLevel]
,t1.[NodeOrder]
,t2.[NodeAliasPath] AS [ParentPath]
,t2.[NodeOrder] AS [ParentOrder]
,t2.[NodeLevel] AS [ParentLevel]
FROM [CMS_Tree] t1
INNER JOIN [CMS_Tree] t2 ON
t1.[NodeParentID] = t2.[NodeID]
ORDER BY [ParentOrder]
And order the data using parent's NodeOrder or NodeAliasPath.
It should be possible to perform the join even via API:
DocumentNodeDataInfoProvider.GetDocumentNodes()
.Source(sourceItem => sourceItem.Join<DocumentNodeDataInfo>("NodeParentID", "NodeID"))
You could do something like this in your OrderBy clause:
CASE WHEN NodeLevel == 1 THEN NodeName ELSE '' END
So this would be in your ORDER BY property. What is is doing is checking the node level if the node level of the document = 1 then it will sort it by NodeName, otherwise it won't sort it. This will only order the NodeLevel 1 items.
See a similar answer I posted here
After talking with Kentico support, we came up with a slightly cleaner solution:
.OrderBy(node => node.Parent.NodeOrder)
That seemed like the cleanest way to handle this, in my opinion.

Neo4j display only one node for 1 to many relationship

i'm trying to solve a problem of the 1: many relationship display in neo4j. My dataset is as below
child,desc,type,parent
1,PGD,Exchange,0
2,MSE 1,MSE,1
3,MSE 2,MSE,1
4,MSE 3,MSE,1
5,MSE 4,MSE,1
6,BRAS 1,BRAS,2
6,BRAS 1,BRAS,3
7,BRAS 2,BRAS,4
7,BRAS 2,BRAS,5
10,NPE 1,NPE,6
11,NPE 2,NPE,7
12,OLT,OLT,10
12,OLT,OLT,11
13,FDC,FDC,12
14,FDP,FDP,13
15,Cust 1,Customer,14
16,Cust 2,Customer,14
17,Cust 3,Customer,14
LOAD CSV WITH HEADERS FROM 'file:///FTTH_sample.csv' AS line
CREATE(:ftthsample
{child_id:line.child,
desc:line.desc,
type:line.type,
parent_id:line.parent});
//Relations
match (child:ftthsample),(parent:ftthsample)
where child.child_id=parent.parent_id
create (child)-[:test]->(parent)
//Query:
MATCH (child)-[childrel:test*]-(elem)-[parentrel:test*]->(parent)
WHERE elem.desc='FDP'
RETURN child,childrel,elem,parentrel
It returns a display as below.
I want the duplicate nodes to be displayed as one. Newbie with Neo4J. Can anyone of the experts help please?
This seems like an error in your graph creation query. You have a few lines in your query specifying the same node multiple times, but with multiple parents:
6,BRAS 1,BRAS,2
6,BRAS 1,BRAS,3
I'm guessing you actually want this to be a single node, with parent relationships to nodes with the given parent ids, instead of two separate nodes.
Let's adjust your import query. Instead of using a CREATE on each line, we'll use MERGE, and just on the child_id, which seems to be your primary key (maybe consider just using id instead, as a node can have an id on its own, without having to consider the context of whether it's a parent or child). We can use the ON CREATE clause after MERGE to add in the remaining properties only if the MERGE resulted in node creation (instead of matching to an existing node.
That will ensure we only have one node created per child_id.
Rather than having to rematch the child, we can use the child node we just created, match on the parent, and create the relationship.
LOAD CSV WITH HEADERS FROM 'file:///FTTH_sample.csv' AS line
MERGE(child:ftthsample {child_id:line.child})
ON CREATE SET
child.desc = line.desc,
child.type = line.type
WITH child, line.parent as parentId
MATCH (parent:ftthsample)
WHERE parent.child_id = parentId
MERGE (child)-[:test]->(parent)
Note that we haven't added line.parent as a property. It's not needed, since we only use that to create relationships, and after the relationships are there, we won't need those again.

Cypher query for creating and linking nodes from a csv file

I have a csv file generated with contents as follows
GOID GOName
GO:0007190 activation of adenylate cyclase activity
DiseaseID DiseaseName
D058490 46 XY Disorders of Sex Development
D000172 Acromegaly
D049913 ACTH-Secreting,Pituitary Adenoma
D058186 Acute Kidney Injury
D000310 Adrenal Gland Neoplasms
D000312 Adrenal Hyperplasia Congenital
C537045 Albright's hereditary osteodystrophy
D000544 Alzheimer Disease
D019969 Amphetamine-Related Disorders
D000855 Anorexia
D000860 Anoxia
D001008 Anxiety Disorders
D001169 Arthritis Experimental
D001171 Arthritis Juvenile
D001172 Arthritis Rheumatoid
D001249 Asthma
D001254 Astrocytoma
and so on.
I want to create link between GOIDs through Diseases such that one disease node is connected to two or more different GOID nodes.
My output should look like this
Load your diseases all at once as under a :Disease label.
Load all your Global data at once under a :Global label
Create another CSV file with the Global->Disease linkages, and use MERGE to create the relationships.
The relationship CSV would look like this:
goID,diseaseID
"GO:1234","D000456"
The command to read the CSV and create the relationships would look like this:
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM "file:/D:/Relationships.csv" as line
MERGE (:Global {goID: line.goID})-[:RELATIONSHIP]->(:Disease {diseaseID: line.diseaseID})
once your data is loaded, you can then query it like so:
MATCH (g:Global {goID: "GO:0007190"})-[r:RELATIONSHIP]->(d:Disease)
return g, r, d
For cases where a disease has multiple global conditions, you can find and create a relationship like so:
match (d:Disease)
match (go1:GO)-[:RELATIONSHIP]->(d)
match (go2:GO)-[:RELATIONSHIP]->(d) where go2 <> go1
create (go1)-[:RELATIONSHIP]->(go2)
create (go2)-[:RELATIONSHIP]->(go1)
Strictly speaking you don't need a bi-directional relationship, so creating the second relationship could be left out. One potential concern is if more than one disease links two global values. If that is a concern, then setting a "Disease" property on the relationship would help identify how these globals are related.

Resources