Package org.jboss.dna.graph

Examples of org.jboss.dna.graph.Location


        for (Projection projection : projections) {
            // Create for all of the top-level nodes ...
            for (Path path : projection.getTopLevelPathsInRepository(pathFactory)) {
                if (path.isRoot()) continue;
                // Create ProxyNodes for each corresponding path-in-source ...
                Location inRepository = Location.create(path);
                ProxyNode previous = null;
                for (Path pathInSource : projection.getPathsInSource(path, pathFactory)) {
                    Location inSource = Location.create(pathInSource);
                    ProxyNode proxy = new ProxyNode(projection, inSource, inRepository);
                    if (previous == null) {
                        previous = proxy;
                        proxyNodesByPath.put(path, proxy);
                    } else {
                        previous.add(proxy);
                    }
                }
                // Walk up the in-repository path to create the placeholder nodes ...
                ProjectedNode child = previous;
                while (!path.isRoot()) {
                    // Create a projected node for the parent of this path ...
                    Path parent = path.getParent();
                    PlaceholderNode parentPlaceholder = placeholdersByPath.get(parent);
                    if (parentPlaceholder == null) {
                        // Need to create the placeholder ...
                        Map<Name, Property> properties = Collections.emptyMap();
                        Location location = Location.create(parent, UUID.randomUUID());
                        parentPlaceholder = new PlaceholderNode(location, properties, new ArrayList<ProjectedNode>());
                        placeholdersByPath.put(parent, parentPlaceholder);
                        placeholderNodes.add(parentPlaceholder);
                        parentPlaceholder.children().add(child);
                    } else {
View Full Code Here


        if (placeholder != null) {
            switch (request.conflictBehavior()) {
                case UPDATE:
                case DO_NOT_REPLACE:
                    // See if there is an existing node at the desired location ...
                    Location parent = request.under();
                    if (parent.hasPath()) {
                        PathFactory pathFactory = getExecutionContext().getValueFactories().getPathFactory();
                        Path childPath = pathFactory.create(parent.getPath(), request.named());
                        Location childLocation = Location.create(childPath);
                        projectedNode = project(childLocation, request.inWorkspace(), request, true);
                        if (projectedNode != null) {
                            if (projectedNode.isProxy()) {
                                ProxyNode proxy = projectedNode.asProxy();
View Full Code Here

            ProxyNode beforeProxy = request.before() != null ? projectedBeforeNode.asProxy() : null;
            assert fromProxy.projection().getSourceName().equals(intoProxy.projection().getSourceName());
            sameLocation = fromProxy.isSameLocationAsOriginal() && intoProxy.isSameLocationAsOriginal();

            // Create the pushed-down request ...
            Location beforeProxyLocation = beforeProxy != null ? beforeProxy.location() : null;
            MoveBranchRequest pushDown = new MoveBranchRequest(fromProxy.location(), intoProxy.location(), beforeProxyLocation,
                                                               intoProxy.workspaceName(), request.desiredName(),
                                                               request.conflictBehavior());
            // Create the federated request ...
            FederatedRequest federatedRequest = new FederatedRequest(request);
            federatedRequest.add(pushDown, sameLocation, false, fromProxy.projection(), intoProxy.projection());

            // Submit the requests for processing and then STOP ...
            submit(federatedRequest);
        } else {
            ProxyNode fromProxy = projectedFromNode.asProxy();
            ProxyNode beforeProxy = request.before() != null ? projectedBeforeNode.asProxy() : null;
            Location beforeProxyLocation = beforeProxy != null ? beforeProxy.location() : null;
            MoveBranchRequest pushDown = new MoveBranchRequest(fromProxy.location(), null, beforeProxyLocation,
                                                               fromProxy.workspaceName(), request.desiredName(),
                                                               request.conflictBehavior());
            // Create the federated request ...
            FederatedRequest federatedRequest = new FederatedRequest(request);
View Full Code Here

        FederatedWorkspace workspace = getWorkspace(request, request.workspaceName());
        if (workspace != null) {
            request.setActualWorkspaceName(workspace.getName());

            // Get the root location ...
            Location root = Location.create(getExecutionContext().getValueFactories().getPathFactory().createRootPath());
            ProjectedNode projectedNode = project(root, workspace.getName(), request, false);

            // Create the federated request ...
            FederatedRequest federatedRequest = new FederatedRequest(request);
            while (projectedNode != null) {
View Full Code Here

            ChildNode childConstraint = (ChildNode)constraint;
            final int locationIndex = columns.getLocationIndex(childConstraint.getSelectorName().getName());
            final String parentPath = childConstraint.getParentPath();
            return new ConstraintChecker() {
                public boolean satisfiesConstraints( Object[] tuple ) {
                    Location location = (Location)tuple[locationIndex];
                    assert location.hasPath();
                    return location.getPath().getParent().equals(parentPath);
                }
            };
        }
        if (constraint instanceof DescendantNode) {
            DescendantNode descendantNode = (DescendantNode)constraint;
            final int locationIndex = columns.getLocationIndex(descendantNode.getSelectorName().getName());
            final String ancestorPath = descendantNode.getAncestorPath();
            return new ConstraintChecker() {
                public boolean satisfiesConstraints( Object[] tuple ) {
                    Location location = (Location)tuple[locationIndex];
                    assert location.hasPath();
                    return analyzer.isDescendantOf(location, ancestorPath);
                }
            };
        }
        if (constraint instanceof SameNode) {
            SameNode sameNode = (SameNode)constraint;
            final int locationIndex = columns.getLocationIndex(sameNode.getSelectorName().getName());
            final String path = sameNode.getPath();
            if (analyzer != null) {
                return new ConstraintChecker() {
                    public boolean satisfiesConstraints( Object[] tuple ) {
                        Location location = (Location)tuple[locationIndex];
                        return analyzer.isSameNode(location, path);
                    }
                };
            }
            return new ConstraintChecker() {
                public boolean satisfiesConstraints( Object[] tuple ) {
                    Location location = (Location)tuple[locationIndex];
                    assert location.hasPath();
                    return location.toString().equals(path);
                }
            };
        }
        if (constraint instanceof PropertyExistence) {
            PropertyExistence propertyExistance = (PropertyExistence)constraint;
            String selectorName = propertyExistance.getSelectorName().getName();
            final String propertyName = propertyExistance.getPropertyName();
            if (analyzer != null) {
                final int locationIndex = columns.getLocationIndex(selectorName);
                return new ConstraintChecker() {
                    public boolean satisfiesConstraints( Object[] tuple ) {
                        Location location = (Location)tuple[locationIndex];
                        return analyzer.hasProperty(location, propertyName);
                    }
                };
            }
            final int columnIndex = columns.getColumnIndexForProperty(selectorName, propertyName);
            return new ConstraintChecker() {
                public boolean satisfiesConstraints( Object[] tuple ) {
                    return tuple[columnIndex] != null;
                }
            };
        }
        if (constraint instanceof FullTextSearch) {
            if (analyzer != null) {
                FullTextSearch search = (FullTextSearch)constraint;
                String selectorName = search.getSelectorName().getName();
                final int locationIndex = columns.getLocationIndex(selectorName);
                final String expression = search.getFullTextSearchExpression();
                if (expression == null) {
                    return new ConstraintChecker() {
                        public boolean satisfiesConstraints( Object[] tuple ) {
                            return false;
                        }
                    };
                }
                final String propertyName = search.getPropertyName(); // may be null
                final int scoreIndex = columns.getFullTextSearchScoreIndexFor(selectorName);
                assert scoreIndex >= 0 : "Columns do not have room for the search scores";
                if (propertyName != null) {
                    return new ConstraintChecker() {
                        public boolean satisfiesConstraints( Object[] tuple ) {
                            Location location = (Location)tuple[locationIndex];
                            if (location == null) return false;
                            double score = analyzer.hasFullText(location, propertyName, expression);
                            // put the score on the correct tuple value ...
                            Double existing = (Double)tuple[scoreIndex];
                            if (existing != null) {
                                score = Math.max(existing.doubleValue(), score);
                            }
                            tuple[scoreIndex] = new Double(score);
                            return true;
                        }
                    };
                }
                return new ConstraintChecker() {
                    public boolean satisfiesConstraints( Object[] tuple ) {
                        Location location = (Location)tuple[locationIndex];
                        if (location == null) return false;
                        double score = analyzer.hasFullText(location, expression);
                        // put the score on the correct tuple value ...
                        Double existing = (Double)tuple[scoreIndex];
                        if (existing != null) {
View Full Code Here

        PathFactory pathFactory = store.getContext().getValueFactories().getPathFactory();
        Path pathToNamespaceNode = pathFactory.create(parentOfNamespaceNodes, prefix);
        try {
            Subgraph nsGraph = store.getSubgraphOfDepth(2).at(parentOfNamespaceNodes);
            // Iterate over the existing mappings, looking for one that uses the URI ...
            Location nsNodeWithPrefix = null;
            boolean updateNode = true;
            Set<Location> locationsToRemove = new HashSet<Location>();
            for (Location nsLocation : nsGraph.getRoot().getChildren()) {
                Node ns = nsGraph.getNode(nsLocation);
                String actualPrefix = getPrefixFor(nsLocation.getPath());
View Full Code Here

    protected final boolean isSameTuple( Columns columns,
                                         Object[] tuple1,
                                         Object[] tuple2 ) {
        for (int i = columns.getColumnCount(); i != columns.getLocationCount(); ++i) {
            Location location = (Location)tuple1[i];
            Location location2 = (Location)tuple2[i];
            if (!location.isSame(location2)) return false;
        }
        return true;
    }
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

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.