01: package org.osbl.orga;
02:
03: import org.osbl.ReferenceChecker;
04: import org.osbl.ServiceProvider;
05: import org.osbl.identity.model.Identity;
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 MemberToIdentityReferenceChecker implements
14: ReferenceChecker<Member, 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<Member> check(Collection<Identity> objects) {
25: try {
26: HibernateEnvironment.getInstance().beginTransaction();
27:
28: JoinedQueryCommand command = (JoinedQueryCommand) getPersistence()
29: .createCommand("list");
30: command.setType(Member.class);
31: command.clearFilters();
32: command.addFilter("identity", Operator.IN, objects);
33: return (List<Member>) command.execute();
34: } finally {
35: HibernateEnvironment.getInstance().endTransaction();
36: }
37: }
38: }
|