01: package org.osbl.orga;
02:
03: import org.osbl.identity.model.Identity;
04: import org.osbl.ReferenceChecker;
05: import org.osbl.ServiceProvider;
06: import org.osbl.orga.model.Group;
07: import org.osbl.orga.model.Member;
08: import org.osbl.persistence.*;
09: import org.conform.hibernate.HibernateEnvironment;
10:
11: import java.util.*;
12:
13: public class GroupToIdentityReferenceChecker implements
14: ReferenceChecker<Group, Identity> {
15: private Persistence persistence;
16:
17: public Persistence getPersistence() {
18: if (persistence == null)
19: persistence = (Persistence) ServiceProvider.getInstance()
20: .getService("OrgaPersistence");
21: return persistence;
22: }
23:
24: public Collection<Group> check(Collection<Identity> objects) {
25: try {
26: HibernateEnvironment.getInstance().beginTransaction();
27:
28: JoinedQueryCommand command = (JoinedQueryCommand) getPersistence()
29: .createCommand("list");
30: command.setType(Group.class);
31: command.addFilter("identity", Operator.IN, objects);
32: return (List<Group>) command.execute();
33: } finally {
34: HibernateEnvironment.getInstance().endTransaction();
35: }
36: }
37: }
|