Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package org.litesoft.prioritizer.server.pos;

import java.io.*;
import java.sql.*;

import org.litesoft.core.simpletypes.*;
import org.litesoft.core.typeutils.*;
import org.litesoft.core.util.*;
import org.litesoft.orsup.base.*;
import org.litesoft.orsup.selection.*;
import org.litesoft.orsup.transact.*;
import org.litesoft.prioritizer.server.*;

public class Story extends StoryGO
{
    public Story( Transaction pTransaction )
    {
        super( pTransaction );
    }

    public Story( ConstructionControl pConstructionControl )
    {
        super( pConstructionControl );
    }

    @Override
    protected void transactionDisposed()
    {
        mCommitUpdate = null;
        super.transactionDisposed();
    }

    private transient StoryUpdate mCommitUpdate = null;

    @Override
    public Serializable aboutToCommit( Timestamp pTransactionTimestamp )
    {
        Transaction zTransaction = getTransaction();
        if ( isNew() )
        {
            if ( getRestrictedResource() == null )
            {
                setRestrictedResource( CurrentRestrictedResourceAccessor.get().getRequiredRestrictedResource().freshIntoIfNotAlreadyIn( zTransaction ) );
            }
            if ( getCreator() == null )
            {
                setCreator( CurrentUserAccessor.get().getRequiredUser().freshIntoIfNotAlreadyIn( zTransaction ) );
            }
        }
        else if ( isAnyAttributeChanged() && notJustPriorityLastChangedBy() )
        {
            if ( mCommitUpdate != null )
            {
                removeUpdates( mCommitUpdate );
                mCommitUpdate.requestDelete();
                mCommitUpdate = null;
            }
            User zUser = CurrentUserAccessor.get().getRequiredUser().freshIntoIfNotAlreadyIn( zTransaction );
            addUpdates( mCommitUpdate = new StoryUpdate( zTransaction, zUser ) );
            for ( String zChangedAttributeName : getChangedAttributeNames() )
            {
                AttributeAccessorSCD<Story> zACD = getAccessorSCDrequired( zChangedAttributeName );
                if ( zACD.isPersisted() )
                {
                    if ( zACD == CD_Priority )
                    {
                        setPriorityLastChangedBy( zUser.getFullName() );
                    }
                    if ( zACD != CD_PriorityLastChangedBy )
                    {
                        String zName = zACD.getName();
                        String zOldValue = Objects.toString( getOriginalValueFor( zName ) );
                        mCommitUpdate.addChanges( new StoryChange( zTransaction, zName, zOldValue ) );
                    }
                }
            }
        }
        return super.aboutToCommit( pTransactionTimestamp );
    }

    private boolean notJustPriorityLastChangedBy()
    {
        int changes = numberOfAttributeChanged();
        return (changes > 1) || ((changes == 1) && !isAttributeChanged( CD_PriorityLastChangedBy ));
    }

    private GenericReference<String> mChanges = null;

    @Override
    protected void LLclearChanges()
    {
        mChanges = GenericReference.dispose( mChanges );
    }

    @Override
    public String getChanges()
    {
        if ( mChanges == null )
        {
            mChanges = new GenericReference<String>( createChanges() );
        }
        return mChanges.get();
    }

    private String createChanges()
    {
        StringBuilder sb = new StringBuilder();
        for ( StoryUpdate zUpdate : getUpdates() )
        {
            zUpdate.toString( sb );
        }
        return sb.toString();
    }

    public static WhereClause getLimitToCurrentRestrictedResource()
    {
        // Add filter to where clause to only select based on RestrictedResource.
        RestrictedResource zRestrictedResource = CurrentRestrictedResourceAccessor.get().getRequiredRestrictedResource();
        return WhereClauseFactory.INSTANCE.isEqual( CD_RestrictedResource, zRestrictedResource );
    }
}

Commits for litesoft/trunk/GWT_Sandbox/Prioritizer/src/org/litesoft/prioritizer/server/pos/Story.java

Diff revisions: vs.
Revision Author Commited Message
822 Diff Diff GeorgeS picture GeorgeS Sun 19 Aug, 2012 01:03:51 +0000
398 GeorgeS picture GeorgeS Mon 15 Aug, 2011 19:57:47 +0000