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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt
package org.litesoft.ui_1_5;

import org.litesoft.*;
import org.litesoft.core.typeutils.*;
import org.litesoft.ui.def.nonpublic.support.*;

public class ServicePeerToFormDataProxy
{
    private static final String POTENTIAL_INTERACTION_CONFLICT_WITH_USER =
            "PotentialInteractionConflictWithUser";
    private static final String POTENTIAL_INTERACTION_CONFLICT_WITH_ANOTHER =
            "PotentialInteractionConflictWithAnother";
    private static final String PROBABLE_OLD_DATA_DUE_TO_UPDATE_BY_USER = "ProbableOldDataDueToUpdateByUser";
    private static final String PROBABLE_OLD_DATA_DUE_TO_UPDATE_BY_ANOTHER =
            "ProbableOldDataDueToUpdateByAnother";

    private ServicePeerToFormDataCollector mCollector = new ServicePeerToFormDataCollector();

    public synchronized ServicePeerToFormData createReturnValueFromCollectorIfMatches(
            Integer pAsyncMessageNumber, FormInteractionHelper pInteractionHelper,
            ExternalizationInterface pExternalization )
    {
        if ( Objects.areNonArraysEqual( pAsyncMessageNumber, mCollector.getAsyncMessageNumber() ) )
        {
            synchronized ( pInteractionHelper )
            {
                for ( FormInteractionStructure zFIS : pInteractionHelper.getUpdatedDataEntries() )
                {
                    addError( pExternalization, zFIS );
                }
                for ( FormInteractionStructure zFIS : pInteractionHelper.getEditingDataEntries() )
                {
                    addWarning( pExternalization, zFIS );
                }
            }
            if ( mCollector.shouldReturn() )
            {
                ServicePeerToFormData rv = new ServicePeerToFormData( mCollector );
                mCollector = new ServicePeerToFormDataCollector();
                return rv;
            }
        }
        return null;
    }

    public synchronized void setCallFromClientForm( Integer pAsyncMessageNumber )
    {
        mCollector.setAsyncMessageNumber( pAsyncMessageNumber );
    }

    public synchronized void update( FormInteractionStructure pCurData, FormInteractionStructure pNewData )
    {
        if ( !Objects.areNonArraysEqual( pCurData.getRootType(), pNewData.getRootType() ) )
        {
            mCollector.setRootType( pNewData.getRootType() );
        }
        if ( !Objects.areNonArraysEqual( pCurData.getRootObjectKey(), pNewData.getRootObjectKey() ) )
        {
            mCollector.setRootObjectKey( pNewData.getRootObjectKey() );
        }
    }

    public synchronized void forceReturn()
    {
        mCollector.forceReturn();
    }

    public synchronized void setFullUpdate()
    {
        mCollector.setFullUpdate( true );
    }

    public synchronized void setCloseRequested()
    {
        mCollector.setCloseRequested( true );
    }

    public synchronized void setSuccessfulTriggeringActionIDIfNotSet( String pSuccessfulTriggeringActionID )
    {
        if ( mCollector.getSuccessfulTriggeringActionID() == null )
        {
            mCollector.setSuccessfulTriggeringActionID( pSuccessfulTriggeringActionID );
        }
    }

    public synchronized void addWarning( String pFormWarning )
    {
        mCollector.addWarning( pFormWarning );
    }

    public synchronized void addError( String pFormError )
    {
        mCollector.addError( pFormError );
    }

    public synchronized boolean hasErrors()
    {
        return mCollector.hasErrors();
    }

    public synchronized void add( AttributeUpdateFormData pAttributeUpdate )
    {
        mCollector.add( pAttributeUpdate );
    }

    public synchronized void add( ActionUpdateFormData pActionUpdate )
    {
        mCollector.add( pActionUpdate );
    }

    public synchronized void add( RelSubFormRowKeys pRowKeys )
    {
        mCollector.add( pRowKeys );
    }

    private void addWarning( ExternalizationInterface pExternalization,
                             FormInteractionStructure pInteractionStructure )
    {
        SerializableSystemUserRef zUserRef = pInteractionStructure.getSystemUserRef();
        if ( zUserRef != null )
        {
            String zDisplayName = Strings.noEmpty( zUserRef.getDisplayName() );
            if ( zDisplayName != null )
            {
                addWarning( pExternalization, POTENTIAL_INTERACTION_CONFLICT_WITH_USER, zDisplayName );
                return;
            }
        }
        addWarning( pExternalization, POTENTIAL_INTERACTION_CONFLICT_WITH_ANOTHER );
    }

    private void addError( ExternalizationInterface pExternalization,
                           FormInteractionStructure pInteractionStructure )
    {
        SerializableSystemUserRef zUserRef = pInteractionStructure.getSystemUserRef();
        if ( zUserRef != null )
        {
            String zDisplayName = Strings.noEmpty( zUserRef.getDisplayName() );
            if ( zDisplayName != null )
            {
                addError( pExternalization, PROBABLE_OLD_DATA_DUE_TO_UPDATE_BY_USER, zDisplayName );
                return;
            }
        }
        addError( pExternalization, PROBABLE_OLD_DATA_DUE_TO_UPDATE_BY_ANOTHER );
    }

    private void addWarning( ExternalizationInterface pExternalization, String pWarningID,
                             Object... pParameters )
    {
        mCollector.addWarning( resolveError( pExternalization, pWarningID, pParameters ) );
    }

    private void addError( ExternalizationInterface pExternalization, String pErrorID, Object... pParameters )
    {
        mCollector.addError( resolveError( pExternalization, pErrorID, pParameters ) );
    }

    private String resolveError( ExternalizationInterface pExternalization, String pErrorID,
                                 Object[] pParameters )
    {
        String resolved = (pExternalization != null) ? pExternalization.resolveError( pErrorID ) : pErrorID;
        return ExternalizationInterface.Helper.injectParameters( resolved, pParameters );
    }

    public void addPopup(FormPopupMessage popup) {
        mCollector.addPopup(popup);
    }
}

Commits for litesoft/trunk/Java/core/jvm1.5/src/org/litesoft/ui_1_5/ServicePeerToFormDataProxy.java

Diff revisions: vs.
Revision Author Commited Message
804 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 12:48:51 +0000
801 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 03:59:02 +0000
49 Diff Diff GeorgeS picture GeorgeS Mon 12 Apr, 2010 02:59:10 +0000

License Text

2 GeorgeS picture GeorgeS Sun 07 Feb, 2010 12:50:58 +0000