01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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:
17: package org.romaframework.module.users.domain;
18:
19: import org.romaframework.aspect.core.annotation.AnnotationConstants;
20: import org.romaframework.aspect.view.annotation.ViewField;
21: import org.romaframework.module.admin.InfoHelper;
22: import org.romaframework.module.admin.domain.Info;
23: import org.romaframework.module.crud.CRUDHelper;
24: import org.romaframework.module.users.view.domain.baseaccount.BaseAccountSelect;
25:
26: public class ActivityLog extends Tracking {
27:
28: private Info category;
29: private int level;
30:
31: private static Integer[] LEVELS = new Integer[] { 0, 1, 2, 3, 4 };
32: private static Info[] CATEGORIES;
33:
34: public static final int LEVEL_DEBUG = 0;
35: public static final int LEVEL_INFO = 1;
36: public static final int LEVEL_WARNING = 2;
37: public static final int LEVEL_ERROR = 3;
38: public static final int LEVEL_FATAL = 4;
39:
40: public static final String LOG_CATEGORY_NAME = "Log";
41:
42: public ActivityLog() {
43: // DOUBLE CHECKING LOCKING PATTERN TO AVOID STATIC INITIALIZATION FOR
44: // ENHANCEMENT ISSUES
45: if (CATEGORIES == null) {
46: synchronized (ActivityLog.class) {
47: if (CATEGORIES == null) {
48: CATEGORIES = InfoHelper.getInstance().getInfoArray(
49: LOG_CATEGORY_NAME);
50: }
51: }
52: }
53: }
54:
55: public ActivityLog(int iLevel, Info iCategory, String iNotes) {
56: super (iNotes);
57: level = iLevel;
58: category = iCategory;
59: }
60:
61: public void onAccount() {
62: CRUDHelper.show(BaseAccountSelect.class, this , "account");
63: }
64:
65: @ViewField(enabled=AnnotationConstants.FALSE)
66: @Override
67: public BaseAccount getAccount() {
68: return super .getAccount();
69: }
70:
71: public Info getCategory() {
72: return category;
73: }
74:
75: public int getLevel() {
76: return level;
77: }
78:
79: public void setCategory(Info category) {
80: this .category = category;
81: }
82:
83: public void setLevel(int level) {
84: this .level = level;
85: }
86:
87: @ViewField(selectionField="level")
88: public Integer[] getLevels() {
89: return LEVELS;
90: }
91:
92: @ViewField(selectionField="category")
93: public Info[] getCategories() {
94: return CATEGORIES;
95: }
96: }
|