01: /*
02: * Copyright (c) 2006 Your Corporation. All Rights Reserved.
03: */
04:
05: package com.technoetic.xplanner.security.install;
06:
07: import java.util.ArrayList;
08: import java.util.Iterator;
09: import java.util.List;
10:
11: import org.apache.log4j.Logger;
12:
13: import com.technoetic.xplanner.domain.Iteration;
14: import com.technoetic.xplanner.domain.UserStory;
15: import com.technoetic.xplanner.upgrade.HibernateMigrationTaskSupport;
16:
17: public class MigrateStoryPriorityToOrderNo extends
18: HibernateMigrationTaskSupport {
19:
20: private static final Logger log = Logger
21: .getLogger(MigrateStoryPriorityToOrderNo.class);
22: private static final String MIGRATION_ERROR = "Error migrating story priority to order number";
23:
24: public MigrateStoryPriorityToOrderNo() {
25: super ("Migrate story priority to order number", 11);
26: }
27:
28: protected void migrate() throws Exception {
29: List iterations = session.find("from iteration in class "
30: + Iteration.class.getName());
31: for (Iterator IterationIterator = iterations.iterator(); IterationIterator
32: .hasNext();) {
33: Iteration iteration = (Iteration) IterationIterator.next();
34: List userStories = new ArrayList(iteration.getUserStories());
35: int[][] storyIdAndNewOrder = new int[userStories.size()][2];
36: for (int index = 0; index < userStories.size(); index++) {
37: UserStory userStory = (UserStory) userStories
38: .get(index);
39: storyIdAndNewOrder[index][Iteration.STORY_ID_INDEX] = userStory
40: .getId();
41: storyIdAndNewOrder[index][Iteration.ORDER_NO_INDEX] = userStory
42: .getPriority();
43: }
44: iteration.modifyStoryOrder(storyIdAndNewOrder);
45: }
46: }
47: }
|