Package org.structr.core.graph

Examples of org.structr.core.graph.RelationshipInterface


      }

    } else {

      // handle relationship
      final RelationshipInterface relationship = (RelationshipInterface) modificationEvent.getGraphObject();
      final RelationshipType relType = modificationEvent.getRelationshipType();

      // only interested in CONTAINS relationships
      if (!("CONTAINS".equals(relType.name()))) {
        return null;
      }

      if (modificationEvent.isDeleted()) { // && "CONTAINS".equals(relType.name())) {

        final WebSocketMessage message = createMessage("REMOVE_CHILD");

        message.setNodeData("parentId", relationship.getSourceNodeId());
        message.setId(relationship.getTargetNodeId());

        return message;
      }

      if (modificationEvent.isCreated()) {

        final WebSocketMessage message = new WebSocketMessage();
        final NodeInterface startNode = relationship.getSourceNode();
        final NodeInterface endNode = relationship.getTargetNode();

        message.setResult(Arrays.asList(new GraphObject[]{endNode}));
        message.setId(endNode.getUuid());
        message.setNodeData("parentId", startNode.getUuid());

        message.setCommand("APPEND_CHILD");

        if (endNode instanceof DOMNode) {

          org.w3c.dom.Node refNode = ((DOMNode) endNode).getNextSibling();
          if (refNode != null) {

            message.setCommand("INSERT_BEFORE");
            message.setNodeData("refId", ((AbstractNode) refNode).getUuid());
          }

        } else if (endNode instanceof User) {

          message.setCommand("APPEND_USER");
          message.setNodeData("refId", startNode.getUuid());
        }

        return message;
      }

      if (modificationEvent.isModified()) {

        final WebSocketMessage message = createMessage("UPDATE");

        message.setGraphObject(relationship);
        message.setId(relationship.getUuid());
        message.getModifiedProperties().addAll(modificationEvent.getModifiedProperties().keySet());
        message.getRemovedProperties().addAll(modificationEvent.getRemovedProperties().keySet());
        message.setNodeData(modificationEvent.getData(securityContext));

        final PropertyMap relProperties = relationship.getProperties();
        final NodeInterface startNode = relationship.getSourceNode();
        final NodeInterface endNode = relationship.getTargetNode();

        relProperties.put(new StringProperty("startNodeId"), startNode.getUuid());
        relProperties.put(new StringProperty("endNodeId"), endNode.getUuid());

        final Map<String, Object> properties = PropertyMap.javaTypeToInputType(securityContext, relationship.getClass(), relProperties);

        message.setRelData(properties);

        return message;
      }
View Full Code Here


      if (template != null) {

        final NodeInterface sourceNode        = identifyStartNode(template, propertySet);
        final NodeInterface targetNode        = identifyEndNode(template, propertySet);
        final PropertyMap properties          = PropertyMap.inputTypeToJavaType(securityContext, entityClass, propertySet);
        RelationshipInterface newRelationship = null;

        if (sourceNode == null) {
          errorBuffer.add(entityClass.getSimpleName(), new EmptyPropertyToken(template.getSourceIdProperty()));
        }
View Full Code Here

      final String typeName                 = receivedRelationshipData.getType();
      final Class relType                   = config.getRelationshipEntityClass(typeName);

      if (targetStartNode != null && targetEndNode != null) {

        final RelationshipInterface existingCandidate = app.relationshipQuery().and(GraphObject.id, uuid).includeDeletedAndHidden().getFirst();
        final PropertyMap properties = PropertyMap.databaseTypeToJavaType(securityContext, relType, receivedRelationshipData.getProperties());

        if (existingCandidate != null) {

          // merge properties?
View Full Code Here

          this.size = ((File)node).getSize();
        }

      } else {

        final RelationshipInterface rel = syncable.getSyncRelationship();
        this.id           = rel.getUuid();
        this.name         = rel.getRelType().name();
        this.type         = rel.getClass().getSimpleName();
        this.node         = false;
      }
    }
  }
View Full Code Here

  @Override
  public PropertyMap getGroupedProperties(SecurityContext securityContext, GraphObject source) {

    if(source instanceof AbstractRelationship) {

      RelationshipInterface rel = (RelationshipInterface)source;
      NodeInterface startNode   = rel.getSourceNode();

      return super.getGroupedProperties(securityContext, startNode);
    }

    return null;
View Full Code Here

    final Object value = serverConnection.getValue(key + "Rels");
    if (value instanceof List) {

      final List<RelationshipInterface> relationships = (List<RelationshipInterface>)value;
      final RelationshipInterface relationship        = relationships.get(nodeIndex);

      serverConnection.send(new RelationshipDataContainer(relationship, nodeIndex));
    }
  }
View Full Code Here

          // do migration of our own ID properties (and only our own!)
          if (rel.hasProperty("uuid") && rel.getProperty("uuid") instanceof String && !rel.hasProperty("id")) {

            try {
              final RelationshipInterface relInterface = relFactory.instantiate(rel);
              final String uuid = relInterface.getProperty(uuidProperty);

              if (uuid != null) {
                relInterface.setProperty(GraphObject.id, uuid);
                relInterface.removeProperty(uuidProperty);
                actualRelCount++;
                hasChanges = true;
              }

            } catch (Throwable t) {
View Full Code Here

  @Override
  public PropertyMap getGroupedProperties(SecurityContext securityContext, GraphObject source) {

    if(source instanceof RelationshipInterface) {

      RelationshipInterface rel = (RelationshipInterface)source;
      NodeInterface end         = rel.getTargetNode();

      return super.getGroupedProperties(securityContext, end);
    }

    return null;
View Full Code Here

TOP

Related Classes of org.structr.core.graph.RelationshipInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.