Exemple #1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private org.neo4j.graphdb.schema.IndexDefinition descriptorToDefinition(final org.neo4j.internal.kernel.api.TokenRead tokenRead, org.neo4j.internal.kernel.api.IndexReference index)
        private IndexDefinition DescriptorToDefinition(TokenRead tokenRead, IndexReference index)
        {
            try
            {
                SchemaDescriptor schema          = index.Schema();
                int[]            entityTokenIds  = Schema.EntityTokenIds;
                bool             constraintIndex = index.Unique;
                string[]         propertyNames   = PropertyNameUtils.GetPropertyKeys(tokenRead, index.Properties());
                switch (Schema.entityType())
                {
                case NODE:
                    Label[] labels = new Label[entityTokenIds.Length];
                    for (int i = 0; i < labels.Length; i++)
                    {
                        labels[i] = label(tokenRead.NodeLabelName(entityTokenIds[i]));
                    }
                    return(new IndexDefinitionImpl(_actions, index, labels, propertyNames, constraintIndex));

                case RELATIONSHIP:
                    RelationshipType[] relTypes = new RelationshipType[entityTokenIds.Length];
                    for (int i = 0; i < relTypes.Length; i++)
                    {
                        relTypes[i] = withName(tokenRead.RelationshipTypeName(entityTokenIds[i]));
                    }
                    return(new IndexDefinitionImpl(_actions, index, relTypes, propertyNames, constraintIndex));

                default:
                    throw new System.ArgumentException("Cannot create IndexDefinition for " + Schema.entityType() + " entity-typed schema.");
                }
            }
            catch (KernelException e)
            {
                throw new Exception(e);
            }
        }