Examples of DepthFirstAnalysis


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

        boolean autoAssign)
        throws SQLException {
        if (graph == null)
            return;

        DepthFirstAnalysis dfa = newDepthFirstAnalysis(graph, autoAssign);
        Collection insertUpdates = new LinkedList();
        Collection deleteUpdates = new LinkedList();
        boolean recalculate;

        // Handle circular constraints:
        // - if deleted row A has a ciricular fk to deleted row B,
        //   then use an update statement to null A's fk to B before flushing,
        //   and then flush
        // - if inserted row A has a circular fk to updated/inserted row B,
        //   then null the fk in the B row object, then flush,
        //   and after flushing, use an update to set the fk back to A
        // Depending on where circular dependencies are broken, the 
        // topological order of the graph nodes has to be re-calculated.
        recalculate = resolveCycles(graph, dfa.getEdges(Edge.TYPE_BACK),
                deleteUpdates, insertUpdates);
        recalculate |= resolveCycles(graph, dfa.getEdges(Edge.TYPE_FORWARD),
                deleteUpdates, insertUpdates);

        if (recalculate) {
            dfa = recalculateDepthFirstAnalysis(graph, autoAssign);
        }

        // flush delete updates to null fks, then all rows in order, then
        // the insert updates to set circular fk values
        flush(deleteUpdates, psMgr);
        Collection nodes = dfa.getSortedNodes();
        for (Iterator itr = nodes.iterator(); itr.hasNext();)
            psMgr.flush((RowImpl) itr.next());
        flush(insertUpdates, psMgr);
    }
View Full Code Here

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

     * @param autoAssign Whether any of the rows in the graph have any
     * auto-assign constraints
     */
    private DepthFirstAnalysis recalculateDepthFirstAnalysis(Graph graph,
        boolean autoAssign) {
        DepthFirstAnalysis dfa;
        // clear previous traversal data
        graph.clearTraversal();
        dfa = newDepthFirstAnalysis(graph, autoAssign);
        // make sure that the graph is non-cyclic now
        assert (dfa.hasNoCycles()): _loc.get("graph-not-cycle-free");
        return dfa;
    }
View Full Code Here

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

     * Create a new {@link DepthFirstAnalysis} suitable for the given graph
     * and auto-assign settings.
     */
    protected DepthFirstAnalysis newDepthFirstAnalysis(Graph graph,
        boolean autoAssign) {
        return new DepthFirstAnalysis(graph);
    }
View Full Code Here

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

        boolean autoAssign)
        throws SQLException {
        if (graph == null)
            return;

        DepthFirstAnalysis dfa = newDepthFirstAnalysis(graph, autoAssign);
        Collection insertUpdates = new LinkedList();
        Collection deleteUpdates = new LinkedList();
        boolean recalculate;

        // Handle circular constraints:
        // - if deleted row A has a ciricular fk to deleted row B,
        //   then use an update statement to null A's fk to B before flushing,
        //   and then flush
        // - if inserted row A has a circular fk to updated/inserted row B,
        //   then null the fk in the B row object, then flush,
        //   and after flushing, use an update to set the fk back to A
        // Depending on where circular dependencies are broken, the 
        // topological order of the graph nodes has to be re-calculated.
        recalculate = resolveCycles(graph, dfa.getEdges(Edge.TYPE_BACK),
                deleteUpdates, insertUpdates);
        recalculate |= resolveCycles(graph, dfa.getEdges(Edge.TYPE_FORWARD),
                deleteUpdates, insertUpdates);

        if (recalculate) {
            dfa = recalculateDepthFirstAnalysis(graph, autoAssign);
        }

        // flush delete updates to null fks, then all rows in order, then
        // the insert updates to set circular fk values
        flush(deleteUpdates, psMgr);
        Collection nodes = dfa.getSortedNodes();
        for (Iterator itr = nodes.iterator(); itr.hasNext();)
            psMgr.flush((RowImpl) itr.next());
        flush(insertUpdates, psMgr);
    }
View Full Code Here

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

     * @param autoAssign Whether any of the rows in the graph have any
     * auto-assign constraints
     */
    private DepthFirstAnalysis recalculateDepthFirstAnalysis(Graph graph,
        boolean autoAssign) {
        DepthFirstAnalysis dfa;
        // clear previous traversal data
        graph.clearTraversal();
        dfa = newDepthFirstAnalysis(graph, autoAssign);
        // make sure that the graph is non-cyclic now
        assert (dfa.hasNoCycles()): _loc.get("graph-not-cycle-free");
        return dfa;
    }
View Full Code Here

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

     * Create a new {@link DepthFirstAnalysis} suitable for the given graph
     * and auto-assign settings.
     */
    protected DepthFirstAnalysis newDepthFirstAnalysis(Graph graph,
        boolean autoAssign) {
        return new DepthFirstAnalysis(graph);
    }
View Full Code Here

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

        boolean autoAssign)
        throws SQLException {
        if (graph == null)
            return;

        DepthFirstAnalysis dfa = newDepthFirstAnalysis(graph, autoAssign);
        Collection insertUpdates = new LinkedList();
        Collection deleteUpdates = new LinkedList();
        boolean recalculate;

        // Handle circular constraints:
        // - if deleted row A has a ciricular fk to deleted row B,
        //   then use an update statement to null A's fk to B before flushing,
        //   and then flush
        // - if inserted row A has a circular fk to updated/inserted row B,
        //   then null the fk in the B row object, then flush,
        //   and after flushing, use an update to set the fk back to A
        // Depending on where circular dependencies are broken, the 
        // topological order of the graph nodes has to be re-calculated.
        recalculate = resolveCycles(graph, dfa.getEdges(Edge.TYPE_BACK),
                deleteUpdates, insertUpdates);
        recalculate |= resolveCycles(graph, dfa.getEdges(Edge.TYPE_FORWARD),
                deleteUpdates, insertUpdates);

        if (recalculate) {
            dfa = recalculateDepthFirstAnalysis(graph, autoAssign);
        }

        // flush delete updates to null fks, then all rows in order, then
        // the insert updates to set circular fk values
        Collection nodes = dfa.getSortedNodes();
        flush(deleteUpdates, nodes, psMgr);
        flush(insertUpdates, psMgr);
    }
View Full Code Here

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

     * @param autoAssign Whether any of the rows in the graph have any
     * auto-assign constraints
     */
    private DepthFirstAnalysis recalculateDepthFirstAnalysis(Graph graph,
        boolean autoAssign) {
        DepthFirstAnalysis dfa;
        // clear previous traversal data
        graph.clearTraversal();
        dfa = newDepthFirstAnalysis(graph, autoAssign);
        // make sure that the graph is non-cyclic now
        assert (dfa.hasNoCycles()): _loc.get("graph-not-cycle-free");
        return dfa;
    }
View Full Code Here

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

     * Create a new {@link DepthFirstAnalysis} suitable for the given graph
     * and auto-assign settings.
     */
    protected DepthFirstAnalysis newDepthFirstAnalysis(Graph graph,
        boolean autoAssign) {
        return new DepthFirstAnalysis(graph);
    }
View Full Code Here

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

        boolean autoAssign)
        throws SQLException {
        if (graph == null)
            return;

        DepthFirstAnalysis dfa = newDepthFirstAnalysis(graph, autoAssign);
        Collection insertUpdates = new LinkedList();
        Collection deleteUpdates = new LinkedList();
        boolean recalculate;

        // Handle circular constraints:
        // - if deleted row A has a ciricular fk to deleted row B,
        //   then use an update statement to null A's fk to B before flushing,
        //   and then flush
        // - if inserted row A has a circular fk to updated/inserted row B,
        //   then null the fk in the B row object, then flush,
        //   and after flushing, use an update to set the fk back to A
        // Depending on where circular dependencies are broken, the 
        // topological order of the graph nodes has to be re-calculated.
        recalculate = resolveCycles(graph, dfa.getEdges(Edge.TYPE_BACK),
                deleteUpdates, insertUpdates);
        recalculate |= resolveCycles(graph, dfa.getEdges(Edge.TYPE_FORWARD),
                deleteUpdates, insertUpdates);

        if (recalculate) {
            dfa = recalculateDepthFirstAnalysis(graph, autoAssign);
        }

        // flush delete updates to null fks, then all rows in order, then
        // the insert updates to set circular fk values
        flush(deleteUpdates, psMgr);
        Collection nodes = dfa.getSortedNodes();
        for (Iterator itr = nodes.iterator(); itr.hasNext();)
            psMgr.flush((RowImpl) itr.next());
        flush(insertUpdates, psMgr);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.