Package org.jboss.dna.graph.properties

Examples of org.jboss.dna.graph.properties.UuidFactory


        children.clear();
        Map<Name, Integer> childNames = new HashMap<Name, Integer>();
        Map<Name, Property> properties = federatedNode.getPropertiesByName();
        properties.clear();
        UUID uuid = null;
        UuidFactory uuidFactory = null;
        final boolean removeDuplicateProperties = isRemoveDuplicateProperties();
        // Iterate over the set of contributions (in order) ...
        for (Contribution contribution : contributions) {
            // If the contribution is a placeholder contribution, then the children should be merged into other children ...
            if (contribution.isPlaceholder()) {
                // Iterate over the children and add only if there is not already one ...
                Iterator<Segment> childIterator = contribution.getChildren();
                while (childIterator.hasNext()) {
                    Segment child = childIterator.next();
                    if (!childNames.containsKey(child.getName())) {
                        childNames.put(child.getName(), 1);
                        children.add(pathFactory.createSegment(child.getName()));
                    }
                }

            } else {
                // Copy the children ...
                Iterator<Segment> childIterator = contribution.getChildren();
                while (childIterator.hasNext()) {
                    Segment child = childIterator.next();
                    int index = Path.NO_INDEX;
                    Integer previous = childNames.put(child.getName(), 1);
                    if (previous != null) {
                        int previousValue = previous.intValue();
                        // Correct the index in the child name map ...
                        childNames.put(child.getName(), ++previousValue);
                        index = previousValue;
                    }
                    children.add(pathFactory.createSegment(child.getName(), index));
                }

                // Copy the properties ...
                Iterator<Property> propertyIterator = contribution.getProperties();
                while (propertyIterator.hasNext()) {
                    Property property = propertyIterator.next();
                    // Skip the "uuid" property on all root nodes ...
                    if (federatedNode.getPath().isRoot() && property.getName().getLocalName().equals("uuid")) continue;
                    Property existing = properties.put(property.getName(), property);
                    if (existing != null) {
                        // There's already an existing property, so we need to merge them ...
                        Property merged = merge(existing, property, context.getPropertyFactory(), removeDuplicateProperties);
                        properties.put(property.getName(), merged);
                    }

                    if (uuid == null && property.getName().getLocalName().equals("uuid") && property.isSingle()) {
                        if (uuidFactory == null) uuidFactory = context.getValueFactories().getUuidFactory();
                        try {
                            uuid = uuidFactory.create(property.getValues().next());
                        } catch (IoException e) {
                            // Ignore conversion exceptions
                            assert uuid == null;
                        }
                    }
View Full Code Here


        }
        // Copy the properties ...
        Map<Name, Property> properties = federatedNode.getPropertiesByName();
        properties.clear();
        UUID uuid = null;
        UuidFactory uuidFactory = null;
        Iterator<Property> propertyIterator = contribution.getProperties();
        while (propertyIterator.hasNext()) {
            Property property = propertyIterator.next();
            if (findUuid && uuid == null && property.getName().getLocalName().equals("uuid")) {
                if (property.isSingle()) {
                    if (uuidFactory == null) uuidFactory = context.getValueFactories().getUuidFactory();
                    try {
                        uuid = uuidFactory.create(property.getValues().next());
                    } catch (ValueFormatException e) {
                        // Ignore conversion exceptions
                    }
                }
            } else {
View Full Code Here

        // Create JCR properties for corresponding DNA properties
        Set<Property> properties = new HashSet<Property>();
        UUID uuid = null;
        Name jcrUuidName = executionContext.getValueFactories().getNameFactory().create("jcr:uuid");
        Name jcrMixinTypesName = executionContext.getValueFactories().getNameFactory().create("jcr:mixinTypes");
        UuidFactory uuidFactory = executionContext.getValueFactories().getUuidFactory();
        org.jboss.dna.graph.properties.Property dnaUuidProp = null;
        boolean referenceable = false;
        for (org.jboss.dna.graph.properties.Property dnaProp : getNodeCommand.getProperties()) {
            Name name = dnaProp.getName();
            if (dnaProp.isMultiple()) properties.add(new JcrMultiValueProperty(node, executionContext, name, dnaProp));
            else {
                if (uuid == null && DnaLexicon.UUID.equals(name)) uuid = uuidFactory.create(dnaProp.getValues()).next();
                else if (jcrUuidName.equals(name)) dnaUuidProp = dnaProp;
                else if (jcrMixinTypesName.equals(name)) {
                    org.jboss.dna.graph.properties.ValueFactory<String> stringFactory = executionContext.getValueFactories().getStringFactory();
                    for (String mixin : stringFactory.create(dnaProp)) {
                        if ("mix:referenceable".equals(mixin)) referenceable = true;
                    }
                }
                properties.add(new JcrProperty(node, executionContext, name, dnaProp.getValues().next()));
            }

        }
        node.setProperties(properties);
        // Set node's UUID, creating one if necessary
        if (uuid == null) {
            if (dnaUuidProp == null || !referenceable) uuid = UUID.randomUUID();
            else {
                uuid = uuidFactory.create(dnaUuidProp.getValues()).next();
                nodesByJcrUuid.put(uuid.toString(), node);
            }
        }
        node.setInternalUuid(uuid);
        // Setup node to be retrieved by DNA UUID
View Full Code Here

        // Create JCR properties for corresponding DNA properties
        Set<Property> properties = new HashSet<Property>();
        UUID uuid = null;
        Name jcrUuidName = executionContext.getValueFactories().getNameFactory().create("jcr:uuid");
        Name jcrMixinTypesName = executionContext.getValueFactories().getNameFactory().create("jcr:mixinTypes");
        UuidFactory uuidFactory = executionContext.getValueFactories().getUuidFactory();
        org.jboss.dna.graph.properties.Property dnaUuidProp = null;
        boolean referenceable = false;
        for (org.jboss.dna.graph.properties.Property dnaProp : graphNode.getProperties()) {
            Name name = dnaProp.getName();
            if (dnaProp.isMultiple()) properties.add(new JcrMultiValueProperty(node, executionContext, name, dnaProp));
            else {
                if (uuid == null && DnaLexicon.UUID.equals(name)) uuid = uuidFactory.create(dnaProp.getValues()).next();
                else if (jcrUuidName.equals(name)) dnaUuidProp = dnaProp;
                else if (jcrMixinTypesName.equals(name)) {
                    org.jboss.dna.graph.properties.ValueFactory<String> stringFactory = executionContext.getValueFactories().getStringFactory();
                    for (String mixin : stringFactory.create(dnaProp)) {
                        if ("mix:referenceable".equals(mixin)) referenceable = true;
                    }
                }
                properties.add(new JcrProperty(node, executionContext, name, dnaProp.getValues().next()));
            }

        }
        node.setProperties(properties);
        // Set node's UUID, creating one if necessary
        if (uuid == null) {
            if (dnaUuidProp == null || !referenceable) uuid = UUID.randomUUID();
            else {
                uuid = uuidFactory.create(dnaUuidProp.getValues()).next();
                nodesByJcrUuid.put(uuid.toString(), node);
            }
        }
        node.setInternalUuid(uuid);
        // Setup node to be retrieved by DNA UUID
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.properties.UuidFactory

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.