Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Implementaion Classes in the project: Database.java package com.ctrl; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Vector; public class Database { Statement st; ResultSet rs; Connection conn; Vector<String> keys; public Database() { try { Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager .getConnection("jdbc:oracle:thin:@server3:1521:server3","assq","assq"); } catch (Exception e) { e.printStackTrace(); } } public void updateConsumerRequired(String cate, String util, String cost) throws SQLException { // TODO Auto-generated method stub PreparedStatement ps; ps = conn.prepareStatement("insert into required values(?,?,?)"); ps.setString(1, cate); ps.setString(2, util); ps.setString(3, cost); ps.executeUpdate(); ps.close(); } public void updateService(String serviceName, String cate, String cost, String util, String value) throws SQLException { // TODO Auto-generated method stub PreparedStatement ps; ps = conn.prepareStatement("insert into services values(?,?,?,?,?)"); ps.setString(1, serviceName); ps.setString(2, cate); ps.setString(3, cost); ps.setString(4, util); ps.setString(5, value); ps.executeUpdate(); ps.close(); } public Vector<Vector<String>> getAllServices() throws SQLException { // TODO Auto-generated method stub Vector<Vector<String>> retV = new Vector<Vector<String>>(); Vector<String> temp = new Vector<String>(); Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select * from services"); while (rs.next()) { temp = new Vector<String>(); for (int i = 1; i <= 5; i++) { temp.add(rs.getString(i)); } retV.add(temp); } return retV; } public Vector<String> getSelectedServiceUtilities(String service) throws SQLException { // TODO Auto-generated method stub Vector<String> utils = null; PreparedStatement ps; ps = conn .prepareStatement("select cost,utility from services where name=?"); ps.setString(1, service); ResultSet rs = ps.executeQuery(); while (rs.next()) { utils = new Vector<String>(); utils.add(rs.getString(1)); utils.add(rs.getString(2)); } return utils; } public Vector<Vector<String>> getConsumerRequiredUtilities(String service) throws SQLException { // TODO Auto-generated method stub Vector<Vector<String>> retV = new Vector<Vector<String>>(); Vector<String> utils = null; PreparedStatement ps; ps = conn .prepareStatement("select category from services where name=?"); ps.setString(1, service); ResultSet rs = ps.executeQuery(); String cate = ""; if (rs.next()) cate = rs.getString(1); ps = conn .prepareStatement("select cost,utility from required where name=?"); ps.setString(1, cate); rs = ps.executeQuery(); while (rs.next()) { utils = new Vector<String>(); utils.add(rs.getString(1)); utils.add(rs.getString(2)); retV.add(utils); } return retV; } public void updateFeedback(String service, int feedback) throws SQLException { // TODO Auto-generated method stub PreparedStatement ps; ps = conn.prepareStatement("insert into feedback values(?,?,?)"); ps.setString(1, service); ps.setString(2, "" + feedback); ps.setString(3, ""); ps.executeUpdate(); ps.close(); } public Vector<String> getAllServiceNames() throws SQLException { // TODO Auto-generated method stub Vector<String> temp = new Vector<String>(); Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select name from services"); while (rs.next()) { temp.add(rs.getString(1)); } return temp; } public void updateConsumerPreference(String serv, String per) throws SQLException { // TODO Auto-generated method stub PreparedStatement ps; ps = conn .prepareStatement("update feedback set preference=? where name = ?"); ps.setString(1, per); ps.setString(2, serv); ps.executeUpdate(); } public Vector<String> getSelectedServices(String selService) throws SQLException { // TODO Auto-generated method stub Vector<String> utils = null; PreparedStatement ps; ps = conn.prepareStatement("select * from services where name=?"); ps.setString(1, selService); ResultSet rs = ps.executeQuery(); while (rs.next()) { utils = new Vector<String>(); utils.add(rs.getString(1)); utils.add(rs.getString(2)); utils.add(rs.getString(3)); utils.add(rs.getString(4)); utils.add(rs.getString(5)); } return utils; } public Vector<String> getFeedbackResult(String service) throws SQLException{ // TODO Auto-generated method stub Vector<String> utils = null; PreparedStatement ps; ps = conn.prepareStatement("select feedback,preference from feedback where name=?"); ps.setString(1, service); ResultSet rs = ps.executeQuery(); while (rs.next()) { utils = new Vector<String>(); utils.add(rs.getString(1)); utils.add(rs.getString(2)); } return utils; } } Helper.java --------------------- package com.ctrl; import java.io.BufferedReader; import java.io.FileReader; import java.sql.SQLException; import java.util.TreeSet; import java.util.Vector; import javax.swing.JComboBox; import javax.swing.JOptionPane; import javax.swing.JTextArea; public class Helper { public void getCategories(JComboBox comCate) { // TODO Auto-generated method stub try { BufferedReader bfr = new BufferedReader(new FileReader( "category.txt")); String fname = bfr.readLine(); while (fname != null) { comCate.addItem(fname); fname = bfr.readLine(); } } catch (Exception e) { e.printStackTrace(); } } public void ratingService(Database database, String service, JTextArea jtaUtility) { // TODO Auto-generated method stub try { Vector<String> serviceUtility = database .getSelectedServiceUtilities(service); Vector<Vector<String>> consumerRequired = database .getConsumerRequiredUtilities(service); System.out.println(serviceUtility); System.out.println("----------------"); System.out.println(consumerRequired); int util; double cost; util = Integer.parseInt(serviceUtility.get(0)); cost = Double.parseDouble(serviceUtility.get(1)); TreeSet<Integer> msre = new TreeSet<Integer>(); for (int i = 0; i < consumerRequired.size(); i++) { Vector<String> tmp = consumerRequired.get(i); int conUtil; double conCost; conUtil = Integer.parseInt(tmp.get(0)); conCost = Double.parseDouble(tmp.get(1)); if (util >= conUtil && cost <= conCost) { jtaUtility.append("Mesured_Service_Utility_Cost = 99%" + "\n"); msre.add(99); } else if (util < conUtil && cost > conCost) { jtaUtility.append("Mesured_Service_Utility_Cost = 50%" + "\n"); msre.add(50); } else if (util >= conUtil && cost >= conCost) { jtaUtility.append("Mesured_Service_Utility_Cost = 80%" + "\n"); msre.add(80); } else if (util >= conUtil || cost <= conCost) { jtaUtility.append("Mesured_Service_Utility_Cost = 70%" + "\n"); msre.add(70); } else if (util < conUtil || cost < conCost) { jtaUtility.append("Mesured_Service_Utility_Cost = 60%" + "\n"); msre.add(60); } } System.out.println(msre); jtaUtility.append("=============================" + "\n"); int feedback = msre.last(); jtaUtility.append("Feedback Result = " + feedback + "%\n"); database.updateFeedback(service, feedback); JOptionPane.showMessageDialog(null, "Feedback Updated Successfully."); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void measureUtilty(Database database, String service, JTextArea jtaUtility) { // TODO Auto-generated method stub try { Vector<String> serviceUtility = database .getSelectedServiceUtilities(service); Vector<Vector<String>> consumerRequired = database .getConsumerRequiredUtilities(service); jtaUtility.append("Service_Utility = " + serviceUtility.get(0) + "\n"); jtaUtility.append("Service_Cost = " + serviceUtility.get(1) + "\n\n"); jtaUtility.append("Consumer Required " + "\n"); jtaUtility.append("----------------------------" + "\n"); for (int i = 0; i < consumerRequired.size(); i++) { Vector<String> tmp = consumerRequired.get(i); jtaUtility.append("Service_Utility = " + tmp.get(0) + "\n"); jtaUtility.append("Service_Cost = " + tmp.get(1) + "\n\n"); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void getServices(JComboBox comSelSer, Database database) { // TODO Auto-generated method stub try { Vector<String> services = database.getAllServiceNames(); for (int i = 0; i < services.size(); i++) { comSelSer.addItem(services.get(i)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void updateScore(JTextArea jtaScore, String service, Vector<String> fb) { // TODO Auto-generated method stub double score = (Double.parseDouble(fb.get(0)) + Double.parseDouble(fb .get(1))) / 2; jtaScore.append("Rating Score for [ " + service + " ] \n"); jtaScore.append("================================\n"); jtaScore.append("Score: " + score + "\n"); jtaScore.append("-------------------------------------------\n"); } } Consumer.java ------------------------- /* * Consumer.java * * Created on __DATE__, __TIME__ */ package com.design; import java.sql.SQLException; import javax.swing.JOptionPane; import com.ctrl.Database; import com.ctrl.Helper; public class Consumer extends javax.swing.JFrame { Database database; Helper helper; private static final long serialVersionUID = 1L; /** Creates new form Consumer */ public Consumer() { initComponents(); init(); helper.getCategories(comCate); helper.getServices(comSelSer, database); } private void init() { // TODO Auto-generated method stub helper = new Helper(); database = new Database(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); comCate = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); txtUtility = new javax.swing.JTextField(); txtCost = new javax.swing.JTextField(); btnSerSubmit = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel5 = new javax.swing.JLabel(); comSelSer = new javax.swing.JComboBox(); jLabel6 = new javax.swing.JLabel(); txtPre = new javax.swing.JTextField(); btnPreSubmit = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(null); jPanel1.setBorder(javax.swing.BorderFactory .createTitledBorder("Required Services")); jPanel1.setLayout(null); jLabel1.setText("Select Category"); jPanel1.add(jLabel1); jLabel1.setBounds(30, 50, 100, 20); jPanel1.add(comCate); comCate.setBounds(130, 50, 290, 20); jLabel2.setText("Utility"); jPanel1.add(jLabel2); jLabel2.setBounds(30, 110, 80, 20); jLabel3.setText("Cost"); jPanel1.add(jLabel3); jLabel3.setBounds(30, 160, 60, 20); jPanel1.add(txtUtility); txtUtility.setBounds(130, 110, 290, 20); jPanel1.add(txtCost); txtCost.setBounds(130, 160, 290, 20); btnSerSubmit.setText("Submit"); btnSerSubmit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSerSubmitActionPerformed(evt); } }); jPanel1.add(btnSerSubmit); btnSerSubmit.setBounds(200, 210, 170, 30); getContentPane().add(jPanel1); jPanel1.setBounds(70, 80, 490, 270); jLabel4.setFont(new java.awt.Font("Tahoma", 3, 24)); jLabel4.setForeground(new java.awt.Color(0, 0, 255)); jLabel4.setText("Consumer"); getContentPane().add(jLabel4); jLabel4.setBounds(260, 20, 140, 30); jPanel2.setBorder(javax.swing.BorderFactory .createTitledBorder("Consumer Preferences")); jPanel2.setLayout(null); jLabel5.setText("Select Service"); jPanel2.add(jLabel5); jLabel5.setBounds(30, 40, 90, 20); jPanel2.add(comSelSer); comSelSer.setBounds(140, 40, 270, 20); jLabel6.setText("Preferences(%)"); jPanel2.add(jLabel6); jLabel6.setBounds(30, 100, 80, 20); jPanel2.add(txtPre); txtPre.setBounds(140, 100, 270, 20); btnPreSubmit.setText("Submit"); btnPreSubmit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPreSubmitActionPerformed(evt); } }); jPanel2.add(btnPreSubmit); btnPreSubmit.setBounds(200, 150, 140, 30); getContentPane().add(jPanel2); jPanel2.setBounds(70, 390, 490, 220); setSize(640, 700); setTitle("Consumer::"); setResizable(false); setVisible(true); }// </editor-fold> // GEN-END:initComponents private void btnPreSubmitActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String serv = comSelSer.getSelectedItem().toString(); String per = txtPre.getText(); try { database.updateConsumerPreference(serv, per); JOptionPane.showMessageDialog(null, "Consumer Preference Updated Successfully."); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); JOptionPane .showMessageDialog( null, "Consumer Preference Updation Failed. Please Update SLA Feedback before this Updation."); } } private void btnSerSubmitActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ String cate = comCate.getSelectedItem().toString(); String util = txtUtility.getText(); String cost = txtCost.getText(); boolean match = false; if (util.equalsIgnoreCase("") && cost.equalsIgnoreCase("")) { JOptionPane.showMessageDialog(null, "Enter the Utility and Cost Values", "Message", JOptionPane.INFORMATION_MESSAGE); hide(); match = true; // return match; }// if else{ // while database.updateConsumerRequired(cate, util, cost); JOptionPane.showMessageDialog(null, "Required Service Updated Successfully."); txtUtility.setText(""); txtCost.setText(""); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Consumer().setVisible(true); } }); } // GEN-BEGIN:variables // Variables declaration - do not modify private javax.swing.JButton btnPreSubmit; private javax.swing.JButton btnSerSubmit; private javax.swing.JComboBox comCate; private javax.swing.JComboBox comSelSer; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JTextField txtCost; private javax.swing.JTextField txtPre; private javax.swing.JTextField txtUtility; // End of variables declaration//GEN-END:variables } ReputationSystem: ---------------------------- /* * ReputationSystem.java * * Created on __DATE__, __TIME__ */ package com.design; import java.sql.SQLException; import java.util.Vector; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import com.ctrl.Database; import com.ctrl.Helper; /** * * @author __USER__ */ public class ReputationSystem extends javax.swing.JFrame { /** * */ private static final long serialVersionUID = 1L; /** Creates new form ReputationSystem */ DefaultTableModel dft; Database database; Helper helper; public ReputationSystem() { initComponents(); init(); helper.getServices(comSer, database); } private void init() { // TODO Auto-generated method stub helper = new Helper(); database = new Database(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); comSer = new javax.swing.JComboBox(); btnSubmit = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); tbl = new javax.swing.JTable(); btnSelect = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jtaScore = new javax.swing.JTextArea(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(null); jLabel1.setFont(new java.awt.Font("Gill Sans Ultra Bold", 3, 24)); jLabel1.setForeground(javax.swing.UIManager.getDefaults().getColor( "EditorPane.selectionBackground")); jLabel1.setText("Reputation System"); getContentPane().add(jLabel1); jLabel1.setBounds(200, 20, 400, 40); jLabel2.setText("Select Service"); getContentPane().add(jLabel2); jLabel2.setBounds(110, 100, 100, 20); getContentPane().add(comSer); comSer.setBounds(220, 100, 340, 20); btnSubmit.setBackground(new java.awt.Color(102, 102, 255)); btnSubmit.setFont(new java.awt.Font("Tahoma", 3, 18)); btnSubmit.setText("Submit"); btnSubmit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSubmitActionPerformed(evt); } }); getContentPane().add(btnSubmit); btnSubmit.setBounds(230, 150, 220, 30); dft = new DefaultTableModel(); tbl.setModel(dft); jScrollPane1.setViewportView(tbl); dft.addColumn("Service Name"); dft.addColumn("Category"); dft.addColumn("Cost"); dft.addColumn("Utility"); dft.addColumn("Value"); getContentPane().add(jScrollPane1); jScrollPane1.setBounds(60, 200, 550, 180); btnSelect.setFont(new java.awt.Font("Bauhaus 93", 3, 18)); btnSelect.setBackground(new java.awt.Color(102, 102, 255)); btnSelect.setText("Selection Function"); btnSelect.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSelectActionPerformed(evt); } }); getContentPane().add(btnSelect); btnSelect.setBounds(230, 410, 250, 30); jLabel3.setText("Score"); getContentPane().add(jLabel3); jLabel3.setBounds(320, 470, 40, 14); jtaScore.setColumns(20); jtaScore.setRows(5); jScrollPane2.setViewportView(jtaScore); getContentPane().add(jScrollPane2); jScrollPane2.setBounds(60, 490, 570, 100); setSize(700, 700); setTitle("Reputation System::"); setResizable(false); setVisible(true); }// </editor-fold> // GEN-END:initComponents private void btnSelectActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String service=comSer.getSelectedItem().toString(); try { Vector<String> fb=database.getFeedbackResult(service); if(fb.size()>0){ if(fb.get(1).equals("")) JOptionPane.showMessageDialog(null, "No Preference Result from Consumer for Selected Service."); else helper.updateScore(jtaScore,service,fb); }else JOptionPane.showMessageDialog(null, "No Feedback for Selected Service from SLA."); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { String selService = comSer.getSelectedItem().toString(); Vector<String> allServices = database .getSelectedServices(selService); dft.addRow(allServices); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * @param args * the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ReputationSystem().setVisible(true); } }); } // GEN-BEGIN:variables // Variables declaration - do not modify private javax.swing.JButton btnSelect; private javax.swing.JButton btnSubmit; private javax.swing.JComboBox comSer; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextArea jtaScore; private javax.swing.JTable tbl; // End of variables declaration//GEN-END:variables } /* * ServiceProvider.java * * Created on __DATE__, __TIME__ */ package com.design; import java.sql.SQLException; import javax.swing.JOptionPane; import com.ctrl.Database; import com.ctrl.Helper; /** * * @author __USER__ */ public class ServiceProvider extends javax.swing.JFrame { /** * */ private static final long serialVersionUID = 1L; /** Creates new form ServiceProvider */ Database database; Helper helper; public ServiceProvider() { initComponents(); init(); helper.getCategories(comCate); } private void init() { // TODO Auto-generated method stub helper=new Helper(); database = new Database(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ //GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); txtSerName = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); comCate = new javax.swing.JComboBox(); txtCost = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); txtUtility = new javax.swing.JTextField(); jLabel6 = new javax.swing.JLabel(); txtValue = new javax.swing.JTextField(); btnAgree = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(null); jLabel1.setFont(new java.awt.Font("Imprint MT Shadow", 3, 24)); jLabel1.setForeground(new java.awt.Color(51, 51, 255)); jLabel1.setText("Service Provider"); getContentPane().add(jLabel1); jLabel1.setBounds(250, 20, 370, 30); jPanel1.setBorder(javax.swing.BorderFactory .createTitledBorder("Service Provider")); jPanel1.setLayout(null); jLabel2.setText("Service Name"); jPanel1.add(jLabel2); jLabel2.setBounds(20, 60, 90, 20); jPanel1.add(txtSerName); txtSerName.setBounds(190, 60, 370, 20); jLabel3.setText("Cost of Service"); jPanel1.add(jLabel3); jLabel3.setBounds(20, 220, 90, 20); jLabel4.setText("Category"); jPanel1.add(jLabel4); jLabel4.setBounds(20, 140, 90, 20); jPanel1.add(comCate); comCate.setBounds(190, 140, 370, 20); jPanel1.add(txtCost); txtCost.setBounds(190, 220, 370, 20); jLabel5.setText("Utility"); jPanel1.add(jLabel5); jLabel5.setBounds(20, 290, 90, 20); jPanel1.add(txtUtility); txtUtility.setBounds(190, 290, 370, 20); jLabel6.setText("Value of Time(Year)"); jPanel1.add(jLabel6); jLabel6.setBounds(20, 360, 120, 20); jPanel1.add(txtValue); txtValue.setBounds(190, 360, 370, 20); btnAgree.setText("Agree to SLA"); btnAgree.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAgreeActionPerformed(evt); } }); jPanel1.add(btnAgree); btnAgree.setBounds(230, 420, 260, 30); getContentPane().add(jPanel1); jPanel1.setBounds(70, 70, 590, 500); setSize(770,700); setResizable(false); setVisible(true); }// </editor-fold> //GEN-END:initComponents private void btnAgreeActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String serviceName=txtSerName.getText(); String cate=comCate.getSelectedItem().toString(); String cost=txtCost.getText(); String util=txtUtility.getText(); String value=txtValue.getText(); boolean match = false; if (cost.equalsIgnoreCase("") && util.equalsIgnoreCase("")&& value.equalsIgnoreCase("")) { JOptionPane.showMessageDialog(null, "Enter the Utility,Cost and Values", "Message", JOptionPane.INFORMATION_MESSAGE); hide(); match = true; // return match; }// if else{ try { database.updateService(serviceName,cate,cost,util,value); JOptionPane.showMessageDialog(null,"New Service Updated to SLA."); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }} } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ServiceProvider().setVisible(true); } }); } //GEN-BEGIN:variables // Variables declaration - do not modify private javax.swing.JButton btnAgree; private javax.swing.JComboBox comCate; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JPanel jPanel1; private javax.swing.JTextField txtCost; private javax.swing.JTextField txtSerName; private javax.swing.JTextField txtUtility; private javax.swing.JTextField txtValue; // End of variables declaration//GEN-END:variables } SLA.java ------------/* * SLA.java * * Created on __DATE__, __TIME__ */ package com.design; import java.sql.SQLException; import java.util.Vector; import javax.swing.table.DefaultTableModel; import com.ctrl.Database; import com.ctrl.Helper; /** * * @author __USER__ */ public class SLA extends javax.swing.JFrame { /** * */ private static final long serialVersionUID = 1L; /** Creates new form SLA */ DefaultTableModel dft; Database database; Helper helper; public SLA() { initComponents(); init(); } private void init() { // TODO Auto-generated method stub database = new Database(); helper=new Helper(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); btnUtility = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); comSelectSer = new javax.swing.JComboBox(); btnRating = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jtaFeedback = new javax.swing.JTextArea(); jScrollPane3 = new javax.swing.JScrollPane(); jtaUtility = new javax.swing.JTextArea(); jScrollPane1 = new javax.swing.JScrollPane(); tbl = new javax.swing.JTable(); btnRetriveSer = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(null); jLabel1.setFont(new java.awt.Font("Wide Latin", 3, 24)); jLabel1.setForeground(new java.awt.Color(0, 102, 153)); jLabel1.setText("Service Level Agreement"); getContentPane().add(jLabel1); jLabel1.setBounds(130, 10, 570, 30); jPanel1.setBorder(javax.swing.BorderFactory .createTitledBorder("Monitering System")); jPanel1.setLayout(null); btnUtility.setText("Utility Measure"); btnUtility.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnUtilityActionPerformed(evt); } }); jPanel1.add(btnUtility); btnUtility.setBounds(100, 340, 250, 30); jLabel2.setText("Select Service"); jPanel1.add(jLabel2); jLabel2.setBounds(20, 300, 120, 20); jPanel1.add(comSelectSer); comSelectSer.setBounds(100, 300, 250, 20); btnRating.setText("Rating Function"); btnRating.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRatingActionPerformed(evt); } }); jPanel1.add(btnRating); btnRating.setBounds(390, 290, 330, 30); jLabel3.setFont(new java.awt.Font("Tahoma", 3, 18)); jLabel3.setText("Feedback :"); jPanel1.add(jLabel3); jLabel3.setBounds(490, 360, 120, 20); jtaFeedback.setColumns(20); jtaFeedback.setRows(5); jScrollPane2.setViewportView(jtaFeedback); jPanel1.add(jScrollPane2); jScrollPane2.setBounds(360, 390, 390, 140); jtaUtility.setColumns(20); jtaUtility.setRows(5); jScrollPane3.setViewportView(jtaUtility); jPanel1.add(jScrollPane3); jScrollPane3.setBounds(20, 386, 330, 140); dft = new DefaultTableModel(); tbl.setModel(dft); jScrollPane1.setViewportView(tbl); dft.addColumn("Service Name"); dft.addColumn("Category"); dft.addColumn("Cost"); dft.addColumn("Utility"); dft.addColumn("Value"); jPanel1.add(jScrollPane1); jScrollPane1.setBounds(20, 80, 720, 190); btnRetriveSer.setText("Retrive Services"); btnRetriveSer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRetriveSerActionPerformed(evt); } }); jPanel1.add(btnRetriveSer); btnRetriveSer.setBounds(270, 30, 240, 30); getContentPane().add(jPanel1); jPanel1.setBounds(30, 80, 760, 560); setSize(830, 700); setTitle("Service Level Agreement::"); setResizable(false); setVisible(true); }// </editor-fold> // GEN-END:initComponents private void btnRatingActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String service=comSelectSer.getSelectedItem().toString(); helper.ratingService(database,service,jtaFeedback); } private void btnUtilityActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String service=comSelectSer.getSelectedItem().toString(); helper.measureUtilty(database,service,jtaUtility); } private void btnRetriveSerActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { Vector<Vector<String>> allServices = database.getAllServices(); for (int i = 0; i < allServices.size(); i++) { Vector<String> tmp=allServices.get(i); dft.addRow(tmp); comSelectSer.addItem(tmp.get(0)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * @param args * the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new SLA().setVisible(true); } }); } // GEN-BEGIN:variables // Variables declaration - do not modify private javax.swing.JButton btnRating; private javax.swing.JButton btnRetriveSer; private javax.swing.JButton btnUtility; private javax.swing.JComboBox comSelectSer; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JTextArea jtaFeedback; private javax.swing.JTextArea jtaUtility; private javax.swing.JTable tbl; // End of variables declaration//GEN-END:variables }