001: /*
002: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.romaframework.module.users.domain;
018:
019: import java.io.Serializable;
020: import java.util.HashMap;
021: import java.util.Map;
022: import java.util.TreeMap;
023:
024: import org.romaframework.aspect.core.annotation.CoreClass;
025: import org.romaframework.aspect.view.annotation.ViewField;
026: import org.romaframework.aspect.view.feature.ViewFieldFeatures;
027: import org.romaframework.module.crud.CRUDHelper;
028: import org.romaframework.module.users.view.domain.baseprofile.BaseProfileSelect;
029:
030: @CoreClass(orderFields="name parent mode modes homePage notes functions")
031: public class BaseProfile implements Serializable {
032:
033: protected String name;
034: protected BaseProfile parent;
035: protected Byte mode;
036: protected Map<String, BaseFunction> functions;
037: protected String homePage;
038: protected String notes;
039:
040: public static final byte MODE_ALLOW_ALL_BUT = 0;
041: public static final byte MODE_DENY_ALL_BUT = 1;
042:
043: public BaseProfile() {
044: }
045:
046: public BaseProfile(String iName, BaseProfile iParent, byte iMode,
047: String iHomePage) {
048: name = iName;
049: parent = iParent;
050: mode = iMode;
051: homePage = iHomePage;
052:
053: functions = new TreeMap<String, BaseFunction>();
054: }
055:
056: @Override
057: public boolean equals(Object obj) {
058: if (!(obj instanceof BaseProfile))
059: return false;
060:
061: BaseProfile other = (BaseProfile) obj;
062: return name.equals(other.name);
063: }
064:
065: public void onParent() {
066: CRUDHelper.show(BaseProfileSelect.class, this , "parent");
067: }
068:
069: @Override
070: public String toString() {
071: return name;
072: }
073:
074: public Byte getMode() {
075: return mode;
076: }
077:
078: public void setMode(Byte iInheritMode) {
079: mode = iInheritMode == -1 ? null : iInheritMode;
080: }
081:
082: public String getName() {
083: return name;
084: }
085:
086: public void setName(String name) {
087: this .name = name;
088: }
089:
090: public BaseProfile getParent() {
091: return parent;
092: }
093:
094: public void setParent(BaseProfile parent) {
095: this .parent = parent;
096: }
097:
098: public Map<String, BaseFunction> getFunctions() {
099: return functions;
100: }
101:
102: public void setFunctions(Map<String, BaseFunction> functions) {
103: this .functions = functions;
104: }
105:
106: public void addFunction(String iName, boolean iAllowed) {
107: if (functions == null)
108: functions = new HashMap<String, BaseFunction>();
109:
110: BaseFunction func = new BaseFunction(iName, iAllowed);
111: functions.put(iName, func);
112: }
113:
114: public String getNotes() {
115: return notes;
116: }
117:
118: public void setNotes(String notes) {
119: this .notes = notes;
120: }
121:
122: public String getHomePage() {
123: return homePage;
124: }
125:
126: public void setHomePage(String homePage) {
127: this.homePage = homePage;
128: }
129: }
|