Initializes all relation properties of the given node state with empty
collections.

@param types
The types.
@param nodeState
The state of the entity.
358877
private void initializeEntity(Collection<? extends TypeMetadata> types, NodeState nodeState) {
        for (TypeMetadata type : types) {
            Collection<TypeMetadata> superTypes = type.getSuperTypes();
            initializeEntity(superTypes, nodeState);
            for (MethodMetadata<?, ?> methodMetadata : type.getProperties()) {
                if (methodMetadata instanceof AbstractRelationPropertyMethodMetadata) {
                    AbstractRelationPropertyMethodMetadata<?> relationPropertyMethodMetadata = (AbstractRelationPropertyMethodMetadata) methodMetadata;
                    RelationTypeMetadata<RelationshipMetadata<RemoteRelationshipType>> relationshipMetadata = relationPropertyMethodMetadata
                            .getRelationshipMetadata();
                    RemoteRelationshipType relationshipType = relationshipMetadata.getDatastoreMetadata().getDiscriminator();
                    RelationTypeMetadata.Direction direction = relationPropertyMethodMetadata.getDirection();
                    RemoteDirection remoteDirection;
                    switch (direction) {
                    case FROM:
                        remoteDirection = RemoteDirection.OUTGOING;
                        break;
                    case TO:
                        remoteDirection = RemoteDirection.INCOMING;
                        break;
                    default:
                        throw new XOException("Unsupported direction: " + direction);
                    }
                    if (nodeState.getRelationships(remoteDirection, relationshipType) == null) {
                        nodeState.setRelationships(remoteDirection, relationshipType, new StateTracker<>(new LinkedHashSet<>()));
                    }
                }
            }
        }
    }
818347
function Node(name, type) {
      this.name = name;
      this.type = type;

      if (type === 1) {
        this.attributes = [];
        this.attributes.map = {};
      }
    }
692434
public void setNodeType(NodeType type) {
        addField(ConfigureNodeFields.node_type, FormField.Type.list_single);
        setAnswer(ConfigureNodeFields.node_type.getFieldName(), getListSingle(type.toString()));
    }
849905
@Override
    public void initialize(Map<String, Object> puProperties)
    {
        reader = new CouchbaseEntityReader(kunderaMetadata);
        setExternalProperties(puProperties);
        initializePropertyReader();
        PersistenceUnitMetadata pum = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadata(getPersistenceUnit());

        Properties pumProps = pum.getProperties();

        if (puProperties != null)
        {
            pumProps.putAll(puProperties);
        }

        String host = pumProps.getProperty("kundera.nodes");
        String keyspace = pumProps.getProperty("kundera.keyspace");

        if (host == null)
        {
            throw new KunderaException("Hostname/IP is null.");
        }

        if (keyspace == null)
        {
            throw new KunderaException("kundera.keyspace is null.");
        }
        cluster = CouchbaseCluster.create(splitHostNames(host));
        String password = ((CouchbasePropertyReader) propertyReader).csmd.getBucketProperty("bucket.password");
        bucket = CouchbaseBucketUtils.openBucket(cluster, keyspace, password);

    }
1234868
private static void addRelationPropertyDefinitions(RelationshipTypeDefinitionImpl type) {

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.SOURCE_ID,
                "Source",
                "Source",
                PropertyType.ID,
                Cardinality.SINGLE,
                Updatability.ONCREATE,
                false,
                true));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.TARGET_ID,
                "Target",
                "Target",
                PropertyType.ID,
                Cardinality.SINGLE,
                Updatability.ONCREATE,
                false,
                true));

    }
154263
public void setKeyTypes(java.util.Collection<String> keyTypes) {
        if (keyTypes == null) {
            this.keyTypes = null;
            return;
        }

        this.keyTypes = new java.util.ArrayList<String>(keyTypes);
    }
468074
void init(List<EllipseInfo> ellipses) {
		nodes.resize(ellipses.size());
		clusters.reset();

		for (int i = 0; i < ellipses.size(); i++) {
			Node n = nodes.get(i);
			n.connections.reset();
			n.which = i;
			n.cluster = -1;
		}

		nn.setPoints(ellipses,true);
	}
933326
public boolean hasAncestorOfType( Set<Type> types ) {
        PlanNode node = this.parent;
        while (node != null) {
            if (types.contains(node.getType())) return true;
            node = node.getParent();
        }
        return false;
    }
1261140
public void setTypes(com.google.api.ads.admanager.axis.v201902.LabelType[] types) {
        this.types = types;
    }
1026816
private void assignNodeLinkProperty(Node node, Relation relation, Node childNode)
    {
        // Construct Node Link for this relationship
        NodeLink nodeLink = new NodeLink(node.getNodeId(), childNode.getNodeId());
        setLink(node, relation, childNode, nodeLink);
    }
874222
public void visit(ASTNode[] nodes, final SourceUnit source) {
        if (nodes.length != 2 || !(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof ClassNode)) {
            source.getErrorCollector().addError(
                    new SyntaxErrorMessage(new SyntaxException("@Category can only be added to a ClassNode but got: " + (nodes.length==2?nodes[1]:"nothing"),
                        nodes[0].getLineNumber(), nodes[0].getColumnNumber()), source));
        }

        AnnotationNode annotation = (AnnotationNode) nodes[0];
        ClassNode parent = (ClassNode) nodes[1];

        ClassNode targetClass = getTargetClass(source, annotation);
        thisExpression.setType(targetClass);

        final LinkedList<Set<String>> varStack = new LinkedList<Set<String>>();
        if (!ensureNoInstanceFieldOrProperty(source, parent)) return;

        Set<String> names = new HashSet<String>();
        for (FieldNode field : parent.getFields()) {
            names.add(field.getName());
        }
        for (PropertyNode field : parent.getProperties()) {
            names.add(field.getName());
        }
        varStack.add(names);

        final Reference parameter = new Reference();
        final ClassCodeExpressionTransformer expressionTransformer = new ClassCodeExpressionTransformer() {
            protected SourceUnit getSourceUnit() {
                return source;
            }

            private void addVariablesToStack(Parameter[] params) {
                Set<String> names = new HashSet<String>();
                names.addAll(varStack.getLast());
                for (Parameter param : params) {
                    names.add(param.getName());
                }
                varStack.add(names);
            }

            @Override
            public void visitCatchStatement(CatchStatement statement) {
                varStack.getLast().add(statement.getVariable().getName());
                super.visitCatchStatement(statement);
                varStack.getLast().remove(statement.getVariable().getName());
            }

            @Override
            public void visitMethod(MethodNode node) {
                addVariablesToStack(node.getParameters());
                super.visitMethod(node);
                varStack.removeLast();
            }

            @Override
            public void visitBlockStatement(BlockStatement block) {
                Set<String> names = new HashSet<String>();
                names.addAll(varStack.getLast());
                varStack.add(names);
                super.visitBlockStatement(block);
                varStack.remove(names);
            }

            @Override
            public void visitClosureExpression(ClosureExpression ce) {
                addVariablesToStack(ce.getParameters());
                super.visitClosureExpression(ce);
                varStack.removeLast();
            }

            @Override
            public void visitDeclarationExpression(DeclarationExpression expression) {
                if (expression.isMultipleAssignmentDeclaration()) {
                    TupleExpression te = expression.getTupleExpression();
                    List<Expression> list = te.getExpressions();
                    for (Expression arg : list) {
                        VariableExpression ve = (VariableExpression) arg;
                        varStack.getLast().add(ve.getName());
                    }
                } else {
                    VariableExpression ve = expression.getVariableExpression();
                    varStack.getLast().add(ve.getName());
                }
                super.visitDeclarationExpression(expression);
            }

            @Override
            public void visitForLoop(ForStatement forLoop) {
                Expression exp = forLoop.getCollectionExpression();
                exp.visit(this);
                Parameter loopParam = forLoop.getVariable();
                if (loopParam != null) {
                    varStack.getLast().add(loopParam.getName());
                }
                super.visitForLoop(forLoop);
            }

            @Override
            public void visitExpressionStatement(ExpressionStatement es) {
                // GROOVY-3543: visit the declaration expressions so that declaration variables get added on the varStack
                Expression exp = es.getExpression();
                if (exp instanceof DeclarationExpression) {
                    exp.visit(this);
                }
                super.visitExpressionStatement(es);
            }

            @Override
            public Expression transform(Expression exp) {
                if (exp instanceof VariableExpression) {
                    VariableExpression ve = (VariableExpression) exp;
                    if (ve.getName().equals("this"))
                        return thisExpression;
                    else {
                        if (!varStack.getLast().contains(ve.getName())) {
                            return new PropertyExpression(thisExpression, ve.getName());
                        }
                    }
                } else if (exp instanceof PropertyExpression) {
                    PropertyExpression pe = (PropertyExpression) exp;
                    if (pe.getObjectExpression() instanceof VariableExpression) {
                        VariableExpression vex = (VariableExpression) pe.getObjectExpression();
                        if (vex.isThisExpression()) {
                            pe.setObjectExpression(thisExpression);
                            return pe;
                        }
                    }
                } else if (exp instanceof ClosureExpression) {
                    ClosureExpression ce = (ClosureExpression) exp;
                    ce.getVariableScope().putReferencedLocalVariable((Parameter) parameter.get());
                    Parameter[] params = ce.getParameters();
                    if (params == null) {
                        params = Parameter.EMPTY_ARRAY;
                    } else if (params.length == 0) {
                        params = new Parameter[]{
                                new Parameter(ClassHelper.OBJECT_TYPE, "it")
                        };
                    }
                    addVariablesToStack(params);
                    ce.getCode().visit(this);
                    varStack.removeLast();
                }
                return super.transform(exp);
            }
        };

        for (MethodNode method : parent.getMethods()) {
            if (!method.isStatic()) {
                method.setModifiers(method.getModifiers() | Opcodes.ACC_STATIC);
                final Parameter[] origParams = method.getParameters();
                final Parameter[] newParams = new Parameter[origParams.length + 1];
                Parameter p = new Parameter(targetClass, "$this");
                p.setClosureSharedVariable(true);
                newParams[0] = p;
                parameter.set(p);
                System.arraycopy(origParams, 0, newParams, 1, origParams.length);
                method.setParameters(newParams);

                expressionTransformer.visitMethod(method);
            }
        }
        new VariableScopeVisitor(source, true).visitClass(parent);
    }
804421
private void logNodeTypes(final NodeType... nodeTypes) {

        if(LOG.isDebugEnabled()){
            StringBuilder buf = new StringBuilder(32);
            buf.append("[\n");
            for(NodeType nt : nodeTypes){
                buf.append(nt.getName()).append(" > ");
                for(NodeType st : nt.getSupertypes()){
                    buf.append(st.getName()).append(", ");
                }
                buf.append('\n');
                for(PropertyDefinition pd : nt.getPropertyDefinitions()){
                    buf.append("\t").append(pd.getName()).append(" (")
                       .append(PropertyType.nameFromValue(pd.getRequiredType()))
                       .append(")\n");
                }
            }
            buf.append(']');
            LOG.debug("Registered NodeTypes: {}",buf.toString());
        }
    }
1177479
private void init(final SecurityContext securityContext, final Class type, final Field field, final String path) throws FrameworkException {

		final QueryConfig config = getConfig(path);

		config.handleTypeArguments(securityContext, type, field.getArguments());

		final SelectionSet selectionSet = field.getSelectionSet();
		if (selectionSet != null) {

			for (final Selection selection : selectionSet.getSelections()) {

				if (selection instanceof Field) {

					final Field childField      = (Field)selection;
					final SelectionSet childSet = childField.getSelectionSet();
					final PropertyKey key       = StructrApp.key(type, childField.getName());
					final Class relatedType     = key.relatedType() != null ? key.relatedType() : type;

					// add field to property set
					config.addPropertyKey(key);
					config.handleFieldArguments(securityContext, relatedType, field, childField);

					// recurse
					if (childSet != null) {

						init(securityContext, relatedType, childField, path + "/" + childField.getName());
					}
				}
			}
		}
	}
1053442
private Boolean constraintsExistsForRelationship(String type, List<String> propertyNames) {
        Schema schema = db.schema();

        for (ConstraintDefinition constraintDefinition : Iterables.asList(schema.getConstraints(RelationshipType.withName(type)))) {
            List<String> properties = Iterables.asList(constraintDefinition.getPropertyKeys());

            if (properties.equals(propertyNames)) {
                return true;
            }
        }

        return false;
    }
43692
public GrRelation createRelation(String type, GrNode startNode, GrNode endNode) {
		return this.resultHandler.getLocalElements().createRelation(type, startNode, endNode);
	}
54769
private function initRelations() {
    if ($this->relations == null) {
      $this->relations = [];
      $this->relations['byrole'] = [];
      $this->relations['bytype'] = [];

      $relations = $this->getRelations();
      foreach ($relations as $relation) {
        $this->relations['byrole'][$relation->getOtherRole()] = $relation;
        $otherType = $relation->getOtherType();
        if (!isset($this->relations['bytype'][$otherType])) {
          $this->relations['bytype'][$otherType] = [];
        }
        $this->relations['bytype'][$otherType][] = $relation;
        $this->relations['bytype'][$this->persistenceFacade->getSimpleType($otherType)][] = $relation;
      }
    }
  }
1353467
private void initializeDependentKeys() {
        visit(new Visitor<NodeT>() {
            @Override
            public void visitNode(NodeT node) {
                if (node.dependencyKeys().isEmpty()) {
                    return;
                }

                String dependentKey = node.key();
                for (String dependencyKey : node.dependencyKeys()) {
                    nodeTable.get(dependencyKey)
                            .addDependent(dependentKey);
                }
            }

            @Override
            public  void visitEdge(String fromKey, String toKey, EdgeType edgeType) {
                if (edgeType == EdgeType.BACK) {
                    throw new IllegalStateException("Detected circular dependency: " + findPath(fromKey, toKey));
                }
            }
        });
    }