3e6d6f42d3e11b6ea47a9c2f2675cc765ea2a92a
[portal/sdk.git] /
1 /*-
2  * ================================================================================
3  * eCOMP Portal SDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 package org.openecomp.portalsdk.analytics.model.base;
21
22 import java.util.*;
23
24 import org.openecomp.portalsdk.analytics.error.RaptorException;
25 import org.openecomp.portalsdk.analytics.system.*;
26
27 public class IdNameList extends Vector {
28         protected int pageNo = -1;
29
30         protected int pageSize = 50;
31
32         private int nextElemIdx = 0;
33         
34         private String oldSql = null;
35
36         public IdNameList() {
37                 super();
38                 pageSize = Globals.getFormFieldsListSize();
39         } // IdNameList
40
41         public int getPageNo() {
42                 return pageNo;
43         } // getPageNo
44
45         public int getPageSize() {
46                 return pageSize;
47         } // getPageSize
48
49         public int getDataSize() {
50                 return size();
51         } // getDataSize
52
53         public void resetNext() {
54                 resetNext(0);
55         } // resetNext
56
57         public void resetNext(int toPos) {
58                 nextElemIdx = toPos;
59         } // resetNext
60
61         public boolean hasNext() {
62                 return (nextElemIdx < size());
63         } // hasNext
64
65         public IdNameValue getNext() {
66                 return hasNext() ? getValue(nextElemIdx++) : null;
67         } // getNext
68
69         public int getCount() {
70                 return size();
71         } // getCount
72
73         public IdNameValue getValue(int idx) {
74                 return (IdNameValue) get(idx);
75         } // getValue
76
77         public void addValue(IdNameValue value) {
78                 add(value);
79         } // addValue
80
81         public void addValue(String id, String name, boolean defaultValue) {
82                 addValue(new IdNameValue(id, name, defaultValue));
83         } // addValue
84
85         public void addValue(String id, String name, boolean defaultValue, boolean readOnly) {
86                 addValue(new IdNameValue(id, name, defaultValue, readOnly));
87         } // addValue
88         
89         public void addValue(String id, String name) {
90                 addValue(new IdNameValue(id, name));
91         } // addValue
92
93         public void addValue(int idx, IdNameValue value) {
94                 add(idx, value);
95         } // addValue
96
97         public void addValue(int idx, String id, String name) {
98                 addValue(idx, new IdNameValue(id, name));
99         } // addValue
100
101         public String getNameById(String id) {
102                 for (int i = 0; i < size(); i++) {
103                         IdNameValue value = getValue(i);
104                         if (value.getId().equals(id))
105                                 return value.getName();
106                 } // for
107
108                 return null;
109         } // getNameById
110
111         public String getIdByName(String name) {
112                 for (int i = 0; i < size(); i++) {
113                         IdNameValue value = getValue(i);
114                         if (value.getName().equals(name))
115                                 return value.getId();
116                 } // for
117
118                 return null;
119         } // getIdByName
120
121         public boolean canUseSearchString() {
122                 return true;
123         }
124
125         public String getBaseSQL() {
126                 return null;
127         }
128
129         public String getOldSql() {
130                 return oldSql;
131         }
132
133         public void setOldSql(String oldSql) {
134                 this.oldSql = oldSql;
135         }
136         public String getBaseWholeSQL() {
137                 return null;
138         }
139         
140         public String getBaseWholeReadonlySQL() {
141                 return null;
142         }
143         
144         public String getBaseSQLForPDFExcel(boolean multiParam) {
145                 return null;
146         }
147         
148         public void clearData() {
149         }
150
151         public void loadData(String pageNo, String searchString, String dbInfo,String userId) throws RaptorException {}
152         public void loadUserData(String pageNo, String searchString, String dbInfo,String userId) throws RaptorException {}
153     public void loadUserData(int pageNo, String searchString, String dbInfo, String userId) throws RaptorException {}
154     public void loadUserData(String searchString, int pageNo,  String dbInfo) throws RaptorException {}
155         
156     public void loadData(String pageNo) throws RaptorException {}
157         public void loadData(int pageNo) throws RaptorException {}  
158         public void loadData(String pageNo, String searchString, String dbInfo) throws RaptorException {}
159         private void loadData(int pageNo, String searchString, String dbInfo) throws RaptorException {} 
160
161 /*    
162         public void loadData(int pageNo, String dbInfo) throws RaptorException {
163         }
164
165     public void loadUserData(int pageNo, String dbInfo, String userId) throws RaptorException {
166     }
167
168
169
170
171         public void loadData(String pageNo, String searchString) throws RaptorException {
172         }
173
174 */
175         protected static String nvl(String s) {
176                 return (s == null) ? "" : s;
177         }
178
179         protected static String nvl(String s, String sDefault) {
180                 return nvl(s).equals("") ? sDefault : s;
181         }
182
183 } // IdNameList