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