4b6dfdef830f46170b6bdca5e654500c2534220f
[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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
37  */
38 package org.onap.portalsdk.analytics.model.search;
39
40 import org.onap.portalsdk.analytics.util.*;
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         
55
56         public String getConfirmationText() {
57                 return confirmationText;
58         }
59
60         public void setConfirmationText(String confirmationText) {
61                 this.confirmationText = confirmationText;
62         }
63
64         public String getDrillDownImage() {
65                 return drillDownImage;
66         }
67
68         public void setDrillDownImage(String drillDownImage) {
69                 this.drillDownImage = drillDownImage;
70         }
71
72         public SearchResultField() {
73         }
74
75         public SearchResultField(String displayValue, String linkIdValue,
76                         SearchResultColumn column, boolean isAuthorized) {
77                 super();
78
79                 if (!isAuthorized)
80                         return;
81
82                 setColumnId(column.getColumnId());
83                 setDisplayValue(displayValue);
84                 setAlignment(column.getAlignment());
85                 if(column.getColumnId().equals("edit")) {
86 //                      setDrillDownLink("report_wizard.htm?action=report.edit&c_master="+linkIdValue);
87                         setDrillDownLink("report#/report_wizard/"+linkIdValue);
88                         setDrillDownImage(column.getLinkImg());
89                         setConfirmationText(null);
90                 } else if(column.getColumnId().equals("copy")) { 
91 //                      setDrillDownLink("report_wizard.htm?action=report.copy&c_master="+linkIdValue);
92                         setDrillDownLink("report#/report_wizard/copy/"+linkIdValue);                    
93                         setDrillDownImage(column.getLinkImg());
94                         setConfirmationText(column.getLinkConfirmMsg());        
95                 } else if(column.getColumnId().equals("delete")) { 
96                         setDrillDownLink("raptor.htm?action=report.delete&c_master="+linkIdValue);
97                         setDrillDownImage(column.getLinkImg());
98                         setConfirmationText(column.getLinkConfirmMsg());                        
99                 } else if(column.getColumnId().equals("schedule")) { 
100                         setDrillDownLink("report_wizard.htm?action=report.schedule.report.submit_wmenu&c_master="+linkIdValue+"&refresh=Y");
101                         setDrillDownImage(column.getLinkImg());
102                         setConfirmationText(null);                      
103                 } else if(column.getColumnId().equals("run")) { 
104                         setDrillDownLink("raptor.htm?action=report.run.container&c_master="+linkIdValue+"&refresh=Y");
105                         setDrillDownImage(column.getLinkImg());
106                         setConfirmationText(null);                      
107                 } else { 
108                 if (column.getLinkURL() != null) {
109                         StringBuffer sb = new StringBuffer();
110
111                         if (column.getLinkForm() == null) {
112                                 sb.append("<a href=\"");
113                                 sb.append(column.getLinkURL());
114                                 sb.append(nvl(linkIdValue));
115                                 if (column.getLinkConfirmMsg() != null) {
116                                         sb.append(" onClick=\"return confirm('");
117                                         sb.append(column.getLinkConfirmMsg());
118                                         sb.append("');\"");
119                                 }
120                                 sb.append("\">");
121                                 if (column.getLinkImg() != null) {
122                                         sb.append("<img src=\"");
123                                         sb.append(column.getLinkImg());
124                                         sb.append("\"");
125                                         sb.append(column.getLinkImgSizeHtml());
126                                         sb.append(" border=\"0\"");
127                                         sb.append(column.getLinkTitle() != null ? " alt=\""
128                                                         + column.getLinkTitle()/*
129                                                                                                          * +(column.isDeleteLink()?"
130                                                                                                          * "+linkIdValue:"")
131                                                                                                          */
132                                                         + "\"" : "");
133                                         sb.append(">");
134                                 } else
135                                         sb.append(column.getLinkTitle());
136                                 sb.append("</a>");
137                         } else {
138                                 sb.append("<input type=\"");
139                                 if (column.getLinkImg() != null) {
140                                         sb.append("image\" src=\"");
141                                         sb.append(column.getLinkImg());
142                                         sb.append("\"");
143                                         sb.append(column.getLinkImgSizeHtml());
144                                         sb.append(" border=\"0\"");
145                                         sb.append(column.getLinkTitle() != null ? " alt=\""
146                                                         + column.getLinkTitle()/*
147                                                                                                          * +(column.isDeleteLink()?"
148                                                                                                          * "+linkIdValue:"")
149                                                                                                          */
150                                                         + "\"" : "");
151                                 } else {
152                                         sb.append("submit\" value=\"");
153                                         sb.append(column.getLinkTitle());
154                                         sb.append("\"");
155                                 }
156                                 sb.append(" onClick=\"");
157                                 if (column.getLinkConfirmMsg() != null) {
158                                         sb.append("if(! confirm('");
159                                         sb.append(column.getLinkConfirmMsg());
160                                         sb.append("')) return false; ");
161                                 }
162                                 sb.append(column.getLinkURL());
163                                 sb.append(" document.");
164                                 sb.append(column.getLinkForm());
165                                 sb.append(".");
166                                 sb.append(AppConstants.RI_REPORT_ID);
167                                 sb.append(".value='");
168                                 sb.append(nvl(linkIdValue));
169                                 sb.append("';");
170                                 sb.append(" document.");
171                                 sb.append(column.getLinkForm());
172                                 sb.append(".");
173                                 sb.append("refresh");
174                                 sb.append(".value='");
175                                 sb.append("Y");
176                                 sb.append("';\">");
177                         } // else
178
179                         setDrillDownLink(sb.toString());
180                 } // if
181                 }
182         } // SearchResultField
183
184         public String getDisplayValue() {
185                 return displayValue;
186         }
187
188         public String getAlignment() {
189                 return alignment;
190         }
191
192         public String getDrillDownLink() {
193                 return drillDownLink;
194         }
195
196         public void setDisplayValue(String displayValue) {
197                 this.displayValue = nvl(displayValue);
198         }
199
200         public void setAlignment(String alignment) {
201                 this.alignment = alignment;
202         }
203
204         public void setDrillDownLink(String drillDownLink) {
205                 this.drillDownLink = drillDownLink;
206         }
207
208         public String getTooltipValue() {
209                 return (displayValue.length() == 0) ? "&nbsp;" : displayValue;
210         }
211
212         /*public String getAlignmentHtml() {
213                 return (alignment.length() == 0) ? "" : (" align=" + alignment);
214         }*/
215
216         /*public String getDisplayValueLinkHtml() {
217                 if (nvl(drillDownLink).length() == 0)
218                         return getDisplayValueHtml();
219                 else
220                         return getDrillDownLink();
221         } // getDisplayValueLinkHtml*/
222
223         public String getColumnId() {
224                 return columnId;
225         }
226
227         public void setColumnId(String columnId) {
228                 this.columnId = columnId;
229         }
230
231         
232 } // SearchResultField