Package org.jboss.dna.graph.property

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


        MapNode copyRoot = copyNode(context, original, newWorkspace, newParent, desiredName, true, oldToNewUuids);

        // 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;
                        }
View Full Code Here


                                           Map<String, String> oldUuidToNewUuid ) throws IOException, ClassNotFoundException {
        assert input != null;
        assert output != null;
        if (oldUuidToNewUuid == null) oldUuidToNewUuid = Collections.emptyMap();

        UuidFactory uuidFactory = valueFactories.getUuidFactory();
        ValueFactory<Reference> referenceFactory = valueFactories.getReferenceFactory();

        // Read the number of properties ...
        int count = input.readInt();
        output.writeInt(count);
        // Deserialize all of the proeprties ...
        for (int i = 0; i != count; ++i) {
            // Read and write the property name ...
            Object name = input.readObject();
            output.writeObject(name);
            // Read and write the number of values ...
            int numValues = input.readInt();
            output.writeInt(numValues);
            // Now read and write each property value ...
            for (int j = 0; j != numValues; ++j) {
                // Read and write the type of value ...
                char type = input.readChar();
                output.writeChar(type);
                switch (type) {
                    case 'S':
                        output.writeObject(input.readObject());
                        break;
                    case 'b':
                        output.writeBoolean(input.readBoolean());
                        break;
                    case 'i':
                        output.writeInt(input.readInt());
                        break;
                    case 'l':
                        output.writeLong(input.readLong());
                        break;
                    case 's':
                        output.writeShort(input.readShort());
                        break;
                    case 'f':
                        output.writeFloat(input.readFloat());
                        break;
                    case 'd':
                        output.writeDouble(input.readDouble());
                        break;
                    case 'c':
                        // char
                        output.writeChar(input.readChar());
                        break;
                    case 'U':
                        // UUID
                        output.writeLong(input.readLong());
                        output.writeLong(input.readLong());
                        break;
                    case 'I':
                        // URI
                        output.writeObject(input.readObject());
                        break;
                    case 'N':
                        // Name
                        output.writeObject(input.readObject());
                        break;
                    case 'P':
                        // Path
                        output.writeObject(input.readObject());
                        break;
                    case 'T':
                        // DateTime
                        output.writeObject(input.readObject());
                        break;
                    case 'D':
                        // BigDecimal
                        output.writeObject(input.readObject());
                        break;
                    case 'R':
                        // Reference
                        String refValue = (String)input.readObject();
                        Reference ref = referenceFactory.create(refValue);
                        try {
                            UUID toUuid = uuidFactory.create(ref);
                            String newUuid = oldUuidToNewUuid.get(toUuid.toString());
                            if (newUuid != null) {
                                // Create a new reference ...
                                ref = referenceFactory.create(newUuid);
                                refValue = ref.getString();
View Full Code Here

            if ((this.uuids != null) && (this.uuids.length != 0)) {
                UUID matchUuid = change.getLocation().getUuid();

                if (matchUuid != null) {
                    accept = false;
                    UuidFactory uuidFactory = getValueFactories().getUuidFactory();

                    for (String uuidText : this.uuids) {
                        if ((uuidText != null) && (uuidText.length() != 0)) {
                            try {
                                UUID testUuid = uuidFactory.create(uuidText);

                                if (matchUuid.equals(testUuid)) {
                                    accept = true;
                                    break;
                                }
View Full Code Here

        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;
                            }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.property.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.