Skip to content

Commit

Permalink
Support relationship constraints in Data Collector.
Browse files Browse the repository at this point in the history
Also add tests for all enterprise constraints.
  • Loading branch information
sherfert committed Mar 14, 2019
1 parent 873a0b4 commit 7d78c87
Showing 1 changed file with 19 additions and 5 deletions.
Expand Up @@ -44,6 +44,7 @@
import org.neo4j.kernel.api.SilentTokenNameLookup; import org.neo4j.kernel.api.SilentTokenNameLookup;
import org.neo4j.register.Register; import org.neo4j.register.Register;
import org.neo4j.register.Registers; import org.neo4j.register.Registers;
import org.neo4j.storageengine.api.EntityType;


/** /**
* The Graph Counts section holds all data that is available form the counts store, plus metadata * The Graph Counts section holds all data that is available form the counts store, plus metadata
Expand Down Expand Up @@ -178,16 +179,29 @@ private static List<Map<String,Object>> constraints( TokenRead tokens, SchemaRea
while ( iterator.hasNext() ) while ( iterator.hasNext() )
{ {
ConstraintDescriptor constraint = iterator.next(); ConstraintDescriptor constraint = iterator.next();

EntityType entityType = constraint.schema().entityType();
Map<String,Object> data = new HashMap<>(); Map<String,Object> data = new HashMap<>();


int labelId = constraint.schema().getEntityTokenIds()[0];
data.put( "label", anonymizer.label( tokenLookup.labelGetName( labelId ), labelId ) );
data.put( "properties", map( constraint.schema().getPropertyIds(), data.put( "properties", map( constraint.schema().getPropertyIds(),
id -> anonymizer.propertyKey( tokenLookup.propertyKeyGetName( id ), id ) ) ); id -> anonymizer.propertyKey( tokenLookup.propertyKeyGetName( id ), id ) ) );
data.put( "type", constraintType( constraint ) ); data.put( "type", constraintType( constraint ) );
int entityTokenId = constraint.schema().getEntityTokenIds()[0];


constraints.add( data ); switch ( entityType )
{
case NODE:
data.put( "label", anonymizer.label( tokenLookup.labelGetName( entityTokenId ), entityTokenId ) );
constraints.add( data );
break;
case RELATIONSHIP:
data.put( "relationshipType", anonymizer.relationshipType( tokenLookup.relationshipTypeGetName( entityTokenId ), entityTokenId ) );
constraints.add( data );
break;
case GRAPH:
// Ignore
break;
default:
}
} }


return constraints; return constraints;
Expand Down

0 comments on commit 7d78c87

Please sign in to comment.