From 7f535078ef80a7b7efa3e3325bfccb994fbd00e8 Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Thu, 31 Aug 2017 15:16:38 -0400 Subject: Rename packages to org.onap in 1.4.0-SNAPSHOT 19 - remove openecomp 72 - remediate Sonar scan issues 79 - removed unwanted left menu under Report 90 - apply approved license text Issue: PORTAL-19, PORTAL-72, PORTAL-79, PORTAL-90 Change-Id: I41a0ef5fba623d2242574bd15f2d9fb8029a496c Signed-off-by: Christopher Lott (cl778h) --- .../analytics/system/fusion/AntBuild.java | 85 + .../analytics/system/fusion/AppUtils.java | 383 +++++ .../portalsdk/analytics/system/fusion/DbUtils.java | 96 ++ .../analytics/system/fusion/RemoteDbUtils.java | 75 + .../adapter/AdapterSessionFactoryContainer.java | 57 + .../analytics/system/fusion/adapter/DateUtils.java | 305 ++++ .../system/fusion/adapter/FusionAdapter.java | 139 ++ .../analytics/system/fusion/adapter/IdName.java | 85 + .../analytics/system/fusion/adapter/Item.java | 73 + .../analytics/system/fusion/adapter/Lookup.java | 103 ++ .../system/fusion/adapter/RaptorAdapter.java | 380 +++++ .../system/fusion/adapter/SpringContext.java | 55 + .../fusion/controller/FileServletController.java | 223 +++ .../analytics/system/fusion/domain/CR_Report.java | 325 ++++ .../analytics/system/fusion/domain/QuickLink.java | 79 + .../system/fusion/domain/RaptorSearch.java | 206 +++ .../analytics/system/fusion/domain/ReportInfo.java | 177 ++ .../system/fusion/service/RaptorService.java | 53 + .../system/fusion/service/RaptorServiceImpl.java | 201 +++ .../system/fusion/web/RaptorController.java | 208 +++ .../system/fusion/web/RaptorControllerAsync.java | 1787 ++++++++++++++++++++ .../fusion/web/ReportsSearchListController.java | 95 ++ 22 files changed, 5190 insertions(+) create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AntBuild.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AppUtils.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/DbUtils.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/AdapterSessionFactoryContainer.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/DateUtils.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/FusionAdapter.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/IdName.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/Item.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/Lookup.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/SpringContext.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/domain/CR_Report.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/domain/QuickLink.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/domain/RaptorSearch.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/domain/ReportInfo.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/service/RaptorService.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/service/RaptorServiceImpl.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorController.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/ReportsSearchListController.java (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion') diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AntBuild.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AntBuild.java new file mode 100644 index 00000000..6451a961 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AntBuild.java @@ -0,0 +1,85 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion; + +import java.io.IOException; +import java.util.Iterator; +import java.util.Map; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; + +/** + * @author sundar + * This class is used to get version and Build information when + * user run "java -jar raptor_fusion.jar" command. + */ +public class AntBuild { + + public static void main(String[] args) { + System.out.println("Jar (raptor_fusion.jar) Information: "); + readManifest(); + } + + public static void readManifest() { + try { + JarFile jar = new JarFile("./raptor_fusion.jar"); + Manifest manifest = jar.getManifest(); + + Attributes attribs = manifest.getMainAttributes(); + Iterator it = attribs.entrySet().iterator(); + while(it.hasNext()) { + Map.Entry entry = (Map.Entry) it.next(); + Attributes.Name attributeName = (Attributes.Name) entry.getKey(); + String attributeValue = (String) entry.getValue(); + if (attributeName.toString().equals("Created-By")) + System.out.println("JDK Version " + " : " + attributeValue); + else if (attributeName.toString().equals("Ant-Version")) + System.out.println(attributeName.toString() + " : " + attributeValue); + else { + if(attributeName.toString().startsWith("Raptor")) + System.out.println(attributeName.toString() + " : " + attributeValue); + } + } + + } catch (IOException e) { + System.err.println("Cannot read jar-file manifest: " + + e.getMessage()); + } + } +} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AppUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AppUtils.java new file mode 100644 index 00000000..e3bd0f7e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AppUtils.java @@ -0,0 +1,383 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion; + +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.Vector; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; + +import org.onap.portalsdk.analytics.config.ConfigLoader; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.model.base.IdNameValue; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.system.IAppUtils; +import org.onap.portalsdk.analytics.system.fusion.adapter.RaptorAdapter; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;; + +public class AppUtils extends org.onap.portalsdk.analytics.RaptorObject implements IAppUtils { + + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppUtils.class); + + private static String tempFolderPath = "/artemis/PROJECT1/MSA/databank/WEB-INF/temp/"; + private static String uploadFolderPath = "/artemis/PROJECT1/MSA/databank/WEB-INF/upload/"; + private static String tempFolderURL = "temp/"; + private static String uploadFolderURL = "upload/"; + private static String SMTPServer = "todo.smtp.server.com"; + private static String defaultEmailSender = "todo.email.sender.com"; + private static String errorPage = "error_page"; + private static String errorPageWMenu = "error_page_wmenu"; + private static String jspContextPath = "raptor/"; + private static String imgFolderURL = "raptor/images/"; + private static String baseFolderURL = "raptor/"; + //private static String reportExecuteActionURL = "dispatcher?action=raptor&r_action=report.run&c_master="; + //private static String dataViewActionURL = "dispatcher?action="; // dispatcher?action=ACTION_ID&c_master=REC_ID + //private static String dataViewActionParam = "c_master="; + private static String directAccessURL = "http://localhost:8082/databank/dispatcher?direct.access=raptor&r_action=report.run&show="; + private static String baseActionURL = "dispatcher?action="; // dispatcher?action=ACTION_ID&c_master=REC_ID or dispatcher?action=raptor&r_action=RAPTOR_ACTION_ID&c_master=REC_ID + private static String baseActionURLNG = "report#/"; // dispatcher?action=ACTION_ID&c_master=REC_ID or dispatcher?action=raptor&r_action=RAPTOR_ACTION_ID&c_master=REC_ID + private static String drillActionURL = "dispatcher?action="; // dispatcher?action=ACTION_ID&c_master=REC_ID or dispatcher?action=raptor&r_action=RAPTOR_ACTION_ID&c_master=REC_ID + private static String baseActionParam = "c_master="; + private static String superRoleID = "1"; + private static Vector adminRoleIDs = new Vector(); + private static Vector quickLinksMenuIDs = new Vector(); + + private static Properties raptorAppProperties; + + private static String encryptedSMTPServer = ""; + public AppUtils() {} + + public void initializeAppUtils(ServletContext servletContext) { + try { + Properties appProperties = ConfigLoader.getProperties(servletContext, ConfigLoader.APP_PROPERTIES, Globals.getSystemType()); + raptorAppProperties = appProperties; + tempFolderPath = appProperties.getProperty("temp_folder_path"); + uploadFolderPath = appProperties.getProperty("upload_folder_path"); + tempFolderURL = appProperties.getProperty("temp_folder_url"); + uploadFolderURL = appProperties.getProperty("upload_folder_url"); + SMTPServer = appProperties.getProperty("smtp_server"); + encryptedSMTPServer = appProperties.getProperty("encrypted_smtp_server"); + defaultEmailSender = appProperties.getProperty("default_email_sender"); + errorPage = appProperties.getProperty("error_page"); + jspContextPath = appProperties.getProperty("jsp_context_path"); + imgFolderURL = appProperties.getProperty("img_folder_url"); + baseFolderURL = appProperties.getProperty("base_folder_url"); +/* reportExecuteActionURL = appProperties.getProperty("report_execute_action_url"); + dataViewActionURL = appProperties.getProperty("data_view_action_url"); + dataViewActionParam = appProperties.getProperty("data_view_action_param");*/ + directAccessURL = appProperties.getProperty("direct_access_url"); + baseActionURL = appProperties.getProperty("base_action_url"); + baseActionURLNG = appProperties.getProperty("base_action_url_ng"); + drillActionURL = appProperties.getProperty("drill_action_url"); + baseActionParam = appProperties.getProperty("base_action_param"); + superRoleID = appProperties.getProperty("super_role_id"); + + adminRoleIDs.removeAllElements(); + StringTokenizer st = new StringTokenizer(appProperties.getProperty("admin_role_ids"), ","); + while(st.hasMoreTokens()) + adminRoleIDs.add(st.nextToken()); + + quickLinksMenuIDs.removeAllElements(); + st = new StringTokenizer(appProperties.getProperty("quick_links_menu_ids"), ","); + while(st.hasMoreTokens()) + quickLinksMenuIDs.add(st.nextToken()); + } catch(Exception e) { + logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] AppUtils.initializeAppUtils: Unable to load properties ["+Globals.getSystemType()+"_"+ConfigLoader.APP_PROPERTIES+"]. Exception: "+e.getMessage())); + //throw new RuntimeException(e.getMessage()); + } + } // initializeAppUtils + + public static void getFullURL(HttpServletRequest req) { + String applicationBase = ""; + if (applicationBase == null) { + applicationBase = req.getScheme() + "://" + req.getServerName() + + getPort(req) + req.getContextPath(); + } + } + + private static String getPort(HttpServletRequest req) { + if ("http".equalsIgnoreCase(req.getScheme()) && req.getServerPort() != 80 || + "https".equalsIgnoreCase(req.getScheme()) && req.getServerPort() != 443 ) { + return (":" + req.getServerPort()); + } else { + return ""; + } + } + public String getUserID(HttpServletRequest request) { + String pdfAttachmentKey = org.onap.portalsdk.analytics.system.AppUtils.getRequestValue(request, "pdfAttachmentKey"); + String report_email_sent_log_id = org.onap.portalsdk.analytics.system.AppUtils.getRequestValue(request, "log_id"); + boolean isEmailAttachment = false; + if(pdfAttachmentKey != null && report_email_sent_log_id !=null) + isEmailAttachment = true; + if(isEmailAttachment) { + return RaptorAdapter.getUserID(org.onap.portalsdk.analytics.system.AppUtils.getRequestValue(request, "user_id")); + } else + return RaptorAdapter.getUserID(request); + } // getUserID + + public Vector getAllUsers(String customizedQuery, String param, boolean isAdmin) { + Map map = RaptorAdapter.getAllUsers(customizedQuery, param, isAdmin); + + Vector vector = new Vector(map.size()); + for(Iterator iter=map.keySet().iterator(); iter.hasNext(); ) { + Long key = (Long) iter.next(); + vector.add(new IdNameValue(""+key, (String) map.get(key))); + } // for + + return vector; + } // getAllUsers + + public String getRoleName(String roleId) { + return RaptorAdapter.getRoleName(roleId); + } // getRoleName + + public Vector getAllRoles(String customizedQuery, String param, boolean isAdmin) { + Map map = RaptorAdapter.getAllRolesUsingCustomizedQuery(customizedQuery, param, isAdmin); + + Vector vector = new Vector(map.size()); + for(Iterator iter=map.keySet().iterator(); iter.hasNext(); ) { + Long key = (Long) iter.next(); + vector.add(new IdNameValue(""+key, (String) map.get(key))); + } // for + + return vector; + } // getAllRoles + + public String getUserName(HttpServletRequest request) { + return RaptorAdapter.getUserName(request); + } // getUserName + + public String getUserName(String userId) { + return RaptorAdapter.getUserName(userId); + } // getUserName + + public String getUserEmail(String userId) { + return RaptorAdapter.getUserEmail(userId); + } // getUserEmail + + public String getUserEmail(HttpServletRequest request) { + return RaptorAdapter.getUserEmail(request); + } // getUserEmail + + public String getUserLoginId(HttpServletRequest request) { + return RaptorAdapter.getUserLoginId(request); + } // getUserLoginId + + public String getUserLoginId(String userId) { + return RaptorAdapter.getUserLoginId(userId); + } // getUserLoginId + + public String getUserBackdoorLoginId(HttpServletRequest request) { + String pdfAttachmentKey = org.onap.portalsdk.analytics.system.AppUtils.getRequestValue(request, "pdfAttachmentKey"); + String report_email_sent_log_id = org.onap.portalsdk.analytics.system.AppUtils.getRequestValue(request, "log_id"); + boolean isEmailAttachment = false; + if(pdfAttachmentKey != null && report_email_sent_log_id !=null) + isEmailAttachment = true; + if(isEmailAttachment) { + return RaptorAdapter.getUserBackdoorLoginId(org.onap.portalsdk.analytics.system.AppUtils.getRequestValue(request, "user_id")); + } else + return RaptorAdapter.getUserBackdoorLoginId(request); + } // getUserBackdoorLoginId + + public boolean isUserInRole(HttpServletRequest request, String roleId) { + return RaptorAdapter.isCurrentUserInRole(request, roleId); + } // isUserInRole + + public Vector getUserRoles(HttpServletRequest request) { +// Map map = RaptorAdapter.getAllRoles(userId); + Set set = RaptorAdapter.getUserRoles(request); + + Vector vector = new Vector(set.size()); + for(Iterator iter=set.iterator(); iter.hasNext(); ) { + Long key = (Long) iter.next(); + vector.add(""+key); + //vector.add(new IdNameValue(""+key, (String) map.get(key))); + } // for + + return vector; + } // getUserRoles + + public Vector getUserRoles(String userId) { + Set set = RaptorAdapter.getUserRoles(userId); + + Vector vector = new Vector(set.size()); + for(Iterator iter=set.iterator(); iter.hasNext(); ) { + Long key = (Long) iter.next(); + vector.add(""+key); + //vector.add(new IdNameValue(""+key, (String) map.get(key))); + } // for + + return vector; + //return null; + } // getUserRoles + + public void resetUserCache() { + } // resetUserCache + + public String getSuperRoleID(){ + return superRoleID; + } // getSuperRoleID + + public Vector getAdminRoleIDs(){ + return adminRoleIDs; + } // getAdminRoleIDs + + + public String getTempFolderPath() { + return tempFolderPath; + } // getTempFolderPath + + public String getUploadFolderPath() { + return uploadFolderPath; + } // getUploadFolderPath + + public String getTempFolderURL() { + return tempFolderURL; + } // getTempFolderURL + + public String getUploadFolderURL() { + return uploadFolderURL; + } // getUploadFolderURL + + public String getSMTPServer() { + return SMTPServer; + } // getSMTPServer + + public String getDefaultEmailSender() { + return defaultEmailSender; + } // getDefaultEmailSender + + public String getErrorPage() { + return errorPage; + } // getErrorPage + + public String getJspContextPath() { + return jspContextPath; + } // getJspContextPath + + public String getImgFolderURL() { + return imgFolderURL; + } // getImgFolderURL + + public String getBaseFolderURL() { + return baseFolderURL; + } // getBaseFolderURL + +/* public String getReportExecuteActionURL() { + return reportExecuteActionURL; + } // getReportExecuteActionURL + + public String getDataViewActionURL() { + return dataViewActionURL; + } // getDataViewActionURL + + public String getDataViewActionParam() { + return dataViewActionParam; + } // getDataViewActionParam +*/ + public String getDirectAccessURL() { + return directAccessURL.trim(); + } // getDirectAccessURL + + public String getBaseActionURL() { + return baseActionURL; + } // getBaseActionURL + + public String getBaseActionURLNG() { + return baseActionURLNG; + } // getBaseActionURLNG + + public String getDrillActionURL() { + return drillActionURL; + } // getBaseActionURL + + public String getBaseActionParam() { + return baseActionParam; + } // getBaseActionParam + + public Vector getQuickLinksMenuIDs(){ + return quickLinksMenuIDs; + } // getQuickLinksMenuIDs + + public String getMenuLabel(String menuId) { + //return menuId.substring(0, 1).toUpperCase()+menuId.substring(1).toLowerCase(); + return menuId; + } // getMenuLabel + + public String getReportDbColsMaskSQL() { + return null; +/* Example: + return "SELECT f.table_name, UPPER(f.column_name) column_name, f.label "+ + "FROM fields f WHERE f.active_yn = 'Y'"; */ + } // getReportDbColsMaskSQL + + public String getReportDbLookupsSQL() { + return null; +/* Example: + return "SELECT DISTINCT f.table_name, UPPER(f.column_name) column_name, f.lookup_table, f.lookup_id_field, f.lookup_name_field "+ + "FROM fields f WHERE f.active_yn = 'Y'"; */ + } // getReportDbLookupsSQL + + public void processErrorNotification(HttpServletRequest request, RaptorException e) { + //RaptorAdapter.processErrorNotification(request, e); +} // processErrorNotification + + public String getErrorPageWMenu() { + return errorPageWMenu; + } + + public String getExcelTemplatePath() { + return nvls(raptorAppProperties.getProperty("excel_template_path"), ""); + } + /** + * @return the encryptedSMTPServer + */ + public String getEncryptedSMTPServer() { + return encryptedSMTPServer; + } + + public String getFolderPathAdj(){ + return nvls(raptorAppProperties.getProperty("folder_path_adj"), ""); + } + +} // AppUtils diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/DbUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/DbUtils.java new file mode 100644 index 00000000..b33995b2 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/DbUtils.java @@ -0,0 +1,96 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion; + +import java.sql.*; +import java.util.*; + +import javax.servlet.*; + +import org.onap.portalsdk.analytics.config.*; +import org.onap.portalsdk.analytics.system.*; +import org.onap.portalsdk.analytics.system.fusion.adapter.FusionAdapter; +import org.onap.portalsdk.analytics.system.fusion.adapter.RaptorAdapter; +import org.onap.portalsdk.analytics.system.fusion.adapter.SpringContext; +import org.onap.portalsdk.analytics.util.*; +import org.springframework.beans.factory.annotation.Autowired; + + + +public class DbUtils implements IDbUtils { + + @Autowired + public RaptorAdapter raptorAdapter; + @Autowired + public FusionAdapter fusionAdapter; + + public DbUtils() {} + + public void initializeDbUtils(ServletContext servletContext) { + raptorAdapter = (RaptorAdapter)SpringContext.getApplicationContext().getBean("raptorAdapter"); + } // initializeDbUtils + + public Connection getConnection() { + return raptorAdapter.getConnection(); + } // getConnection + + public void clearConnection(Connection con) { + raptorAdapter.releaseConnection(con); + } // clearConnection + + public RaptorAdapter getRaptorAdapter() { + return raptorAdapter; + } + + public void setRaptorAdapter(RaptorAdapter raptorAdapter) { + this.raptorAdapter = raptorAdapter; + } + + public FusionAdapter getFusionAdapter() { + return fusionAdapter; + } + + public void setFusionAdapter(FusionAdapter fusionAdapter) { + this.fusionAdapter = fusionAdapter; + } + + + + + +} // DbUtils diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java new file mode 100644 index 00000000..a6abfb7d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java @@ -0,0 +1,75 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import javax.servlet.ServletContext; + +import org.onap.portalsdk.analytics.error.ReportSQLException; +import org.onap.portalsdk.analytics.system.RDbUtils; +import org.onap.portalsdk.analytics.system.fusion.adapter.RaptorAdapter; +import org.onap.portalsdk.analytics.system.fusion.adapter.SpringContext; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.Log; +import org.springframework.beans.factory.annotation.Autowired; + + + +public class RemoteDbUtils implements RDbUtils{ + + private RaptorAdapter raptorAdapter; + + + public void initializeDbUtils(ServletContext servletContext) { + raptorAdapter = (RaptorAdapter)SpringContext.getApplicationContext().getBean("raptorAdapter"); + } // initializeDbUtils + + + public Connection getRemoteConnection(String dbKey) { + return raptorAdapter.getConnection(dbKey); + } + + public void clearConnection(Connection conn) { + raptorAdapter.releaseConnection(conn); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/AdapterSessionFactoryContainer.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/AdapterSessionFactoryContainer.java new file mode 100644 index 00000000..e95b0ec6 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/AdapterSessionFactoryContainer.java @@ -0,0 +1,57 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion.adapter; + +import java.util.*; + +public class AdapterSessionFactoryContainer { + + private LinkedHashMap sessionFactories; + + public AdapterSessionFactoryContainer() { + } + + public LinkedHashMap getSessionFactories() { + return sessionFactories; + } + + public void setSessionFactories(LinkedHashMap sessionFactories) { + this.sessionFactories = sessionFactories; + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/DateUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/DateUtils.java new file mode 100644 index 00000000..d5939764 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/DateUtils.java @@ -0,0 +1,305 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion.adapter; + + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; + +import org.onap.portalsdk.core.FusionObject; +import org.onap.portalsdk.core.domain.User; +import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.portalsdk.core.web.support.AppUtils; + + +public class DateUtils implements Serializable, FusionObject{ + + public static final String US_PACIFIC = "US/Pacific"; + public static final String US_MOUNTAIN = "US/Mountain"; + public static final String US_CENTRAL = "US/Central"; + public static final String US_EASTERN = "US/Eastern"; + public static final String US_HAWAII = "US/Hawaii"; + public static final String US_ALASKA = "US/Alaska"; + + //Arizona State has Mountain Time with no Daylight Savings + public static final String US_ARIZONA = "America/Phoenix"; + + private static final String DB_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; + private static final String GET_CURRENT_DATE = "getCurrentDate"; + + private static DataAccessService dataAccessService; + + public static DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } + + /** + * Parses a date value with given pattern, + * to return a Date Object + * + * @param dateValue + * @param inPattern + * @return Date Object + * @throws Exception + * + */ + public static Date parseDate(String dateValue,String inPattern) throws Exception{ + return parseDate(dateValue,inPattern,null); + } + + /** + * Parses a date value with the given pattern for the specific TimeZone, + * to return a Date Object + * + * @param dateValue + * @param inPattern + * @param currentTimeZone + * @return Date Object + * @throws Exception + * + */ + public static Date parseDate(String dateValue,String inPattern, + String currentTimeZone) throws Exception{ + DateFormat df = new SimpleDateFormat(inPattern); + if(currentTimeZone !=null && !(currentTimeZone.trim().equals(""))){ + df.setTimeZone(TimeZone.getTimeZone(currentTimeZone)); + } + Date date = df.parse(dateValue); + return date; + } + + /** + * Parses a date value with the given pattern for the specific User(in User TimeZone), + * to return a Date Object + * + * @param dateValue + * @param inPattern + * @param userId + * @return Date Object + * @throws Exception + * + */ + public static Date parseUserDate(String dateValue, String inPattern, Long userId) throws Exception{ + User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); + + String userTimeZone = null; + Long timezoneId = user.getTimeZoneId(); + + if (timezoneId != null) { + userTimeZone = AppUtils.getLookupValueByLabel(timezoneId.toString(), "fn_lu_timezone", "timezone_id", "timezone_value"); + } + + return parseDate(dateValue,inPattern,userTimeZone); + } + + /** + * Formats a given date object to the desired pattern + * + * @param date + * @param outPattern + * @return Formatted date value + * @throws Exception + */ + public static String formatDate(Date date,String outPattern)throws Exception{ + return formatDate(date,outPattern,null); + } + + /** + * Formats a date value with the given pattern into a date value with the desired pattern + * + * @param dateValue + * @param inPattern + * @param outPattern + * @return Formatted date value + * @throws Exception + * + */ + public static String formatDate(String dateValue,String inPattern, + String outPattern) throws Exception{ + return formatDate(dateValue,inPattern,null,outPattern,null); + } + + /** + * Formats a given date object to the desired pattern for the TimeZone provided + * @param date + * @param outPattern + * @param requiredTimeZone + * @return Formatted date value + * @throws Exception + */ + public static String formatDate(Date date,String outPattern, + String requiredTimeZone) throws Exception{ + DateFormat df = new SimpleDateFormat(outPattern); + if(requiredTimeZone != null && !requiredTimeZone.trim().equals("")){ + df.setTimeZone(TimeZone.getTimeZone(requiredTimeZone)); + } + return df.format(date); + } + + /** + * Formats a date value with the given pattern + * into a date value with the desired pattern for the TimeZone provided + * + * @param dateValue + * @param inPattern + * @param outPattern + * @param requiredTimeZone + * @return Formatted date value + * @throws Exception + * + */ + public static String formatDate(String dateValue,String inPattern, + String outPattern,String requiredTimeZone) throws Exception{ + return formatDate(dateValue,inPattern,null,outPattern,requiredTimeZone); + } + + /** + * Formats a date value with the given pattern for a specific TimeZone, + * into a date value with the desired pattern for the TimeZone provided + * + * @param dateValue + * @param inPattern + * @param currentTimeZone + * @param outPattern + * @param requiredTimeZone + * @return Formatted date value + * @throws Exception + * + */ + public static String formatDate(String dateValue,String inPattern,String currentTimeZone, + String outPattern,String requiredTimeZone) throws Exception{ + Date date = parseDate(dateValue,inPattern,currentTimeZone); + return formatDate(date,outPattern,requiredTimeZone); + } + + /** + * Formats a date value with the given pattern, for a specific User(in User TimeZone), + * into a date value with the desired pattern for the TimeZone provided + * + * @param dateValue + * @param inPattern + * @param userId + * @param outPattern + * @param requiredTimeZone + * @return Formatted date value + * @throws Exception + * + */ + public static String formatUserDate(String dateValue,String inPattern, Long userId,String outPattern,String requiredTimeZone) throws Exception{ + User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); + + String userTimeZone = null; + Long timezoneId = user.getTimeZoneId(); + + if (timezoneId != null) { + userTimeZone = AppUtils.getLookupValueByLabel(timezoneId.toString(), "fn_lu_timezone", "timezone_id", "timezone_value"); + } + + return formatDate(dateValue,inPattern,userTimeZone,outPattern,requiredTimeZone); + } + + /** + * Formats a date value with a given pattern for a specific User(User TimeZone), + * into a date value with the desired pattern for Database TimeZone + * + * @param dateValue + * @param inPattern + * @param userId + * @param outPattern + * @return Formatted date value + * @throws Exception + * + */ + public static String formatUserDateForDBTimeZone(String dateValue,String inPattern, Long userId,String outPattern) throws Exception{ + User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); + + String userTimeZone = null; + Long timezoneId = user.getTimeZoneId(); + + /*if (timezoneId != null) { + userTimeZone = AppUtils.getLookupValueByLabel(timezoneId.toString(), "fn_lu_timezone", "timezone_id", "timezone_value"); + }*/ + + String dbTimeZone = SystemProperties.getProperty(SystemProperties.DATABASE_TIME_ZONE); + + return formatDate(dateValue,inPattern,userTimeZone,outPattern,dbTimeZone); + } + + /** + * Get the current database Date/Time + * @return Date object + */ + public static Date getCurrentDBDate()throws Exception{ + String dbTimeZone = SystemProperties.getProperty(SystemProperties.DATABASE_TIME_ZONE); + List results = (List)getDataAccessService().executeNamedQuery(GET_CURRENT_DATE, null, null); + return parseDate(((Object[])results.get(0))[0]+" "+((Object[])results.get(0))[1],DB_DATE_FORMAT,dbTimeZone); + } + + /** + * Get the current date value formatted for the User's TimeZone in the desired pattern + * + * @param outPattern + * @param userId + * @return Date value + * @throws Exception + */ + public static String getCurrentDBDateForUser(String outPattern,Long userId)throws Exception{ + User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); + + String userTimeZone = null; + Long timezoneId = user.getTimeZoneId(); + + /*if (timezoneId != null) { + userTimeZone = AppUtils.getLookupValueByLabel(timezoneId.toString(), "fn_lu_timezone", "timezone_id", "timezone_value"); + }*/ + + Date dbDate = getCurrentDBDate(); + + return formatDate(dbDate,outPattern,userTimeZone); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/FusionAdapter.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/FusionAdapter.java new file mode 100644 index 00000000..c4732207 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/FusionAdapter.java @@ -0,0 +1,139 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion.adapter; + +import java.sql.*; +import java.util.*; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.servlet.*; + +import com.mchange.v2.c3p0.ComboPooledDataSource; + +import org.hibernate.SessionFactory; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.engine.spi.SessionImplementor; +import org.onap.portalsdk.core.FusionObject; +import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +public class FusionAdapter implements FusionObject { + + public static final String LOCAL_SESSION_FACTORY_KEY = "local"; + + + private ComboPooledDataSource dataSource; + private Map dataSourceMap; + + //private SessionFactory sessionFactory; + private ServletContext servletContext; + + public FusionAdapter() { + } + + + public ServletContext getServletContext() { + return servletContext; + } + + public void setServletContext(ServletContext servletContext) { + this.servletContext = servletContext; + } + + /** Gets connection to the database **/ + public Connection getConnection() { + Connection connection = null; + try { + connection = getDataSource().getConnection(); + } catch(Exception ex) { + ex.printStackTrace(); + } + return connection; + } + + + /** Gets connection to the database indicated via the session factory key **/ + public synchronized Connection getConnection(String schemaId) { + Connection connection = null; + try { + connection = getDataSourceMap().get(schemaId).getConnection(); + } catch (Exception e) { + e.printStackTrace(); + } + + return connection; + } + + + /** Releases connection to the database **/ + public void releaseConnection(Connection conn) { + try { + conn.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + + public ComboPooledDataSource getDataSource() { + return dataSource; + } + + + @Autowired + public void setDataSource(ComboPooledDataSource dataSource) { + this.dataSource = dataSource; + } + + public Map getDataSourceMap() { + if(dataSourceMap==null) + dataSourceMap = (Map)SpringContext.getApplicationContext().getBean("dataSourceMap"); + + return dataSourceMap; + } + + public void setdataSourceMap(Map dataSourceMap) { + this.dataSourceMap = dataSourceMap; + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/IdName.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/IdName.java new file mode 100644 index 00000000..ac068614 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/IdName.java @@ -0,0 +1,85 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion.adapter; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.onap.portalsdk.core.domain.support.DomainVo; + +/** + *

IdName.java

+ *

Represents a id/name data object.

+*/ +@Entity +public class IdName extends DomainVo { + + private String name; + private Long id; + + public IdName() {} + + @Id + @GeneratedValue + @Column(name = "ID", unique = true, nullable = false) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int compareTo(Object obj){ + String c1 = getName(); + String c2 = ((IdName)obj).getName(); + + return (c1 == null || c2 == null) ? 1 : c1.compareTo(c2); + } + +} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/Item.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/Item.java new file mode 100644 index 00000000..97e8a219 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/Item.java @@ -0,0 +1,73 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion.adapter; + + +public class Item { + private String _id; + private String _name; + + public Item() { + } + + public Item(String id, String name) { + this._id = id; + this._name = name; + } + + public String getId() { + return _id; + } + + public void setId(String id) { + this._id = id; + } + + public String getName() { + return _name; + } + + public void setName(String name) { + this._name = name; + } + + public String toString() { + return _name; + } +} + diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/Lookup.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/Lookup.java new file mode 100644 index 00000000..a2952242 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/Lookup.java @@ -0,0 +1,103 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.system.fusion.adapter; + + +import java.io.*; + +import org.onap.portalsdk.core.domain.FusionVo; +import org.onap.portalsdk.core.domain.support.NameValueId; + + + +public class Lookup extends FusionVo implements Serializable { + + private NameValueId nameValueId = new NameValueId(); + + public Lookup() {} + + public Lookup(String label, String value) { + this(); + setLabel(label); + setValue(value); + } + + public String getValue() { + return getNameValueId().getVal(); + } + + public String getLabel() { + return getNameValueId().getLab(); + } + + public void setValue(String value) { + getNameValueId().setVal(value); + } + + public void setLabel(String label) { + getNameValueId().setLab(label); + } + + public NameValueId getNameValueId() { + return nameValueId; + } + + public void setNameValueId(NameValueId nameValueId) { + this.nameValueId = nameValueId; + } + + // required by ZK for to set the selectedItems of Listboxes (used heavily for