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