01: /*
02: *
03: * Copyright 2007 Luca Molino (luca.molino@assetdata.it)
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.romaframework.module.users.domain.portal;
18:
19: import java.util.List;
20:
21: import org.romaframework.aspect.persistence.PersistenceAspect;
22: import org.romaframework.aspect.persistence.QueryByFilter;
23: import org.romaframework.core.flow.ObjectContext;
24: import org.romaframework.module.users.domain.BaseAccount;
25:
26: /**
27: * Helper class for <code>PortalPreferences</code>
28: *
29: * @author l.molino
30: *
31: */
32: public class PortalPreferencesHelper {
33:
34: /**
35: * Method that gets the account's portlet preferences
36: *
37: * @param account the logged account to search preferences
38: * @return this account's <code>PortalPreferences</code>
39: * @see PortalPreferences
40: * @see BaseAccount
41: */
42: public static PortalPreferences getUserPreferences(
43: BaseAccount account) {
44: QueryByFilter query = new QueryByFilter(PortalPreferences.class);
45: query.addItem("account", QueryByFilter.FIELD_EQUALS, account);
46: List<PortalPreferences> result = ObjectContext.getInstance()
47: .getComponent(PersistenceAspect.class).query(query);
48: if (result.size() < 0 || result.isEmpty())
49: return null;
50: else
51: return result.get(0);
52: }
53:
54: }
|