01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.core.dao.ojb;
17:
18: import java.util.Arrays;
19:
20: import org.apache.ojb.broker.query.Criteria;
21: import org.apache.ojb.broker.query.QueryFactory;
22: import org.apache.ojb.broker.query.ReportQueryByCriteria;
23: import org.kuali.core.bo.user.KualiModuleUserProperty;
24: import org.kuali.core.dao.KualiModuleUserDao;
25:
26: public class KualiModuleUserDaoOjb implements KualiModuleUserDao {
27:
28: public Object getActiveUserQueryCriteria(String moduleId) {
29: // build the criteria for the sub query
30: Criteria isActiveCriteria = new Criteria();
31: // ensure users equal
32: isActiveCriteria.addEqualToField("personUniversalIdentifier",
33: Criteria.PARENT_QUERY_PREFIX
34: + "personUniversalIdentifier");
35: isActiveCriteria.addEqualTo("moduleId", moduleId);
36: Criteria activePropertyNameCriteria = new Criteria();
37: activePropertyNameCriteria.addEqualTo("name", "active");
38: isActiveCriteria.addAndCriteria(activePropertyNameCriteria);
39: Criteria activeIsYesCriteria = new Criteria();
40: activeIsYesCriteria.addEqualTo("value", "Y");
41: isActiveCriteria.addAndCriteria(activeIsYesCriteria);
42: // create the query object and insert into an exists sub-query
43: ReportQueryByCriteria moduleUserPropertySubQuery = QueryFactory
44: .newReportQuery(KualiModuleUserProperty.class,
45: isActiveCriteria);
46: moduleUserPropertySubQuery
47: .setAttributes(new String[] { "personUniversalIdentifier" }); // don't need to select all attributes (the default)
48: Criteria criteria = new Criteria();
49: criteria.addExists(moduleUserPropertySubQuery);
50: return criteria;
51: }
52:
53: public Object getActiveFacultyStaffAffiliateCriteria(
54: String[] allowedEmployeeStatusValues) {
55: Criteria criteria = new Criteria();
56: criteria.addEqualTo("staff", "Y");
57: Criteria isFacultyCriteria = new Criteria();
58: isFacultyCriteria.addEqualTo("faculty", "Y");
59: Criteria isAffiliateCriteria = new Criteria();
60: isAffiliateCriteria.addEqualTo("affiliate", "Y");
61: criteria.addOrCriteria(isFacultyCriteria);
62: criteria.addOrCriteria(isAffiliateCriteria);
63: criteria.addIn("employeeStatusCode", Arrays
64: .asList(allowedEmployeeStatusValues));
65: return criteria;
66: }
67:
68: }
|