Package org.apache.openjpa.lib.graph

Examples of org.apache.openjpa.lib.graph.Edge


        graph.addNode(row2);

        // add an edge from row1 to row2, and set the fk causing the
        // dependency as the user object so we can retrieve it when resolving
        // circular constraints
        Edge edge = new Edge(row1, row2, true);
        edge.setUserObject(fk);
        graph.addEdge(edge);

        return graph;
    }
View Full Code Here


     * Circular dependencies can be broken at this point.
     * @param cycle Cycle in the dependency graph.
     * @return Edge corresponding to a nullable foreign key.
     */
    private Edge findBreakableLink(List cycle) {
        Edge breakableLink = null;
        for (Iterator iter = cycle.iterator(); iter.hasNext(); ) {
            Edge edge = (Edge) iter.next();
            Object userObject = edge.getUserObject();
            if (userObject instanceof ForeignKey) {
                 if (!((ForeignKey) userObject).hasNotNullColumns()) {
                     breakableLink = edge;
                     break;
                 }
View Full Code Here

    private boolean resolveCycles(Graph graph, Collection edges,
        Collection deleteUpdates, Collection insertUpdates)
        throws SQLException {
        boolean recalculate = false;
        for (Iterator itr = edges.iterator(); itr.hasNext();) {
            Edge edge = (Edge) itr.next();
            List cycle = edge.getCycle();

            if (cycle != null) {
                // find a nullable foreign key
                Edge breakableLink = findBreakableLink(cycle);
                if (breakableLink == null) {
                    throw new UserException(_loc.get("no-nullable-fk"));
                }

                // topologic node order must be re-calculated,  if the
                // breakable link is different from the edge where
                // the circular dependency was originally detected
                if (edge != breakableLink) {
                    recalculate = true;
                }

                if (!breakableLink.isRemovedFromGraph()) {

                    // use a primary row update to prevent setting pk and fk values
                    // until after flush, to get latest auto-increment values
                    PrimaryRow row = (PrimaryRow) breakableLink.getFrom();
                    if (row.getAction() == Row.ACTION_DELETE) {
                        addDeleteUpdate(breakableLink, deleteUpdates);
                    } else {
                        addInsertUpdate(row, breakableLink, insertUpdates);
                    }
View Full Code Here

        graph.addNode(row2);

        // add an edge from row1 to row2, and set the fk causing the
        // dependency as the user object so we can retrieve it when resolving
        // circular constraints
        Edge edge = new Edge(row1, row2, true);
        edge.setUserObject(fk);
        graph.addEdge(edge);

        return graph;
    }
View Full Code Here

     * Circular dependencies can be broken at this point.
     * @param cycle Cycle in the dependency graph.
     * @return Edge corresponding to a nullable foreign key.
     */
    private Edge findBreakableLink(List cycle) {
        Edge breakableLink = null;
        for (Iterator iter = cycle.iterator(); iter.hasNext(); ) {
            Edge edge = (Edge) iter.next();
            Object userObject = edge.getUserObject();
            if (userObject instanceof ForeignKey) {
                 if (!((ForeignKey) userObject).hasNotNullColumns()) {
                     breakableLink = edge;
                     break;
                 }
View Full Code Here

    private boolean resolveCycles(Graph graph, Collection edges,
        Collection deleteUpdates, Collection insertUpdates)
        throws SQLException {
        boolean recalculate = false;
        for (Iterator itr = edges.iterator(); itr.hasNext();) {
            Edge edge = (Edge) itr.next();
            List cycle = edge.getCycle();

            if (cycle != null) {
                // find a nullable foreign key
                Edge breakableLink = findBreakableLink(cycle);
                if (breakableLink == null) {
                    throw new UserException(_loc.get("no-nullable-fk"));
                }

                // topologic node order must be re-calculated,  if the
                // breakable link is different from the edge where
                // the circular dependency was originally detected
                if (edge != breakableLink) {
                    recalculate = true;
                }

                if (!breakableLink.isRemovedFromGraph()) {

                    // use a primary row update to prevent setting pk and fk values
                    // until after flush, to get latest auto-increment values
                    PrimaryRow row = (PrimaryRow) breakableLink.getFrom();
                    if (row.getAction() == Row.ACTION_DELETE) {
                        addDeleteUpdate(breakableLink, deleteUpdates);
                    } else {
                        addInsertUpdate(row, breakableLink, insertUpdates);
                    }
View Full Code Here

        graph.addNode(row2);

        // add an edge from row1 to row2, and set the fk causing the
        // dependency as the user object so we can retrieve it when resolving
        // circular constraints
        Edge edge = new Edge(row1, row2, true);
        edge.setUserObject(fk);
        graph.addEdge(edge);

        return graph;
    }
View Full Code Here

     * Circular dependencies can be broken at this point.
     * @param cycle Cycle in the dependency graph.
     * @return Edge corresponding to a nullable foreign key.
     */
    private Edge findBreakableLink(List cycle) {
        Edge breakableLink = null;
        for (Iterator iter = cycle.iterator(); iter.hasNext(); ) {
            Edge edge = (Edge) iter.next();
            Object userObject = edge.getUserObject();
            if (userObject instanceof ForeignKey) {
                 if (!((ForeignKey) userObject).hasNotNullColumns()) {
                     breakableLink = edge;
                     break;
                 }
View Full Code Here

    private boolean resolveCycles(Graph graph, Collection edges,
        Collection deleteUpdates, Collection insertUpdates)
        throws SQLException {
        boolean recalculate = false;
        for (Iterator itr = edges.iterator(); itr.hasNext();) {
            Edge edge = (Edge) itr.next();
            List cycle = edge.getCycle();

            if (cycle != null) {
                // find a nullable foreign key
                Edge breakableLink = findBreakableLink(cycle);
                if (breakableLink == null) {
                    throw new UserException(_loc.get("no-nullable-fk"));
                }

                // topologic node order must be re-calculated,  if the
                // breakable link is different from the edge where
                // the circular dependency was originally detected
                if (edge != breakableLink) {
                    recalculate = true;
                }

                if (!breakableLink.isRemovedFromGraph()) {

                    // use a primary row update to prevent setting pk and fk
                    // values until after flush, to get latest auto-increment
                    // values
                    PrimaryRow row = (PrimaryRow) breakableLink.getFrom();
                    if (row.getAction() == Row.ACTION_DELETE) {
                        addDeleteUpdate(breakableLink, deleteUpdates);
                    } else {
                        addInsertUpdate(row, breakableLink, insertUpdates);
                    }
View Full Code Here

        graph.addNode(row2);

        // add an edge from row1 to row2, and set the fk causing the
        // dependency as the user object so we can retrieve it when resolving
        // circular constraints
        Edge edge = new Edge(row1, row2, true);
        edge.setUserObject(fk);
        graph.addEdge(edge);

        return graph;
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.lib.graph.Edge

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.