Package org.jboss.dna.graph

Examples of org.jboss.dna.graph.Location


            int depth = cache.getDepthForLoadingNodes();
            if (depth == 1) {
                // Then read the node from the store ...
                org.jboss.dna.graph.Node persistentNode = cache.store.getNodeAt(getLocation());
                // Check the actual location ...
                Location actualLocation = persistentNode.getLocation();
                if (!this.location.equals(actualLocation)) {
                    // The actual location is changed, so update it ...
                    this.location = actualLocation;
                }
                // Update the persistent information ...
                cache.nodeOperations.materialize(persistentNode, this);
            } else {
                // Then read the node from the store ...
                Subgraph subgraph = cache.store.getSubgraphOfDepth(depth).at(getLocation());
                Location actualLocation = subgraph.getLocation();
                if (!this.location.equals(actualLocation)) {
                    // The actual location is changed, so update it ...
                    this.location = actualLocation;
                }
                // Update the persistent information ...
View Full Code Here


                if (this.isRoot()) return;
                // This must be the root ...
                newPath = cache.pathFactory.createRootPath();
                assert this.isRoot();
            }
            Location newLocation = this.location.with(newPath);
            if (newLocation != this.location) {
                Location oldLocation = this.location;
                this.location = newLocation;
                cache.nodeOperations.postUpdateLocation(this, oldLocation);
            }

            if (isLoaded() && childrenByName != cache.NO_CHILDREN) {
View Full Code Here

            cache.nodeOperations.preCopy(this, parent);

            Name childName = child.getName();
            // Figure out the name and SNS of the new copy ...
            List<Node<Payload, PropertyPayload>> currentChildren = parent.childrenByName.get(childName);
            Location copyLocation = Location.create(cache.pathFactory.create(parent.getPath(),
                                                                             childName,
                                                                             currentChildren.size() + 1));

            // Perform the copy ...
            cache.operations.copy(child.getLocation()).to(copyLocation);
View Full Code Here

            load();

            // Figure out the name and SNS of the new copy ...
            List<Node<Payload, PropertyPayload>> currentChildren = childrenByName.get(name);
            Path newPath = cache.pathFactory.create(path, name, currentChildren.size() + 1);
            Location newChild = idProperties != null && !idProperties.isEmpty() ? Location.create(newPath, idProperties) : Location.create(newPath);

            // Create the properties ...
            Map<Name, PropertyInfo<PropertyPayload>> newProperties = new HashMap<Name, PropertyInfo<PropertyPayload>>();
            if (idProperties != null) {
                for (Property idProp : idProperties) {
                    PropertyInfo<PropertyPayload> info = new PropertyInfo<PropertyPayload>(idProp, idProp.isMultiple(),
                                                                                           Status.NEW, null);
                    newProperties.put(info.getName(), info);
                }
            }
            if (remainingProperties != null) {
                for (Property property : remainingProperties) {
                    PropertyInfo<PropertyPayload> info2 = new PropertyInfo<PropertyPayload>(property, property.isMultiple(),
                                                                                            Status.NEW, null);
                    newProperties.put(info2.getName(), info2);
                }
            }

            // Notify before the addition ...
            cache.nodeOperations.preCreateChild(this, newPath.getLastSegment(), newProperties);

            // Record the current state before any changes ...
            Status statusBefore = this.status;
            boolean changedBelowBefore = this.changedBelow;

            // Add the child to the parent ...
            Node<Payload, PropertyPayload> child = cache.createNode(this, cache.idFactory.create(), newChild);
            child.markAsNew(); // marks parent as changed
            if (childrenByName == cache.NO_CHILDREN) {
                childrenByName = Multimaps.newLinkedListMultimap();
            }
            childrenByName.put(name, child);

            // Set the properties on the new node, but in a private backdoor way ...
            assert child.properties == null;
            child.properties = newProperties;
            child.childrenByName = cache.NO_CHILDREN;

            try {
                // The node has been changed, so try notifying before we record the creation (which can't be undone) ...
                cache.nodeOperations.postCreateChild(this, child, child.properties);

                // Notification was fine, so now do the create ...
                Graph.Create<Graph.Batch> create = cache.operations.create(newChild.getPath());
                if (!child.properties.isEmpty()) {
                    // Process the property infos (in case some were added during the pre- or post- operations ...
                    for (PropertyInfo<PropertyPayload> property : child.properties.values()) {
                        create.with(property.getProperty());
                    }
View Full Code Here

            public NodeId create() {
                return new NodeId(++nextId);
            }
        };
        // Create the root node ...
        Location rootLocation = Location.create(pathFactory.createRootPath());
        NodeId rootId = idFactory.create();
        this.root = createNode(null, rootId, rootLocation);
        this.nodes.put(rootId, root);

        // Create the batch operations ...
View Full Code Here

                        // Add the children and properties in the lowest cached node ...
                        Path previousPath = null;
                        Node<Payload, PropertyPayload> topNode = node;
                        Node<Payload, PropertyPayload> previousNode = node;
                        for (org.jboss.dna.graph.Node persistentNode : batchResults) {
                            Location location = persistentNode.getLocation();
                            Path path = location.getPath();
                            if (path.isRoot()) {
                                previousNode = root;
                                root.location = location;
                            } else {
                                if (path.getParent().equals(previousPath)) {
View Full Code Here

        authorizer.checkPermissions(nodeToMove.getParent(), Action.REMOVE);

        // Perform the move operation, but use a batch so that we can read the latest list of children ...
        Results results = store.batch().move(nodeToMove).as(newName).into(newParentPath).execute();
        MoveBranchRequest moveRequest = (MoveBranchRequest)results.getRequests().get(0);
        Location locationAfter = moveRequest.getActualLocationAfter();

        // Find the parent node in the session ...
        Node<Payload, PropertyPayload> parent = this.findNodeWith(locationAfter.getPath().getParent(), false);
        if (parent != null && parent.isLoaded()) {
            // Update the children to make them match the latest snapshot from the store ...
            parent.synchronizeWithNewlyPersistedNode(locationAfter);
        }
    }
View Full Code Here

        // but use a batch so that we can read the latest list of children ...
        Results results = store.batch().copy(source).fromWorkspace(sourceWorkspace).to(destination).execute();

        // Find the copy request to get the actual location of the copy ...
        CopyBranchRequest request = (CopyBranchRequest)results.getRequests().get(0);
        Location locationOfCopy = request.getActualLocationAfter();

        // Find the parent node in the session ...
        Node<Payload, PropertyPayload> parent = this.findNodeWith(locationOfCopy.getPath().getParent(), false);
        if (parent != null && parent.isLoaded()) {
            // Update the children to make them match the latest snapshot from the store ...
            parent.synchronizeWithNewlyPersistedNode(locationOfCopy);
        }
    }
View Full Code Here

        // Now execute these two operations ...
        Results results = batch.execute();

        // Find the copy request to get the actual location of the copy ...
        CloneBranchRequest request = (CloneBranchRequest)results.getRequests().get(0);
        Location locationOfCopy = request.getActualLocationAfter();

        // Remove from the session all of the nodes that were removed as part of this clone ...
        for (Location removed : request.getRemovedNodes()) {
            Node<Payload, PropertyPayload> removedNode = findNodeWith(removed.getPath(), false);
            if (removedNode != null) removedNode.remove(false);
        }

        // Find the parent node in the session ...
        Node<Payload, PropertyPayload> parent = this.findNodeWith(locationOfCopy.getPath().getParent(), false);
        if (parent != null && parent.isLoaded()) {
            // Update the children to make them match the latest snapshot from the store ...
            parent.synchronizeWithNewlyPersistedNode(locationOfCopy);
        }
    }
View Full Code Here

                String path = snapshot.getLocation().getPath().getString(registry);
                maxLength = Math.max(maxLength, path.length());
            }
            StringBuilder sb = new StringBuilder();
            for (Snapshot<PropertyPayload> snapshot : this) {
                Location location = snapshot.getLocation();
                sb.append(StringUtil.justifyLeft(location.getPath().getString(registry), maxLength, ' '));
                // Append the node identifier ...
                sb.append(StringUtil.justifyRight(snapshot.getId().toString(), 10, ' '));
                // Append the various state flags
                if (snapshot.isChanged()) sb.append(" (*)");
                else if (!snapshot.isLoaded()) sb.append(" (-)");
                else sb.append("    ");
                // Append the location's identifier properties ...
                if (location.hasIdProperties()) {
                    sb.append("  ");
                    if (location.getIdProperties().size() == 1 && location.getUuid() != null) {
                        sb.append(location.getUuid());
                    } else {
                        boolean first = true;
                        sb.append('[');
                        for (Property property : location) {
                            sb.append(property.getString(registry));
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.Location

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.