Examples of NodeInterface


Examples of info.walnutstreet.vs.ps04.p2p.ring.interfaces.NodeInterface

   
    assertEquals(node.numberOfNodes(), 1);
  }
 
  private void testOrder(Node min, Node max, int size) throws RemoteException {
    NodeInterface n = min;
    do {
      assertTrue(n.getId() < n.getNext().getId());
      assertEquals(min.getId(), n.getMinId());
      assertEquals(max.getMaxId(), max.getId());
      assertEquals(n.numberOfNodes(), size);
    } while ((n = n.getNext()).getNext() != min);

    n = max;
    do {
      assertTrue(n.getId() > n.getPrevious().getId());
    } while ((n = n.getPrevious()) != min);
   
    assertEquals(max.getNext(), min);
    assertEquals(min.getPrevious(), max);
   
  }
View Full Code Here

Examples of info.walnutstreet.vs.ps04.p2p.ring.interfaces.NodeInterface

    ft.createFingerTable();
   
    Map<Integer, NodeInterface> abc = ft.getRemoteNodes();
    Set<Integer> set = abc.keySet();
    for (Integer integer : set) {
      NodeInterface na = abc.get(integer);
      System.out.println(integer + ": " + na.getId() + " - " + na.getName());
    }
    NodeInterface searchNode = node1.lookupChord("n2");
    assertEquals(searchNode, node2);
  }
View Full Code Here

Examples of info.walnutstreet.vs.ps04.p2p.ring.interfaces.NodeInterface

   
    int maxNum = this.localNode.numberOfNodes();
    for (int i = 0; i < Math.sqrt(maxNum); i++) {
      int nextId = (this.localNode.getId() + (int)Math.pow(2, i)) % P2PFingerTable.MODULO_VALUE;
     
      NodeInterface nodeThatAlreadyExists = this.getEntry(nextId);
      if (nodeThatAlreadyExists == null) { // if the node with the id 'nextId' doesn't exists
        NodeInterface predecessorOfSearchedNextId = this.getPrevFTEntry(nextId);
        NodeInterface nodeWithIdAsNextId = null;
        if (predecessorOfSearchedNextId == null) { // no predecessor exists
          nodeWithIdAsNextId = this.localNode.lookup(nextId);
        } else { // ok, we have a predecessor in the table
          nodeWithIdAsNextId = predecessorOfSearchedNextId.lookupChord(nextId);
        }
View Full Code Here

Examples of info.walnutstreet.vs.ps04.p2p.ring.interfaces.NodeInterface

  }

  public NodeInterface getEntry(int nextId) throws RemoteException {
    Set<Integer> set = this.remoteNodes.keySet();
    for (Integer integer : set) {
      NodeInterface node = this.remoteNodes.get(integer);
      if (node.getId() == nextId)
        return node;
    }
    return null;
  }
View Full Code Here

Examples of info.walnutstreet.vs.ps04.p2p.ring.interfaces.NodeInterface

    return null;
  }
 
  private NodeInterface getPrevFTEntry(int nextid) throws RemoteException {
    Set<Integer> ids = this.remoteNodes.keySet();
    NodeInterface n = null;
   
    for (Integer integer : ids) {
      NodeInterface node = this.remoteNodes.get(integer);
      if (node.getId() < nextid)
        n = node;
      else
        break;
    }
   
View Full Code Here

Examples of info.walnutstreet.vs.ps04.p2p.ring.interfaces.NodeInterface

  /* (non-Javadoc)
   * @see info.walnutstreet.vs.ps04.p2p.ring.interfaces.NodeInterface#lookupChord(int)
   */
  @Override
  public NodeInterface lookupChord(int nextId) throws RemoteException {
    NodeInterface node = this.fingerTable.getEntry(nextId);
    if (node != null) {
      return node;
    }
    return this.lookup(nextId);
  }
View Full Code Here

Examples of org.structr.core.graph.NodeInterface

  // ----- private methods -----
  private WebSocketMessage getMessageForEvent(final SecurityContext securityContext, final ModificationEvent modificationEvent) throws FrameworkException {

    if (modificationEvent.isNode()) {

      final NodeInterface node = (NodeInterface) modificationEvent.getGraphObject();

      if (modificationEvent.isDeleted()) {

        final WebSocketMessage message = createMessage("DELETE");

        message.setId(modificationEvent.getRemovedProperties().get(GraphObject.id));

        return message;
      }

      if (modificationEvent.isCreated()) {

        final WebSocketMessage message = createMessage("CREATE");

        message.setGraphObject(node);
        message.setResult(Arrays.asList(new GraphObject[]{node}));

        return message;
      }

      if (modificationEvent.isModified()) {

        final WebSocketMessage message = createMessage("UPDATE");

        message.setGraphObject(node);
        message.setResult(Arrays.asList(new GraphObject[]{node}));
        message.setId(node.getUuid());
        message.getModifiedProperties().addAll(modificationEvent.getModifiedProperties().keySet());
        message.getRemovedProperties().addAll(modificationEvent.getRemovedProperties().keySet());
        message.setNodeData(modificationEvent.getData(securityContext));

        return message;
      }

    } 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);
View Full Code Here

Examples of org.structr.core.graph.NodeInterface

  public RestMethodResult doPost(final Map<String, Object> propertySet) throws FrameworkException {

    if (isNode) {

      final App app         = StructrApp.getInstance(securityContext);
      NodeInterface newNode = null;

      newNode = createNode(propertySet);

      final RestMethodResult result = new RestMethodResult(HttpServletResponse.SC_CREATED);
      if (newNode != null) {

        result.addHeader("Location", buildLocationHeader(newNode));
        result.addContent(newNode);
      }

      result.serializeAsPrimitiveArray(true);
     
      // finally: return 201 Created
      return result;

    } else {

      final App app                         = StructrApp.getInstance(securityContext);
      final Relation template               = getRelationshipTemplate();
      final ErrorBuffer errorBuffer         = new ErrorBuffer();

      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

Examples of org.structr.core.graph.NodeInterface

      return null;
    }

    final PropertyMap properties             = PropertyMap.databaseTypeToJavaType(securityContext, nodeType, receivedNodeData.getProperties());
    final String uuid                        = receivedNodeData.getSourceNodeId();
    NodeInterface newOrExistingNode          = null;

    final NodeInterface existingCandidate = app.nodeQuery().and(GraphObject.id, uuid).includeDeletedAndHidden().getFirst();
    if (existingCandidate != null && existingCandidate instanceof NodeInterface) {

      newOrExistingNode = (NodeInterface) existingCandidate;

      // merge properties
View Full Code Here

Examples of org.structr.core.graph.NodeInterface

    if (targetStartNodeId != null && targetEndNodeId != null) {

      // Get new start and end node
      final SecurityContext securityContext = SecurityContext.getSuperUserInstance();
      final NodeInterface targetStartNode   = (NodeInterface) app.get(targetStartNodeId);
      final NodeInterface targetEndNode     = (NodeInterface) app.get(targetEndNodeId);
      final String typeName                 = receivedRelationshipData.getType();
      final Class relType                   = config.getRelationshipEntityClass(typeName);

      if (targetStartNode != null && targetEndNode != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.