001: /*
002: *
003: * Copyright (c) 2004 SourceTap - www.sourcetap.com
004: *
005: * The contents of this file are subject to the SourceTap Public License
006: * ("License"); You may not use this file except in compliance with the
007: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
008: * Software distributed under the License is distributed on an "AS IS" basis,
009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
010: * the specific language governing rights and limitations under the License.
011: *
012: * The above copyright notice and this permission notice shall be included
013: * in all copies or substantial portions of the Software.
014: *
015: */
016:
017: package com.sourcetap.sfa.ui;
018:
019: import java.util.HashMap;
020: import java.util.List;
021:
022: import org.ofbiz.entity.GenericDelegator;
023: import org.ofbiz.entity.GenericEntityException;
024: import org.ofbiz.entity.GenericValue;
025:
026: /**
027: * DOCUMENT ME!
028: *
029: */
030: public class UIScreen {
031: public static final String module = UIScreen.class.getName();
032: protected String screenId = "";
033: protected String applicationId = "";
034: protected String screenName = "";
035: protected String screenDescription = "";
036:
037: public UIScreen() {
038: }
039:
040: public UIScreen(String screenName, GenericDelegator delegator)
041: throws GenericEntityException {
042:
043: initialize(screenName, delegator);
044: }
045:
046: // public UIScreen(String screenId_, String applicationId_, String screenName_, String screenDescription) {
047: // setScreenId(uiScreenGV.getString("screenId")==null ? "" : uiScreenGV.getString("screenId"));
048: // setApplicationId(uiScreenGV.getString("applicationId")==null ? "" : uiScreenGV.getString("applicationId"));
049: // setScreenName(uiScreenGV.getString("screenName")==null ? "" : uiScreenGV.getString("screenName"));
050: // setScreenDescription(uiScreenGV.getString("screenDescription")==null ? "" : uiScreenGV.getString("screenDescription"));
051: // }
052: public UIScreen(GenericValue uiScreenGV, GenericDelegator delegator) {
053: initialize(uiScreenGV, delegator);
054: }
055:
056: /**
057: * DOCUMENT ME!
058: *
059: * @param screenId_
060: */
061: public void setScreenId(String screenId_) {
062: screenId = screenId_;
063: }
064:
065: /**
066: * DOCUMENT ME!
067: *
068: * @return
069: */
070: public String getScreenId() {
071: return screenId;
072: }
073:
074: /**
075: * DOCUMENT ME!
076: *
077: * @param applicationId_
078: */
079: public void setApplicationId(String applicationId_) {
080: applicationId = applicationId_;
081: }
082:
083: /**
084: * DOCUMENT ME!
085: *
086: * @return
087: */
088: public String getApplicationId() {
089: return applicationId;
090: }
091:
092: /**
093: * DOCUMENT ME!
094: *
095: * @param screenName_
096: */
097: public void setScreenName(String screenName_) {
098: screenName = screenName_;
099: }
100:
101: /**
102: * DOCUMENT ME!
103: *
104: * @return
105: */
106: public String getScreenName() {
107: return screenName;
108: }
109:
110: /**
111: * DOCUMENT ME!
112: *
113: * @param screenDescription_
114: */
115: public void setScreenDescription(String screenDescription_) {
116: screenDescription = screenDescription_;
117: }
118:
119: /**
120: * DOCUMENT ME!
121: *
122: * @return
123: */
124: public String getScreenDescription() {
125: return screenDescription;
126: }
127:
128: /**
129: * DOCUMENT ME!
130: *
131: * @param uiScreenGV
132: * @param delegator
133: */
134: public void initialize(GenericValue uiScreenGV,
135: GenericDelegator delegator) {
136: setScreenId((uiScreenGV.getString("screenId") == null) ? ""
137: : uiScreenGV.getString("screenId"));
138: setApplicationId((uiScreenGV.getString("applicationId") == null) ? ""
139: : uiScreenGV.getString("applicationId"));
140: setScreenName((uiScreenGV.getString("screenName") == null) ? ""
141: : uiScreenGV.getString("screenName"));
142: setScreenDescription((uiScreenGV.getString("screenDescription") == null) ? ""
143: : uiScreenGV.getString("screenDescription"));
144: }
145:
146: /**
147: * DOCUMENT ME!
148: *
149: * @param screenName
150: * @param delegator
151: *
152: * @throws GenericEntityException
153: */
154: public void initialize(String screenName, GenericDelegator delegator)
155: throws GenericEntityException {
156:
157: HashMap findHashMap = new HashMap();
158: findHashMap.put("screenName", screenName);
159:
160: List uiScreenGVL = delegator.findByAnd("UiScreen", findHashMap,
161: null);
162:
163: if (uiScreenGVL.size() == 0) {
164: throw new GenericEntityException("No screen with name \""
165: + screenName + "\" was found in database.");
166: }
167:
168: if (uiScreenGVL.size() > 1) {
169: throw new GenericEntityException(
170: "More than one screen found with name \""
171: + screenName + "\".");
172: }
173:
174: GenericValue uiScreenGV = (GenericValue) uiScreenGVL.iterator()
175: .next();
176: initialize(uiScreenGV, delegator);
177: }
178: }
|