|
@@ -6,6 +6,7 @@ |
6 |
6 |
|
import org.litesoft.bo.views.server.*; |
7 |
7 |
|
import org.litesoft.core.util.*; |
8 |
8 |
|
import org.litesoft.datt.client.boviews.*; |
|
9 |
+ |
import org.litesoft.datt.client.support.*; |
9 |
10 |
|
import org.litesoft.datt.server.*; |
10 |
11 |
|
import org.litesoft.datt.server.boviews.*; |
11 |
12 |
|
import org.litesoft.datt.server.pos.*; |
|
@@ -27,10 +28,10 @@ |
27 |
28 |
|
super.LLinitialize(); |
28 |
29 |
|
|
29 |
30 |
|
register( new StoryViewServerFunctionMergeStory() ); |
30 |
|
- |
// register( new StoryViewServerFunctionFetchReprioritizeRows() ); |
31 |
|
- |
// register( new StoryViewServerFunctionFetchInitialPrioritizeRows() ); |
32 |
|
- |
// register( new StoryViewServerFunctionReprioritizeBetween() ); |
33 |
|
- |
// register( new StoryViewServerFunctionReprioritizeToGroup() ); |
|
31 |
+ |
register( new StoryViewServerFunctionFetchReprioritizeRows() ); |
|
32 |
+ |
register( new StoryViewServerFunctionFetchInitialPrioritizeRows() ); |
|
33 |
+ |
register( new StoryViewServerFunctionReprioritizeBetween() ); |
|
34 |
+ |
register( new StoryViewServerFunctionReprioritizeToGroup() ); |
34 |
35 |
|
} |
35 |
36 |
|
|
36 |
37 |
|
// @Override |
|
@@ -54,70 +55,70 @@ |
54 |
55 |
|
/** |
55 |
56 |
|
* Reprioritize all the pToReprioritize to the "bottom" of the pPrioritizeToGroup |
56 |
57 |
|
*/ |
57 |
|
- |
// public SCresult reprioritizeToGroup( PriorityGroup pPrioritizeToGroup, StoryView[] pToReprioritize ) |
58 |
|
- |
// throws PersistenceException |
59 |
|
- |
// { |
60 |
|
- |
// try |
61 |
|
- |
// { |
62 |
|
- |
// pPrioritizeToGroup = PriorityGroup.deNull( pPrioritizeToGroup, PriorityGroup.Medium ); |
63 |
|
- |
// UnfilteringFinder zFinder = DataStoreLocator.get().getUnfilteredFinder(); |
64 |
|
- |
// WhereClause zWC_Bottom = pPrioritizeToGroup.isBottomInclusive() ? // |
65 |
|
- |
// WCF.isGreaterThanEqual( Story.CD_Priority, pPrioritizeToGroup.getRangeBottom() ) : // |
66 |
|
- |
// WCF.isGreaterThan( Story.CD_Priority, pPrioritizeToGroup.getRangeBottom() ); |
67 |
|
- |
// WhereClause zWC_Top = pPrioritizeToGroup.isTopInclusive() ? // |
68 |
|
- |
// WCF.isLessThanEqual( Story.CD_Priority, pPrioritizeToGroup.getRangeTop() ) : // |
69 |
|
- |
// WCF.isLessThan( Story.CD_Priority, pPrioritizeToGroup.getRangeTop() ); |
70 |
|
- |
// WhereClause zWhereClause = WCF.and( zWC_Bottom, zWC_Top ); |
71 |
|
- |
// List<Story> zUpperRangeStories = zFinder.findSubset( Story.class, zWhereClause, new OrderBy( Story.CD_Priority ), 0, 1 ); |
72 |
|
- |
// Float zUpperBound = zUpperRangeStories.isEmpty() ? pPrioritizeToGroup.getRangeTop() : zUpperRangeStories.get( 0 ).getPriority(); |
73 |
|
- |
// return reprioritizeBetween( zFinder, new PriorityGroup.Range( pPrioritizeToGroup.getRangeBottom(), zUpperBound ), pToReprioritize ); |
74 |
|
- |
// } |
75 |
|
- |
// catch ( ConcurrentModificationException e ) |
76 |
|
- |
// { |
77 |
|
- |
// return staleData( e.getMessage() ); |
78 |
|
- |
// } |
79 |
|
- |
// } |
|
58 |
+ |
public SCresult reprioritizeToGroup( PriorityGroup pPrioritizeToGroup, StoryView[] pToReprioritize ) |
|
59 |
+ |
throws PersistenceException |
|
60 |
+ |
{ |
|
61 |
+ |
try |
|
62 |
+ |
{ |
|
63 |
+ |
pPrioritizeToGroup = PriorityGroup.deNull( pPrioritizeToGroup, PriorityGroup.Medium ); |
|
64 |
+ |
UnfilteringFinder zFinder = DataStoreLocator.get().getUnfilteredFinder(); |
|
65 |
+ |
WhereClause zWC_Bottom = pPrioritizeToGroup.isBottomInclusive() ? // |
|
66 |
+ |
WCF.isGreaterThanEqual( Story.CD_Priority, pPrioritizeToGroup.getRangeBottom() ) : // |
|
67 |
+ |
WCF.isGreaterThan( Story.CD_Priority, pPrioritizeToGroup.getRangeBottom() ); |
|
68 |
+ |
WhereClause zWC_Top = pPrioritizeToGroup.isTopInclusive() ? // |
|
69 |
+ |
WCF.isLessThanEqual( Story.CD_Priority, pPrioritizeToGroup.getRangeTop() ) : // |
|
70 |
+ |
WCF.isLessThan( Story.CD_Priority, pPrioritizeToGroup.getRangeTop() ); |
|
71 |
+ |
WhereClause zWhereClause = WCF.and( zWC_Bottom, zWC_Top ); |
|
72 |
+ |
List<Story> zUpperRangeStories = zFinder.findSubset( Story.class, zWhereClause, new OrderBy( Story.CD_Priority ), 0, 1 ); |
|
73 |
+ |
Float zUpperBound = zUpperRangeStories.isEmpty() ? pPrioritizeToGroup.getRangeTop() : zUpperRangeStories.get( 0 ).getPriority(); |
|
74 |
+ |
return reprioritizeBetween( zFinder, new PriorityGroup.Range( pPrioritizeToGroup.getRangeBottom(), zUpperBound ), pToReprioritize ); |
|
75 |
+ |
} |
|
76 |
+ |
catch ( ConcurrentModificationException e ) |
|
77 |
+ |
{ |
|
78 |
+ |
return staleData( e.getMessage() ); |
|
79 |
+ |
} |
|
80 |
+ |
} |
80 |
81 |
|
|
81 |
82 |
|
/** |
82 |
83 |
|
* Reprioritize all the pToReprioritize between the pLowerBound & the pUpperBound. |
83 |
84 |
|
* If either (but not both) are null, then use the edges of the PriorityGroup indicated by the other. |
84 |
85 |
|
* If BOTH are null then use the bounds of PriorityGroup.Medium. |
85 |
86 |
|
*/ |
86 |
|
- |
// public SCresult reprioritizeBetween( StoryView pLowerBound, StoryView pUpperBound, StoryView[] pToReprioritize ) |
87 |
|
- |
// throws PersistenceException |
88 |
|
- |
// { |
89 |
|
- |
// try |
90 |
|
- |
// { |
91 |
|
- |
// UnfilteringFinder zFinder = DataStoreLocator.get().getUnfilteredFinder(); |
92 |
|
- |
// return reprioritizeBetween( zFinder, createRange( zFinder, pLowerBound, pUpperBound ), pToReprioritize ); |
93 |
|
- |
// } |
94 |
|
- |
// catch ( ConcurrentModificationException e ) |
95 |
|
- |
// { |
96 |
|
- |
// return staleData( e.getMessage() ); |
97 |
|
- |
// } |
98 |
|
- |
// } |
|
87 |
+ |
public SCresult reprioritizeBetween( StoryView pLowerBound, StoryView pUpperBound, StoryView[] pToReprioritize ) |
|
88 |
+ |
throws PersistenceException |
|
89 |
+ |
{ |
|
90 |
+ |
try |
|
91 |
+ |
{ |
|
92 |
+ |
UnfilteringFinder zFinder = DataStoreLocator.get().getUnfilteredFinder(); |
|
93 |
+ |
return reprioritizeBetween( zFinder, createRange( zFinder, pLowerBound, pUpperBound ), pToReprioritize ); |
|
94 |
+ |
} |
|
95 |
+ |
catch ( ConcurrentModificationException e ) |
|
96 |
+ |
{ |
|
97 |
+ |
return staleData( e.getMessage() ); |
|
98 |
+ |
} |
|
99 |
+ |
} |
99 |
100 |
|
|
100 |
101 |
|
/* |
101 |
102 |
|
* If either (but not both) are null, then use the edges of the PriorityGroup indicated by the other. |
102 |
103 |
|
* If BOTH are null then use the bounds of PriorityGroup.Medium. |
103 |
104 |
|
*/ |
104 |
|
- |
// private PriorityGroup.Range createRange( UnfilteringFinder zFinder, StoryView pLowerBound, StoryView pUpperBound ) |
105 |
|
- |
// { |
106 |
|
- |
// switch ( DualNullCheck.of( pLowerBound, pUpperBound ) ) |
107 |
|
- |
// { |
108 |
|
- |
// default: |
109 |
|
- |
// case BothNull: |
110 |
|
- |
// return PriorityGroup.Medium.getRangeAssumingExclusive(); |
111 |
|
- |
// case Only1stNull: |
112 |
|
- |
// Float zUpperBound = validatePriority( zFinder, pUpperBound ); |
113 |
|
- |
// return new PriorityGroup.Range( PriorityGroup.from( zUpperBound ).getRangeBottom(), zUpperBound ); |
114 |
|
- |
// case Only2ndNull: |
115 |
|
- |
// Float zLowerBound = validatePriority( zFinder, pLowerBound ); |
116 |
|
- |
// return new PriorityGroup.Range( zLowerBound, PriorityGroup.from( zLowerBound ).getRangeTop() ); |
117 |
|
- |
// case NeitherNull: |
118 |
|
- |
// return new PriorityGroup.Range( validatePriority( zFinder, pLowerBound ), validatePriority( zFinder, pUpperBound ) ); |
119 |
|
- |
// } |
120 |
|
- |
// } |
|
105 |
+ |
private PriorityGroup.Range createRange( UnfilteringFinder zFinder, StoryView pLowerBound, StoryView pUpperBound ) |
|
106 |
+ |
{ |
|
107 |
+ |
switch ( DualNullCheck.of( pLowerBound, pUpperBound ) ) |
|
108 |
+ |
{ |
|
109 |
+ |
default: |
|
110 |
+ |
case BothNull: |
|
111 |
+ |
return PriorityGroup.Medium.getRangeAssumingExclusive(); |
|
112 |
+ |
case Only1stNull: |
|
113 |
+ |
Float zUpperBound = validatePriority( zFinder, pUpperBound ); |
|
114 |
+ |
return new PriorityGroup.Range( PriorityGroup.from( zUpperBound ).getRangeBottom(), zUpperBound ); |
|
115 |
+ |
case Only2ndNull: |
|
116 |
+ |
Float zLowerBound = validatePriority( zFinder, pLowerBound ); |
|
117 |
+ |
return new PriorityGroup.Range( zLowerBound, PriorityGroup.from( zLowerBound ).getRangeTop() ); |
|
118 |
+ |
case NeitherNull: |
|
119 |
+ |
return new PriorityGroup.Range( validatePriority( zFinder, pLowerBound ), validatePriority( zFinder, pUpperBound ) ); |
|
120 |
+ |
} |
|
121 |
+ |
} |
121 |
122 |
|
|
122 |
123 |
|
private Float validatePriority( UnfilteringFinder zFinder, StoryView pStoryView ) |
123 |
124 |
|
{ |
|
@@ -146,19 +147,19 @@ |
146 |
147 |
|
return VOSC.result( "Your View is Stale - Data Changed\n\n" + pMessage ); |
147 |
148 |
|
} |
148 |
149 |
|
|
149 |
|
- |
// private SCresult reprioritizeBetween( UnfilteringFinder pFinder, PriorityGroup.Range pRange, StoryView[] pToReprioritize ) |
150 |
|
- |
// throws PersistenceException |
151 |
|
- |
// { |
152 |
|
- |
// if ( UtilsCommon.isNullOrEmpty( pToReprioritize ) ) |
153 |
|
- |
// { |
154 |
|
- |
// return VOSC.result( "Nothing to Reprioritize" ); |
155 |
|
- |
// } |
156 |
|
- |
// Transaction zTransaction = pFinder.createUnaugmentedTransaction(); |
157 |
|
- |
// List<Story> zStories = validate( pToReprioritize, zTransaction.findAllByKeys( Story.class, getKeysFor( pToReprioritize ) ) ); |
158 |
|
- |
// updatePriorities( zStories, pRange.rePrioritizeBetween( extractPriorities( zStories ) ) ); |
159 |
|
- |
// zTransaction.commit(); |
160 |
|
- |
// return VOSC.result( "" ); |
161 |
|
- |
// } |
|
150 |
+ |
private SCresult reprioritizeBetween( UnfilteringFinder pFinder, PriorityGroup.Range pRange, StoryView[] pToReprioritize ) |
|
151 |
+ |
throws PersistenceException |
|
152 |
+ |
{ |
|
153 |
+ |
if ( UtilsCommon.isNullOrEmpty( pToReprioritize ) ) |
|
154 |
+ |
{ |
|
155 |
+ |
return VOSC.result( "Nothing to Reprioritize" ); |
|
156 |
+ |
} |
|
157 |
+ |
Transaction zTransaction = pFinder.createUnaugmentedTransaction(); |
|
158 |
+ |
List<Story> zStories = validate( pToReprioritize, zTransaction.findAllByKeys( Story.class, getKeysFor( pToReprioritize ) ) ); |
|
159 |
+ |
updatePriorities( zStories, pRange.rePrioritizeBetween( extractPriorities( zStories ) ) ); |
|
160 |
+ |
zTransaction.commit(); |
|
161 |
+ |
return VOSC.result( "" ); |
|
162 |
+ |
} |
162 |
163 |
|
|
163 |
164 |
|
private void updatePriorities( List<Story> pStories, float[] pPriorities ) |
164 |
165 |
|
{ |
|
@@ -224,13 +225,12 @@ |
224 |
225 |
|
Story zMergeIntoPO = getStoryPO( zMergeIntoID, zTransaction ); |
225 |
226 |
|
Story zMergeFromPO = getStoryPO( zMergeFromID, zTransaction ); |
226 |
227 |
|
List<Task> zTasks = zMergeFromPO.getTasks(); |
227 |
|
- |
for (Task zTask : zTasks) |
|
228 |
+ |
for ( Task zTask : zTasks ) |
228 |
229 |
|
{ |
229 |
230 |
|
zMergeIntoPO.addTasks( zTask ); |
230 |
231 |
|
} |
231 |
232 |
|
zMergeIntoPO.addUpdates( new StoryUpdate( zTransaction, CurrentUserAccessor.get().getRequiredUser().freshIntoIfNotAlreadyIn( zTransaction ), |
232 |
|
- |
"Tasks merged from story: " + zMergeFromPO.getName()) ); |
233 |
|
- |
|
|
233 |
+ |
"Tasks merged from story: " + zMergeFromPO.getName() ) ); |
234 |
234 |
|
|
235 |
235 |
|
zMergeFromPO.requestDelete(); |
236 |
236 |
|
try |
|
@@ -244,7 +244,7 @@ |
244 |
244 |
|
} |
245 |
245 |
|
} |
246 |
246 |
|
} |
247 |
|
- |
|
|
247 |
+ |
|
248 |
248 |
|
private Story getStoryPO( Long pMergeIntoID, Transaction pTransaction ) |
249 |
249 |
|
{ |
250 |
250 |
|
Story zStory = (Story) findPO( pTransaction, pMergeIntoID ); |
|
@@ -254,6 +254,4 @@ |
254 |
254 |
|
} |
255 |
255 |
|
return zStory; |
256 |
256 |
|
} |
257 |
|
- |
|
258 |
|
- |
|
259 |
257 |
|
} |