Package org.jboss.dna.graph.request

Examples of org.jboss.dna.graph.request.ReadPropertyRequest


        FederatedRequest federatedRequest = new FederatedRequest(request);
        while (projectedNode != null) {
            if (projectedNode.isPlaceholder()) {
                PlaceholderNode placeholder = projectedNode.asPlaceholder();
                // Create a request and set the results ...
                ReadPropertyRequest placeholderRequest = new ReadPropertyRequest(placeholder.location(), request.inWorkspace(),
                                                                                 request.named());
                Property property = placeholder.properties().get(request.named());
                placeholderRequest.setProperty(property);
                placeholderRequest.setActualLocationOfNode(placeholder.location());
                federatedRequest.add(placeholderRequest, true, true, null);
            } else if (projectedNode.isProxy()) {
                ProxyNode proxy = projectedNode.asProxy();
                // Create and submit a request for the projection ...
                ReadPropertyRequest pushDownRequest = new ReadPropertyRequest(proxy.location(), proxy.workspaceName(),
                                                                              request.named());
                federatedRequest.add(pushDownRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection());
            }
            projectedNode = projectedNode.next();
        }
View Full Code Here


            public Map<Location, Property> on( Collection<Location> locations ) {
                CheckArg.isNotNull(locations, "locations");
                final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
                String workspace = getCurrentWorkspaceName();
                for (Location location : locations) {
                    requests.add(new ReadPropertyRequest(location, workspace, name));
                }
                return execute(requests);
            }

            public Map<Location, Property> on( Location first,
                                               Location... additional ) {
                CheckArg.isNotNull(first, "first");
                final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
                String workspace = getCurrentWorkspaceName();
                requests.add(new ReadPropertyRequest(first, workspace, name));
                for (Location location : additional) {
                    requests.add(new ReadPropertyRequest(location, workspace, name));
                }
                return execute(requests);
            }

            public Map<Location, Property> on( String first,
                                               String... additional ) {
                CheckArg.isNotNull(first, "first");
                final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
                String workspace = getCurrentWorkspaceName();
                requests.add(new ReadPropertyRequest(Location.create(createPath(first)), workspace, name));
                for (String path : additional) {
                    requests.add(new ReadPropertyRequest(Location.create(createPath(path)), workspace, name));
                }
                return execute(requests);
            }

            public Map<Location, Property> on( Path first,
                                               Path... additional ) {
                CheckArg.isNotNull(first, "first");
                final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
                String workspace = getCurrentWorkspaceName();
                requests.add(new ReadPropertyRequest(Location.create(first), workspace, name));
                for (Path path : additional) {
                    requests.add(new ReadPropertyRequest(Location.create(path), workspace, name));
                }
                return execute(requests);
            }

            public Map<Location, Property> on( UUID first,
                                               UUID... additional ) {
                CheckArg.isNotNull(first, "first");
                final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
                String workspace = getCurrentWorkspaceName();
                requests.add(new ReadPropertyRequest(Location.create(first), workspace, name));
                for (UUID uuid : additional) {
                    requests.add(new ReadPropertyRequest(Location.create(uuid), workspace, name));
                }
                return execute(requests);
            }

            protected Map<Location, Property> execute( List<ReadPropertyRequest> requests ) {
View Full Code Here

            public Map<Name, Property> on( Location at ) {
                final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
                String workspace = getCurrentWorkspaceName();
                for (Name propertyName : names) {
                    requests.add(new ReadPropertyRequest(at, workspace, propertyName));
                }
                // Create a composite request ...
                Request composite = CompositeRequest.with(requests);
                Graph.this.execute(composite);
                Map<Name, Property> results = new HashMap<Name, Property>();
                for (ReadPropertyRequest request : requests) {
                    Property property = request.getProperty();
                    results.put(property.getName(), property);
                }
                return results;
            }

            public Map<Location, Map<Name, Property>> on( Collection<Location> locations ) {
                CheckArg.isNotNull(locations, "locations");
                final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
                String workspace = getCurrentWorkspaceName();
                for (Location location : locations) {
                    if (location == null) continue;
                    for (Name propertyName : names) {
                        if (propertyName == null) continue;
                        requests.add(new ReadPropertyRequest(location, workspace, propertyName));
                    }
                }
                return execute(requests);
            }

            /**
             * {@inheritDoc}
             *
             * @see org.jboss.dna.graph.Graph.OnMultiple#on(org.jboss.dna.graph.Location, org.jboss.dna.graph.Location[])
             */
            public Map<Location, Map<Name, Property>> on( Location first,
                                                          Location... additional ) {
                CheckArg.isNotNull(first, "first");
                final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
                String workspace = getCurrentWorkspaceName();
                for (Location location : additional) {
                    if (location == null) continue;
                    for (Name propertyName : names) {
                        if (propertyName == null) continue;
                        requests.add(new ReadPropertyRequest(first, workspace, propertyName));
                        requests.add(new ReadPropertyRequest(location, workspace, propertyName));
                    }
                }
                return execute(requests);
            }

View Full Code Here

     *
     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.ReadPropertyRequest)
     */
    @Override
    public void process( ReadPropertyRequest request ) {
        ReadPropertyRequest source = (ReadPropertyRequest)federatedRequest.getFirstProjectedRequest().getRequest();
        if (checkErrorOrCancel(request, source)) return;
        request.setActualLocationOfNode(source.getActualLocationOfNode());
        request.setProperty(source.getProperty());
        request.setCachePolicy(getDefaultCachePolicy());
        setCacheableInfo(request, source.getCachePolicy());
    }
View Full Code Here

        request.setCachePolicy(getDefaultCachePolicy());
        Location actualLocation = request.on();
        int numMerged = 0;
        while (projectedRequest != null) {
            ReadPropertyRequest readFromSource = (ReadPropertyRequest)projectedRequest.getRequest();
            if (readFromSource.hasError()) {
                projectedRequest = projectedRequest.next();
                continue;
            }
            if (readFromSource.isCancelled()) {
                request.cancel();
                return;
            }

            // Make sure we have an actual location ...
            Location sourceLocation = readFromSource.getActualLocationOfNode();
            actualLocation = determineActualLocation(actualLocation, sourceLocation, projectedRequest.getProjection());

            if (sourceLocation.hasIdProperties()) {
                // Accumulate the identification properties ...
                for (Property propertyInSource : sourceLocation.getIdProperties()) {
                    Name name = propertyInSource.getName();
                    Property existing = actualLocation.getIdProperty(name);
                    if (existing != null) {
                        // Merge the property values ...
                        propertyInSource = merge(existing, propertyInSource, propertyFactory, true);
                    }
                    actualLocation = actualLocation.with(propertyInSource);
                }
            }

            // Add all the properties ...
            Property read = readFromSource.getProperty();
            if (read != null) {
                Property existing = request.getProperty();
                if (existing != null) {
                    // Merge the property values ...
                    request.setProperty(merge(existing, read, propertyFactory, true));
                } else {
                    request.setProperty(read);
                }
            }
            setCacheableInfo(request, readFromSource.getCachePolicy());
            projectedRequest = projectedRequest.next();
            ++numMerged;
        }
        if (numMerged == 0) {
            // No source requests had results ...
View Full Code Here

                if (request instanceof ReadAllPropertiesRequest) {
                    ReadAllPropertiesRequest read = (ReadAllPropertiesRequest)request;
                    DateTime expires = computeExpirationTime(read);
                    getOrCreateNode(read.getActualLocationOfNode(), expires).setProperties(read.getPropertiesByName());
                } else if (request instanceof ReadPropertyRequest) {
                    ReadPropertyRequest read = (ReadPropertyRequest)request;
                    DateTime expires = computeExpirationTime(read);
                    getOrCreateNode(read.getActualLocationOfNode(), expires).addProperty(read.getProperty());
                } else if (request instanceof ReadNodeRequest) {
                    ReadNodeRequest read = (ReadNodeRequest)request;
                    DateTime expires = computeExpirationTime(read);
                    BatchResultsNode node = getOrCreateNode(read.getActualLocationOfNode(), expires);
                    node.setProperties(read.getPropertiesByName());
                    node.setChildren(read.getChildren());
                } else if (request instanceof ReadBlockOfChildrenRequest) {
                    throw new IllegalStateException();
                } else if (request instanceof ReadAllChildrenRequest) {
                    ReadAllChildrenRequest read = (ReadAllChildrenRequest)request;
                    DateTime expires = computeExpirationTime(read);
                    getOrCreateNode(read.getActualLocationOfNode(), expires).setChildren(read.getChildren());
                } else if (request instanceof ReadBranchRequest) {
                    ReadBranchRequest read = (ReadBranchRequest)request;
                    DateTime expires = computeExpirationTime(read);
                    for (Location location : read) {
                        BatchResultsNode node = getOrCreateNode(location, expires);
                        node.setProperties(read.getPropertiesFor(location));
                        node.setChildren(read.getChildren(location));
                    }
                }
            }
            for (Map.Entry<Path, BatchResultsNode> entry : nodes.entrySet()) {
                entry.getValue().freeze();
View Full Code Here

            if (request instanceof ReadAllPropertiesRequest) {
                ReadAllPropertiesRequest read = (ReadAllPropertiesRequest)request;
                DateTime expires = computeExpirationTime(read);
                getOrCreateNode(read.getActualLocationOfNode(), expires).setProperties(read.getPropertiesByName());
            } else if (request instanceof ReadPropertyRequest) {
                ReadPropertyRequest read = (ReadPropertyRequest)request;
                DateTime expires = computeExpirationTime(read);
                getOrCreateNode(read.getActualLocationOfNode(), expires).addProperty(read.getProperty());
            } else if (request instanceof ReadNodeRequest) {
                ReadNodeRequest read = (ReadNodeRequest)request;
                DateTime expires = computeExpirationTime(read);
                BatchResultsNode node = getOrCreateNode(read.getActualLocationOfNode(), expires);
                node.setProperties(read.getPropertiesByName());
                node.setChildren(read.getChildren());
            } else if (request instanceof ReadBlockOfChildrenRequest) {
                throw new IllegalStateException();
            } else if (request instanceof ReadAllChildrenRequest) {
                ReadAllChildrenRequest read = (ReadAllChildrenRequest)request;
                DateTime expires = computeExpirationTime(read);
                getOrCreateNode(read.getActualLocationOfNode(), expires).setChildren(read.getChildren());
            } else if (request instanceof ReadBranchRequest) {
                ReadBranchRequest read = (ReadBranchRequest)request;
                DateTime expires = computeExpirationTime(read);
                for (Location location : read) {
                    BatchResultsNode node = getOrCreateNode(location, expires);
                    node.setProperties(read.getPropertiesFor(location));
                    node.setChildren(read.getChildren(location));
                }
            }
            for (Map.Entry<Path, BatchResultsNode> entry : nodes.entrySet()) {
                entry.getValue().freeze();
            }
View Full Code Here

        String workspaceName = request.inWorkspace();
        Location on = request.on();
        Name propertyName = request.property();

        // Read in the current values
        ReadPropertyRequest readProperty = new ReadPropertyRequest(on, workspaceName, propertyName);
        process(readProperty);

        if (readProperty.hasError()) {
            request.setError(readProperty.getError());
            return;
        }

        Property property = readProperty.getProperty();
        List<Object> actualRemovedValues = new ArrayList<Object>(request.removedValues().size());
        List<Object> newValues = property == null ? new LinkedList<Object>() : new LinkedList<Object>(
                                                                                                      Arrays.asList(property.getValuesAsArray()));
        // Calculate what the new values should be
        for (Object removedValue : request.removedValues()) {
View Full Code Here

        FederatedRequest federatedRequest = new FederatedRequest(request);
        while (projectedNode != null) {
            if (projectedNode.isPlaceholder()) {
                PlaceholderNode placeholder = projectedNode.asPlaceholder();
                // Create a request and set the results ...
                ReadPropertyRequest placeholderRequest = new ReadPropertyRequest(placeholder.location(), request.inWorkspace(),
                                                                                 request.named());
                Property property = placeholder.properties().get(request.named());
                placeholderRequest.setProperty(property);
                placeholderRequest.setActualLocationOfNode(placeholder.location());
                federatedRequest.add(placeholderRequest, true, true, null);
            } else if (projectedNode.isProxy()) {
                ProxyNode proxy = projectedNode.asProxy();
                // Create and submit a request for the projection ...
                ReadPropertyRequest pushDownRequest = new ReadPropertyRequest(proxy.location(), proxy.workspaceName(),
                                                                              request.named());
                federatedRequest.add(pushDownRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection());
            }
            projectedNode = projectedNode.next();
        }
View Full Code Here

        assert projectedRequest != null;
        request.setCachePolicy(getDefaultCachePolicy());
        Location actualLocation = request.on();
        int numMerged = 0;
        while (projectedRequest != null) {
            ReadPropertyRequest readFromSource = (ReadPropertyRequest)projectedRequest.getRequest();
            if (readFromSource.hasError()) {
                projectedRequest = projectedRequest.next();
                continue;
            }
            if (readFromSource.isCancelled()) {
                request.cancel();
                return;
            }

            // Make sure we have an actual location ...
            Location sourceLocation = readFromSource.getActualLocationOfNode();
            actualLocation = determineActualLocation(actualLocation, sourceLocation, projectedRequest.getProjection());

            if (sourceLocation.hasIdProperties()) {
                // Accumulate the identification properties ...
                for (Property propertyInSource : sourceLocation.getIdProperties()) {
                    Name name = propertyInSource.getName();
                    Property existing = actualLocation.getIdProperty(name);
                    if (existing != null) {
                        // Merge the property values ...
                        propertyInSource = merge(existing, propertyInSource, propertyFactory, true);
                    }
                    actualLocation = actualLocation.with(propertyInSource);
                }
            }

            // Add all the properties ...
            Property read = readFromSource.getProperty();
            if (read != null) {
                Property existing = request.getProperty();
                if (existing != null) {
                    // Merge the property values ...
                    request.setProperty(merge(existing, read, propertyFactory, true));
                } else {
                    request.setProperty(read);
                }
            }
            setCacheableInfo(request, readFromSource.getCachePolicy());
            projectedRequest = projectedRequest.next();
            ++numMerged;
        }
        if (numMerged == 0) {
            // No source requests had results ...
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.request.ReadPropertyRequest

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.