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.ArrayList;
19: import java.util.Collection;
20:
21: import org.apache.ojb.broker.query.Criteria;
22: import org.apache.ojb.broker.query.QueryFactory;
23: import org.kuali.core.bo.user.KualiModuleUserProperty;
24: import org.kuali.core.bo.user.UniversalUser;
25: import org.kuali.core.dao.KualiModuleUserPropertyDao;
26: import org.springmodules.orm.ojb.PersistenceBrokerTemplate;
27:
28: public class KualiModuleUserPropertyDaoOjb extends
29: PlatformAwareDaoBaseOjb implements KualiModuleUserPropertyDao {
30:
31: public void save(KualiModuleUserProperty property) {
32: getPersistenceBrokerTemplate().store(property);
33: }
34:
35: public void save(Collection<KualiModuleUserProperty> properties) {
36: PersistenceBrokerTemplate pbt = getPersistenceBrokerTemplate();
37: for (KualiModuleUserProperty prop : properties) {
38: pbt.store(prop);
39: }
40: }
41:
42: public Collection<KualiModuleUserProperty> getPropertiesForUser(
43: UniversalUser user) {
44: if (user == null || user.getPersonUniversalIdentifier() == null) {
45: return new ArrayList<KualiModuleUserProperty>();
46: }
47: return getPropertiesForUser(user.getPersonUniversalIdentifier());
48: }
49:
50: public Collection<KualiModuleUserProperty> getPropertiesForUser(
51: String personUniversalIdentifier) {
52: if (personUniversalIdentifier == null) {
53: return new ArrayList<KualiModuleUserProperty>();
54: }
55: Criteria criteria = new Criteria();
56: criteria.addEqualTo("personUniversalIdentifier",
57: personUniversalIdentifier);
58: return getPersistenceBrokerTemplate().getCollectionByQuery(
59: QueryFactory.newQuery(KualiModuleUserProperty.class,
60: criteria));
61: }
62:
63: }
|