litesoft
@ 220
litesoft / trunk / GWT_Sandbox / Prioritizer / GWT / App / src / org / litesoft / prioritizer / server / pos / Story.java
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 |
package org.litesoft.prioritizer.server.pos; import java.io.*; import java.sql.*; import java.util.*; import org.litesoft.core.simpletypes.*; import org.litesoft.core.util.*; import org.litesoft.orsup.base.*; 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(); User zUser = CurrentUserAccessor.get().getRequiredUser().refreshInto( zTransaction ); if ( isNew() ) { setCreator( zUser ); } else if ( isAnyAttributeChanged() && notJustPriorityLastChangedBy() ) { if ( mCommitUpdate != null ) { removeUpdates( mCommitUpdate ); mCommitUpdate.requestDelete(); mCommitUpdate = null; } 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 = UtilsCommon.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() { // return zLastUpdate == null ? null : TypeConverter.to_SimpleTimestamp( TimeRes.ToMIN, zLastUpdate.getCreated() ).toString(); List<StoryUpdate> zUpdates = getUpdates(); if ( zUpdates.isEmpty() ) { return null; } if ( zUpdates.size() > 1 ) { zUpdates = new ArrayList<StoryUpdate>( zUpdates ); Collections.sort( zUpdates ); } // return zUpdates.get( 0 ); return null; } } |