Package org.jboss.dna.graph.property

Examples of org.jboss.dna.graph.property.PropertyFactory


        if (!reuseUuids) {
            assert oldToNewUuids != null;
            // Now, adjust any references in the new subgraph to objects in the original subgraph
            // (because they were internal references, and need to be internal to the new subgraph)
            PropertyFactory propertyFactory = context.getPropertyFactory();
            UuidFactory uuidFactory = context.getValueFactories().getUuidFactory();
            ValueFactory<Reference> referenceFactory = context.getValueFactories().getReferenceFactory();
            for (Map.Entry<UUID, UUID> oldToNew : oldToNewUuids.entrySet()) {
                MapNode oldNode = this.getNode(oldToNew.getKey());
                MapNode newNode = newWorkspace.getNode(oldToNew.getValue());
                assert oldNode != null;
                assert newNode != null;
                // Iterate over the properties of the new ...
                for (Map.Entry<Name, Property> entry : newNode.getProperties().entrySet()) {
                    Property property = entry.getValue();
                    // Now see if any of the property values are references ...
                    List<Object> newValues = new ArrayList<Object>();
                    boolean foundReference = false;
                    for (Iterator<?> iter = property.getValues(); iter.hasNext();) {
                        Object value = iter.next();
                        PropertyType type = PropertyType.discoverType(value);
                        if (type == PropertyType.REFERENCE) {
                            UUID oldReferencedUuid = uuidFactory.create(value);
                            UUID newReferencedUuid = oldToNewUuids.get(oldReferencedUuid);
                            if (newReferencedUuid != null) {
                                newValues.add(referenceFactory.create(newReferencedUuid));
                                foundReference = true;
                            }
                        } else {
                            newValues.add(value);
                        }
                    }
                    // If we found at least one reference, we have to build a new Property object ...
                    if (foundReference) {
                        Property newProperty = propertyFactory.create(property.getName(), newValues);
                        entry.setValue(newProperty);
                    }
                }
            }
        }
View Full Code Here


     * @return this map node
     */
    public MapNode setProperty( ExecutionContext context,
                                String name,
                                Object... values ) {
        PropertyFactory propertyFactory = context.getPropertyFactory();
        Name propertyName = context.getValueFactories().getNameFactory().create(name);
        return setProperty(propertyFactory.create(propertyName, values));
    }
View Full Code Here

        final String workspaceName = getCurrentWorkspaceName();
        return new CreateAt<Graph>() {
            private final List<Property> properties = new LinkedList<Property>();

            public CreateAt<Graph> and( UUID uuid ) {
                PropertyFactory factory = getContext().getPropertyFactory();
                properties.add(factory.create(DnaLexicon.UUID, uuid));
                return this;
            }

            public CreateAt<Graph> and( Property property ) {
                properties.add(property);
                return this;
            }

            public CreateAt<Graph> and( Iterable<Property> properties ) {
                for (Property property : properties) {
                    this.properties.add(property);
                }
                return this;
            }

            public CreateAt<Graph> and( String name,
                                        Object... values ) {
                ExecutionContext context = getContext();
                PropertyFactory factory = context.getPropertyFactory();
                NameFactory nameFactory = context.getValueFactories().getNameFactory();
                properties.add(factory.create(nameFactory.create(name), values));
                return this;
            }

            public CreateAt<Graph> and( Name name,
                                        Object... values ) {
                ExecutionContext context = getContext();
                PropertyFactory factory = context.getPropertyFactory();
                properties.add(factory.create(name, values));
                return this;
            }

            public CreateAt<Graph> and( Property property,
                                        Property... additionalProperties ) {
View Full Code Here

     */
    private void buildPathTo( Path targetPath,
                              SequencerContext context,
                              Set<Path> builtPaths ) {
        PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
        PropertyFactory propFactory = context.getExecutionContext().getPropertyFactory();

        if (targetPath.isRoot()) return;
        Path workingPath = pathFactory.createRootPath();
        Path.Segment[] segments = targetPath.getSegmentsArray();
        int i = 0;
        Property primaryType = propFactory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.UNSTRUCTURED);
        for (int max = segments.length; i < max; i++) {
            workingPath = pathFactory.create(workingPath, segments[i]);

            if (!builtPaths.contains(workingPath)) {
                try {
View Full Code Here

                               SequencerOutputMap output,
                               SequencerContext context,
                               Set<Path> builtPaths ) {
        if (output.isEmpty()) return;
        final PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
        final PropertyFactory propertyFactory = context.getExecutionContext().getPropertyFactory();
        final Path outputNodePath = pathFactory.create(nodePath);

        // Iterate over the entries in the output, in Path's natural order (shorter paths first and in lexicographical order by
        // prefix and name)
        for (SequencerOutputMap.Entry entry : output) {
            Path targetNodePath = entry.getPath();

            // Resolve this path relative to the output node path, handling any parent or self references ...
            Path absolutePath = targetNodePath.isAbsolute() ? targetNodePath : outputNodePath.resolve(targetNodePath);

            List<Property> properties = new LinkedList<Property>();
            // Set all of the properties on this
            for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues()) {
                properties.add(propertyFactory.create(property.getName(), property.getValue()));
                // TODO: Handle reference properties - currently passed in as Paths
            }

            if (absolutePath.getParent() != null) {
                buildPathTo(absolutePath.getParent(), context, builtPaths);
View Full Code Here

            // Create the node for the node type ...
            if (name == null) return null;
            Path path = pathFactory().create(parentPath, name);

            PropertyFactory factory = context.getPropertyFactory();
            destination.create(path,
                               factory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.NODE_TYPE),
                               factory.create(JcrLexicon.SUPERTYPES, (Object[])supertypes),
                               factory.create(JcrLexicon.IS_ABSTRACT, isAbstract),
                               factory.create(JcrLexicon.HAS_ORDERABLE_CHILD_NODES, hasOrderableChildNodes),
                               factory.create(JcrLexicon.IS_MIXIN, isMixin),
                               factory.create(JcrLexicon.IS_QUERYABLE, isQueryable),
                               factory.create(JcrLexicon.PRIMARY_ITEM_NAME, primaryItemName));

            return path;
        }
View Full Code Here

            // Create the node for the node type ...
            if (name == null) return null;
            Path path = pathFactory().create(parentPath, name);

            PropertyFactory factory = context.getPropertyFactory();
            destination.create(path,
                               factory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.PROPERTY_DEFINITION),
                               factory.create(JcrLexicon.REQUIRED_TYPE, requiredType),
                               factory.create(JcrLexicon.DEFAULT_VALUES, (Object[])defaultValues),
                               factory.create(JcrLexicon.MULTIPLE, multiple),
                               factory.create(JcrLexicon.MANDATORY, mandatory),
                               factory.create(JcrLexicon.AUTO_CREATED, autoCreated),
                               factory.create(JcrLexicon.PROTECTED, isProtected),
                               factory.create(JcrLexicon.ON_PARENT_VERSION, onParentVersion),
                               // factory.create(DnaLexicon.QUERY_OPERATORS, queryOperators),
                               factory.create(JcrLexicon.IS_FULL_TEXT_SEARCHABLE, isFullTextSearchable),
                               factory.create(JcrLexicon.IS_QUERY_ORDERABLE, isQueryOrderable),
                               factory.create(JcrLexicon.VALUE_CONSTRAINTS, (Object[])valueConstraints));

            return path;
        }
View Full Code Here

            // Create the node for the node type ...
            if (name == null) return null;
            Path path = pathFactory().create(parentPath, name);

            PropertyFactory factory = context.getPropertyFactory();
            destination.create(path,
                               factory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.CHILD_NODE_DEFINITION),
                               factory.create(JcrLexicon.REQUIRED_PRIMARY_TYPES, (Object[])requiredPrimaryTypes),
                               factory.create(JcrLexicon.DEFAULT_PRIMARY_TYPE, defaultPrimaryType),
                               factory.create(JcrLexicon.MANDATORY, mandatory),
                               factory.create(JcrLexicon.AUTO_CREATED, autoCreated),
                               factory.create(JcrLexicon.PROTECTED, isProtected),
                               factory.create(JcrLexicon.ON_PARENT_VERSION, onParentVersion),
                               factory.create(JcrLexicon.SAME_NAME_SIBLINGS, sameNameSiblings));

            return path;
        }
View Full Code Here

        graph.create("/segmentTestUuids").and();
        // Copy once to get the UUID into the default workspace
        graph.clone("/node1").fromWorkspace(workspaceName).as(name("node1")).into("/segmentTestUuids").failingIfAnyUuidsMatch();

        // Create a new child node that in the target workspace that has no corresponding node in the source workspace
        PropertyFactory propFactory = context.getPropertyFactory();
        graph.create("/segmentTestUuids/node1", propFactory.create(name("identifier"), "backup copy")).and();

        // Copy again to test the behavior now that the UUIDs are already in the default workspace
        // This should remove /segmentTestUuids/node1[1]
        graph.clone("/node1")
             .fromWorkspace(workspaceName)
View Full Code Here

        super.setUp();

        // Set up the context and register any namespaces that we'll be using to manage the namespaces ...
        context = new ExecutionContext();
        NameFactory nameFactory = context.getValueFactories().getNameFactory();
        PropertyFactory propertyFactory = context.getPropertyFactory();
        context.getNamespaceRegistry().register("nsx", "http://www.example.com/namespaces");
        context.getNamespaceRegistry().register("other", "http://www.example.com/other");
        uriPropertyName = context.getValueFactories().getNameFactory().create("nsx:uri");
        additionalNamespaceProperties = new Property[] {
            propertyFactory.create(nameFactory.create("nsx:something"), "Some value"),
            propertyFactory.create(nameFactory.create("nsx:something2"), "Some value2"),
            propertyFactory.create(nameFactory.create("other:something2"), "Some other value2")};

        // Set up the repository that we'll be using ...
        source = new InMemoryRepositorySource();
        source.setName("namespace repository");
        graph = Graph.create(source, context);
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.property.PropertyFactory

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.