9f32eebaf376da4362dde643193a5e168f64515f
[portal/sdk.git] /
1 /*
2  * ============LICENSE_START==========================================
3  * ONAP Portal SDK
4  * ===================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the "License");
10  * you may not use this software except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 package org.onap.portalsdk.analytics.model.search;
39
40 import org.onap.portalsdk.analytics.util.AppConstants;
41
42 public class SearchResultField extends org.onap.portalsdk.analytics.RaptorObject {
43         private String columnId;
44         private String displayValue = "";
45
46         private String alignment = "Left";
47
48         private String drillDownLink = null;
49
50         private String drillDownImage = null;
51         
52         private String confirmationText = null;
53         
54         private boolean isAuthorized = false;   
55         
56         public boolean isAuthorized() {
57                 return isAuthorized;
58         }
59
60         public void setAuthorized(boolean isAuthorized) {
61                 this.isAuthorized = isAuthorized;
62         }
63
64         public String getConfirmationText() {
65                 return confirmationText;
66         }
67
68         public void setConfirmationText(String confirmationText) {
69                 this.confirmationText = confirmationText;
70         }
71
72         public String getDrillDownImage() {
73                 return drillDownImage;
74         }
75
76         public void setDrillDownImage(String drillDownImage) {
77                 this.drillDownImage = drillDownImage;
78         }
79
80         public SearchResultField() {
81         }
82
83         public SearchResultField(String displayValue, String linkIdValue,
84                         SearchResultColumn column, boolean isAuthorized) {
85                 super();
86
87                 if (!isAuthorized)
88                         return;
89
90                 setColumnId(column.getColumnId());
91                 setDisplayValue(displayValue);
92                 setAlignment(column.getAlignment());
93                 setAuthorized(isAuthorized);
94                 if(column.getColumnId().equals("edit")) {
95                         setDrillDownLink("report#/report_wizard/"+linkIdValue);
96                         setDrillDownImage(column.getLinkImg());
97                         setConfirmationText(null);
98                 } else if(column.getColumnId().equals("copy")) { 
99                         setDrillDownLink("report#/report_wizard/copy/"+linkIdValue);                    
100                         setDrillDownImage(column.getLinkImg());
101                         setConfirmationText(column.getLinkConfirmMsg());        
102                 } else if(column.getColumnId().equals("delete")) { 
103                         setDrillDownLink("raptor.htm?action=report.delete&c_master="+linkIdValue);
104                         setDrillDownImage(column.getLinkImg());
105                         setConfirmationText(column.getLinkConfirmMsg());                        
106                 } else if(column.getColumnId().equals("schedule")) { 
107                         setDrillDownLink("report_wizard.htm?action=report.schedule.report.submit_wmenu&c_master="+linkIdValue+"&refresh=Y");
108                         setDrillDownImage(column.getLinkImg());
109                         setConfirmationText(null);                      
110                 } else if(column.getColumnId().equals("run")) { 
111                         setDrillDownLink("raptor.htm?action=report.run.container&c_master="+linkIdValue+"&refresh=Y");
112                         setDrillDownImage(column.getLinkImg());
113                         setConfirmationText(null);                      
114                 } else { 
115                 if (column.getLinkURL() != null) {
116                         StringBuffer sb = new StringBuffer();
117
118                         if (column.getLinkForm() == null) {
119                                 sb.append("<a href=\"");
120                                 sb.append(column.getLinkURL());
121                                 sb.append(nvl(linkIdValue));
122                                 if (column.getLinkConfirmMsg() != null) {
123                                         sb.append(" onClick=\"return confirm('");
124                                         sb.append(column.getLinkConfirmMsg());
125                                         sb.append("');\"");
126                                 }
127                                 sb.append("\">");
128                                 if (column.getLinkImg() != null) {
129                                         sb.append("<img src=\"");
130                                         sb.append(column.getLinkImg());
131                                         sb.append("\"");
132                                         sb.append(column.getLinkImgSizeHtml());
133                                         sb.append(" border=\"0\"");
134                                         sb.append(column.getLinkTitle() != null ? " alt=\""
135                                                         + column.getLinkTitle()/*
136                                                                                                          * +(column.isDeleteLink()?"
137                                                                                                          * "+linkIdValue:"")
138                                                                                                          */
139                                                         + "\"" : "");
140                                         sb.append(">");
141                                 } else
142                                         sb.append(column.getLinkTitle());
143                                 sb.append("</a>");
144                         } else {
145                                 sb.append("<input type=\"");
146                                 if (column.getLinkImg() != null) {
147                                         sb.append("image\" src=\"");
148                                         sb.append(column.getLinkImg());
149                                         sb.append("\"");
150                                         sb.append(column.getLinkImgSizeHtml());
151                                         sb.append(" border=\"0\"");
152                                         sb.append(column.getLinkTitle() != null ? " alt=\""
153                                                         + column.getLinkTitle()/*
154                                                                                                          * +(column.isDeleteLink()?"
155                                                                                                          * "+linkIdValue:"")
156                                                                                                          */
157                                                         + "\"" : "");
158                                 } else {
159                                         sb.append("submit\" value=\"");
160                                         sb.append(column.getLinkTitle());
161                                         sb.append("\"");
162                                 }
163                                 sb.append(" onClick=\"");
164                                 if (column.getLinkConfirmMsg() != null) {
165                                         sb.append("if(! confirm('");
166                                         sb.append(column.getLinkConfirmMsg());
167                                         sb.append("')) return false; ");
168                                 }
169                                 sb.append(column.getLinkURL());
170                                 sb.append(" document.");
171                                 sb.append(column.getLinkForm());
172                                 sb.append(".");
173                                 sb.append(AppConstants.RI_REPORT_ID);
174                                 sb.append(".value='");
175                                 sb.append(nvl(linkIdValue));
176                                 sb.append("';");
177                                 sb.append(" document.");
178                                 sb.append(column.getLinkForm());
179                                 sb.append(".");
180                                 sb.append("refresh");
181                                 sb.append(".value='");
182                                 sb.append("Y");
183                                 sb.append("';\">");
184                         } // else
185
186                         setDrillDownLink(sb.toString());
187                 } // if
188                 }
189         } // SearchResultField
190
191         public String getDisplayValue() {
192                 return displayValue;
193         }
194
195         public String getAlignment() {
196                 return alignment;
197         }
198
199         public String getDrillDownLink() {
200                 return drillDownLink;
201         }
202
203         public void setDisplayValue(String displayValue) {
204                 this.displayValue = nvl(displayValue);
205         }
206
207         public void setAlignment(String alignment) {
208                 this.alignment = alignment;
209         }
210
211         public void setDrillDownLink(String drillDownLink) {
212                 this.drillDownLink = drillDownLink;
213         }
214
215         public String getTooltipValue() {
216                 return (displayValue.length() == 0) ? "&nbsp;" : displayValue;
217         }
218
219         /*public String getAlignmentHtml() {
220                 return (alignment.length() == 0) ? "" : (" align=" + alignment);
221         }*/
222
223         /*public String getDisplayValueLinkHtml() {
224                 if (nvl(drillDownLink).length() == 0)
225                         return getDisplayValueHtml();
226                 else
227                         return getDrillDownLink();
228         } // getDisplayValueLinkHtml*/
229
230         public String getColumnId() {
231                 return columnId;
232         }
233
234         public void setColumnId(String columnId) {
235                 this.columnId = columnId;
236         }
237
238         
239 } // SearchResultField