summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/ReportSearchResult.java85
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/ReportSearchResultJSON.java249
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResult.java212
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultColumn.java256
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultField.java214
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultJSON.java86
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultRow.java92
7 files changed, 1194 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/ReportSearchResult.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/ReportSearchResult.java
new file mode 100644
index 00000000..567dfeb3
--- /dev/null
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/ReportSearchResult.java
@@ -0,0 +1,85 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.analytics.model.search;
+
+import java.util.*;
+
+import org.openecomp.portalsdk.analytics.system.*;
+import org.openecomp.portalsdk.analytics.util.*;
+
+public class ReportSearchResult extends SearchResult {
+ private static final String HTML_FORM = "forma";
+
+ public ReportSearchResult(int pageNo) {
+ this(pageNo, Globals.getDefaultPageSize(), -1, -1);
+ } // ReportSearchResult
+
+ public ReportSearchResult(int pageNo, int writeAccessColIndex, int ownerIndicatorColIndex) {
+ this(pageNo, Globals.getDefaultPageSize(), writeAccessColIndex, ownerIndicatorColIndex);
+ } // ReportSearchResult
+
+ public ReportSearchResult(int pageNo, int pageSize, int writeAccessColIndex,
+ int ownerIndicatorColIndex) {
+ super(pageNo, pageSize, writeAccessColIndex, ownerIndicatorColIndex);
+
+ addColumn(new SearchResultColumn("no","No", "5%", "Center"));
+ addColumn(new SearchResultColumn("rep_id","Report ID", "5%", "Center"));
+ addColumn(new SearchResultColumn("rep_name","Report Name", "25%", "Left"));
+ addColumn(new SearchResultColumn("descr","Description", "30%", "Left"));
+ addColumn(new SearchResultColumn("owner","Report Owner", "10%", "Center"));
+ addColumn(new SearchResultColumn("create_date","Create Date", "10%", "Center"));
+ addColumn(new SearchResultColumn("copy","  Copy  ", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.copy';", "Copy report", HTML_FORM,
+ "Are you sure you want to create a copy of this report?", AppUtils
+ .getImgFolderURL()
+ + "modify_icon.gif", "13", "12", true, false, false));
+ /*addColumn(new SearchResultColumn("  Schedule  ", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.schedule_only';", "Schedule report", HTML_FORM,
+ null, AppUtils
+ .getImgFolderURL()
+ + "calendar_icon.gif", "13", "12", true, false, false));
+ */
+
+ addColumn(new SearchResultColumn("edit","  Edit  ", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.edit';", "Edit report", HTML_FORM, null, AppUtils
+ .getImgFolderURL()
+ + "pen_paper.gif", "12", "12", false, true, false));
+ addColumn(new SearchResultColumn("delete","Delete", "5%", "Center", "document." + HTML_FORM
+ + "." + AppConstants.RI_ACTION + ".value='report.delete';", "Delete report",
+ HTML_FORM, "Are you sure you want to delete this report?", AppUtils
+ .getImgFolderURL()
+ + "deleteicon.gif", "12", "12", false, false, true));
+ addColumn(new SearchResultColumn("schedule","Schedule", "5%", "Center", "document." + HTML_FORM
+ + "." + AppConstants.RI_ACTION + ".value='report.schedule.report.submit_wmenu';", "Schedule report",
+ HTML_FORM, null, AppUtils
+ .getImgFolderURL()
+ + "calendar_icon.gif", "20", "20", false, false, false, true));
+ addColumn(new SearchResultColumn("run","  Run  ", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.run';", "Run report", HTML_FORM, null, AppUtils
+ .getImgFolderURL()
+ + "test_run.gif", "12", "12"));
+ } // ReportSearchResult
+
+} // ReportSearchResult
+
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/ReportSearchResultJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/ReportSearchResultJSON.java
new file mode 100644
index 00000000..1c170d36
--- /dev/null
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/ReportSearchResultJSON.java
@@ -0,0 +1,249 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.analytics.model.search;
+
+import java.util.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.portalsdk.analytics.error.RaptorException;
+import org.openecomp.portalsdk.analytics.system.*;
+import org.openecomp.portalsdk.analytics.util.*;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+class MetaReport {
+ private boolean pagination = true;
+ private int pageSize;
+ private int totalSize;
+ private int pageNo;
+ public boolean isPagination() {
+ return pagination;
+ }
+ public void setPagination(boolean pagination) {
+ this.pagination = pagination;
+ }
+ public int getPageSize() {
+ return pageSize;
+ }
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+ public int getTotalSize() {
+ return totalSize;
+ }
+ public void setTotalSize(int totalSize) {
+ this.totalSize = totalSize;
+ }
+ public int getPageNo() {
+ return pageNo;
+ }
+ public void setPageNo(int pageNo) {
+ this.pageNo = pageNo;
+ }
+
+
+}
+class SearchReport {
+ private MetaReport metaReport;
+ public MetaReport getMetaReport() {
+ return metaReport;
+ }
+ public void setMetaReport(MetaReport metaReport) {
+ this.metaReport = metaReport;
+ }
+ private ArrayList<ArrayList<SearchResultColumn>> columns = new ArrayList<ArrayList<SearchResultColumn>>();
+ private ArrayList<ArrayList<SearchResultRow>> rows = new ArrayList<ArrayList<SearchResultRow>>();
+ public ArrayList<ArrayList<SearchResultColumn>> getColumns() {
+ return columns;
+ }
+ public void setColumns(ArrayList<ArrayList<SearchResultColumn>> columns) {
+ this.columns = columns;
+ }
+ public ArrayList<ArrayList<SearchResultRow>> getRows() {
+ return rows;
+ }
+ public void setRows(ArrayList<ArrayList<SearchResultRow>> rows) {
+ this.rows = rows;
+ }
+
+}
+
+public class ReportSearchResultJSON extends SearchResultJSON {
+ private static final String HTML_FORM = "forma";
+ private String JSONString= "";
+ private SearchReport searchReport;
+ //private ArrayList<ArrayList<SearchResultColumn>> columns = new ArrayList<ArrayList<SearchResultColumn>>();
+ //private ArrayList<ArrayList<SearchResultRow>> rows = new ArrayList<ArrayList<SearchResultRow>>();
+
+
+ public ReportSearchResultJSON(int pageNo) {
+ this(pageNo, Globals.getDefaultPageSize(), -1, -1);
+ } // ReportSearchResult
+
+ public ReportSearchResultJSON(int pageNo, int writeAccessColIndex, int ownerIndicatorColIndex) {
+ this(pageNo, Globals.getDefaultPageSize(), writeAccessColIndex, ownerIndicatorColIndex);
+ } // ReportSearchResult
+
+ public ReportSearchResultJSON(int pageNo, int pageSize, int writeAccessColIndex,
+ int ownerIndicatorColIndex) {
+
+ searchReport = new SearchReport();
+ MetaReport metaReport = new MetaReport();
+ //if(searchReport.getMetaReport()!=null)
+ searchReport.setMetaReport(metaReport);
+ metaReport.setPageNo(pageNo);
+ metaReport.setPageSize(pageSize);
+ metaReport.setPagination(true);
+ addColumn(new SearchResultColumn("no", "No", "5%", "Center"));
+ addColumn(new SearchResultColumn("rep_id", "Report ID", "5%", "Center"));
+ addColumn(new SearchResultColumn("rep_name", "Report Name", "25%", "Left"));
+ addColumn(new SearchResultColumn("descr", "Description", "30%", "Left"));
+ addColumn(new SearchResultColumn("owner", "Report Owner", "10%", "Center"));
+ addColumn(new SearchResultColumn("create_date", "Create Date", "10%", "Center"));
+ addColumn(new SearchResultColumn("copy", "Copy", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.copy';", "Copy report", HTML_FORM,
+ "Are you sure you want to create a copy of this report?", AppUtils
+ .getImgFolderURL()
+ + "modify_icon.gif", "13", "12", true, false, false));
+ /*addColumn(new SearchResultColumn("&nbsp;&nbsp;Schedule&nbsp;&nbsp;", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.schedule_only';", "Schedule report", HTML_FORM,
+ null, AppUtils
+ .getImgFolderURL()
+ + "calendar_icon.gif", "13", "12", true, false, false));
+ */
+
+ addColumn(new SearchResultColumn("edit", "Edit", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.edit';", "Edit report", HTML_FORM, null, AppUtils
+ .getImgFolderURL()
+ + "pen_paper.gif", "12", "12", false, true, false));
+ addColumn(new SearchResultColumn("delete", "Delete", "5%", "Center", "document." + HTML_FORM
+ + "." + AppConstants.RI_ACTION + ".value='report.delete';", "Delete report",
+ HTML_FORM, "Are you sure you want to delete this report?", AppUtils
+ .getImgFolderURL()
+ + "deleteicon.gif", "12", "12", false, false, true));
+ addColumn(new SearchResultColumn("schedule", "Schedule", "5%", "Center", "document." + HTML_FORM
+ + "." + AppConstants.RI_ACTION + ".value='report.schedule.report.submit_wmenu';", "Schedule report",
+ HTML_FORM, null, AppUtils
+ .getImgFolderURL()
+ + "calendar_icon.gif", "20", "20", false, false, false, true));
+ addColumn(new SearchResultColumn("run", "Run", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.run';", "Run report", HTML_FORM, null, AppUtils
+ .getImgFolderURL()
+ + "test_run.gif", "12", "12"));
+ searchReport.getColumns().add(searchResultColumns);
+ } // ReportSearchResult
+
+ public void parseData(DataSet ds, HttpServletRequest request, int pageNo, int pageSize, int writeAccessColIndex, int ownerIndicatorColIndex) throws RaptorException {
+ // Presumes single ID field in the first column of the DataSet and row
+ // number in the first SearchResultColumn
+
+ pageNo = AppUtils.getRequestNvlValue(request, "r_page").length()>0?Integer.parseInt(AppUtils.getRequestNvlValue(request, "r_page")):0;
+ String userID = AppUtils.getUserID(request);
+ int dataSize = ds.getRowCount();
+ //pageSize = 0;
+
+ if(searchReport.getMetaReport()!=null) {
+ searchReport.getMetaReport().setPageNo(pageNo);
+ //searchReport.getMetaReport().setPageSize(pageSize);
+ pageSize = searchReport.getMetaReport().getPageSize();
+ searchReport.getMetaReport().setTotalSize(dataSize);
+ }
+ int startRow = (pageNo >= 0) ? (pageNo * pageSize) : 0;
+ int endRow = (pageNo >= 0) ? Math.min(startRow + pageSize, ds.getRowCount()) : ds
+ .getRowCount();
+ for (int r = startRow; r < endRow; r++) {
+ SearchResultRow row = new SearchResultRow();
+ searchResultRows.add(row);
+
+ String idValue = ds.getString(r, 0);
+
+ boolean bCanEdit = true;
+ if (writeAccessColIndex >= 0) {
+ String isReadOnlyValue = nvl(ds.getString(r, writeAccessColIndex), "Y");
+ bCanEdit = AppUtils.isSuperUser(request) || AppUtils.isAdminUser(request)
+ || isReadOnlyValue.equals("N");
+ }
+
+ boolean bCanDelete = bCanEdit;
+ if (Globals.getDeleteOnlyByOwner() && ownerIndicatorColIndex >= 0) {
+ String isOwnedByUserRecord = nvl(ds.getString(r, ownerIndicatorColIndex), "N");
+ bCanDelete = AppUtils.isSuperUser(request) || isOwnedByUserRecord.equals("Y");
+ }
+
+ boolean bCanSchedule = ds.getString(r, getNumColumns()-3).equals("Y");
+
+ row.addColumnContent(new ColumnContent(getColumn(0).getColumnId(), new SearchResultField("" + (r + 1), idValue,
+ getColumn(0), true)));
+ boolean isAuthorized = true;
+ for (int c = 1; c < getNumColumns(); c++) {
+ SearchResultColumn column = getColumn(c);
+ isAuthorized = true;
+
+ if(column.isCopyLink())
+ isAuthorized = Globals.getCanCopyOnReadOnly()? true:bCanEdit;
+ else if (column.isDeleteLink())
+ isAuthorized = bCanDelete;
+ else if (column.isEditLink())
+ isAuthorized = bCanEdit;
+ else if (column.isScheduleLink())
+ isAuthorized = bCanSchedule;
+ row.addColumnContent(new ColumnContent(column.getColumnId(), new SearchResultField(
+ (column.getLinkURL() == null) ? ds.getString(r, c) : column
+ .getLinkTitle(), idValue, column, isAuthorized
+ )));
+ } // for
+ } // for
+ searchReport.getRows().add(searchResultRows);
+ ObjectMapper mapper = new ObjectMapper();
+ String jsonInString = "";
+ try {
+ jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(searchReport);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+
+ }
+ System.out.println(jsonInString);
+ this.JSONString = jsonInString;
+ } // parseData
+
+ private String nvl(String s) {
+ return (s == null) ? "" : s;
+ }
+
+ private String nvl(String s, String sDefault) {
+ return nvl(s).equals("") ? sDefault : s;
+ }
+
+ public String getJSONString() {
+ return JSONString;
+ }
+
+ public void setJSONString(String jSONString) {
+ JSONString = jSONString;
+ }
+
+
+} // ReportSearchResult
+
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResult.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResult.java
new file mode 100644
index 00000000..7d33cab5
--- /dev/null
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResult.java
@@ -0,0 +1,212 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.analytics.model.search;
+
+import java.util.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.portalsdk.analytics.error.RaptorException;
+import org.openecomp.portalsdk.analytics.system.*;
+import org.openecomp.portalsdk.analytics.util.*;
+
+public class SearchResult{
+ private int pageNo = -1;
+
+ private int pageSize = 50;
+
+ private int dataSize = -1;
+
+ private int writeAccessColIndex = -1;
+
+ private int ownerIndicatorColIndex = -1;
+
+ private String csvPageFileName = null;
+
+
+
+ private String csvAllRowsFileName = null;
+
+ private String excelAllRowsFileName = null;
+
+ public ArrayList searchResultColumns = new ArrayList();
+
+ public ArrayList searchResultRows = new ArrayList();
+
+ public SearchResult(int pageNo) {
+ this(pageNo, Globals.getDefaultPageSize());
+ } // SearchResult
+
+ public SearchResult(int pageNo, int pageSize) {
+ this(pageNo, pageSize, -1, -1);
+ } // SearchResult
+
+ public SearchResult(int pageNo, int pageSize, int writeAccessColIndex,
+ int ownerIndicatorColIndex) {
+ super();
+
+ this.pageNo = pageNo;
+ this.pageSize = pageSize;
+
+ this.writeAccessColIndex = writeAccessColIndex;
+ this.ownerIndicatorColIndex = ownerIndicatorColIndex;
+ } // SearchResult
+
+ public int getPageNo() {
+ return pageNo;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public int getDataSize() {
+ return dataSize;
+ }
+
+ public String getCsvPageFileName() {
+ return csvPageFileName;
+ }
+
+ public String getCsvAllRowsFileName() {
+ return csvAllRowsFileName;
+ }
+
+ public String getExcelAllRowsFileName() {
+ return excelAllRowsFileName;
+ }
+
+ private void setDataSize(int dataSize) {
+ this.dataSize = dataSize;
+ }
+
+ public void setCsvPageFileName(String csvPageFileName) {
+ this.csvPageFileName = csvPageFileName;
+ }
+
+
+
+ public void setCsvAllRowsFileName(String csvAllRowsFileName) {
+ this.csvAllRowsFileName = csvAllRowsFileName;
+ }
+
+
+
+ public void addColumn(SearchResultColumn column) {
+ searchResultColumns.add(column);
+ } // addColumn
+
+ public SearchResultColumn getColumn(int index) {
+ return (SearchResultColumn) searchResultColumns.get(index);
+ } // getColumn
+
+ public int getNumColumns() {
+ return searchResultColumns.size();
+ } // getNumColumns
+
+ public int getNumRows() {
+ return searchResultRows.size();
+ } // getNumRows
+
+ public SearchResultRow getRow(int index) {
+ return (SearchResultRow) searchResultRows.get(index);
+ } // getRow
+
+ public void parseData(DataSet ds, HttpServletRequest request) throws RaptorException {
+ // Presumes single ID field in the first column of the DataSet and row
+ // number in the first SearchResultColumn
+ String userID = AppUtils.getUserID(request);
+ setDataSize(ds.getRowCount());
+
+ int startRow = (pageNo >= 0) ? (pageNo * pageSize) : 0;
+ int endRow = (pageNo >= 0) ? Math.min(startRow + pageSize, ds.getRowCount()) : ds
+ .getRowCount();
+ for (int r = startRow; r < endRow; r++) {
+ SearchResultRow row = new SearchResultRow();
+ searchResultRows.add(row);
+
+ String idValue = ds.getString(r, 0);
+
+ boolean bCanEdit = true;
+ if (writeAccessColIndex >= 0) {
+ String isReadOnlyValue = nvl(ds.getString(r, writeAccessColIndex), "Y");
+ bCanEdit = AppUtils.isSuperUser(request) || AppUtils.isAdminUser(request)
+ || isReadOnlyValue.equals("N");
+ }
+
+ boolean bCanDelete = bCanEdit;
+ if (Globals.getDeleteOnlyByOwner() && ownerIndicatorColIndex >= 0) {
+ String isOwnedByUserRecord = nvl(ds.getString(r, ownerIndicatorColIndex), "N");
+ bCanDelete = AppUtils.isSuperUser(request) || isOwnedByUserRecord.equals("Y");
+ }
+
+ boolean bCanSchedule = ds.getString(r, getNumColumns()-3).equals("Y");
+
+ row.addSearchResultField(new SearchResultField("" + (r + 1), idValue,
+ getColumn(0), true));
+ boolean isAuthorized = true;
+ for (int c = 1; c < getNumColumns(); c++) {
+ SearchResultColumn column = getColumn(c);
+ isAuthorized = true;
+
+ if(column.isCopyLink())
+ isAuthorized = Globals.getCanCopyOnReadOnly()? true:bCanEdit;
+ else if (column.isDeleteLink())
+ isAuthorized = bCanDelete;
+ else if (column.isEditLink())
+ isAuthorized = bCanEdit;
+ else if (column.isScheduleLink())
+ isAuthorized = bCanSchedule;
+
+ row.addSearchResultField(new SearchResultField(
+ (column.getLinkURL() == null) ? ds.getString(r, c) : column
+ .getLinkTitle(), idValue, column, isAuthorized
+ ));
+ } // for
+ } // for
+ } // parseData
+
+ public void truncateToPage(int pageNo) {
+ if (this.pageNo >= 0 || pageNo < 0)
+ return;
+
+ this.pageNo = pageNo;
+
+ int startRow = pageNo * pageSize;
+ int endRow = Math.min(startRow + pageSize, dataSize);
+
+ for (int r = getNumRows() - 1; r >= endRow; r--)
+ searchResultRows.remove(r);
+
+ for (int r = startRow - 1; r >= 0; r--)
+ searchResultRows.remove(r);
+ } // truncateToPage
+
+ /** *********************************************************************** */
+
+ private String nvl(String s) {
+ return (s == null) ? "" : s;
+ }
+
+ private String nvl(String s, String sDefault) {
+ return nvl(s).equals("") ? sDefault : s;
+ }
+
+} // SearchResult
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultColumn.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultColumn.java
new file mode 100644
index 00000000..3c0f68e4
--- /dev/null
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultColumn.java
@@ -0,0 +1,256 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.analytics.model.search;
+
+import org.openecomp.portalsdk.analytics.util.*;
+
+public class SearchResultColumn extends org.openecomp.portalsdk.analytics.RaptorObject {
+ private String columnId = "";
+ private String columnTitle = "";
+
+ private String columnWidth = "";
+
+ private String alignment = "Left";
+
+ private String linkURL = null; // if not null => display link instead of
+ // text
+
+ private String linkTitle = null; // if img => hint, otherwise link
+ // display text
+
+ private String linkForm = null; // if not null => displays input submit
+ // instead of link
+
+ private String linkConfirmMsg = null; // if not null => display conf. box
+ // on link click
+
+ private String linkImg = null; // if not null => link shows image, not text
+
+ private String linkImgWidth = null; // optional
+
+ private String linkImgHeight = null; // optional
+
+ private boolean copyLink = false; // optional
+
+ private boolean editLink = false; // optional
+
+ private boolean deleteLink = false; // optional
+
+ private boolean scheduleLink = false; // optional
+
+ public SearchResultColumn(String columnId, String columnTitle) {
+ super();
+ setColumnId(columnId);
+ setColumnTitle(columnTitle);
+ } // SearchResultColumn
+
+ public SearchResultColumn(String columnId, String columnTitle, String columnWidth, String alignment) {
+ super();
+ setColumnId(columnId);
+ setColumnTitle(columnTitle);
+ setColumnWidth(columnWidth);
+ setAlignment(alignment);
+ } // SearchResultColumn
+
+ public SearchResultColumn(String columnId, String columnTitle, String columnWidth, String alignment,
+ String linkURL, String linkTitle, String linkForm, String linkConfirmMsg,
+ String linkImg) {
+ super();
+ setColumnId(columnId);
+ setColumnTitle(columnTitle);
+ setColumnWidth(columnWidth);
+ setAlignment(alignment);
+ setLinkURL(linkURL);
+ setLinkTitle(linkTitle);
+ setLinkForm(linkForm);
+ setLinkConfirmMsg(linkConfirmMsg);
+ setLinkImg(linkImg);
+ } // SearchResultColumn
+
+ public SearchResultColumn(String columnId, String columnTitle, String columnWidth, String alignment,
+ String linkURL, String linkTitle, String linkForm, String linkConfirmMsg,
+ String linkImg, String linkImgWidth, String linkImgHeight) {
+ this(columnId, columnTitle, columnWidth, alignment, linkURL, linkTitle, linkForm,
+ linkConfirmMsg, linkImg);
+
+ setLinkWidth(linkImgWidth);
+ setLinkHeight(linkImgHeight);
+ } // SearchResultColumn
+
+ public SearchResultColumn(String columnId, String columnTitle, String columnWidth, String alignment,
+ String linkURL, String linkTitle, String linkForm, String linkConfirmMsg,
+ String linkImg, String linkImgWidth, String linkImgHeight, boolean copyLink,
+ boolean editLink, boolean deleteLink) {
+ this(columnId, columnTitle, columnWidth, alignment, linkURL, linkTitle, linkForm,
+ linkConfirmMsg, linkImg, linkImgWidth, linkImgHeight);
+
+ setCopyLink(copyLink);
+ setEditLink(editLink);
+ setDeleteLink(deleteLink);
+ } // SearchResultColumn
+
+ public SearchResultColumn(String columnId, String columnTitle, String columnWidth, String alignment,
+ String linkURL, String linkTitle, String linkForm, String linkConfirmMsg,
+ String linkImg, String linkImgWidth, String linkImgHeight, boolean copyLink,
+ boolean editLink, boolean deleteLink, boolean scheduleLink) {
+ this(columnId, columnTitle, columnWidth, alignment, linkURL, linkTitle, linkForm,
+ linkConfirmMsg, linkImg, linkImgWidth, linkImgHeight);
+
+ setCopyLink(copyLink);
+ setEditLink(editLink);
+ setDeleteLink(deleteLink);
+ setScheduleLink(scheduleLink);
+ } // SearchResultColumn
+
+ public String getColumnTitle() {
+ return columnTitle;
+ }
+
+ public String getColumnWidth() {
+ return columnWidth;
+ }
+
+ public String getAlignment() {
+ return alignment;
+ }
+
+ public String getLinkURL() {
+ return linkURL;
+ }
+
+ public String getLinkTitle() {
+ return linkTitle;
+ }
+
+ public String getLinkForm() {
+ return linkForm;
+ }
+
+ public String getLinkConfirmMsg() {
+ return linkConfirmMsg;
+ }
+
+ public String getLinkImg() {
+ return linkImg;
+ }
+
+ public String getLinkImgWidth() {
+ return linkImgWidth;
+ }
+
+ public String getLinkImgHeight() {
+ return linkImgHeight;
+ }
+
+ public boolean isCopyLink() {
+ return copyLink;
+ }
+
+ public boolean isEditLink() {
+ return editLink;
+ }
+
+ public boolean isDeleteLink() {
+ return deleteLink;
+ }
+
+ public void setColumnTitle(String columnTitle) {
+ this.columnTitle = nvl(columnTitle);
+ }
+
+ public void setColumnWidth(String columnWidth) {
+ this.columnWidth = nvl(columnWidth);
+ }
+
+ public void setAlignment(String alignment) {
+ this.alignment = alignment;
+ }
+
+ public void setLinkURL(String linkURL) {
+ this.linkURL = linkURL;
+ }
+
+ public void setLinkTitle(String linkTitle) {
+ this.linkTitle = linkTitle;
+ }
+
+ public void setLinkForm(String linkForm) {
+ this.linkForm = linkForm;
+ }
+
+ public void setLinkConfirmMsg(String linkConfirmMsg) {
+ this.linkConfirmMsg = linkConfirmMsg;
+ }
+
+ public void setLinkImg(String linkImg) {
+ this.linkImg = linkImg;
+ }
+
+ public void setLinkWidth(String linkImgWidth) {
+ this.linkImgWidth = linkImgWidth;
+ }
+
+ public void setLinkHeight(String linkImgHeight) {
+ this.linkImgHeight = linkImgHeight;
+ }
+
+ public void setCopyLink(boolean copyLink) {
+ this.copyLink = copyLink;
+ }
+
+ public void setEditLink(boolean editLink) {
+ this.editLink = editLink;
+ }
+
+ public void setDeleteLink(boolean deleteLink) {
+ this.deleteLink = deleteLink;
+ }
+
+ public String getColumnTitleHtml() {
+ return (columnTitle.length() == 0) ? "&nbsp;" : columnTitle;
+ }
+
+ public String getColumnWidthHtml() {
+ return (columnWidth.length() == 0) ? "" : (" width=" + columnWidth);
+ }
+
+ public String getLinkImgSizeHtml() {
+ return ((nvl(linkImgWidth).length() > 0) ? " width=\"" + linkImgWidth + "\"" : "")
+ + ((nvl(linkImgHeight).length() > 0) ? " height=\"" + linkImgHeight + "\""
+ : "");
+ }
+
+ public boolean isScheduleLink() {
+ return scheduleLink;
+ }
+
+ public void setScheduleLink(boolean scheduleLink) {
+ this.scheduleLink = scheduleLink;
+ }
+
+ public String getColumnId() {
+ return columnId;
+ }
+
+ public void setColumnId(String columnId) {
+ this.columnId = columnId;
+ }
+
+} // SearchResultColumn
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultField.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultField.java
new file mode 100644
index 00000000..bae32b19
--- /dev/null
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultField.java
@@ -0,0 +1,214 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.analytics.model.search;
+
+import org.openecomp.portalsdk.analytics.util.*;
+
+public class SearchResultField extends org.openecomp.portalsdk.analytics.RaptorObject {
+ private String columnId;
+ private String displayValue = "";
+
+ private String alignment = "Left";
+
+ private String drillDownLink = null;
+
+ private String drillDownImage = null;
+
+ private String confirmationText = null;
+
+
+
+ public String getConfirmationText() {
+ return confirmationText;
+ }
+
+ public void setConfirmationText(String confirmationText) {
+ this.confirmationText = confirmationText;
+ }
+
+ public String getDrillDownImage() {
+ return drillDownImage;
+ }
+
+ public void setDrillDownImage(String drillDownImage) {
+ this.drillDownImage = drillDownImage;
+ }
+
+ public SearchResultField() {
+ }
+
+ public SearchResultField(String displayValue, String linkIdValue,
+ SearchResultColumn column, boolean isAuthorized) {
+ super();
+
+ if (!isAuthorized)
+ return;
+
+ setColumnId(column.getColumnId());
+ setDisplayValue(displayValue);
+ setAlignment(column.getAlignment());
+ if(column.getColumnId().equals("edit")) {
+// setDrillDownLink("report_wizard.htm?action=report.edit&c_master="+linkIdValue);
+ setDrillDownLink("report#/report_wizard/"+linkIdValue);
+ setDrillDownImage(column.getLinkImg());
+ setConfirmationText(null);
+ } else if(column.getColumnId().equals("copy")) {
+// setDrillDownLink("report_wizard.htm?action=report.copy&c_master="+linkIdValue);
+ setDrillDownLink("report#/report_wizard/copy/"+linkIdValue);
+ setDrillDownImage(column.getLinkImg());
+ setConfirmationText(column.getLinkConfirmMsg());
+ } else if(column.getColumnId().equals("delete")) {
+ setDrillDownLink("raptor.htm?action=report.delete&c_master="+linkIdValue);
+ setDrillDownImage(column.getLinkImg());
+ setConfirmationText(column.getLinkConfirmMsg());
+ } else if(column.getColumnId().equals("schedule")) {
+ setDrillDownLink("report_wizard.htm?action=report.schedule.report.submit_wmenu&c_master="+linkIdValue+"&refresh=Y");
+ setDrillDownImage(column.getLinkImg());
+ setConfirmationText(null);
+ } else if(column.getColumnId().equals("run")) {
+ setDrillDownLink("raptor.htm?action=report.run.container&c_master="+linkIdValue+"&refresh=Y");
+ setDrillDownImage(column.getLinkImg());
+ setConfirmationText(null);
+ } else {
+ if (column.getLinkURL() != null) {
+ StringBuffer sb = new StringBuffer();
+
+ if (column.getLinkForm() == null) {
+ sb.append("<a href=\"");
+ sb.append(column.getLinkURL());
+ sb.append(nvl(linkIdValue));
+ if (column.getLinkConfirmMsg() != null) {
+ sb.append(" onClick=\"return confirm('");
+ sb.append(column.getLinkConfirmMsg());
+ sb.append("');\"");
+ }
+ sb.append("\">");
+ if (column.getLinkImg() != null) {
+ sb.append("<img src=\"");
+ sb.append(column.getLinkImg());
+ sb.append("\"");
+ sb.append(column.getLinkImgSizeHtml());
+ sb.append(" border=\"0\"");
+ sb.append(column.getLinkTitle() != null ? " alt=\""
+ + column.getLinkTitle()/*
+ * +(column.isDeleteLink()?"
+ * "+linkIdValue:"")
+ */
+ + "\"" : "");
+ sb.append(">");
+ } else
+ sb.append(column.getLinkTitle());
+ sb.append("</a>");
+ } else {
+ sb.append("<input type=\"");
+ if (column.getLinkImg() != null) {
+ sb.append("image\" src=\"");
+ sb.append(column.getLinkImg());
+ sb.append("\"");
+ sb.append(column.getLinkImgSizeHtml());
+ sb.append(" border=\"0\"");
+ sb.append(column.getLinkTitle() != null ? " alt=\""
+ + column.getLinkTitle()/*
+ * +(column.isDeleteLink()?"
+ * "+linkIdValue:"")
+ */
+ + "\"" : "");
+ } else {
+ sb.append("submit\" value=\"");
+ sb.append(column.getLinkTitle());
+ sb.append("\"");
+ }
+ sb.append(" onClick=\"");
+ if (column.getLinkConfirmMsg() != null) {
+ sb.append("if(! confirm('");
+ sb.append(column.getLinkConfirmMsg());
+ sb.append("')) return false; ");
+ }
+ sb.append(column.getLinkURL());
+ sb.append(" document.");
+ sb.append(column.getLinkForm());
+ sb.append(".");
+ sb.append(AppConstants.RI_REPORT_ID);
+ sb.append(".value='");
+ sb.append(nvl(linkIdValue));
+ sb.append("';");
+ sb.append(" document.");
+ sb.append(column.getLinkForm());
+ sb.append(".");
+ sb.append("refresh");
+ sb.append(".value='");
+ sb.append("Y");
+ sb.append("';\">");
+ } // else
+
+ setDrillDownLink(sb.toString());
+ } // if
+ }
+ } // SearchResultField
+
+ public String getDisplayValue() {
+ return displayValue;
+ }
+
+ public String getAlignment() {
+ return alignment;
+ }
+
+ public String getDrillDownLink() {
+ return drillDownLink;
+ }
+
+ public void setDisplayValue(String displayValue) {
+ this.displayValue = nvl(displayValue);
+ }
+
+ public void setAlignment(String alignment) {
+ this.alignment = alignment;
+ }
+
+ public void setDrillDownLink(String drillDownLink) {
+ this.drillDownLink = drillDownLink;
+ }
+
+ public String getTooltipValue() {
+ return (displayValue.length() == 0) ? "&nbsp;" : displayValue;
+ }
+
+ /*public String getAlignmentHtml() {
+ return (alignment.length() == 0) ? "" : (" align=" + alignment);
+ }*/
+
+ /*public String getDisplayValueLinkHtml() {
+ if (nvl(drillDownLink).length() == 0)
+ return getDisplayValueHtml();
+ else
+ return getDrillDownLink();
+ } // getDisplayValueLinkHtml*/
+
+ public String getColumnId() {
+ return columnId;
+ }
+
+ public void setColumnId(String columnId) {
+ this.columnId = columnId;
+ }
+
+
+} // SearchResultField
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultJSON.java
new file mode 100644
index 00000000..fb565a84
--- /dev/null
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultJSON.java
@@ -0,0 +1,86 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.analytics.model.search;
+
+import java.util.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.portalsdk.analytics.error.RaptorException;
+import org.openecomp.portalsdk.analytics.system.*;
+import org.openecomp.portalsdk.analytics.util.*;
+
+public class SearchResultJSON{
+
+ public ArrayList<SearchResultColumn> searchResultColumns = new ArrayList<SearchResultColumn>();
+
+ public ArrayList<SearchResultRow> searchResultRows = new ArrayList<SearchResultRow>();
+
+
+
+
+
+
+ public ArrayList<SearchResultColumn> getSearchResultColumns() {
+ return searchResultColumns;
+ }
+
+ public void setSearchResultColumns(ArrayList<SearchResultColumn> searchResultColumns) {
+ this.searchResultColumns = searchResultColumns;
+ }
+
+ public ArrayList<SearchResultRow> getSearchResultRows() {
+ return searchResultRows;
+ }
+
+ public void setSearchResultRows(ArrayList<SearchResultRow> searchResultRows) {
+ this.searchResultRows = searchResultRows;
+ }
+
+ public void addColumn(SearchResultColumn column) {
+ searchResultColumns.add(column);
+ } // addColumn
+
+ public SearchResultColumn getColumn(int index) {
+ return (SearchResultColumn) searchResultColumns.get(index);
+ } // getColumn
+
+ public int getNumColumns() {
+ return searchResultColumns.size();
+ } // getNumColumns
+
+ public int getNumRows() {
+ return searchResultRows.size();
+ } // getNumRows
+
+ public SearchResultRow getRow(int index) {
+ return (SearchResultRow) searchResultRows.get(index);
+ } // getRow
+
+
+ private String nvl(String s) {
+ return (s == null) ? "" : s;
+ }
+
+ private String nvl(String s, String sDefault) {
+ return nvl(s).equals("") ? sDefault : s;
+ }
+
+} // SearchResultJSON
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultRow.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultRow.java
new file mode 100644
index 00000000..8f53f0b3
--- /dev/null
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/search/SearchResultRow.java
@@ -0,0 +1,92 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.analytics.model.search;
+
+import java.util.*;
+
+class ColumnContent {
+ String columnId;
+ SearchResultField searchresultField;
+
+ public ColumnContent(String columnId, SearchResultField searchresultField) {
+ this.columnId = columnId;
+ this.searchresultField = searchresultField;
+ }
+ public String getColumnId() {
+ return columnId;
+ }
+ public void setColumnId(String columnId) {
+ this.columnId = columnId;
+ }
+ public SearchResultField getSearchresultField() {
+ return searchresultField;
+ }
+ public void setSearchresultField(SearchResultField searchresultField) {
+ this.searchresultField = searchresultField;
+ }
+
+
+
+}
+public class SearchResultRow extends ArrayList {
+
+
+ //private SearchResultField searchresultField;
+ private int nextElemIdx = 0;
+
+ public void resetNext() {
+ resetNext(0);
+ } // resetNext
+
+ public void resetNext(int toPos) {
+ nextElemIdx = toPos;
+ } // resetNext
+
+ public boolean hasNext() {
+ return (nextElemIdx < size());
+ } // hasNext
+
+ public SearchResultField getNext() {
+ return hasNext() ? getSearchResultField(nextElemIdx++) : null;
+ } // getNext
+
+ public SearchResultField getSearchResultField(int idx) {
+ return (SearchResultField) get(idx);
+ } // getRowHeader
+
+ public void addSearchResultField(SearchResultField searchResultField) {
+ add(searchResultField);
+ } // addSearchResultField
+
+ public void addSearchResultField(int idx, SearchResultField searchResultField) {
+ add(idx, searchResultField);
+ } // addSearchResultField
+
+ public void addColumnContent(ColumnContent cc ) {
+
+ add(cc);
+ } // addSearchResultField
+
+ public void addColumnContent(int idx, ColumnContent cc) {
+ add(idx, cc);
+ } // addSearchResultField
+
+
+} // SearchResultRow