01: package org.osbl.authorization.gui;
02:
03: import org.conform.BeanMeta;
04: import org.conform.VariationBeanMetaProvider;
05: import org.conform.hibernate.HibernateEnvironment;
06: import org.conform.modifier.InlineModifier;
07: import org.osbl.client.wings.form.*;
08: import org.osbl.client.wings.shell.Client;
09: import org.osbl.persistence.*;
10: import org.osbl.identity.gui.SimpleQueryCommandTableModel;
11: import org.osbl.ServiceProvider;
12: import org.osbl.authorization.model.Profile;
13:
14: import java.io.Serializable;
15:
16: public class ProfileList extends GenericObjectList {
17: private Persistence persistence;
18:
19: protected BeanMeta createBeanMeta() {
20: return new VariationBeanMetaProvider(Client.getInstance()
21: .getBeanMetaProvider()).addModifier(
22: new InlineModifier() {
23: protected void configure() {
24: property("id").setWritable(false);
25: property("key").setWritable(false);
26: property("created").setWritable(false);
27: property("createdBy").setWritable(false);
28: property("name").setWritable(false);
29: }
30: }).getBeanMeta(Profile.class);
31: }
32:
33: protected ObjectTableModel createModel(BeanMeta beanMeta) {
34: SimpleQueryCommand command = (SimpleQueryCommand) getCommandFactory()
35: .createCommand("list");
36: command.setType(Profile.class);
37: SimpleQueryCommandTableModel tableModel = new SimpleQueryCommandTableModel(
38: command, beanMeta, "key", "name");
39: tableModel.setSortableColumns("key", "name");
40: tableModel.setFilterableColumns("key", "name");
41: return tableModel;
42: }
43:
44: public Object getRow(int index) { // was protected
45: LoadCommand command = (LoadCommand) getCommandFactory()
46: .createCommand("load");
47: command.setType(Profile.class);
48: command.setId((Serializable) ((ObjectTableModel) getModel())
49: .getRowId(index));
50: try {
51: HibernateEnvironment.getInstance().beginTransaction();
52: return command.execute();
53: } finally {
54: HibernateEnvironment.getInstance().endTransaction();
55: }
56: }
57:
58: public Persistence getCommandFactory() {
59: if (persistence == null)
60: persistence = (Persistence) ServiceProvider.getInstance()
61: .getService("AuthorizationPersistence");
62: return persistence;
63: }
64: }
|