Package org.modeshape.jcr.value

Examples of org.modeshape.jcr.value.Reference


        // Create a session that we'll used to change the node ...
        SessionCache versionSession = session.spawnSessionCache(false);
        MutableCachedNode versionable = versionSession.mutable(node.key());
        NodeKey baseVersionKey = node.getBaseVersion().key();
        PropertyFactory props = propertyFactory();
        Reference baseVersionRef = session.referenceFactory().create(baseVersionKey, true);
        versionable.setProperty(versionSession, props.create(JcrLexicon.PREDECESSORS, new Object[] {baseVersionRef}));
        versionable.setProperty(versionSession, props.create(JcrLexicon.IS_CHECKED_OUT, Boolean.TRUE));
        versionSession.save();
    }
View Full Code Here


    protected final void clearCheckoutStatus( MutableCachedNode node,
                                              NodeKey baseVersion,
                                              SessionCache cache,
                                              PropertyFactory propFactory ) {
        Reference baseVersionRef = session.referenceFactory().create(baseVersion);
        node.setProperty(cache, propFactory.create(JcrLexicon.IS_CHECKED_OUT, Boolean.FALSE));
        node.setProperty(cache, propFactory.create(JcrLexicon.BASE_VERSION, baseVersionRef));
    }
View Full Code Here

        if (property != null && property.isReference()) {
            updatedPropertyIsReference = true;
            propertyWhichWasAdded = property;
            for (Object referenceObject : property.getValuesAsArray()) {
                assert referenceObject instanceof Reference;
                Reference updatedReference = (Reference)referenceObject;
                if (referencesToRemove.contains(updatedReference)) {
                    // the reference is already present on a property with the same name, so this is a no-op for that reference
                    // therefore we remove it from the list of references that will be removed
                    if (referencesToRemove.remove(updatedReference)) {

                        // Make sure that the referenced node is not modified to remove the back-reference to this node.
                        // See MODE-2283 for an example ...
                        NodeKey referredKey = nodeKeyFromReference(updatedReference);
                        CachedNode referredNode = cache.getNode(referredKey);
                        if (referredNode instanceof SessionNode) {
                            // The node was modified during this session and has unsaved changes ...
                            SessionNode changedReferrerNode = (SessionNode)referredNode;
                            ReferrerChanges changes = changedReferrerNode.getReferrerChanges();
                            if (changes != null) {
                                // There are changes to that node's referrers ...
                                ReferenceType type = updatedReference.isWeak() ? ReferenceType.WEAK : ReferenceType.STRONG;
                                if (changes.isRemovedReferrer(key, type)) {
                                    // The referenced node had a back reference to this node, but we're no longer removing
                                    // this node's reference to the referenced node, and that means we should no longer remove
                                    // the referenced node's backreference to this node ...
                                    if (updatedReference.isWeak()) changes.addWeakReferrer(propertyWhichWasRemoved, key);
                                    else changes.addStrongReferrer(propertyWhichWasRemoved, key);
                                }
                            }
                        }
                    }
View Full Code Here

        while (referenceValuesIterator.hasNext()) {
            Object value = referenceValuesIterator.next();
            assert value instanceof Reference;

            Reference reference = (Reference)value;
            NodeKey referredKey = nodeKeyFromReference(reference);
            boolean isWeak = reference.isWeak();

            if (isFrozenNode && !isWeak) {
                // JCR 3.13.4.6 ignore all strong outgoing references from a frozen node
                return;
            }
View Full Code Here

                }
                MutableCachedNode targetNode = targetCache.mutable(targetKey);
                for (Property property : referenceProperties) {
                    List<Reference> resolvedReferences = new ArrayList<Reference>();
                    for (Iterator<?> valuesIterator = property.getValues(); valuesIterator.hasNext();) {
                        Reference reference = (Reference)valuesIterator.next();
                        resolvedReferences.add(resolveReference(sourceKey, targetKey, property.getName(), reference));
                    }
                    Property updatedProperty = property.isMultiple() ? propertyFactory.create(property.getName(),
                                                                                              resolvedReferences) : propertyFactory.create(property.getName(),
                                                                                                                                           resolvedReferences.get(0));
View Full Code Here

        }
        if (value instanceof BigDecimal) {
            return Schematic.newDocument("$dec", this.strings.create((BigDecimal)value));
        }
        if (value instanceof Reference) {
            Reference ref = (Reference)value;
            String key = null;
            if (ref.isSimple()) {
                key = SIMPLE_REFERENCE_FIELD;
            } else {
                key = ref.isWeak() ? WEAK_REFERENCE_FIELD : REFERENCE_FIELD;
            }

            String refString = ref instanceof NodeKeyReference ? ((NodeKeyReference)ref).getNodeKey().toString() : this.strings.create(ref);
            boolean isForeign = ref.isForeign();
            return Schematic.newDocument(key, refString, "$foreign", isForeign);
        }
        if (value instanceof URI) {
            return Schematic.newDocument("$uri", this.strings.create((URI)value));
        }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.value.Reference

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.