0% found this document useful (0 votes)
34 views4 pages

Neo4j Data Import with Constraints

The document contains Cypher queries that create nodes and relationships between them based on imported data. The nodes created include tenants, repositories, users, viewers, and other application components. Relationships are also created to link the nodes together, such as a tenant having repositories, users belonging to roles, and viewers belonging to repositories.

Uploaded by

Deepak Damodaran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views4 pages

Neo4j Data Import with Constraints

The document contains Cypher queries that create nodes and relationships between them based on imported data. The nodes created include tenants, repositories, users, viewers, and other application components. Relationships are also created to link the nodes together, such as a tenant having repositories, users belonging to roles, and viewers belonging to repositories.

Uploaded by

Deepak Damodaran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

CREATE CONSTRAINT ON (node:`UNIQUE IMPORT LABEL`) ASSERT (node.

`UNIQUE IMPORT ID`)


IS UNIQUE;
UNWIND [{_id:46, properties:{dbUsername:"75eec7516707087c", isSuperTenant:false,
name:"easlocal", uuid:"75eec7516707087c1d44", dbPassword:"WGjDzGcRd83OcWw",
status:"ACTIVE"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:Tenant;
UNWIND [{_id:44, properties:{sortIndex:0, name:"sandbox", description:"",
uuid:"cbe01139a38eeafba83b", status:"ACTIVE"}}, {_id:45, properties:{sortIndex:1,
name:"production", description:"", uuid:"6760bd7453fddae778e6", status:"ACTIVE"}}]
AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:Repository;
UNWIND [{_id:8, properties:{name:"Identity Provider Settings",
uuid:"d60d3a03db5ed54909f8"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:IdentityProviderSettings;
UNWIND [{_id:20, properties:{name:"Essential Editor",
uuid:"052c2f4898269e2e3701"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:Editor;
UNWIND [{_id:17, properties:{lastName:"user", firstName:"test",
isSupportAccount:false, contentApprovalForMetaModelClses:[], type:"INTERNAL",
uuid:"bd96c281ca971321627b", status:"ACTIVE"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:User;
UNWIND [{_id:0, properties:{name:"classSlotEditor", uuid:"8109091007de5f071253",
friendlyName:"Class/Slot Editor", isMandatory:false}}, {_id:1, properties:
{name:"instanceViewer", uuid:"9cecfac47515511247af", friendlyName:"Instance
Viewer", isMandatory:true}}, {_id:2, properties:{name:"instanceEditor",
uuid:"87a596e37cddf6296029", friendlyName:"Instance Editor", isMandatory:false}},
{_id:3, properties:{name:"publisher", uuid:"220637ad7783d132cb9f",
friendlyName:"Publisher", isMandatory:false}}, {_id:4, properties:
{name:"repositoryAdmin", uuid:"79aa8f270d69574f0a45", friendlyName:"Repository
Admin", isMandatory:false}}, {_id:5, properties:{name:"classSlotViewer",
uuid:"e0bad27291a6dde921b0", friendlyName:"Class/Slot Viewer", isMandatory:false}},
{_id:6, properties:{name:"dataImport", uuid:"740f0d5990b907251536",
friendlyName:"Import Data", isMandatory:false}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:RepositoryRole;
UNWIND [{_id:7, properties:{dbUsername:"9772336ca447729a", name:"mastertenant",
uuid:"9772336ca447729a61d4", dbPassword:"aDZm5IZUqSb6sFY"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:MasterTenant;
UNWIND [{_id:14, properties:{idpUuid:"00u1dutri41bZZnG20h8",
uuid:"7d085403b32a1ff02871", email:"test@[Link]"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:Account;
UNWIND [{_id:15, properties:{name:"Settings", uuid:"9e701fbc2e862f12204f",
status:"ACTIVE"}}, {_id:16, properties:{name:"Settings",
uuid:"522da09f3d10119358df", status:"ACTIVE"}}, {_id:42, properties:
{name:"Settings", uuid:"8a23eb13b7ac7fa5cbfd", status:"ACTIVE"}}, {_id:43,
properties:{name:"Settings", uuid:"d5c98a1ac5965120c972", status:"ACTIVE"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:ViewerSettings;
UNWIND [{_id:10, properties:{name:"systemAdmin", uuid:"9921008770bb9ba05548",
friendlyName:"System Administrator", isMandatory:false}}, {_id:11, properties:
{name:"systemAdminAddRemoveUser", uuid:"d97a3112797c3de44211",
friendlyName:"Add/Remove System User", isMandatory:false}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:SystemRole;
UNWIND [{_id:9, properties:{name:"Platform", uuid:"93e34b57af373e8f0343"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:Platform;
UNWIND [{_id:50, properties:{sortIndex:0, name:"viewer.1", description:"",
locked:false, uuid:"a5f91448512886639ac2", url:"[Link]
status:"ACTIVE"}}, {_id:51, properties:{sortIndex:1, name:"viewer.2",
description:"", locked:false, uuid:"5e1d4289f940771e5156", url:"[Link]
status:"ACTIVE"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:Viewer;
UNWIND [{_id:18, properties:{name:"Settings", uuid:"1d762279be8d93af74c9",
status:"ACTIVE"}}, {_id:19, properties:{name:"Settings",
uuid:"b84158150617e712ef13", status:"ACTIVE"}}, {_id:48, properties:
{name:"Settings", uuid:"5e5ea915f9c37023b109", status:"ACTIVE"}}, {_id:49,
properties:{name:"Settings", uuid:"f7448dfced80be135869", status:"ACTIVE"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n +=
[Link] SET n:RepositorySettings;
UNWIND [{start: {_id:47}, end: {_id:42}, properties:{}}, {start: {_id:47}, end:
{_id:43}, properties:{}}, {start: {_id:17}, end: {_id:15}, properties:{}}, {start:
{_id:17}, end: {_id:16}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_VIEWER_SETTINGS]->(end) SET r += [Link];
UNWIND [{start: {_id:7}, end: {_id:41}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_USER]->(end) SET r += [Link];
UNWIND [{start: {_id:47}, end: {_id:49}, properties:{}}, {start: {_id:47}, end:
{_id:48}, properties:{}}, {start: {_id:17}, end: {_id:18}, properties:{}}, {start:
{_id:17}, end: {_id:19}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_REPOSITORY_SETTINGS]->(end) SET r += [Link];
UNWIND [{start: {_id:9}, end: {_id:8}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_IDENTITY_PROVIDER_SETTINGS]->(end) SET r += [Link];
UNWIND [{start: {_id:9}, end: {_id:7}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_MASTER_TENANT]->(end) SET r += [Link];
UNWIND [{start: {_id:47}, end: {_id:10}, properties:{}}, {start: {_id:17}, end:
{_id:10}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:BELONGS_TO_SYSTEM_ROLE]->(end) SET r += [Link];
UNWIND [{start: {_id:46}, end: {_id:44}, properties:{}}, {start: {_id:46}, end:
{_id:45}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_REPOSITORY]->(end) SET r += [Link];
UNWIND [{start: {_id:46}, end: {_id:47}, properties:{}}, {start: {_id:46}, end:
{_id:17}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_USER]->(end) SET r += [Link];
UNWIND [{start: {_id:40}, end: {_id:41}, properties:{}}, {start: {_id:40}, end:
{_id:47}, properties:{}}, {start: {_id:14}, end: {_id:17}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_USER]->(end) SET r += [Link];
UNWIND [{start: {_id:9}, end: {_id:46}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_TENANT]->(end) SET r += [Link];
UNWIND [{start: {_id:46}, end: {_id:50}, properties:{}}, {start: {_id:46}, end:
{_id:51}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_VIEWER]->(end) SET r += [Link];
UNWIND [{start: {_id:49}, end: {_id:44}, properties:{}}, {start: {_id:48}, end:
{_id:45}, properties:{}}, {start: {_id:18}, end: {_id:45}, properties:{}}, {start:
{_id:19}, end: {_id:44}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:BELONGS_TO_REPOSITORY]->(end) SET r += [Link];
UNWIND [{start: {_id:9}, end: {_id:40}, properties:{}}, {start: {_id:9}, end:
{_id:14}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_ACCOUNT]->(end) SET r += [Link];
UNWIND [{start: {_id:42}, end: {_id:50}, properties:{}}, {start: {_id:43}, end:
{_id:51}, properties:{}}, {start: {_id:15}, end: {_id:51}, properties:{}}, {start:
{_id:16}, end: {_id:50}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:BELONGS_TO_VIEWER]->(end) SET r += [Link];
UNWIND [{start: {_id:9}, end: {_id:6}, properties:{}}, {start: {_id:9}, end:
{_id:0}, properties:{}}, {start: {_id:9}, end: {_id:1}, properties:{}}, {start:
{_id:9}, end: {_id:2}, properties:{}}, {start: {_id:9}, end: {_id:3}, properties:
{}}, {start: {_id:9}, end: {_id:4}, properties:{}}, {start: {_id:9}, end: {_id:5},
properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_REPOSITORY_ROLE]->(end) SET r += [Link];
UNWIND [{start: {_id:9}, end: {_id:10}, properties:{}}, {start: {_id:9}, end:
{_id:11}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:HAS_SYSTEM_ROLE]->(end) SET r += [Link];
UNWIND [{start: {_id:48}, end: {_id:5}, properties:{}}, {start: {_id:48}, end:
{_id:6}, properties:{}}, {start: {_id:48}, end: {_id:2}, properties:{}}, {start:
{_id:49}, end: {_id:1}, properties:{}}, {start: {_id:49}, end: {_id:3}, properties:
{}}, {start: {_id:49}, end: {_id:4}, properties:{}}, {start: {_id:49}, end:
{_id:0}, properties:{}}, {start: {_id:49}, end: {_id:5}, properties:{}}, {start:
{_id:49}, end: {_id:6}, properties:{}}, {start: {_id:49}, end: {_id:2}, properties:
{}}, {start: {_id:48}, end: {_id:1}, properties:{}}, {start: {_id:48}, end:
{_id:3}, properties:{}}, {start: {_id:48}, end: {_id:4}, properties:{}}, {start:
{_id:48}, end: {_id:0}, properties:{}}, {start: {_id:18}, end: {_id:2}, properties:
{}}, {start: {_id:18}, end: {_id:4}, properties:{}}, {start: {_id:19}, end:
{_id:6}, properties:{}}, {start: {_id:19}, end: {_id:1}, properties:{}}, {start:
{_id:19}, end: {_id:3}, properties:{}}, {start: {_id:19}, end: {_id:5}, properties:
{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:BELONGS_TO_REPOSITORY_ROLE]->(end) SET r += [Link];
UNWIND [{start: {_id:19}, end: {_id:0}, properties:{}}, {start: {_id:19}, end:
{_id:2}, properties:{}}, {start: {_id:19}, end: {_id:4}, properties:{}}, {start:
{_id:18}, end: {_id:6}, properties:{}}, {start: {_id:18}, end: {_id:1}, properties:
{}}, {start: {_id:18}, end: {_id:3}, properties:{}}, {start: {_id:18}, end:
{_id:5}, properties:{}}, {start: {_id:18}, end: {_id:0}, properties:{}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: [Link]._id})
CREATE (start)-[r:BELONGS_TO_REPOSITORY_ROLE]->(end) SET r += [Link];
MATCH (n:`UNIQUE IMPORT LABEL`) WITH n LIMIT 20000 REMOVE n:`UNIQUE IMPORT LABEL`
REMOVE n.`UNIQUE IMPORT ID`;
DROP CONSTRAINT ON (node:`UNIQUE IMPORT LABEL`) ASSERT (node.`UNIQUE IMPORT ID`) IS
UNIQUE;

You might also like