a_igin

neo4j_get_catalog_info_with_graph_data

Oct 10th, 2023
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. match (owner:User) - [:USER_CATALOGS] -> (catalog:Catalog)
  2. where ID(catalog)=$catalog_id
  3. optional match (catalog) <- [domain_rel:DOMAIN_OF_CATALOG] - (domains:Domain)
  4. optional match (domains) <- [subdomain_rel:SUB_DOMAIN_TO] - (sub_domain:Domain)
  5. optional match (catalog) <- [catalog_skill_rel:SKILL_OF_CATALOG] - (skill:Skill)
  6. optional match (skill) <- [level_of_skill_rel:LEVEL_OF_SKILL*..] - (skill_level:SkillLevel)
  7. optional match (skill_level) <- [input_level_of_level_rel:INPUT_LEVEL_FOR] - (other_skill_level:SkillLevel)
  8. optional match (other_skill_level) - [input_level_of_level_rel:LEVEL_OF_SKILL] -> (other_skill:Skill)
  9. UNWIND (CASE WHEN level_of_skill_rel is NULL then [null] else
  10. level_of_skill_rel end) as level_of_skill_rels
  11.  
  12. return collect(distinct domains {.*, identity: ID(domains)}) as domains,
  13. count(distinct domains) as domains_count,
  14. collect( distinct domain_rel
  15.  
  16. { identity: id(domain_rel),
  17. type: type(domain_rel),
  18. properties: properties(domain_rel),
  19. start: id(startNode(domain_rel)),
  20. end: id(endNode(domain_rel))
  21. }
  22.  
  23. ) + collect( distinct subdomain_rel
  24.  
  25. { identity: id(subdomain_rel),
  26. type: type(subdomain_rel),
  27. properties: properties(subdomain_rel),
  28. start: id(startNode(subdomain_rel)),
  29. end: id(endNode(subdomain_rel))
  30. }
  31.  
  32. ) + collect( distinct catalog_skill_rel
  33.  
  34. { identity: id(catalog_skill_rel),
  35. type: type(catalog_skill_rel),
  36. properties: properties(catalog_skill_rel),
  37. start: id(startNode(catalog_skill_rel)),
  38. end: id(endNode(catalog_skill_rel))
  39. }
  40.  
  41. ) + collect( distinct input_level_of_level_rel
  42.  
  43. { identity: id(input_level_of_level_rel),
  44. type: type(input_level_of_level_rel),
  45. properties: properties(input_level_of_level_rel),
  46. start: id(startNode(input_level_of_level_rel)),
  47. end: id(endNode(input_level_of_level_rel))
  48. }
  49.  
  50. ) + collect( distinct level_of_skill_rels
  51.  
  52. { identity: id(level_of_skill_rels),
  53. type: type(level_of_skill_rels),
  54. properties: properties(level_of_skill_rels),
  55. start: id(startNode(level_of_skill_rels)),
  56. end: id(endNode(level_of_skill_rels))
  57. }
  58.  
  59. ) as raw_relations,
  60. collect(distinct skill {.*, identity: ID(skill)}) as skills,
  61. catalog
  62. {
  63. .*,
  64. identity: ID(catalog)
  65. }
  66. ,owner
  67. {
  68. .*,
  69. identity: ID(owner)
  70. }
  71. ,
  72. collect(distinct skill_level {
  73. .*,
  74. identity: ID(skill_level),
  75. title: skill.title + ':
  76. ' + skill_level.title
  77. }
  78. ) as skill_levels
Advertisement
Add Comment
Please, Sign In to add comment