| 1 |
|
package org.trails.record; |
| 2 |
|
|
| 3 |
|
import org.apache.commons.logging.Log; |
| 4 |
|
import org.apache.commons.logging.LogFactory; |
| 5 |
|
import org.apache.tapestry.record.PropertyChange; |
| 6 |
|
import org.apache.tapestry.record.PropertyChangeImpl; |
| 7 |
|
|
| 8 |
|
import java.util.ArrayList; |
| 9 |
|
import java.util.Collection; |
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
0 |
public abstract class ReattachPropertyPersistenceStrategy extends AbstractSessionPropertyPersistenceStrategy |
| 17 |
|
{ |
| 18 |
|
|
| 19 |
|
protected abstract Object reattach(Object entity); |
| 20 |
|
|
| 21 |
0 |
private static final Log LOG = LogFactory.getLog(ReattachPropertyPersistenceStrategy.class); |
| 22 |
|
|
| 23 |
|
public Collection getStoredChanges(String pageName) |
| 24 |
|
{ |
| 25 |
0 |
final Collection<PropertyChange> pageChanges = super.getStoredChanges(pageName); |
| 26 |
0 |
Collection<PropertyChange> result = new ArrayList<PropertyChange>(); |
| 27 |
|
|
| 28 |
0 |
for (PropertyChange propertyChange : pageChanges) |
| 29 |
|
{ |
| 30 |
0 |
final Object entity = propertyChange.getNewValue(); |
| 31 |
0 |
LOG.debug("Reattaching property " + propertyChange.getPropertyName() + " on component " + propertyChange.getComponentPath()); |
| 32 |
|
|
| 33 |
|
try |
| 34 |
|
{ |
| 35 |
0 |
result.add(new PropertyChangeImpl(propertyChange.getComponentPath(), propertyChange.getPropertyName(), reattach(entity))); |
| 36 |
0 |
} catch (Exception e) |
| 37 |
|
{ |
| 38 |
0 |
e.printStackTrace(); |
| 39 |
|
} |
| 40 |
|
} |
| 41 |
0 |
return result; |
| 42 |
|
} |
| 43 |
|
} |