Package org.apache.cayenne.reflect

Examples of org.apache.cayenne.reflect.ArcProperty


    static void unsetReverse(
            final Persistent sourceObject,
            String propertyName,
            final Persistent targetObject) {

        ArcProperty property = (ArcProperty) Cayenne
                .getClassDescriptor(sourceObject)
                .getProperty(propertyName);
        ArcProperty reverseArc = property.getComplimentaryReverseArc();
        if (reverseArc != null) {
            reverseArc.visit(new PropertyVisitor() {

                public boolean visitToMany(ToManyProperty property) {
                    property.removeTargetDirectly(targetObject, sourceObject);
                    return false;
                }

                public boolean visitToOne(ToOneProperty property) {
                    property.setTarget(targetObject, null, false);
                    return false;
                }

                public boolean visitAttribute(AttributeProperty property) {
                    return false;
                }

            });

            sourceObject.getObjectContext().getGraphManager().arcDeleted(
                    targetObject.getObjectId(),
                    sourceObject.getObjectId(),
                    reverseArc.getName());

            markAsDirty(targetObject);
        }
    }
View Full Code Here


            return;
        }

        ClassDescriptor descriptor = context.getEntityResolver().getClassDescriptor(
                ((ObjectId) nodeId).getEntityName());
        ArcProperty property = (ArcProperty) descriptor.getProperty(arcId.toString());

        setExternalChange(Boolean.TRUE);
        try {
            property.visit(new PropertyVisitor() {

                public boolean visitAttribute(AttributeProperty property) {
                    return false;
                }

                public boolean visitToMany(ToManyProperty property) {
                    // connect reverse arc if the relationship is marked as "runtime"
                    ArcProperty reverseArc = property.getComplimentaryReverseArc();
                    boolean autoConnectReverse = reverseArc != null
                            && reverseArc.getRelationship().isRuntime();

                    property.addTarget(source, target, autoConnectReverse);
                    return false;
                }
View Full Code Here

                    return false;
                }

                public boolean visitToMany(ToManyProperty property) {
                    // connect reverse arc if the relationship is marked as "runtime"
                    ArcProperty reverseArc = property.getComplimentaryReverseArc();
                    boolean autoConnectReverse = reverseArc != null
                            && reverseArc.getRelationship().isRuntime();

                    Persistent target = findObject(targetNodeId);

                    if (target == null) {
View Full Code Here

            return;
        }

        ClassDescriptor descriptor = context.getEntityResolver().getClassDescriptor(
                ((ObjectId) nodeId).getEntityName());
        ArcProperty property = (ArcProperty) descriptor.getProperty(arcId.toString());

        property.visit(new PropertyVisitor() {

            public boolean visitAttribute(AttributeProperty property) {
                return false;
            }

            public boolean visitToMany(ToManyProperty property) {
                property.addTargetDirectly(source, target);
                return false;
            }

            public boolean visitToOne(ToOneProperty property) {
                property.setTarget(source, target, false);
                return false;
            }
        });
        context.propertyChanged(source, (String) arcId, null, target);
    }
View Full Code Here

        }

        // TODO (Andrus, 10/17/2005) - check for local modifications to avoid
        // overwriting...

        ArcProperty p = (ArcProperty) propertyForId(nodeId, arcId.toString());
        if (p.isFault(source)) {
            return;
        }

        Object target = context.internalGraphManager().getNode(targetNodeId);
        if (target == null) {
            target = context.createFault((ObjectId) targetNodeId);
        }

        try {
            if (p instanceof ToManyProperty) {
                ((ToManyProperty) p).addTargetDirectly(source, target);
            }
            else {
                p.writePropertyDirectly(source, null, target);
            }
        }
        finally {
        }
    }
View Full Code Here

            // no need to disconnect non-existent object
            return;
        }

        // (see "TODO" in 'arcCreated')
        ArcProperty p = (ArcProperty) propertyForId(nodeId, arcId.toString());
        if (p.isFault(source)) {
            return;
        }

        Object target = context.internalGraphManager().getNode(targetNodeId);
        if (target == null) {
            target = context.createFault((ObjectId) targetNodeId);
        }

        try {
            if (p instanceof ToManyProperty) {
                ((ToManyProperty) p).removeTargetDirectly(source, target);
            }
            else {
                p.writePropertyDirectly(source, target, null);
            }
        }
        finally {
        }
    }
View Full Code Here

    static void setReverse(
            final Persistent sourceObject,
            String propertyName,
            final Persistent targetObject) {

        ArcProperty property = (ArcProperty) Cayenne
                .getClassDescriptor(sourceObject)
                .getProperty(propertyName);
        ArcProperty reverseArc = property.getComplimentaryReverseArc();
        if (reverseArc != null) {
            reverseArc.visit(new PropertyVisitor() {

                public boolean visitToMany(ToManyProperty property) {
                    property.addTargetDirectly(targetObject, sourceObject);
                    return false;
                }

                public boolean visitToOne(ToOneProperty property) {
                    property.setTarget(targetObject, sourceObject, false);
                    return false;
                }

                public boolean visitAttribute(AttributeProperty property) {
                    return false;
                }

            });

            sourceObject.getObjectContext().getGraphManager().arcCreated(
                    targetObject.getObjectId(),
                    sourceObject.getObjectId(),
                    reverseArc.getName());

            markAsDirty(targetObject);
        }
    }
View Full Code Here

    static void unsetReverse(
            final Persistent sourceObject,
            String propertyName,
            final Persistent targetObject) {

        ArcProperty property = (ArcProperty) Cayenne
                .getClassDescriptor(sourceObject)
                .getProperty(propertyName);
        ArcProperty reverseArc = property.getComplimentaryReverseArc();
        if (reverseArc != null) {
            reverseArc.visit(new PropertyVisitor() {

                public boolean visitToMany(ToManyProperty property) {
                    property.removeTargetDirectly(targetObject, sourceObject);
                    return false;
                }

                public boolean visitToOne(ToOneProperty property) {
                    property.setTarget(targetObject, null, false);
                    return false;
                }

                public boolean visitAttribute(AttributeProperty property) {
                    return false;
                }

            });

            sourceObject.getObjectContext().getGraphManager().arcDeleted(
                    targetObject.getObjectId(),
                    sourceObject.getObjectId(),
                    reverseArc.getName());

            markAsDirty(targetObject);
        }
    }
View Full Code Here

        // test that checking for modifications does not trigger a fault, and generally
        // works well

        ClassDescriptor d = context.getEntityResolver().getClassDescriptor(
                "FlattenedTest3");
        ArcProperty flattenedRel = (ArcProperty) d.getProperty("toFT1");

        ObjectDiff diff = context.getObjectStore().registerDiff(ft3.getObjectId(), null);
        assertFalse(DataRowUtils.isToOneTargetModified(flattenedRel, ft3, diff));
        assertTrue(ft3.readPropertyDirectly("toFT1") instanceof Fault);
    }
View Full Code Here

    static void setReverse(
            final Persistent sourceObject,
            String propertyName,
            final Persistent targetObject) {

        ArcProperty property = (ArcProperty) Cayenne
                .getClassDescriptor(sourceObject)
                .getProperty(propertyName);
        ArcProperty reverseArc = property.getComplimentaryReverseArc();
        if (reverseArc != null) {
            reverseArc.visit(new PropertyVisitor() {

                public boolean visitToMany(ToManyProperty property) {
                    property.addTargetDirectly(targetObject, sourceObject);
                    return false;
                }

                public boolean visitToOne(ToOneProperty property) {
                    property.setTarget(targetObject, sourceObject, false);
                    return false;
                }

                public boolean visitAttribute(AttributeProperty property) {
                    return false;
                }

            });

            sourceObject.getObjectContext().getGraphManager().arcCreated(
                    targetObject.getObjectId(),
                    sourceObject.getObjectId(),
                    reverseArc.getName());

            markAsDirty(targetObject);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.reflect.ArcProperty

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.