|
34 | 34 |
|
35 | 35 | public abstract class AbstractCRUDAction extends ActionSupport { |
36 | 36 |
|
37 | | - private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class); |
| 37 | + private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class); |
38 | 38 |
|
39 | | - private Collection availableItems; |
40 | | - private String[] toDelete; |
| 39 | + private Collection availableItems; |
| 40 | + private String[] toDelete; |
41 | 41 |
|
42 | | - protected abstract Dao getDao(); |
| 42 | + protected abstract Dao getDao(); |
43 | 43 |
|
44 | | - public Collection getAvailableItems() { |
45 | | - return availableItems; |
46 | | - } |
| 44 | + public Collection getAvailableItems() { |
| 45 | + return availableItems; |
| 46 | + } |
47 | 47 |
|
48 | | - public String[] getToDelete() { |
49 | | - return toDelete; |
50 | | - } |
| 48 | + public String[] getToDelete() { |
| 49 | + return toDelete; |
| 50 | + } |
51 | 51 |
|
52 | | - @StrutsParameter |
53 | | - public void setToDelete(String[] toDelete) { |
54 | | - this.toDelete = toDelete; |
55 | | - } |
| 52 | + @StrutsParameter |
| 53 | + public void setToDelete(String[] toDelete) { |
| 54 | + this.toDelete = toDelete; |
| 55 | + } |
56 | 56 |
|
57 | | - public String list() throws Exception { |
58 | | - this.availableItems = getDao().findAll(); |
59 | | - if (log.isDebugEnabled()) { |
60 | | - log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found"); |
61 | | - } |
62 | | - return execute(); |
63 | | - } |
| 57 | + public String list() throws Exception { |
| 58 | + this.availableItems = getDao().findAll(); |
| 59 | + if (log.isDebugEnabled()) { |
| 60 | + log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found"); |
| 61 | + } |
| 62 | + return execute(); |
| 63 | + } |
64 | 64 |
|
65 | | - public String delete() throws Exception { |
66 | | - if (toDelete != null) { |
67 | | - int count = 0; |
| 65 | + public String delete() throws Exception { |
| 66 | + if (toDelete != null) { |
| 67 | + int count = 0; |
68 | 68 | for (String s : toDelete) { |
69 | 69 | count = count + getDao().delete(s); |
70 | 70 | } |
71 | | - if (log.isDebugEnabled()) { |
| 71 | + if (log.isDebugEnabled()) { |
72 | 72 | log.debug("AbstractCRUDAction - [delete]: {} items deleted.", count); |
73 | | - } |
74 | | - } |
75 | | - return SUCCESS; |
76 | | - } |
| 73 | + } |
| 74 | + } |
| 75 | + return SUCCESS; |
| 76 | + } |
77 | 77 |
|
78 | | - /** |
79 | | - * Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle. |
80 | | - * |
81 | | - * @param tryId The id to try to get persistent object for |
82 | | - * @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent |
83 | | - * object for |
84 | | - * @return The persistent object, if found. <tt>null</tt> otherwise. |
85 | | - */ |
86 | | - protected IdEntity fetch(Serializable tryId, IdEntity tryObject) { |
87 | | - IdEntity result = null; |
88 | | - if (tryId != null) { |
89 | | - result = getDao().get(tryId); |
90 | | - } else if (tryObject != null) { |
91 | | - result = getDao().get(tryObject.getId()); |
92 | | - } |
93 | | - return result; |
94 | | - } |
| 78 | + /** |
| 79 | + * Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle. |
| 80 | + * |
| 81 | + * @param tryId The id to try to get persistent object for |
| 82 | + * @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent |
| 83 | + * object for |
| 84 | + * @return The persistent object, if found. <tt>null</tt> otherwise. |
| 85 | + */ |
| 86 | + protected IdEntity fetch(Serializable tryId, IdEntity tryObject) { |
| 87 | + IdEntity result = null; |
| 88 | + if (tryId != null) { |
| 89 | + result = getDao().get(tryId); |
| 90 | + } else if (tryObject != null) { |
| 91 | + result = getDao().get(tryObject.getId()); |
| 92 | + } |
| 93 | + return result; |
| 94 | + } |
95 | 95 | } |
0 commit comments