Commit c470c29f84a5e515e3f7c909868ca310aa9f052a

Authored by Dancovich
1 parent 669b81e1
Exists in master

Atualizadas classes que implementam a interface Crud para corresponder

com as novas assinaturas dos métodos.
impl/core/src/main/java/br/gov/frameworkdemoiselle/template/DelegateCrud.java
... ... @@ -46,6 +46,19 @@ import br.gov.frameworkdemoiselle.transaction.Transactional;
46 46 import br.gov.frameworkdemoiselle.util.Beans;
47 47 import br.gov.frameworkdemoiselle.util.Reflections;
48 48  
  49 +/**
  50 + * An implementation of the {@link Crud} interface that delegates it's operations
  51 + * to another {@link Crud} implementation.
  52 + *
  53 + * @author serpro
  54 + *
  55 + * @param <T>
  56 + * bean object type
  57 + * @param <I>
  58 + * bean id type
  59 + * @param <C>
  60 + * type of {@link Crud} implementation this class will delegate to
  61 + */
49 62 public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> {
50 63  
51 64 private static final long serialVersionUID = 1L;
... ... @@ -137,21 +150,21 @@ public class DelegateCrud&lt;T, I, C extends Crud&lt;T, I&gt;&gt; implements Crud&lt;T, I&gt; {
137 150 * A entity to be inserted by the delegate
138 151 */
139 152 @Override
140   - public void insert(final T bean) {
  153 + public T insert(final T bean) {
141 154 if (isRunningTransactionalOperations()) {
142   - transactionalInsert(bean);
  155 + return transactionalInsert(bean);
143 156 } else {
144   - nonTransactionalInsert(bean);
  157 + return nonTransactionalInsert(bean);
145 158 }
146 159 }
147 160  
148 161 @Transactional
149   - private void transactionalInsert(final T bean) {
150   - nonTransactionalInsert(bean);
  162 + private T transactionalInsert(final T bean) {
  163 + return nonTransactionalInsert(bean);
151 164 }
152 165  
153   - private void nonTransactionalInsert(final T bean) {
154   - getDelegate().insert(bean);
  166 + private T nonTransactionalInsert(final T bean) {
  167 + return getDelegate().insert(bean);
155 168 }
156 169  
157 170 /**
... ... @@ -171,21 +184,21 @@ public class DelegateCrud&lt;T, I, C extends Crud&lt;T, I&gt;&gt; implements Crud&lt;T, I&gt; {
171 184 * The instance containing the updated state.
172 185 */
173 186 @Override
174   - public void update(final T bean) {
  187 + public T update(final T bean) {
175 188 if (isRunningTransactionalOperations()) {
176   - transactionalUpdate(bean);
  189 + return transactionalUpdate(bean);
177 190 } else {
178   - nonTransactionalUpdate(bean);
  191 + return nonTransactionalUpdate(bean);
179 192 }
180 193 }
181 194  
182 195 @Transactional
183   - private void transactionalUpdate(final T bean) {
184   - nonTransactionalUpdate(bean);
  196 + private T transactionalUpdate(final T bean) {
  197 + return nonTransactionalUpdate(bean);
185 198 }
186 199  
187   - private void nonTransactionalUpdate(final T bean) {
188   - getDelegate().update(bean);
  200 + private T nonTransactionalUpdate(final T bean) {
  201 + return getDelegate().update(bean);
189 202 }
190 203  
191 204 private boolean isRunningTransactionalOperations() {
... ...