01: package org.osbl.identity.gui;
02:
03: import org.osbl.client.wings.form.*;
04: import org.osbl.ServiceProvider;
05: import org.osbl.persistence.*;
06: import org.osbl.identity.model.Identity;
07: import org.conform.hibernate.HibernateEnvironment;
08:
09: public class IdentityEditor extends GenericObjectEditor {
10: private Persistence persistence;
11:
12: protected ObjectForm initializeForm() {
13: return new IdentityForm();
14: }
15:
16: protected ObjectList initializeList() {
17: return new IdentityList();
18: }
19:
20: public Class getType() {
21: return Identity.class;
22: }
23:
24: public void saveObject(Object object) {
25: SaveOrUpdateGeneralCommand command = (SaveOrUpdateGeneralCommand) getPersistence()
26: .createCommand("save");
27: command.setObject(object);
28: try {
29: HibernateEnvironment.getInstance().beginTransaction();
30: command.execute();
31: } finally {
32: HibernateEnvironment.getInstance().endTransaction();
33: }
34: }
35:
36: public void deleteObject(Object object) {
37: DeleteCommand command = (DeleteCommand) getPersistence()
38: .createCommand("delete");
39: command.setObject(object);
40: try {
41: HibernateEnvironment.getInstance().beginTransaction();
42: command.execute();
43: } finally {
44: HibernateEnvironment.getInstance().endTransaction();
45: }
46: }
47:
48: public void revertObject(Object object) {
49: RevertCommand command = (RevertCommand) getPersistence()
50: .createCommand("revert");
51: command.setObject(object);
52: try {
53: HibernateEnvironment.getInstance().beginTransaction();
54: command.execute();
55: } finally {
56: HibernateEnvironment.getInstance().endTransaction();
57: }
58: }
59:
60: public Persistence getPersistence() {
61: if (persistence == null)
62: persistence = (Persistence) ServiceProvider.getInstance()
63: .getService("IdentityPersistence");
64: return persistence;
65: }
66: }
|