Package org.apache.ojb.odmg.states

Examples of org.apache.ojb.odmg.states.ModificationState


     * is not persisten already. The state will be set to StateOldClean if the object is already persistent.
     */
    private void prepareInitialState(boolean isNewObject)
    {
        // determine appropriate modification state
        ModificationState initialState;
        if(isNewObject)
        {
            // if object is not already persistent it must be marked as new
            // it must be marked as dirty because it must be stored even if it will not modified during tx
            initialState = StateNewDirty.getInstance();
View Full Code Here


     * @return an Edge object or null if the two database operations can
     *      be performed in any order
     */
    protected Edge buildConcrete11Edge(Vertex vertex1, Vertex vertex2, boolean fkToRef)
    {
        ModificationState state1 = vertex1.getEnvelope().getModificationState();
        ModificationState state2 = vertex2.getEnvelope().getModificationState();
        if (state1.needsUpdate() || state1.needsInsert())
        {
            if (state2.needsInsert())
            {
                // (2) must be inserted before (1) can point to it
                return new Edge(vertex2, vertex1, fkToRef ? CONCRETE_EDGE_WEIGHT_WITH_FK : CONCRETE_EDGE_WEIGHT);
            }
        }
        else if (state1.needsDelete())
        {
            if (state2.needsDelete())
            {
                // (1) points to (2) and must be deleted first
                return new Edge(vertex1, vertex2, fkToRef ? CONCRETE_EDGE_WEIGHT_WITH_FK : CONCRETE_EDGE_WEIGHT);
            }
        }
View Full Code Here

     * @return an Edge object or null if the two database operations can
     *      be performed in any order
     */
    protected Edge buildPotential11Edge(Vertex vertex1, Vertex vertex2, boolean fkToRef)
    {
        ModificationState state1 = vertex1.getEnvelope().getModificationState();
        ModificationState state2 = vertex2.getEnvelope().getModificationState();
        if (state1.needsUpdate() || state1.needsDelete())
        {
            if (state2.needsDelete())
            {
                // old version of (1) might point to (2)
                return new Edge(vertex1, vertex2, fkToRef ? POTENTIAL_EDGE_WEIGHT_WITH_FK : POTENTIAL_EDGE_WEIGHT);
            }
        }
View Full Code Here

     * @return an Edge object or null if the two database operations can
     *      be performed in any order
     */
    protected Edge buildConcrete1NEdge(Vertex vertex1, Vertex vertex2)
    {
        ModificationState state1 = vertex1.getEnvelope().getModificationState();
        ModificationState state2 = vertex2.getEnvelope().getModificationState();
        if (state1.needsInsert())
        {
            if (state2.needsUpdate() || state2.needsInsert())
            {
                // (2) now contains an FK to (1) thus (1) must be inserted first
                return new Edge(vertex1, vertex2, CONCRETE_EDGE_WEIGHT);
            }
        }
        else if (state1.needsDelete())
        {
            if (state2.needsUpdate() || state2.needsDelete())
            {
                // Before deleting (1) give (2) a chance to drop its FK to it
                return new Edge(vertex2, vertex1, CONCRETE_EDGE_WEIGHT);
            }
        }
View Full Code Here

     * @return an Edge object or null if the two database operations can
     *      be performed in any order
     */
    protected Edge buildPotential1NEdge(Vertex vertex1, Vertex vertex2)
    {
        ModificationState state1 = vertex1.getEnvelope().getModificationState();
        ModificationState state2 = vertex2.getEnvelope().getModificationState();
        if (state1.needsDelete())
        {
            if (state2.needsUpdate() || state2.needsDelete())
            {
                // Before deleting (1) give potential previous collection
                // members a chance to drop their FKs to it
                return new Edge(vertex2, vertex1, POTENTIAL_EDGE_WEIGHT);
            }
View Full Code Here

     * @return an Edge object or null if the two database operations can
     *      be performed in any order
     */
    protected Edge buildConcreteMNEdge(Vertex vertex1, Vertex vertex2)
    {
        ModificationState state1 = vertex1.getEnvelope().getModificationState();
        ModificationState state2 = vertex2.getEnvelope().getModificationState();
        if (state1.needsUpdate() || state1.needsInsert())
        {
            if (state2.needsInsert())
            {
                // (2) must be inserted before we can create a link to it
                return new Edge(vertex2, vertex1, CONCRETE_EDGE_WEIGHT);
            }
        }
        else if (state1.needsDelete())
        {
            if (state2.needsDelete())
            {
                // there is a link from (1) to (2) which must be deleted first,
                // which will happen when deleting (1) - thus:
                return new Edge(vertex1, vertex2, POTENTIAL_EDGE_WEIGHT);
            }
View Full Code Here

     * @return an Edge object or null if the two database operations can
     *      be performed in any order
     */
    protected Edge buildPotentialMNEdge(Vertex vertex1, Vertex vertex2)
    {
        ModificationState state1 = vertex1.getEnvelope().getModificationState();
        ModificationState state2 = vertex2.getEnvelope().getModificationState();
        if (state1.needsUpdate() || state1.needsDelete())
        {
            if (state2.needsDelete())
            {
                // old version of (1) might comprise a link to (2)
                return new Edge(vertex1, vertex2, POTENTIAL_EDGE_WEIGHT);
            }
        }
View Full Code Here

        }
        catch (ODMGException ex)
        {
            fail("ODMGException: " + ex.getMessage());
        }
        ModificationState oldState = StateNewClean.getInstance();
        ModificationState newState = oldState.markDirty();
        assertEquals(StateNewDirty.getInstance(), newState);

        oldState = newState;
        newState = oldState.markDirty();
        assertEquals(oldState, newState);
View Full Code Here

        }
        catch (ODMGException ex)
        {
            fail("ODMGException: " + ex.getMessage());
        }
        ModificationState oldState = StateNewClean.getInstance();
        ModificationState newState = oldState.markDirty();
        assertEquals(StateNewDirty.getInstance(), newState);

        oldState = newState;
        newState = oldState.markDirty();
        assertEquals(oldState, newState);
View Full Code Here

     * is not persisten already. The state will be set to StateOldClean if the object is already persistent.
     */
    private void prepareInitialState()
    {
        // determine appropriate modification state
        ModificationState initialState = null;
        boolean needsInsert;
        try
        {
            // try to lookup the object.
            needsInsert = tx.getBroker().serviceObjectCache().lookup(oid) == null
View Full Code Here

TOP

Related Classes of org.apache.ojb.odmg.states.ModificationState

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.