Package org.jboss.dna.graph.properties

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


                }

                // 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;
                        }
                    }
                }
            }
        }
        // If we found a single "uuid" property whose value is a valid UUID ..
        if (uuid != null) {
            // then set the UUID on the federated node ...
            federatedNode.setUuid(uuid);
        }
        // Set the UUID as a property ...
        Property uuidProperty = context.getPropertyFactory().create(DnaLexicon.UUID, federatedNode.getUuid());
        properties.put(uuidProperty.getName(), uuidProperty);

        // Assign the merge plan ...
        MergePlan mergePlan = MergePlan.create(contributions);
        federatedNode.setMergePlan(mergePlan);
    }
View Full Code Here


        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 {
                properties.put(property.getName(), property);
            }
        }
        // If we found a single "uuid" property whose value is a valid UUID ..
        if (uuid != null) {
            // then set the UUID on the federated node ...
            federatedNode.setUuid(uuid);
        }
        // Set the UUID as a property ...
        Property uuidProperty = context.getPropertyFactory().create(DnaLexicon.UUID, federatedNode.getUuid());
        properties.put(uuidProperty.getName(), uuidProperty);

        // Assign the merge plan ...
        MergePlan mergePlan = MergePlan.create(contributions);
        federatedNode.setMergePlan(mergePlan);
    }
View Full Code Here

            boolean first = true;
            Iterator<Property> propIter = getProperties();
            while (propIter.hasNext()) {
                if (!first) sb.append(", ");
                else first = false;
                Property property = propIter.next();
                sb.append(property.getName());
                sb.append('=');
                sb.append(StringUtil.readableString(property.getValuesAsArray()));
            }
            sb.append(" }");
        }
        if (getChildrenCount() != 0) {
            sb.append("< ");
View Full Code Here

                }
            }

            // Look for the default cache policy ...
            BasicCachePolicy cachePolicy = new BasicCachePolicy();
            Property timeToLiveProperty = getRepository.getPropertiesByName().get(nameFactory.create(CACHE_POLICY_TIME_TO_LIVE_CONFIG_PROPERTY_NAME));
            if (timeToLiveProperty != null && !timeToLiveProperty.isEmpty()) {
                cachePolicy.setTimeToLive(longFactory.create(timeToLiveProperty.getValues().next()), TimeUnit.MILLISECONDS);
            }
            CachePolicy defaultCachePolicy = cachePolicy.isEmpty() ? null : cachePolicy.getUnmodifiable();
            return new FederatedRepositoryConfig(repositoryName, cacheProjection, sourceProjections, defaultCachePolicy);
        } catch (InvalidPathException err) {
            I18n msg = FederationI18n.federatedRepositoryCannotBeFound;
View Full Code Here

        String sourceName = path.getLastSegment().getName().getLocalName();

        // Get the rules ...
        Projection.Rule[] projectionRules = null;
        Property projectionRulesProperty = properties.get(nameFactory.create(PROJECTION_RULES_CONFIG_PROPERTY_NAME));
        if (projectionRulesProperty != null && !projectionRulesProperty.isEmpty()) {
            String[] projectionRuleStrs = stringFactory.create(projectionRulesProperty.getValuesAsArray());
            if (projectionRuleStrs != null && projectionRuleStrs.length != 0) {
                projectionRules = projectionParser.rulesFromStrings(context, projectionRuleStrs);
            }
        }
        if (problems.hasErrors()) return null;
View Full Code Here

        // Create the node, and use the existing UUID if one is found in the cache ...
        ExecutionContext context = getExecutionContext();
        assert context != null;
        UUID uuid = null;
        if (fromCache != null) {
            Property uuidProperty = fromCache.getPropertiesByName().get(DnaLexicon.UUID);
            if (uuidProperty != null && !uuidProperty.isEmpty()) {
                uuid = context.getValueFactories().getUuidFactory().create(uuidProperty.getValues().next());
            }
        }
        if (uuid == null) uuid = UUID.randomUUID();
        FederatedNode mergedNode = new FederatedNode(path, uuid);
View Full Code Here

            }
        }
    }

    protected MergePlan getMergePlan( BasicGetNodeCommand command ) {
        Property mergePlanProperty = command.getPropertiesByName().get(mergePlanPropertyName);
        if (mergePlanProperty == null || mergePlanProperty.isEmpty()) {
            return null;
        }
        Object value = mergePlanProperty.getValues().next();
        return value instanceof MergePlan ? (MergePlan)value : null;
    }
View Full Code Here

            } else {
                // Get the identification properties for each contribution ...
                Location contributionLocation = contribution.getLocationInSource();
                for (Property idProperty : contributionLocation) {
                    // Record the property ...
                    Property existing = properties.put(idProperty.getName(), idProperty);
                    if (existing != null) {
                        // There's already an existing property, so we need to merge them ...
                        Property merged = merge(existing, idProperty, context.getPropertyFactory(), removeDuplicateProperties);
                        properties.put(merged.getName(), merged);
                    }
                }

                // Accumulate the children ...
                Iterator<Location> childIterator = contribution.getChildren();
                while (childIterator.hasNext()) {
                    Location child = childIterator.next();
                    Name childName = child.getPath().getLastSegment().getName();
                    int index = Path.NO_INDEX;
                    Integer previous = childNames.put(childName, 1);
                    if (previous != null) {
                        int previousValue = previous.intValue();
                        // Correct the index in the child name map ...
                        childNames.put(childName, ++previousValue);
                        index = previousValue;
                    }
                    Path pathToChild = pathFactory.create(location.getPath(), childName, index);
                    federatedNode.addChild(new Location(pathToChild));
                }

                // Add in the properties ...
                Iterator<Property> propertyIter = contribution.getProperties();
                while (propertyIter.hasNext()) {
                    Property property = propertyIter.next();
                    // Skip the "uuid" property on all root nodes ...
                    if (isRoot && property.getName().getLocalName().equals("uuid")) continue;

                    // Record the property ...
                    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 (idProperties.size() != 0) {
            // Update the location based upon the merged ID properties ...
            Location newLocation = new Location(location.getPath(), idProperties.values());
            federatedNode.setActualLocationOfNode(newLocation);

            // Look for the UUID property on the location, and update the federated node ...
            Property uuidProperty = idProperties.get(DnaLexicon.UUID);
            if (uuidProperty != null && !uuidProperty.isEmpty()) {
                UUID uuid = context.getValueFactories().getUuidFactory().create(uuidProperty.getValues().next());
                federatedNode.setUuid(uuid);

                // Set the UUID as a property ...
                properties.put(uuidProperty.getName(), uuidProperty);
            }
        } else {
            // Generate a new UUID property and add to the node ...
            UUID uuid = federatedNode.getUuid();
            if (uuid == null) {
                uuid = context.getValueFactories().getUuidFactory().create();
                federatedNode.setUuid(uuid);
            }

            // Set the UUID as a property ...
            Property uuidProperty = context.getPropertyFactory().create(DnaLexicon.UUID, uuid);
            properties.put(uuidProperty.getName(), uuidProperty);
        }

        // Assign the merge plan ...
        MergePlan mergePlan = MergePlan.create(contributions);
        federatedNode.setMergePlan(mergePlan);
View Full Code Here

            Location child = translateChildFromSourceToRepository(pathFactory, location, childIterator.next());
            federatedNode.addChild(child);
        }

        // Copy the properties ...
        Property uuidProperty = null;
        Property dnaUuidProperty = null;
        Iterator<Property> propertyIterator = contribution.getProperties();
        while (propertyIterator.hasNext()) {
            Property property = propertyIterator.next();
            federatedNode.addProperty(property);
            if (property.isSingle()) {
                if (property.getName().equals(DnaLexicon.UUID) && hasUuidValue(context, property)) {
                    dnaUuidProperty = property;
                } else if (property.getName().getLocalName().equals("uuid") && hasUuidValue(context, property)) {
                    uuidProperty = property;
                }
            }
        }
        if (dnaUuidProperty != null) uuidProperty = dnaUuidProperty; // use "dna:uuid" if there is one
View Full Code Here

        // Create the node, and use the existing UUID if one is found in the cache ...
        ExecutionContext context = getExecutionContext();
        assert context != null;
        UUID uuid = null;
        Property uuidProperty = location.getIdProperty(DnaLexicon.UUID);
        // If the actual location has no UUID identification property ...
        if (uuidProperty == null || uuidProperty.isEmpty()) {
            uuid = context.getValueFactories().getUuidFactory().create();
            uuidProperty = context.getPropertyFactory().create(DnaLexicon.UUID, uuid);
            // Replace the actual location with one that includes the new UUID property ...
            location = location.with(uuidProperty);
        } else {
            assert uuidProperty.isEmpty() == false;
            uuid = context.getValueFactories().getUuidFactory().create(uuidProperty.getValues().next());
        }
        assert uuid != null;
        FederatedNode mergedNode = new FederatedNode(location, uuid);

        // Merge the results into a single set of results ...
View Full Code Here

TOP

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

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.